|
9 | 9 | import com.danikula.videocache.support.ProxyCacheTestUtils; |
10 | 10 | import com.danikula.videocache.support.Response; |
11 | 11 |
|
12 | | -import junit.framework.Assert; |
13 | | - |
14 | 12 | import org.junit.Before; |
15 | 13 | import org.junit.Test; |
16 | 14 | import org.robolectric.RuntimeEnvironment; |
|
33 | 31 | import static com.danikula.videocache.support.ProxyCacheTestUtils.HTTP_DATA_URL_ONE_REDIRECT; |
34 | 32 | import static com.danikula.videocache.support.ProxyCacheTestUtils.getFileContent; |
35 | 33 | import static com.danikula.videocache.support.ProxyCacheTestUtils.getPort; |
36 | | -import static com.danikula.videocache.support.ProxyCacheTestUtils.getPortWithoutPing; |
37 | 34 | import static com.danikula.videocache.support.ProxyCacheTestUtils.installExternalSystemProxy; |
38 | 35 | import static com.danikula.videocache.support.ProxyCacheTestUtils.loadAssetFile; |
39 | 36 | import static com.danikula.videocache.support.ProxyCacheTestUtils.readProxyResponse; |
@@ -352,15 +349,15 @@ public void testWorkWithExternalProxy() throws Exception { |
352 | 349 | assertThat(response.second.data).isEqualTo(loadAssetFile(ASSETS_DATA_NAME)); |
353 | 350 | } |
354 | 351 |
|
355 | | - @Test(expected = IOException.class) // https://github.com/danikula/AndroidVideoCache/issues/28 |
| 352 | + @Test // https://github.com/danikula/AndroidVideoCache/issues/28 |
356 | 353 | public void testDoesNotWorkWithoutCustomProxySelector() throws Exception { |
357 | 354 | HttpProxyCacheServer httpProxyCacheServer = new HttpProxyCacheServer(RuntimeEnvironment.application); |
358 | 355 | // IgnoreHostProxySelector is set in HttpProxyCacheServer constructor. So let reset it by custom. |
359 | 356 | installExternalSystemProxy(); |
360 | 357 |
|
361 | | - String proxiedUrl = "http://127.0.0.1:" + getPortWithoutPing(httpProxyCacheServer) + "/" + HTTP_DATA_URL; |
362 | | - readProxyResponse(httpProxyCacheServer, proxiedUrl); |
363 | | - Assert.fail(); // should throw IOException on the previous line |
| 358 | + String proxiedUrl = httpProxyCacheServer.getProxyUrl(HTTP_DATA_URL); |
| 359 | + // server can't proxy this url due to it is not alive (can't ping itself), so it returns original url |
| 360 | + assertThat(proxiedUrl).isEqualTo(HTTP_DATA_URL); |
364 | 361 | } |
365 | 362 |
|
366 | 363 | private Pair<File, Response> readProxyData(String url, int offset) throws IOException { |
@@ -390,6 +387,6 @@ private HttpProxyCacheServer newProxy(File cacheDir) { |
390 | 387 | } |
391 | 388 |
|
392 | 389 | private void waitForAsyncTrimming() throws InterruptedException { |
393 | | - Thread.sleep(100); |
| 390 | + Thread.sleep(500); |
394 | 391 | } |
395 | 392 | } |
0 commit comments