1
|
package eu.dnetlib.data.collector.plugins;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.net.HttpURLConnection;
|
5
|
import java.net.URL;
|
6
|
|
7
|
import eu.dnetlib.data.collector.rmi.CollectorServiceException;
|
8
|
import org.apache.commons.logging.Log;
|
9
|
import org.apache.commons.logging.LogFactory;
|
10
|
import org.junit.Before;
|
11
|
import org.junit.Ignore;
|
12
|
import org.junit.Test;
|
13
|
|
14
|
@Ignore
|
15
|
public class HttpConnectorTest {
|
16
|
|
17
|
private static final Log log = LogFactory.getLog(HttpConnectorTest.class);
|
18
|
private HttpConnector connector;
|
19
|
|
20
|
private static final String URL = "https://researchdata.ands.org.au/registry/services/oai?verb=Identify";
|
21
|
private static final String URL_MISCONFIGURED_SERVER = "https://www.alexandria.unisg.ch/cgi/oai2?verb=Identify";
|
22
|
private static final String URL_GOODSNI_SERVER = "https://air.unimi.it/oai/openaire?verb=Identify";
|
23
|
|
24
|
@Before
|
25
|
public void setUp() {
|
26
|
connector = new HttpConnector();
|
27
|
}
|
28
|
|
29
|
@Test
|
30
|
@Ignore
|
31
|
public void testGetInputSource() throws CollectorServiceException {
|
32
|
System.out.println(connector.getInputSource(URL));
|
33
|
}
|
34
|
|
35
|
@Test
|
36
|
@Ignore
|
37
|
public void testMisconfiguredServers() throws CollectorServiceException {
|
38
|
System.out.println(connector.getInputSource(URL_MISCONFIGURED_SERVER));
|
39
|
}
|
40
|
|
41
|
@Test(expected = javax.net.ssl.SSLProtocolException.class)
|
42
|
public void testMisconfiguredServers2() throws IOException {
|
43
|
HttpURLConnection urlConn = (HttpURLConnection) new URL(URL_MISCONFIGURED_SERVER).openConnection();
|
44
|
urlConn.getResponseMessage();
|
45
|
}
|
46
|
|
47
|
@Test
|
48
|
public void testGoodServers() throws CollectorServiceException {
|
49
|
System.out.println(connector.getInputSource(URL_GOODSNI_SERVER));
|
50
|
}
|
51
|
|
52
|
|
53
|
}
|