Project

General

Profile

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
import eu.dnetlib.oai.mongo.ProvenanceExtractor;
14

    
15
/**
16
 * ProvenanceExtractor Tester.
17
 *
18
 * @author <Authors name>
19
 * @version 1.0
20
 * @since
21
 * 
22
 *        <pre>
23
 * Apr 6, 2016
24
 *        </pre>
25
 */
26
public class ProvenanceExtractorTest {
27

    
28
	final ProvenanceExtractor extractor = new ProvenanceExtractor();
29
	final SAXReader reader = new SAXReader();
30
	private Document doc;
31
	private final String filePath = "/eu/dnetlib/data/oai/store/mongo/testRecord.xml";
32

    
33
	@Before
34
	public void before() throws Exception {
35
		final String testRecord = IOUtils.toString(new ClassPathResource(this.filePath).getInputStream());
36
		this.doc = this.reader.read(new StringReader(testRecord));
37
	}
38

    
39
	@After
40
	public void after() throws Exception {}
41

    
42
	/**
43
	 * Method: evaluate(final Document xmlDoc)
44
	 */
45
	@Test
46
	public void testEvaluate() throws Exception {
47
		final long timeStart = System.currentTimeMillis();
48
		final String prov = this.extractor.apply(this.doc);
49
		final long timeEnd = System.currentTimeMillis();
50
		System.out.println("Got provenance in ms " + (timeEnd - timeStart));
51
		System.out.println(prov);
52
	}
53

    
54
}
(3-3/4)