1
|
/**
|
2
|
* Copyright (C) 2009 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.dwca.in;
|
10
|
|
11
|
import static org.junit.Assert.assertNotNull;
|
12
|
|
13
|
import java.io.FileNotFoundException;
|
14
|
import java.net.URI;
|
15
|
import java.net.URISyntaxException;
|
16
|
import java.net.URL;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
import org.junit.Assert;
|
20
|
import org.junit.Before;
|
21
|
import org.junit.Test;
|
22
|
import org.unitils.database.annotations.Transactional;
|
23
|
import org.unitils.database.util.TransactionMode;
|
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
|
|
30
|
/**
|
31
|
* @author a.mueller
|
32
|
* @date 23.11.2011
|
33
|
*/
|
34
|
@Transactional(TransactionMode.ROLLBACK)
|
35
|
public class DwcaImportIntegrationTest extends CdmTransactionalIntegrationTest{
|
36
|
@SuppressWarnings("unused")
|
37
|
private static final Logger logger = Logger.getLogger(DwcaImportIntegrationTest.class);
|
38
|
|
39
|
@SpringBeanByName
|
40
|
CdmApplicationAwareDefaultImport<?> defaultImport;
|
41
|
|
42
|
private URI uri;
|
43
|
private DwcaImportConfigurator configurator;
|
44
|
/**
|
45
|
* @throws java.lang.Exception
|
46
|
*/
|
47
|
@Before
|
48
|
public void setUp() throws Exception {
|
49
|
String inputFile = "/eu/etaxonomy/cdm/io/dwca/in/DwcaZipToStreamConverterTest-input.zip";
|
50
|
URL url = this.getClass().getResource(inputFile);
|
51
|
uri = url.toURI();
|
52
|
assertNotNull("URI for the test file '" + inputFile + "' does not exist", uri);
|
53
|
try {
|
54
|
configurator = DwcaImportConfigurator.NewInstance(url.toURI(), null);
|
55
|
configurator.addObserver(new LoggingIoObserver());
|
56
|
} catch (URISyntaxException e) {
|
57
|
e.printStackTrace();
|
58
|
Assert.fail();
|
59
|
}
|
60
|
assertNotNull("Configurator could not be created", configurator);
|
61
|
}
|
62
|
|
63
|
@Test
|
64
|
public void testInit() {
|
65
|
assertNotNull("import instance should not be null", defaultImport);
|
66
|
assertNotNull("configurator instance should not be null", configurator);
|
67
|
}
|
68
|
|
69
|
@Test
|
70
|
public void testInvoke() {
|
71
|
configurator.setDefaultPartitionSize(3);
|
72
|
boolean result = defaultImport.invoke(configurator).isSuccess();
|
73
|
Assert.assertTrue("Invoke should return true", result);
|
74
|
//to be continued
|
75
|
// final String[]tableNames = {"TaxonBase","TaxonNameBase","Classification",
|
76
|
// "TaxonNode","HomotypicalGroup"};
|
77
|
// commitAndStartNewTransaction(tableNames);
|
78
|
}
|
79
|
|
80
|
/* (non-Javadoc)
|
81
|
* @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
|
82
|
*/
|
83
|
@Override
|
84
|
public void createTestDataSet() throws FileNotFoundException {
|
85
|
// TODO Auto-generated method stub
|
86
|
|
87
|
}
|
88
|
|
89
|
}
|