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.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.BeforeClass;
|
22
|
import org.junit.Test;
|
23
|
|
24
|
import eu.etaxonomy.cdm.io.common.events.LoggingIoObserver;
|
25
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
26
|
import eu.etaxonomy.cdm.model.name.Rank;
|
27
|
|
28
|
/**
|
29
|
* @author a.mueller
|
30
|
* @date 23.11.2011
|
31
|
*/
|
32
|
public class DwcaImportTest {
|
33
|
@SuppressWarnings("unused")
|
34
|
private static final Logger logger = Logger.getLogger(DwcaImportTest.class);
|
35
|
|
36
|
private URI uri;
|
37
|
private DwcaImportConfigurator configurator;
|
38
|
private DwcaImport dwcaImport;
|
39
|
private DwcaImportState state;
|
40
|
|
41
|
@BeforeClass
|
42
|
public static void setUpBeforeClass() throws Exception{
|
43
|
if (Rank.SPECIES() == null){
|
44
|
DefaultTermInitializer initializer = new DefaultTermInitializer();
|
45
|
initializer.initialize();
|
46
|
}
|
47
|
}
|
48
|
|
49
|
|
50
|
/**
|
51
|
* @throws java.lang.Exception
|
52
|
*/
|
53
|
@Before
|
54
|
public void setUp() throws Exception {
|
55
|
String inputFile = "/eu/etaxonomy/cdm/io/dwca/in/DwcaZipToStreamConverterTest-input.zip";
|
56
|
URL url = this.getClass().getResource(inputFile);
|
57
|
uri = url.toURI();
|
58
|
assertNotNull("URI for the test file '" + inputFile + "' does not exist", uri);
|
59
|
try {
|
60
|
configurator = DwcaImportConfigurator.NewInstance(url.toURI(), null);
|
61
|
configurator.addObserver(new LoggingIoObserver());
|
62
|
} catch (URISyntaxException e) {
|
63
|
e.printStackTrace();
|
64
|
Assert.fail();
|
65
|
}
|
66
|
assertNotNull("Configurator could not be created", configurator);
|
67
|
dwcaImport = new DwcaImport();
|
68
|
state = new DwcaImportState(configurator);
|
69
|
}
|
70
|
|
71
|
|
72
|
@Test
|
73
|
public void testResultSet() {
|
74
|
boolean result = dwcaImport.invoke(state);
|
75
|
Assert.assertTrue("Import result should be true", result);
|
76
|
}
|
77
|
|
78
|
}
|