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

    
10
package eu.etaxonomy.cdm.io.tcsrdf;
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

    
20
import org.junit.Assert;
21
import org.junit.Before;
22
import org.junit.Test;
23
import org.unitils.dbunit.annotation.DataSet;
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.test.integration.CdmTransactionalIntegrationTest;
31

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

    
39
	@SpringBeanByName
40
	CdmApplicationAwareDefaultImport<?> defaultImport;
41

    
42
	@SpringBeanByType
43
	INameService nameService;
44

    
45
	private IImportConfigurator configurator;
46

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

    
75

    
76
    @Override
77
    public void createTestDataSet() throws FileNotFoundException {}
78

    
79
}
    (1-1/1)