1
|
package eu.dnetlib.data.collector.plugins.httplist;
|
2
|
|
3
|
import java.io.File;
|
4
|
import java.io.FileWriter;
|
5
|
import java.io.IOException;
|
6
|
import java.util.Iterator;
|
7
|
|
8
|
import eu.dnetlib.data.collector.plugins.HttpConnector;
|
9
|
import org.apache.commons.io.FileUtils;
|
10
|
import org.junit.Before;
|
11
|
import org.junit.Ignore;
|
12
|
import org.junit.Test;
|
13
|
|
14
|
public class HttpListIteratorTest {
|
15
|
|
16
|
private HttpConnector httpConnector;
|
17
|
// Under test
|
18
|
private Iterator<String> iter;
|
19
|
|
20
|
@Before
|
21
|
public void setUp() throws Exception {
|
22
|
httpConnector = new HttpConnector();
|
23
|
iter = new HttpListIterator("http://www.dlib.org/", "http://www.dlib.org/metadata/dlib_meta_files.txt", httpConnector);
|
24
|
}
|
25
|
|
26
|
@Test
|
27
|
@Ignore
|
28
|
public void testHttpListIterator() throws IOException {
|
29
|
FileUtils.forceMkdir(new File("/tmp/dlibmagazine"));
|
30
|
|
31
|
int i = 0;
|
32
|
while (iter.hasNext()) {
|
33
|
final String file = "/tmp/dlibmagazine/" + i++ + ".xml";
|
34
|
final FileWriter fw = new FileWriter(file);
|
35
|
System.out.println("Download " + file);
|
36
|
fw.append(iter.next());
|
37
|
fw.flush();
|
38
|
fw.close();
|
39
|
}
|
40
|
System.out.println("* END *");
|
41
|
}
|
42
|
}
|