Revision 53895
Added by Alessia Bardi over 5 years ago
HttpSimpleCollectorPluginTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.collector.plugins; |
2 | 2 |
|
3 | 3 |
import com.google.common.collect.Lists; |
4 |
import eu.dnetlib.data.collector.plugins.oai.engine.HttpConnector; |
|
4 | 5 |
import eu.dnetlib.rmi.data.CollectorServiceException; |
5 | 6 |
import eu.dnetlib.rmi.data.InterfaceDescriptor; |
6 | 7 |
import org.junit.Assert; |
... | ... | |
18 | 19 |
|
19 | 20 |
private InterfaceDescriptor apiDescriptor; |
20 | 21 |
private HttpSimpleCollectorPlugin plugin; |
22 |
private HttpConnector connector; |
|
21 | 23 |
|
22 | 24 |
@Before |
23 | 25 |
public void prepare(){ |
26 |
connector = new HttpConnector(); |
|
24 | 27 |
plugin = new HttpSimpleCollectorPlugin(); |
28 |
plugin.setHttpConnector(connector); |
|
25 | 29 |
apiDescriptor = new InterfaceDescriptor(); |
26 |
apiDescriptor.setBaseUrl("http://data.d4science.org/em1EemhBdUZ0bjNGTWJNNjlxVDltcm9acDFmMHlBSVVHbWJQNStIS0N6Yz0"); |
|
30 |
|
|
27 | 31 |
} |
28 | 32 |
|
29 | 33 |
@Test |
30 | 34 |
public void test() throws CollectorServiceException { |
31 |
Iterable<String> res = plugin.collect(apiDescriptor, null, null); |
|
32 |
Assert.assertTrue(Lists.newArrayList(res).size() == 1); |
|
33 |
for(String r : res){ |
|
34 |
System.out.println(r); |
|
35 |
Assert.assertNotNull(r); |
|
35 |
apiDescriptor.setBaseUrl("http://data.d4science.org/em1EemhBdUZ0bjNGTWJNNjlxVDltcm9acDFmMHlBSVVHbWJQNStIS0N6Yz0"); |
|
36 |
Iterable<String> res = plugin.collect(apiDescriptor, null, null); |
|
37 |
Assert.assertTrue(Lists.newArrayList(res).size() == 1); |
|
38 |
for(String r : res){ |
|
39 |
System.out.println(r); |
|
40 |
Assert.assertNotNull(r); |
|
41 |
} |
|
36 | 42 |
} |
37 | 43 |
|
44 |
@Test |
|
45 |
public void test301() throws CollectorServiceException { |
|
46 |
apiDescriptor.setBaseUrl("http://data.huma-num.fr/parthenos/nakala/"); |
|
47 |
Iterable<String> res = plugin.collect(apiDescriptor, null, null); |
|
48 |
Assert.assertTrue(Lists.newArrayList(res).size() == 1); |
|
49 |
for(String r : res){ |
|
50 |
System.out.println(r); |
|
51 |
Assert.assertNotNull(r); |
|
52 |
} |
|
38 | 53 |
} |
39 | 54 |
|
40 | 55 |
} |
Also available in: Unified diff
HttpSimpleCollectorPlugin now uses HttpConnector so that it can deal with redirect and retries