1
|
package eu.dnetlib.data.collector.plugins.httpfilename;
|
2
|
import java.util.Iterator;
|
3
|
|
4
|
import org.junit.Ignore;
|
5
|
import org.junit.Test;
|
6
|
|
7
|
|
8
|
/**
|
9
|
* Created by miriam on 07/05/2018.
|
10
|
*/
|
11
|
@Ignore
|
12
|
public class HTTPWithFileNameTest {
|
13
|
|
14
|
private void iterate(Iterator<String> iterator, boolean exit){
|
15
|
try{
|
16
|
while (iterator.hasNext()){
|
17
|
|
18
|
System.out.println(iterator.next());
|
19
|
if(exit)
|
20
|
System.exit(0);
|
21
|
|
22
|
|
23
|
}
|
24
|
|
25
|
}catch(Exception ex){
|
26
|
ex.printStackTrace();
|
27
|
}
|
28
|
}
|
29
|
|
30
|
@Test
|
31
|
@Ignore
|
32
|
public void testRSCollectorFrontiers()
|
33
|
{
|
34
|
HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/Frontiers/data/Frontiers/metadata/000/",null);
|
35
|
iterate(rsc.iterator(),false);
|
36
|
|
37
|
}
|
38
|
|
39
|
@Test
|
40
|
@Ignore
|
41
|
public void testRSCollectorPLOSCount()
|
42
|
{
|
43
|
HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/PLOS/data/public_library_of_science/metadata/354/","article-type=\"correction\"");
|
44
|
Iterator<String> iterator = rsc.iterator();
|
45
|
int count = 0;
|
46
|
int body = 0;
|
47
|
int corrections = 0;
|
48
|
try{
|
49
|
while (iterator.hasNext()){
|
50
|
|
51
|
String meta = iterator.next();
|
52
|
if (!meta.contains("article-type=\"correction\"")){
|
53
|
count++;
|
54
|
int index = meta.indexOf("<body>");
|
55
|
if(meta.substring(index).contains("<sec"))
|
56
|
body++;
|
57
|
else {
|
58
|
System.out.println(meta);
|
59
|
System.out.println(count);
|
60
|
}
|
61
|
|
62
|
}else
|
63
|
corrections++;
|
64
|
|
65
|
}
|
66
|
System.out.println(count + " " + body + " " + corrections);
|
67
|
}catch(Exception ex){
|
68
|
ex.printStackTrace();
|
69
|
}
|
70
|
}
|
71
|
|
72
|
@Test
|
73
|
@Ignore
|
74
|
public void testRSCollectorPLOS()
|
75
|
{
|
76
|
HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/PLOS/data/public_library_of_science/metadata/400/","article-type=\"correction\"");
|
77
|
|
78
|
|
79
|
iterate(rsc.iterator(),false);
|
80
|
}
|
81
|
|
82
|
@Test
|
83
|
@Ignore
|
84
|
public void testRSCollectorSpringer()
|
85
|
{
|
86
|
HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/Springer-OA/data/Springer-OA/metadata/8a0/",null);
|
87
|
|
88
|
iterate(rsc.iterator(),false);
|
89
|
|
90
|
}
|
91
|
|
92
|
@Test
|
93
|
public void testEmptyCollection()
|
94
|
{
|
95
|
HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("",null);
|
96
|
|
97
|
iterate(rsc.iterator(),true);
|
98
|
}
|
99
|
|
100
|
@Test
|
101
|
@Ignore
|
102
|
public void testCheck(){
|
103
|
HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/Elsevier/data/elsevier/metadata/000/",null);
|
104
|
Iterator<String> iterator = rsc.iterator();
|
105
|
int count=0;
|
106
|
while (iterator.hasNext()) {
|
107
|
iterator.next();
|
108
|
count += 1;
|
109
|
}
|
110
|
System.out.println("count = " + count);
|
111
|
}
|
112
|
|
113
|
}
|