Project

General

Profile

Download (2.88 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.dwca.in;
11

    
12
import static org.junit.Assert.assertNotNull;
13

    
14
import java.io.FileNotFoundException;
15
import java.net.URI;
16
import java.net.URISyntaxException;
17
import java.net.URL;
18

    
19
import org.apache.log4j.Logger;
20
import org.junit.Assert;
21
import org.junit.Before;
22
import org.junit.Test;
23
import org.unitils.database.annotations.Transactional;
24
import org.unitils.spring.annotation.SpringBeanByName;
25

    
26
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
27
import eu.etaxonomy.cdm.io.common.events.LoggingIoObserver;
28
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
29
import org.unitils.database.util.TransactionMode;
30

    
31
/**
32
 * @author a.mueller
33
 * @date 23.11.2011
34
 */
35
@Transactional(TransactionMode.ROLLBACK)
36
public class DwcaImportIntegrationTest extends CdmTransactionalIntegrationTest{
37
	@SuppressWarnings("unused")
38
	private static final Logger logger = Logger.getLogger(DwcaImportIntegrationTest.class);
39
	
40
	@SpringBeanByName
41
	CdmApplicationAwareDefaultImport<?> defaultImport;
42

    
43
	private URI uri;
44
	private DwcaImportConfigurator configurator;
45
	/**
46
	 * @throws java.lang.Exception
47
	 */
48
	@Before
49
	public void setUp() throws Exception {
50
		String inputFile = "/eu/etaxonomy/cdm/io/dwca/in/DwcaZipToStreamConverterTest-input.zip";
51
		URL url = this.getClass().getResource(inputFile);
52
		uri = url.toURI();
53
		assertNotNull("URI for the test file '" + inputFile + "' does not exist", uri);
54
		try {
55
			configurator = DwcaImportConfigurator.NewInstance(url.toURI(), null);
56
			configurator.addObserver(new LoggingIoObserver());
57
		} catch (URISyntaxException e) {
58
			e.printStackTrace();
59
			Assert.fail();
60
		}
61
		assertNotNull("Configurator could not be created", configurator);
62
	}
63
	
64
	@Test
65
	public void testInit() {
66
		assertNotNull("import instance should not be null", defaultImport);
67
		assertNotNull("configurator instance should not be null", configurator);
68
	}
69
	
70
	@Test
71
	public void testInvoke() {
72
		configurator.setDefaultPartitionSize(3);
73
		boolean result = defaultImport.invoke(configurator);
74
		Assert.assertTrue("Invoke should return true", result);
75
		//to be continued
76
//		final String[]tableNames = {"TaxonBase","TaxonNameBase","Classification",
77
//                "SynonymRelationship","TaxonNode",
78
//                "HomotypicalGroup"};
79
//		commitAndStartNewTransaction(tableNames);
80
	}
81

    
82
    /* (non-Javadoc)
83
     * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
84
     */
85
    @Override
86
    public void createTestDataSet() throws FileNotFoundException {
87
        // TODO Auto-generated method stub
88
        
89
    }
90

    
91
}
(2-2/3)