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
.net
.URISyntaxException
;
19 import org
.junit
.Assert
;
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
;
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
.name
.TaxonNameBase
;
31 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
32 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
39 public class SpecimenImportConfiguratorTest
extends CdmTransactionalIntegrationTest
{
42 CdmApplicationAwareDefaultImport
<?
> defaultImport
;
45 INameService nameService
;
48 IOccurrenceService occurrenceService
;
51 private IImportConfigurator configurator
;
55 String inputFile
= "/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportConfiguratorTest-input.xml";
56 URL url
= this.getClass().getResource(inputFile
);
57 assertNotNull("URL for the test file '" + inputFile
+ "' does not exist", url
);
59 configurator
= Abcd206ImportConfigurator
.NewInstance(url
.toURI(), null);
60 } catch (URISyntaxException e
) {
64 assertNotNull("Configurator could not be created", configurator
);
68 public void testInit() {
69 assertNotNull("import instance should not be null", defaultImport
);
70 assertNotNull("nameService should not be null", nameService
);
71 assertNotNull("occurence service should not be null", occurrenceService
);
75 @DataSet(value
="../../../BlankDataSet.xml")
76 public void testDoInvoke() {
77 boolean result
= defaultImport
.invoke(configurator
);
78 assertTrue("Return value for import.invoke should be true", result
);
80 assertEquals("Number of TaxonNames is incorrect", 11, nameService
.count(TaxonNameBase
.class));
81 assertEquals("Number of specimen is incorrect", 10, occurrenceService
.count(DerivedUnitBase
.class));