Debian Codegraph @

src/test/java/com/github/markusbernhardt/proxy/selector/pac/PacPerProtocolTest.java

raw symbols SCIP
1 package com.github.markusbernhardt.proxy.selector.pac;
2
3 import static org.junit.Assert.assertEquals;
4
5 import java.io.File;
6 import java.io.IOException;
7 import java.net.MalformedURLException;
8 import java.net.Proxy;
9 import java.net.URI;
10 import java.net.URISyntaxException;
11 import java.util.List;
12
13 import org.junit.Test;
14
15 import com.github.markusbernhardt.proxy.TestUtil;
16 import com.github.markusbernhardt.proxy.selector.pac.PacProxySelector;
17 import com.github.markusbernhardt.proxy.selector.pac.UrlPacScriptSource;
18
19 /**
20 * @author Markus Bernhardt, Copyright 2016
21 * @author Bernd Rosstauscher, Copyright 2009
22 */
23 public class PacPerProtocolTest {
24
25 /*************************************************************************
26 * Test the PAC selector for a given protocol.
27 *
28 * @throws IOException
29 * of read error.
30 * @throws URISyntaxException
31 * on uri syntax error.
32 ************************************************************************/
33 @Test
34 public void testPacForSocket() throws IOException, URISyntaxException {
35
36 new URI("socket://host1.unit-test.invalid/");
37
38 List<Proxy> result = new PacProxySelector(new UrlPacScriptSource(toUrl("test1.pac")))
39 .select(TestUtil.SOCKET_TEST_URI);
40
41 assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0));
42 }
43
44 /*************************************************************************
45 * Helper method to build the url to the given test file
46 *
47 * @param testFile
48 * the name of the test file.
49 * @return the URL.
50 * @throws MalformedURLException
51 ************************************************************************/
52
53 private String toUrl(String testFile) throws MalformedURLException {
54 return new File(TestUtil.TEST_DATA_FOLDER + "pac", testFile).toURI().toURL().toString();
55 }
56
57 }