Project

General

Profile

« Previous | Next » 

Revision 48023

integrated latest changes from dnet40

View differences:

HTTPCSVCollectorPluginTest.java
3 3
import java.net.URISyntaxException;
4 4
import java.util.HashMap;
5 5

  
6
import org.junit.Assert;
7
import org.junit.Test;
8

  
9 6
import eu.dnetlib.data.collector.plugins.HttpCSVCollectorPlugin;
10 7
import eu.dnetlib.data.collector.rmi.CollectorServiceException;
11 8
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor;
9
import org.junit.Test;
12 10

  
11
import static org.junit.Assert.assertFalse;
12
import static org.junit.Assert.assertTrue;
13

  
13 14
public class HTTPCSVCollectorPluginTest {
14 15

  
15 16
	private String FILE_URL = HTTPCSVCollectorPluginTest.class.getResource("testCSVwithBOM.csv").toString();
17
	final HttpCSVCollectorPlugin plugin = new HttpCSVCollectorPlugin();
16 18

  
17
	// private String FILE_URL = "file:///Users/michele/Downloads/P3_GrantExport.csv";
18

  
19 19
	@Test
20 20
	public void testCSVHeader() throws URISyntaxException, CollectorServiceException {
21 21

  
......
27 27
		params.put("identifier", "ID");
28 28
		descr.setBaseUrl(FILE_URL);
29 29
		descr.setParams(params);
30
		final HttpCSVCollectorPlugin plugin = new HttpCSVCollectorPlugin();
30

  
31 31
		int i = 0;
32 32
		for (final String s : plugin.collect(descr, null, null)) {
33
			Assert.assertTrue(s.length() > 0);
33
			assertTrue(s.length() > 0);
34 34
			System.out.println(s);
35

  
36 35
			i++;
37 36
		}
38
		Assert.assertTrue(i > 0);
37
		System.out.println(i);
38
		assertTrue(i > 0);
39 39
	}
40

  
41
	@Test
42
	public void testVerifyQuotesOk(){
43
		String correct = "\"5\",\"Il Padrino\",\"EEEEEEEE \"\"ZZZZZ\"\" EEEEEEEEEE\",1970";
44
		assertTrue(plugin.verifyQuotes(correct, ','));
45
	}
46

  
47
	@Test
48
	public void testVerifyQuotesWRONG(){
49
		String correct = "5\",\"Il Padrino\",\"EEEEEEEE \"ZZZZZ\" EEEEEEEEEE\",1970";
50
		assertFalse(plugin.verifyQuotes(correct, ','));
51
	}
52

  
53
	@Test
54
	public void testSNSF(){
55
		String s = "\"8773\";\"3101-008773\";\"EMBO workshop on structure, function and regulation of membrane transport proteins\";\"\";\"Rossier Bernard C.\";\"Scientific Conferences\";\"Science communication\";\"Département de Pharmacologie & Toxicologie Faculté de Biologie et de Médecine Université de Lausanne\";\"Université de Lausanne - LA\";\"30103\";\"Cellular Biology, Cytology\";\"Biology and Medicine;Basic Biological Research\";\"01.04.1987\";\"30.09.1987\";\"10000.00\";\"\";\"30103\"" ;
56
		assertTrue(plugin.verifyQuotes(s, ';'));
57
	}
58

  
59
	@Test
60
	public void testSNSF2(){
61
		String s = "\"11000\";\"4021-011000\";\"Literarische und nationale Erziehung : Schweizerisches Selbstverständnis in der Literatur für Kinder und Jugend- liche\";\"\";\"Tschirky Rosmarie\";\"NRP 21 Cultural Diversity and National Identity\";\"Programmes;National Research Programmes (NRPs)\";\"Schweiz. Inst. für Kinder- und Jugendmedien\";\"Universität Zürich - ZH\";\"10501\";\"German and English languages and literature\";\"Human and Social Sciences;Linguistics and literature, philosophy\";\"10501\";\"01.10.1986\";\"31.03.1990\";\"308807.00\";\"\"";
62
		assertTrue(plugin.verifyQuotes(s, ';'));
63
	}
64

  
65
	@Test
66
	public void testSNSFInvalid(){
67
		String s = "\"35918\";\"1113-035918\";\"Entwicklung eines dreisprachigen Thesaurus des schweizerischen Rechts zur Unterstützung der Suche in Volltextdatenbanken.\";\"\";\"Verein \"Schweizerische Juristische Datenbank\"\";\"Project funding (Div. I-III)\";\"Project funding\";\"Verein \"\"Schweizerische Juristische Datenbank\"\"\";\"NPO (Biblioth., Museen, Verwalt.) - NPO\";\"10205\";\"Legal sciences\";\"Human and Social Sciences;Economics, law\";\"10205\";\"01.12.1992\";\"31.03.1995\";\"500366.00\";\"\"";
68
		assertFalse(plugin.verifyQuotes(s, ';'));
69
	}
70

  
40 71
}

Also available in: Unified diff