Project

General

Profile

Download (2.38 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.common.URI;
28
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
29
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
30
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
31

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

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

    
41
	@SpringBeanByType
42
	private INameService nameService;
43

    
44
	private IImportConfigurator configurator;
45

    
46
	@Before
47
	public void setUp() {
48
		String inputFile = "/eu/etaxonomy/cdm/io/tcsrdf/TcsRdfImportConfiguratorTest-input.xml";
49
		URL url = this.getClass().getResource(inputFile);
50
		assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
51
		try {
52
			configurator = TcsRdfImportConfigurator.NewInstance(URI.fromUrl(url), null);
53
		} catch (URISyntaxException e) {
54
			e.printStackTrace();
55
			Assert.fail();
56
		}
57
		assertNotNull("Configurator could not be created", configurator);
58
	}
59

    
60
	@Test
61
	public void testInit() {
62
		assertNotNull("cdmTcsXmlImport should not be null", defaultImport);
63
		assertNotNull("nameService should not be null", nameService);
64
	}
65

    
66
	@Test
67
	@DataSet(value="/eu/etaxonomy/cdm/database/ClearDBDataSet.xml")
68
	public void testDoInvoke() {
69
		boolean result = defaultImport.invoke(configurator).isSuccess();
70
		assertTrue("Return value for import.invoke should be true", result);
71
		assertEquals("Number of TaxonNames should be 5", 5, nameService.count(null));
72
	}
73

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