Project

General

Profile

« Previous | Next » 

Revision 46e87061

Added by Patricia Kelbert almost 11 years ago

Add new Tests for ABCD imports

View differences:

cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportConfiguratorTest.java
13 13
import static org.junit.Assert.assertNotNull;
14 14
import static org.junit.Assert.assertTrue;
15 15

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

  
......
30 31
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
31 32
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
32 33
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
33
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
34 34

  
35 35
/**
36 36
 * @author a.mueller
......
50 50

  
51 51

  
52 52
	private IImportConfigurator configurator;
53
	private IImportConfigurator configurator2;
54
	private IImportConfigurator configurator3;
53 55

  
54 56
	@Before
55 57
	public void setUp() {
......
57 59
		URL url = this.getClass().getResource(inputFile);
58 60
		assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
59 61
		try {
60
			configurator = Abcd206ImportConfigurator.NewInstance(url.toURI(), null);
62
			configurator = Abcd206ImportConfigurator.NewInstance(url.toURI(), null,false);
61 63
		} catch (URISyntaxException e) {
62 64
			e.printStackTrace();
63 65
			Assert.fail();
64 66
		}
65 67
		assertNotNull("Configurator could not be created", configurator);
68

  
69
		inputFile = "/eu/etaxonomy/cdm/io/specimen/abcd206/in/ABCDImportTestCalvumPart1.xml";
70
        url = this.getClass().getResource(inputFile);
71
        assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
72
        try {
73
            configurator2 = Abcd206ImportConfigurator.NewInstance(url.toURI(), null,false);
74
        } catch (URISyntaxException e) {
75
            e.printStackTrace();
76
            Assert.fail();
77
        }
78
        assertNotNull("Configurator2 could not be created", configurator2);
79

  
80
//        inputFile = "/eu/etaxonomy/cdm/io/specimen/abcd206/in/ABCDImportTestCalvumPart2.xml";
81
//        url = this.getClass().getResource(inputFile);
82
//        assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
83
//        try {
84
//            configurator3 = Abcd206ImportConfigurator.NewInstance(url.toURI(), null,false);
85
//        } catch (URISyntaxException e) {
86
//            e.printStackTrace();
87
//            Assert.fail();
88
//        }
89
//        assertNotNull("Configurator3 could not be created", configurator3);
90

  
66 91
	}
67 92

  
68 93
	@Test
......
72 97
		assertNotNull("occurence service should not be null", occurrenceService);
73 98
	}
74 99

  
75
	@Test
76
	@DataSet( value="../../../BlankDataSet.xml")  //loadStrategy=CleanSweepInsertLoadStrategy.class
77
	public void testDoInvoke() {
78
		boolean result = defaultImport.invoke(configurator);
79
		assertTrue("Return value for import.invoke should be true", result);
80

  
81
		assertEquals("Number of TaxonNames is incorrect", 2, nameService.count(TaxonNameBase.class));
82
		assertEquals("Number of specimen is incorrect", 10, occurrenceService.count(DerivedUnitBase.class));
83

  
84

  
85
	}
100
//	@Test
101
//	@DataSet( value="../../../BlankDataSet.xml")  //loadStrategy=CleanSweepInsertLoadStrategy.class
102
//	public void testDoInvoke() {
103
//		boolean result = defaultImport.invoke(configurator);
104
//		assertTrue("Return value for import.invoke should be true", result);
105
//		assertEquals("Number of TaxonNames is incorrect", 2, nameService.count(TaxonNameBase.class));
106
//		assertEquals("Number of specimen is incorrect", 10, occurrenceService.count(DerivedUnitBase.class));
107
//	}
86 108

  
109
	@Test
110
    @DataSet( value="../../../BlankDataSet.xml")  //loadStrategy=CleanSweepInsertLoadStrategy.class
111
    public void testDoInvoke2() {
112
        boolean result = defaultImport.invoke(configurator2);
113
        assertTrue("Return value for import.invoke should be true", result);
114
        assertEquals("Number of TaxonNames is incorrect", 2, nameService.count(TaxonNameBase.class));
115
        assertEquals("Number of specimen and observation is incorrect", 10, occurrenceService.count(DerivedUnitBase.class));
116
        try {
117
            writeDbUnitDataSetFile(new String[] {
118
                    "TAXONBASE", "TAXONNAMEBASE",
119
                    "REFERENCE", "DESCRIPTIONELEMENTBASE", "DESCRIPTIONBASE",
120
                    "AGENTBASE", "CLASSIFICATION", "CLASSIFICATION_TAXONNODE", "TAXONNODE",
121
                    "HOMOTYPICALGROUP", "LANGUAGESTRING","COLLECTION","SPECIMENOROBSERVATIONBASE",
122
                    "ORIGINALSOURCEBASE", "GATHERINGEVENT", "DETERMINATIONEVENT",
123
                    "DERIVATIONEVENT", "SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT",
124
                    "HIBERNATE_SEQUENCES",
125
             });
126
        } catch (FileNotFoundException e) {
127
            // TODO Auto-generated catch block
128
            e.printStackTrace();
129
        }
130
//                File file = new File("./ABCDPart1Dataset.xml");
131
//        FileOutputStream fos;
132
//        try {
133
//            fos = new FileOutputStream(file);
134
//            printDataSet(fos);
135
//            fos.close();
136
//        } catch (FileNotFoundException e) {
137
//            // TODO Auto-generated catch block
138
//            e.printStackTrace();
139
//        } catch (IOException e) {
140
//            // TODO Auto-generated catch block
141
//            e.printStackTrace();
142
//        }
143

  
144

  
145

  
146
    }
87 147
}

Also available in: Unified diff