1 |
afa7e7e1
|
Andreas Müller
|
/**
|
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 |
01be5674
|
Andreas Müller
|
package eu.etaxonomy.cdm.io.taxonx;
|
11 |
|
|
|
12 |
|
|
import static org.junit.Assert.assertNotNull;
|
13 |
|
|
|
14 |
f9a87300
|
Andreas Müller
|
import java.net.URISyntaxException;
|
15 |
01be5674
|
Andreas Müller
|
import java.net.URL;
|
16 |
|
|
|
17 |
f9a87300
|
Andreas Müller
|
import org.junit.Assert;
|
18 |
01be5674
|
Andreas Müller
|
import org.junit.Before;
|
19 |
|
|
import org.junit.Test;
|
20 |
|
|
import org.unitils.spring.annotation.SpringBeanByName;
|
21 |
|
|
import org.unitils.spring.annotation.SpringBeanByType;
|
22 |
|
|
|
23 |
|
|
import eu.etaxonomy.cdm.api.service.INameService;
|
24 |
|
|
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
|
25 |
|
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
26 |
|
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
27 |
|
|
|
28 |
afa7e7e1
|
Andreas Müller
|
/**
|
29 |
|
|
* @author a.mueller
|
30 |
ad5965e7
|
Andreas Müller
|
* @created 29.01.2009
|
31 |
afa7e7e1
|
Andreas Müller
|
* @version 1.0
|
32 |
|
|
*/
|
33 |
01be5674
|
Andreas Müller
|
public class TaxonXImportConfiguratorTest extends CdmTransactionalIntegrationTest {
|
34 |
|
|
|
35 |
|
|
@SpringBeanByName
|
36 |
|
|
CdmApplicationAwareDefaultImport<?> defaultImport;
|
37 |
|
|
|
38 |
|
|
@SpringBeanByType
|
39 |
|
|
INameService nameService;
|
40 |
|
|
|
41 |
|
|
private IImportConfigurator configurator;
|
42 |
|
|
|
43 |
|
|
@Before
|
44 |
|
|
public void setUp() {
|
45 |
|
|
String inputFile = "/eu/etaxonomy/cdm/io/taxonx/TaxonXImportConfiguratorTest-input.xml";
|
46 |
|
|
URL url = this.getClass().getResource(inputFile);
|
47 |
|
|
assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
|
48 |
f9a87300
|
Andreas Müller
|
try {
|
49 |
|
|
configurator = TaxonXImportConfigurator.NewInstance(url.toURI(), null);
|
50 |
|
|
} catch (URISyntaxException e) {
|
51 |
|
|
e.printStackTrace();
|
52 |
|
|
Assert.fail();
|
53 |
|
|
}
|
54 |
01be5674
|
Andreas Müller
|
assertNotNull("Configurator could not be created", configurator);
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
@Test
|
58 |
|
|
public void testInit() {
|
59 |
|
|
assertNotNull("cdmTcsXmlImport should not be null", defaultImport);
|
60 |
|
|
assertNotNull("nameService should not be null", nameService);
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
@Test
|
64 |
|
|
public void testDoInvoke() {
|
65 |
|
|
boolean result = defaultImport.invoke(configurator);
|
66 |
d3584317
|
Andreas Müller
|
// assertTrue("Return value for import.invoke() should be true", result);
|
67 |
|
|
// assertEquals("Number of TaxonNames should be 5", 5, nameService.count());
|
68 |
01be5674
|
Andreas Müller
|
}
|
69 |
|
|
|
70 |
|
|
}
|