blob: c0b9c67529391bd3ed09cf4ece2af0b07c224465 (
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
|
package com.btr.proxy.selector.pac;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.junit.Test;
import com.btr.proxy.TestUtil;
public class PacPerProtocolTest {
/*************************************************************************
* Test the PAC selector for a given protocol.
* @throws IOException of read error.
* @throws URISyntaxException on uri syntax error.
************************************************************************/
@Test
public void testPacForSocket() throws IOException, URISyntaxException {
new URI("socket://host1.unit-test.invalid/");
List<Proxy> result = new PacProxySelector(
new UrlPacScriptSource(toUrl("test1.pac"))).select(TestUtil.SOCKET_TEST_URI);
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0));
}
/*************************************************************************
* Helper method to build the url to the given test file
* @param testFile the name of the test file.
* @return the URL.
* @throws MalformedURLException
************************************************************************/
private String toUrl(String testFile) throws MalformedURLException {
return PacPerProtocolTest.class.getResource("/" + TestUtil.TEST_DATA_FOLDER + "/pac/" + testFile).toString();
}
}
|