1
|
package eu.dnetlib.data.oai.store.mongo;
|
2
|
|
3
|
import java.io.StringReader;
|
4
|
|
5
|
import org.apache.commons.io.IOUtils;
|
6
|
import org.dom4j.Document;
|
7
|
import org.dom4j.io.SAXReader;
|
8
|
import org.junit.After;
|
9
|
import org.junit.Before;
|
10
|
import org.junit.Test;
|
11
|
import org.springframework.core.io.ClassPathResource;
|
12
|
|
13
|
/**
|
14
|
* ProvenanceExtractor Tester.
|
15
|
*
|
16
|
* @author <Authors name>
|
17
|
* @version 1.0
|
18
|
* @since <pre>Apr 6, 2016</pre>
|
19
|
*/
|
20
|
public class ProvenanceExtractorTest {
|
21
|
|
22
|
final ProvenanceExtractor extractor = new ProvenanceExtractor();
|
23
|
final SAXReader reader = new SAXReader();
|
24
|
private Document doc;
|
25
|
private String filePath = "/eu/dnetlib/data/oai/store/mongo/testRecord.xml";
|
26
|
|
27
|
@Before
|
28
|
public void before() throws Exception {
|
29
|
String testRecord = IOUtils.toString(new ClassPathResource(filePath).getInputStream());
|
30
|
doc = reader.read(new StringReader(testRecord));
|
31
|
}
|
32
|
|
33
|
@After
|
34
|
public void after() throws Exception {
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* Method: evaluate(final Document xmlDoc)
|
39
|
*/
|
40
|
@Test
|
41
|
public void testEvaluate() throws Exception {
|
42
|
long timeStart = System.currentTimeMillis();
|
43
|
String prov = extractor.evaluate(doc);
|
44
|
long timeEnd = System.currentTimeMillis();
|
45
|
System.out.println("Got provenance in ms " + (timeEnd - timeStart));
|
46
|
System.out.println(prov);
|
47
|
}
|
48
|
|
49
|
}
|