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.net.URL;
17  
18  import org.junit.Before;
19  import org.junit.Ignore;
20  import org.junit.Test;
21  import org.unitils.spring.annotation.SpringBeanByName;
22  import org.unitils.spring.annotation.SpringBeanByType;
23  
24  import eu.etaxonomy.cdm.api.service.INameService;
25  import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
26  import eu.etaxonomy.cdm.io.common.IImportConfigurator;
27  import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
28  
29  /**
30   * @author a.mueller
31   * @created 29.01.2009
32   * @version 1.0
33   */
34  @Ignore  //TODO some strange Hibernate exceptions appear if running this test in maven (in line with other tests)
35  public class TcsRdfImportConfiguratorTest extends CdmTransactionalIntegrationTest {
36  	
37  	@SpringBeanByName
38  	CdmApplicationAwareDefaultImport<?> defaultImport;
39  
40  	@SpringBeanByType
41  	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  		configurator = TcsRdfImportConfigurator.NewInstance(url.toString(), null);
51  		assertNotNull("Configurator could not be created", configurator);
52  	}
53  	
54  	@Test
55  	public void testInit() {
56  		assertNotNull("cdmTcsXmlImport should not be null", defaultImport);
57  		assertNotNull("nameService should not be null", nameService);
58  	}
59  	
60  	@Test
61  	public void testDoInvoke() {
62  		boolean result = defaultImport.invoke(configurator);
63  		assertTrue("Return value for import.invoke should be true", result);
64  		assertEquals("Number of TaxonNames should be 5", 5, nameService.count(null));
65  	}
66  
67  }