Project

General

Profile

Download (3.26 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.io.specimen.excel.in;
11

    
12
import static org.junit.Assert.assertEquals;
13
import static org.junit.Assert.assertNotNull;
14
import static org.junit.Assert.assertTrue;
15

    
16
import java.io.FileNotFoundException;
17
import java.net.URISyntaxException;
18
import java.net.URL;
19

    
20
import org.junit.Before;
21
import org.junit.Test;
22
import org.unitils.dbunit.annotation.DataSet;
23
import org.unitils.spring.annotation.SpringBeanByName;
24
import org.unitils.spring.annotation.SpringBeanByType;
25

    
26
import eu.etaxonomy.cdm.api.service.INameService;
27
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
28
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
29
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
30
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
31
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
32
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
33
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
34

    
35
/**
36
 * @author a.mueller
37
 * @created 29.01.2009
38
 * @version 1.0
39
 */
40
//@Ignore("Test class is just a copy of the ABCD import test. It still needs to be adapted")
41
public class ExcelImportConfiguratorTest extends CdmTransactionalIntegrationTest {
42

    
43
	@SpringBeanByName
44
	CdmApplicationAwareDefaultImport<?> defaultImport;
45

    
46
	@SpringBeanByType
47
	INameService nameService;
48

    
49
	@SpringBeanByType
50
	IOccurrenceService occurrenceService;
51

    
52

    
53
	private IImportConfigurator configurator;
54

    
55
	@Before
56
	public void setUp() throws URISyntaxException {
57
		String inputFile = "/eu/etaxonomy/cdm/io/specimen/excel/in/ExcelImportConfiguratorTest-input.xls";
58
		URL url = this.getClass().getResource(inputFile);
59
		assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
60
		configurator = SpecimenSynthesysExcelImportConfigurator.NewInstance(url.toURI(), null, false);
61
		assertNotNull("Configurator could not be created", configurator);
62
	}
63

    
64
	@Test
65
	public void testInit() {
66
		assertNotNull("import instance should not be null", defaultImport);
67
		assertNotNull("nameService should not be null", nameService);
68
		assertNotNull("occurence service should not be null", occurrenceService);
69
	}
70

    
71
	@Test
72
	@DataSet("../../../BlankDataSet.xml")
73
	public void testDoInvoke() {
74
		boolean result = defaultImport.invoke(configurator);
75
		assertTrue("Return value for import.invoke should be true", result);
76
		assertEquals("Number of TaxonNames should be 3", 3, nameService.count(null));
77
		assertEquals("Number of specimen should be 6", 6, occurrenceService.count(SpecimenOrObservationBase.class));
78
		assertEquals("Number of specimen should be 3", 3, occurrenceService.count(DerivedUnit.class));
79
		assertEquals("Number of specimen should be 3", 3, occurrenceService.count(FieldUnit.class));
80

    
81
	}
82

    
83
    /* (non-Javadoc)
84
     * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
85
     */
86
    @Override
87
    public void createTestDataSet() throws FileNotFoundException {
88
        // TODO Auto-generated method stub
89
        
90
    }
91

    
92
}
(1-1/2)