| 1 |
package com.github.markusbernhardt.proxy.search.browser; |
| 2 |
|
| 3 |
import static org.junit.Assert.assertEquals; |
| 4 |
|
| 5 |
import java.net.Proxy; |
| 6 |
import java.net.ProxySelector; |
| 7 |
import java.net.URISyntaxException; |
| 8 |
import java.util.List; |
| 9 |
|
| 10 |
import org.junit.BeforeClass; |
| 11 |
import org.junit.Test; |
| 12 |
|
| 13 |
import com.github.markusbernhardt.proxy.TestUtil; |
| 14 |
import com.github.markusbernhardt.proxy.search.browser.firefox.FirefoxProxySearchStrategy; |
| 15 |
import com.github.markusbernhardt.proxy.util.ProxyException; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class FirefoxTest { |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
@BeforeClass |
| 30 |
public static void setup() { |
| 31 |
|
| 32 |
System.setProperty("os.name", "Linux"); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@Test |
| 42 |
public void testNone() throws ProxyException { |
| 43 |
TestUtil.setTestDataFolder("ff3_none"); |
| 44 |
|
| 45 |
FirefoxProxySearchStrategy ff = new FirefoxProxySearchStrategy(); |
| 46 |
ProxySelector ps = ff.getProxySelector(); |
| 47 |
|
| 48 |
List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); |
| 49 |
assertEquals(Proxy.NO_PROXY, result.get(0)); |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
@Test |
| 62 |
public void testManualHttp() throws ProxyException, URISyntaxException { |
| 63 |
TestUtil.setTestDataFolder("ff3_manual"); |
| 64 |
|
| 65 |
ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); |
| 66 |
|
| 67 |
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); |
| 68 |
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
@Test |
| 80 |
public void testManualHttps() throws ProxyException, URISyntaxException { |
| 81 |
TestUtil.setTestDataFolder("ff3_manual"); |
| 82 |
|
| 83 |
ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); |
| 84 |
|
| 85 |
List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); |
| 86 |
assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
@Test |
| 98 |
public void testManualFtp() throws ProxyException, URISyntaxException { |
| 99 |
TestUtil.setTestDataFolder("ff3_manual"); |
| 100 |
|
| 101 |
ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); |
| 102 |
|
| 103 |
List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); |
| 104 |
assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
@Test |
| 116 |
public void testManualSocks() throws ProxyException, URISyntaxException { |
| 117 |
TestUtil.setTestDataFolder("ff3_manual"); |
| 118 |
|
| 119 |
ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); |
| 120 |
|
| 121 |
List<Proxy> result = ps.select(TestUtil.SOCKS_TEST_URI); |
| 122 |
assertEquals(TestUtil.SOCKS_TEST_PROXY, result.get(0)); |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
@Test |
| 134 |
public void testPac() throws ProxyException, URISyntaxException { |
| 135 |
TestUtil.setTestDataFolder("ff3_pac_script"); |
| 136 |
|
| 137 |
ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); |
| 138 |
|
| 139 |
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); |
| 140 |
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
@Test |
| 152 |
public void testWhiteList() throws ProxyException, URISyntaxException { |
| 153 |
TestUtil.setTestDataFolder("ff3_white_list"); |
| 154 |
|
| 155 |
ProxySelector ps = new FirefoxProxySearchStrategy().getProxySelector(); |
| 156 |
|
| 157 |
List<Proxy> result = ps.select(TestUtil.NO_PROXY_TEST_URI); |
| 158 |
assertEquals(Proxy.NO_PROXY, result.get(0)); |
| 159 |
} |
| 160 |
|
| 161 |
} |