Project

General

Profile

« Previous | Next » 

Revision 52242

testing for HTTPCOllectorWithFileNamePlugin

View differences:

modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/excel/ReadExcelTest.java
26 26

  
27 27
		params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}," +
28 28
				"\"replace_currency\":[{\"from\":\"$\",\"to\":\"€\"}],\"col_currency\":10}");
29

  
30
		params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}," +
31
				"\"replace_currency\":[{\"from\":\"$\",\"to\":\"€\"}],\"col_currency\":10}");
29 32
		params.put("header_row","4");
30 33
		params.put("tmp_file","//tmp//fwf.xslx");
31 34
		params.put("remove_empty_lines","yes");
modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/HTTPWithFileName/HTTPWithFileNameTest.java
1
package eu.dnetlib.data.collector.plugins.HTTPWithFileName;
2
import org.junit.Test;
3
import java.util.Iterator;
4

  
5

  
6
/**
7
 * Created by miriam on 07/05/2018.
8
 */
9
public class HTTPWithFileNameTest {
10

  
11
    private void iterate(Iterator<String> iterator, boolean exit){
12
        try{
13
            while (iterator.hasNext()){
14

  
15
                System.out.println(iterator.next());
16
                if(exit)
17
                    System.exit(0);
18

  
19

  
20
            }
21

  
22
        }catch(Exception ex){
23
            ex.printStackTrace();
24
        }
25
    }
26

  
27
    @Test
28
    public void testRSCollectorFrontiers()
29
    {
30
        HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/Frontiers/data/Frontiers/metadata/000/",null);
31
        iterate(rsc.iterator(),false);
32

  
33
    }
34

  
35
    @Test
36
    public void testRSCollectorPLOSCount()
37
    {
38
        HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/PLOS/data/public_library_of_science/metadata/354/","article-type=\"correction\"");
39
        Iterator<String> iterator = rsc.iterator();
40
        int count = 0;
41
        int body = 0;
42
        int corrections = 0;
43
        try{
44
            while (iterator.hasNext()){
45

  
46
                String meta = iterator.next();
47
                if (!meta.contains("article-type=\"correction\"")){
48
                    count++;
49
                    int index = meta.indexOf("<body>");
50
                    if(meta.substring(index).contains("<sec"))
51
                        body++;
52
                    else {
53
                        System.out.println(meta);
54
                        System.out.println(count);
55
                    }
56

  
57
                }else
58
                    corrections++;
59

  
60
            }
61
            System.out.println(count + "       "  + body + "                  " + corrections);
62
        }catch(Exception ex){
63
            ex.printStackTrace();
64
        }
65
    }
66

  
67
    @Test
68
    public void testRSCollectorPLOS()
69
    {
70
        HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/PLOS/data/public_library_of_science/metadata/400/","article-type=\"correction\"");
71

  
72

  
73
        iterate(rsc.iterator(),false);
74
    }
75

  
76
    @Test
77
    public void testRSCollectorSpringer()
78
    {
79
        HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("https://dev-openaire.d4science.org/RS/Springer-OA/data/Springer-OA/metadata/8a0/",null);
80

  
81
        iterate(rsc.iterator(),false);
82

  
83
    }
84

  
85
    @Test
86
    public void testEmptyCollection()
87
    {
88
        HTTPWithFileNameCollectorIterable rsc = new HTTPWithFileNameCollectorIterable("",null);
89

  
90
        iterate(rsc.iterator(),true);
91
    }
92

  
93

  
94
}

Also available in: Unified diff