| 1 |
package com.github.markusbernhardt.proxy.search.kde; |
| 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.Ignore; |
| 11 |
import org.junit.Test; |
| 12 |
|
| 13 |
import com.github.markusbernhardt.proxy.TestUtil; |
| 14 |
import com.github.markusbernhardt.proxy.search.desktop.kde.KdeProxySearchStrategy; |
| 15 |
import com.github.markusbernhardt.proxy.util.ProxyException; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class KdeProxySearchTest { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@Test |
| 42 |
public void testNone() throws ProxyException { |
| 43 |
TestUtil.setTestDataFolder("kde_none"); |
| 44 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 45 |
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); |
| 46 |
|
| 47 |
assertEquals(Proxy.NO_PROXY, result.get(0)); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
@Test |
| 59 |
public void testManualHttp() throws ProxyException, URISyntaxException { |
| 60 |
TestUtil.setTestDataFolder("kde_manual"); |
| 61 |
|
| 62 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 63 |
|
| 64 |
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); |
| 65 |
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
@Test |
| 77 |
public void testManualHttps() throws ProxyException, URISyntaxException { |
| 78 |
TestUtil.setTestDataFolder("kde_manual"); |
| 79 |
|
| 80 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 81 |
|
| 82 |
List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); |
| 83 |
assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
@Test |
| 95 |
public void testManualFtp() throws ProxyException, URISyntaxException { |
| 96 |
TestUtil.setTestDataFolder("kde_manual"); |
| 97 |
|
| 98 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 99 |
|
| 100 |
List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); |
| 101 |
assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
@Test |
| 113 |
public void testPac() throws ProxyException, URISyntaxException { |
| 114 |
TestUtil.setTestDataFolder("kde_pac_script"); |
| 115 |
|
| 116 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 117 |
|
| 118 |
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); |
| 119 |
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
@Test |
| 131 |
@Ignore |
| 132 |
public void testEnvHttp() throws ProxyException, URISyntaxException { |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
TestUtil.setTestDataFolder("kde_env"); |
| 138 |
|
| 139 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 140 |
|
| 141 |
List<Proxy> result = ps.select(TestUtil.HTTP_TEST_URI); |
| 142 |
assertEquals(TestUtil.HTTP_TEST_PROXY, result.get(0)); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
@Test |
| 154 |
@Ignore |
| 155 |
public void testEnvHttps() throws ProxyException, URISyntaxException { |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
TestUtil.setTestDataFolder("kde_env"); |
| 161 |
|
| 162 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 163 |
|
| 164 |
List<Proxy> result = ps.select(TestUtil.HTTPS_TEST_URI); |
| 165 |
assertEquals(TestUtil.HTTPS_TEST_PROXY, result.get(0)); |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
@Test |
| 177 |
@Ignore |
| 178 |
public void testEnvFtp() throws ProxyException, URISyntaxException { |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
TestUtil.setTestDataFolder("kde_env"); |
| 184 |
|
| 185 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 186 |
|
| 187 |
List<Proxy> result = ps.select(TestUtil.FTP_TEST_URI); |
| 188 |
assertEquals(TestUtil.FTP_TEST_PROXY, result.get(0)); |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
@Test |
| 200 |
public void testWhiteList() throws ProxyException, URISyntaxException { |
| 201 |
TestUtil.setTestDataFolder("kde_white_list"); |
| 202 |
|
| 203 |
ProxySelector ps = new KdeProxySearchStrategy().getProxySelector(); |
| 204 |
|
| 205 |
List<Proxy> result = ps.select(TestUtil.NO_PROXY_TEST_URI); |
| 206 |
assertEquals(Proxy.NO_PROXY, result.get(0)); |
| 207 |
} |
| 208 |
|
| 209 |
} |