2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
14 import static org
.junit
.Assert
.assertTrue
;
16 import java
.io
.FileNotFoundException
;
17 import java
.net
.URISyntaxException
;
20 import org
.junit
.Assert
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
23 import org
.unitils
.dbunit
.annotation
.DataSet
;
24 import org
.unitils
.spring
.annotation
.SpringBeanByName
;
25 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
27 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
28 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
29 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
30 import eu
.etaxonomy
.cdm
.io
.common
.CdmApplicationAwareDefaultImport
;
31 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
32 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
34 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
41 public class SpecimenImportConfiguratorTest
extends CdmTransactionalIntegrationTest
{
44 CdmApplicationAwareDefaultImport
<?
> defaultImport
;
47 INameService nameService
;
50 IOccurrenceService occurrenceService
;
53 ITermService termService
;
56 private IImportConfigurator configurator
;
57 private IImportConfigurator configurator2
;
58 private IImportConfigurator configurator3
;
62 String inputFile
= "/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportConfiguratorTest-input.xml";
63 URL url
= this.getClass().getResource(inputFile
);
64 assertNotNull("URL for the test file '" + inputFile
+ "' does not exist", url
);
66 configurator
= Abcd206ImportConfigurator
.NewInstance(url
.toURI(), null,false);
67 } catch (URISyntaxException e
) {
71 assertNotNull("Configurator could not be created", configurator
);
73 inputFile
= "/eu/etaxonomy/cdm/io/specimen/abcd206/in/ABCDImportTestCalvumPart1.xml";
74 url
= this.getClass().getResource(inputFile
);
75 assertNotNull("URL for the test file '" + inputFile
+ "' does not exist", url
);
77 configurator2
= Abcd206ImportConfigurator
.NewInstance(url
.toURI(), null,false);
78 } catch (URISyntaxException e
) {
82 assertNotNull("Configurator2 could not be created", configurator2
);
84 // inputFile = "/eu/etaxonomy/cdm/io/specimen/abcd206/in/ABCDImportTestCalvumPart2.xml";
85 // url = this.getClass().getResource(inputFile);
86 // assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
88 // configurator3 = Abcd206ImportConfigurator.NewInstance(url.toURI(), null,false);
89 // } catch (URISyntaxException e) {
90 // e.printStackTrace();
93 // assertNotNull("Configurator3 could not be created", configurator3);
98 public void testInit() {
99 assertNotNull("import instance should not be null", defaultImport
);
100 assertNotNull("nameService should not be null", nameService
);
101 assertNotNull("occurence service should not be null", occurrenceService
);
102 assertNotNull("term service should not be null", termService
);
106 // @DataSet( value="../../../BlankDataSet.xml") //loadStrategy=CleanSweepInsertLoadStrategy.class
107 // public void testDoInvoke() {
108 // boolean result = defaultImport.invoke(configurator);
109 // assertTrue("Return value for import.invoke should be true", result);
110 // assertEquals("Number of TaxonNames is incorrect", 2, nameService.count(TaxonNameBase.class));
111 // assertEquals("Number of specimen is incorrect", 10, occurrenceService.count(DerivedUnitBase.class));
115 @DataSet( value
="../../../BlankDataSet.xml") //loadStrategy=CleanSweepInsertLoadStrategy.class
116 public void testDoInvoke2() {
117 boolean result
= defaultImport
.invoke(configurator2
);
118 assertTrue("Return value for import.invoke should be true", result
);
119 assertEquals("Number of TaxonNames is incorrect", 2, nameService
.count(TaxonNameBase
.class));
120 assertEquals("Number of specimen and observation is incorrect", 10, occurrenceService
.count(DerivedUnitBase
.class));
122 writeDbUnitDataSetFile(new String
[] {
123 "TAXONBASE", "TAXONNAMEBASE",
124 "REFERENCE", "DESCRIPTIONELEMENTBASE", "DESCRIPTIONBASE",
125 "AGENTBASE", "CLASSIFICATION", "CLASSIFICATION_TAXONNODE", "TAXONNODE",
126 "HOMOTYPICALGROUP", "LANGUAGESTRING","COLLECTION","SPECIMENOROBSERVATIONBASE",
127 "ORIGINALSOURCEBASE", "GATHERINGEVENT", "DETERMINATIONEVENT",
128 "DERIVATIONEVENT", "SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT",
129 "HIBERNATE_SEQUENCES",
131 } catch (FileNotFoundException e
) {
132 // TODO Auto-generated catch block
135 // File file = new File("./ABCDPart1Dataset.xml");
136 // FileOutputStream fos;
138 // fos = new FileOutputStream(file);
139 // printDataSet(fos);
141 // } catch (FileNotFoundException e) {
142 // // TODO Auto-generated catch block
143 // e.printStackTrace();
144 // } catch (IOException e) {
145 // // TODO Auto-generated catch block
146 // e.printStackTrace();