Project

General

Profile

1
package eu.dnetlib.data.collector.plugins.sftp;
2

    
3
import eu.dnetlib.rmi.data.CollectorServiceException;
4
import eu.dnetlib.rmi.data.InterfaceDescriptor;
5
import org.junit.Assert;
6
import org.junit.Before;
7
import org.junit.Ignore;
8
import org.junit.Test;
9
import org.junit.runner.RunWith;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.test.context.ContextConfiguration;
12
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
13

    
14
/**
15
 * Created by alessia on 16/03/17.
16
 */
17
@RunWith(SpringJUnit4ClassRunner.class)
18
@ContextConfiguration
19
@Ignore
20
public class SftpPubKeyCollectorPluginTest {
21

    
22
	@Autowired
23
	private  SftpPubKeyCollectorPlugin plugin;
24
	private InterfaceDescriptor apiDescriptor;
25
	private int max_records = 10;
26

    
27
	@Before
28
	public void prepare(){
29
		apiDescriptor = new InterfaceDescriptor();
30
		apiDescriptor.setBaseUrl("sftp://ariadne2.isti.cnr.it/../../data/transform/old/acdm_correct/dir_021");
31
		apiDescriptor.setProtocol("sftp");
32
		apiDescriptor.setId("testSFTP");
33
		apiDescriptor.getParams().put("recursive", "true");
34
		apiDescriptor.getParams().put("extensions", "xml");
35
		apiDescriptor.getParams().put("username", "alessia");
36
	}
37

    
38
	@Test
39
	public void testWithAriadneServer() throws CollectorServiceException {
40

    
41
		Iterable<String> res = plugin.collect(apiDescriptor, null, null);
42
		Assert.assertNotNull(res);
43
		int i =0;
44
		for(String r : res){
45
			i++;
46
			Assert.assertNotNull(r);
47
			if(i > max_records) break;
48
		}
49

    
50
	}
51

    
52
	@Test
53
	public void testIncrementalWithAriadneServer() throws CollectorServiceException {
54

    
55
		Iterable<String> res = plugin.collect(apiDescriptor, "2017-06-06", null);
56
		Assert.assertNotNull(res);
57
		int i =0;
58
		for(String r : res){
59
			i++;
60
			Assert.assertNotNull(r);
61
			if(i > max_records) break;
62
		}
63
	}
64

    
65
	@Test
66
	public void testIncrementalWithAriadneServerFullDate() throws CollectorServiceException {
67

    
68
		Iterable<String> res = plugin.collect(apiDescriptor, "2016-02-21T10:58:53Z", null);
69
		Assert.assertNotNull(res);
70
		int i =0;
71
		for(String r : res){
72
			i++;
73
			Assert.assertNotNull(r);
74
			if(i > max_records) break;
75
		}
76
	}
77

    
78
	@Test(expected=CollectorServiceException.class)
79
	public void testIncrementalWithAriadneServerWrongDateFormat() throws CollectorServiceException {
80
		plugin.collect(apiDescriptor, "20160221", null);
81
	}
82
}
    (1-1/1)