1
|
package eu.dnetlib.oai.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
|
19
|
*
|
20
|
* <pre>
|
21
|
* Apr 6, 2016
|
22
|
* </pre>
|
23
|
*/
|
24
|
public class ProvenanceExtractorTest {
|
25
|
|
26
|
final ProvenanceExtractor extractor = new ProvenanceExtractor();
|
27
|
final SAXReader reader = new SAXReader();
|
28
|
private Document doc;
|
29
|
private final String filePath = "/eu/dnetlib/oai/mongo/testRecord.xml";
|
30
|
|
31
|
@Before
|
32
|
public void before() throws Exception {
|
33
|
final String testRecord = IOUtils.toString(new ClassPathResource(this.filePath).getInputStream());
|
34
|
this.doc = this.reader.read(new StringReader(testRecord));
|
35
|
}
|
36
|
|
37
|
@After
|
38
|
public void after() throws Exception {}
|
39
|
|
40
|
/**
|
41
|
* Method: evaluate(final Document xmlDoc)
|
42
|
*/
|
43
|
@Test
|
44
|
public void testEvaluate() throws Exception {
|
45
|
final long timeStart = System.currentTimeMillis();
|
46
|
final String prov = this.extractor.apply(this.doc);
|
47
|
final long timeEnd = System.currentTimeMillis();
|
48
|
System.out.println("Got provenance in ms " + (timeEnd - timeStart));
|
49
|
System.out.println(prov);
|
50
|
}
|
51
|
|
52
|
}
|