| 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 |
|
| 21 |
|
| 22 |
|
| 23 |
public class PacPerProtocolTest { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 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 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 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 |
} |