Project

General

Profile

« Previous | Next » 

Revision 57701

changed test for readexcel plugin

View differences:

modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/excel/ReadExcelTest.java
17 17
	private InterfaceDescriptor descr;
18 18
	private Read r;
19 19

  
20
	private String excelPath = "eu/dnetlib/data/collector/plugins/excel/fwf_projects_100.xlsx";
20
	//private String excelPath = "eu/dnetlib/data/collector/plugins/excel/fwf_projects_100.xlsx";
21 21

  
22

  
22 23
	@Before
23 24
	public void setUp() throws Exception {
24 25
		descr = new InterfaceDescriptor();
25
		descr.setBaseUrl("https://pf.fwf.ac.at/en/research-in-practice/project-finder.xlsx?&&&search%5Bcall%5D=&search%5Bdecision_board_ids%5D=&search%5Bend_date%5D=&search%5Binstitute_name%5D=&search%5Blead_firstname%5D=&search%5Blead_lastname%5D=&search%5Bper_page%5D=10&search%5Bproject_number%5D=&search%5Bproject_title%5D=&search%5Bscience_discipline_id%5D=&search%5Bstart_date%5D=&search%5Bstatus_id%5D=&search%5Bwhat%5D=&action=index&controller=projects&locale=en&per_page=10" );
26
		//descr.setBaseUrl("https://pf.fwf.ac.at/en/research-in-practice/project-finder.xlsx?&&&search%5Bcall%5D=&search%5Bdecision_board_ids%5D=&search%5Bend_date%5D=&search%5Binstitute_name%5D=&search%5Blead_firstname%5D=&search%5Blead_lastname%5D=&search%5Bper_page%5D=10&search%5Bproject_number%5D=&search%5Bproject_title%5D=&search%5Bscience_discipline_id%5D=&search%5Bstart_date%5D=&search%5Bstatus_id%5D=&search%5Bwhat%5D=&action=index&controller=projects&locale=en&per_page=10" );
26 27
		HashMap<String, String> params = new HashMap<String, String>();
27 28

  
28
		params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}}");
29
		params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}, \"replace_currency\":[{\"from\":\"a\", \"to\":\"b\"}],\"col_currency\":3}");
29 30

  
31

  
30 32
		params.put("header_row","4");
31 33
		params.put("tmp_file","//tmp//fwf.xslx");
32 34
		params.put("remove_empty_lines","yes");
......
38 40
		params.put("separator", ",");
39 41
		params.put("quote","\"");
40 42
		descr.setParams(params);
41
//		descr.setBaseUrl("file:///tmp/gsrt_whole.xlsx");
43

  
44

  
45
		//descr.setBaseUrl(excelPath);
42 46
//		HashMap<String, String> params = new HashMap<String, String>();
43 47
//
44 48
//		params.put("header_row","0");
45
//		params.put("tmp_file","/tmp/ERC.xslx");
49
//		params.put("tmp_file","/tmp/RSF.xslx");
46 50
//		params.put("remove_empty_lines","yes");
47
//		params.put("remove_lines_with_id"," – ");
48
//		params.put("col_id","2");
51
//		params.put("remove_lines_with_id","-“ ");
52
//		params.put("col_id","0");
49 53
//		params.put("remove_tmp_file","no");
50
//		params.put("sheet_number","0");
51
//		params.put("file_to_save","/tmp/ERC.csv");
54
//		params.put("sheet_number","1");
55
//		params.put("file_to_save","/tmp/RSF.csv");
52 56
//		params.put("separator", ",");
53 57
//		params.put("quote","\"");
54 58
//		descr.setParams(params);
......
56 60
		r.setCollector(new HttpCSVCollectorPlugin());
57 61
	}
58 62

  
63
//	@Test
64
//	//@Ignore
65
//	public void readExcelFromUrl()throws Exception{
66
//		Iterator<String> it = r.parseFile().iterator();
67
//		int i = 0;
68
//		String st = null;
69
//		try {
70
//			while (it.hasNext()) {
71
//				st = it.next();
72
//				Assert.assertNotNull(st);
73
//				i++;
74
//				//System.out.println(it.next());
75
//			}
76
//		}catch(Exception e){
77
//			System.out.println("linea " + i);
78
//			e.printStackTrace();
79
//			System.out.println(st);
80
//		}
81
//
82
//	}
83

  
59 84
	@Test
60
	//@Ignore
61
	public void readExcelFromUrl()throws Exception{
85
	public void readExcelFromFile() throws Exception{
62 86
		Iterator<String> it = r.parseFile().iterator();
63
		int i = 0;
87
		int i =1;
64 88
		String st = null;
65 89
		try {
66 90
			while (it.hasNext()) {
......
75 99
			System.out.println(st);
76 100
		}
77 101

  
102

  
78 103
	}
79

  
80
//	@Test
81
//	public void readExcelFromFile() throws Exception{
82
//		Iterator<String> it = r.parseFile().iterator();
83
//		int i =1;
84
//		String st = null;
85
//		try {
86
//			while (it.hasNext()) {
87
//				st = it.next();
88
//				Assert.assertNotNull(st);
89
//				i++;
90
//				//System.out.println(it.next());
91
//			}
92
//		}catch(Exception e){
93
//			System.out.println("linea " + i);
94
//			e.printStackTrace();
95
//			System.out.println(st);
96
//		}
97
//
98
//
99
//	}
100 104
}

Also available in: Unified diff