Project

General

Profile

Download (2.34 KB) Statistics
| Branch: | Tag: | Revision:
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.tcsrdf;
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

    
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;
25

    
26
import eu.etaxonomy.cdm.api.service.INameService;
27
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
28
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
29
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
30

    
31
/**
32
 * @author a.mueller
33
 * @since 29.01.2009
34
 */
35
public class TcsRdfImportConfiguratorTest extends CdmTransactionalIntegrationTest {
36

    
37
	@SpringBeanByName
38
	private CdmApplicationAwareDefaultImport<?> defaultImport;
39

    
40
	@SpringBeanByType
41
	private INameService nameService;
42

    
43
	private IImportConfigurator configurator;
44

    
45
	@Before
46
	public void setUp() {
47
		String inputFile = "/eu/etaxonomy/cdm/io/tcsrdf/TcsRdfImportConfiguratorTest-input.xml";
48
		URL url = this.getClass().getResource(inputFile);
49
		assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
50
		try {
51
			configurator = TcsRdfImportConfigurator.NewInstance(url.toURI(), null);
52
		} catch (URISyntaxException e) {
53
			e.printStackTrace();
54
			Assert.fail();
55
		}
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
	@DataSet(value="/eu/etaxonomy/cdm/database/ClearDBDataSet.xml")
67
	public void testDoInvoke() {
68
		boolean result = defaultImport.invoke(configurator).isSuccess();
69
		assertTrue("Return value for import.invoke should be true", result);
70
		assertEquals("Number of TaxonNames should be 5", 5, nameService.count(null));
71
	}
72

    
73
    @Override
74
    public void createTestDataSet() throws FileNotFoundException {}
75
}
    (1-1/1)