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