blob: 875e2d5b18b15aa08e1a2e1cd19fbf12a9ce02dd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
package com.btr.proxy.search.gnome;
import static org.junit.Assert.assertEquals;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URISyntaxException;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import com.btr.proxy.TestUtil;
import com.btr.proxy.search.desktop.gnome.GnomeProxySearchStrategy;
import com.btr.proxy.util.ProxyException;
/*****************************************************************************
* Unit tests for the Gnome settings search strategy.
* For every test the "user.home" system property is switched to the test/data
* folder where we provide some Gnome config files prepared for the test cases.
*
* @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009
****************************************************************************/
@Ignore
public class GnomeProxySearchTest {
/*************************************************************************
* Test method
* @throws ProxyException on proxy detection error.
************************************************************************/
@Test
public void testNone() throws ProxyException {
TestUtil.setTestDataFolder("gnome_none");
ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector();
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI);
assertEquals(Proxy.NO_PROXY, result.get(0));
}
/*************************************************************************
* Test method
* @throws ProxyException on proxy detection error.
* @throws URISyntaxException on invalid URL syntax.
************************************************************************/
@Test
public void testManualHttp() throws ProxyException, URISyntaxException {
TestUtil.setTestDataFolder("gnome_manual");
ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector();
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI);
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0));
}
/*************************************************************************
* Test method
* @throws ProxyException on proxy detection error.
* @throws URISyntaxException on invalid URL syntax.
************************************************************************/
@Test
public void testManualHttps() throws ProxyException, URISyntaxException {
TestUtil.setTestDataFolder("gnome_manual");
ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector();
List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI);
assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0));
}
/*************************************************************************
* Test method
* @throws ProxyException on proxy detection error.
* @throws URISyntaxException on invalid URL syntax.
************************************************************************/
@Test
public void testManualFtp() throws ProxyException, URISyntaxException {
TestUtil.setTestDataFolder("gnome_manual");
ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector();
List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI);
assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0));
}
/*************************************************************************
* Test method
* @throws ProxyException on proxy detection error.
* @throws URISyntaxException on invalid URL syntax.
************************************************************************/
@Test
public void testPac() throws ProxyException, URISyntaxException {
TestUtil.setTestDataFolder("gnome_pac_script");
ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector();
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI);
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0));
}
/*************************************************************************
* Test method
* @throws ProxyException on proxy detection error.
* @throws URISyntaxException on invalid URL syntax.
************************************************************************/
@Test
public void testWhiteList() throws ProxyException, URISyntaxException {
TestUtil.setTestDataFolder("gnome_white_list");
ProxySelector ps = new GnomeProxySearchStrategy().getProxySelector();
List<Proxy> result = ps.select(TestUtil.NO_PROXY_TEST_URI);
assertEquals(Proxy.NO_PROXY, result.get(0));
}
}
|