1
|
import java.io.BufferedReader;
|
2
|
import java.io.InputStreamReader;
|
3
|
|
4
|
import org.apache.log4j.BasicConfigurator;
|
5
|
import org.junit.*;
|
6
|
|
7
|
import eu.dnetlib.data.utility.resource_discovery.plugin.ResourceDiscoveryPlugin;
|
8
|
|
9
|
|
10
|
public class TestPlugin {
|
11
|
|
12
|
MySourceDataProvider provider;
|
13
|
static private int N = 7;
|
14
|
|
15
|
@BeforeClass
|
16
|
public static void Config() {
|
17
|
BasicConfigurator.configure();
|
18
|
}
|
19
|
|
20
|
@Before
|
21
|
public void InitializeProvider() throws Exception {
|
22
|
provider = new MySourceDataProvider();
|
23
|
for(int i=7;i<=N;i++) {
|
24
|
BufferedReader br = new BufferedReader(new InputStreamReader(TestPlugin.class.getResourceAsStream("record"+i+".xml")));
|
25
|
|
26
|
String line;
|
27
|
String record = "";
|
28
|
while((line = br.readLine()) != null)
|
29
|
record += line;
|
30
|
provider.addDMFRecord(record);
|
31
|
}
|
32
|
}
|
33
|
|
34
|
@Test
|
35
|
public void TestResourcePlugin() throws Exception {
|
36
|
ResourceDiscoveryPlugin plugin = new ResourceDiscoveryPlugin();
|
37
|
plugin.setDao(new MyResultDao());
|
38
|
plugin.setSourceDataProvider(provider);
|
39
|
plugin.init();
|
40
|
|
41
|
//System.out.println(provider.getRecords(1, 2));
|
42
|
//System.out.println(provider.getRecords(1, 2).size());
|
43
|
plugin.execute();
|
44
|
System.out.println("\n\n" + plugin.getDao().getResults(1, 1));
|
45
|
}
|
46
|
|
47
|
}
|