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
|
package eu.etaxonomy.cdm.io.tcsxml;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
import static org.junit.Assert.assertNotNull;
|
13
|
import static org.junit.Assert.assertTrue;
|
14
|
|
15
|
import java.io.FileNotFoundException;
|
16
|
import java.net.URISyntaxException;
|
17
|
import java.net.URL;
|
18
|
import java.util.List;
|
19
|
|
20
|
import org.junit.Before;
|
21
|
import org.junit.Test;
|
22
|
import org.unitils.dbunit.annotation.DataSet;
|
23
|
import org.unitils.dbunit.annotation.DataSets;
|
24
|
import org.unitils.spring.annotation.SpringBeanByName;
|
25
|
import org.unitils.spring.annotation.SpringBeanByType;
|
26
|
|
27
|
import eu.etaxonomy.cdm.api.service.INameService;
|
28
|
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
|
29
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
30
|
import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
|
31
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
32
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
33
|
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
|
34
|
|
35
|
/**
|
36
|
* @author a.mueller
|
37
|
* @since 29.01.2009
|
38
|
*/
|
39
|
public class TcsXmlImportConfiguratorTest extends CdmTransactionalIntegrationTest {
|
40
|
|
41
|
@SpringBeanByName
|
42
|
private CdmApplicationAwareDefaultImport<?> defaultImport;
|
43
|
|
44
|
@SpringBeanByType
|
45
|
private INameService nameService;
|
46
|
|
47
|
private IImportConfigurator configurator;
|
48
|
|
49
|
@Before
|
50
|
public void setUp() throws URISyntaxException {
|
51
|
|
52
|
String inputFile = "/eu/etaxonomy/cdm/io/tcsxml/TcsXmlImportConfiguratorTest-input.xml";
|
53
|
URL url = this.getClass().getResource(inputFile);
|
54
|
assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
|
55
|
configurator = TcsXmlImportConfigurator.NewInstance(url.toURI(), null);
|
56
|
assertNotNull("Configurator could not be created", configurator);
|
57
|
}
|
58
|
|
59
|
@Test
|
60
|
public void testInit() {
|
61
|
assertNotNull("cdmTcsXmlImport should not be null", defaultImport);
|
62
|
assertNotNull("nameService should not be null", nameService);
|
63
|
}
|
64
|
|
65
|
@Test
|
66
|
@DataSets({
|
67
|
@DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
|
68
|
@DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
|
69
|
})
|
70
|
public void testDoInvoke() {
|
71
|
boolean result = defaultImport.invoke(configurator).isSuccess();
|
72
|
assertTrue("Return value for import.invoke should be true", result);
|
73
|
List<TaxonName> listz = nameService.list(TaxonName.class, null, 0, null, null);
|
74
|
assertEquals("Number of TaxonNames should be 16", 16, nameService.count(null));
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void createTestDataSet() throws FileNotFoundException {}
|
79
|
}
|