Fix URLConnectionTest for devices without full internet access.
This removes two bad tests that are covered elsewhere, using
mocks.
test_getContentEncoding() was hitting http://www.amazon.com, to see
if a URLConnection getter was working. That getter is now tested in
libcore/luni/src/test/java/libcore/java/net/URLConnectionTest.java,
in testClientConfiguredGzipContentEncoding().
test_getLastModified() was hitting
http://www.php.net/manual/en/function.explode.php, to see if
getHeaderFieldDate was working for Last-Modified. That getter is
better tested in test_getHeaderFieldDateLjava_lang_StringJ(), in the
same file.
Bug:18480776
(cherry picked from commit 939e6a1aceff448445928ad5d815479e84e84383)
Change-Id: Ia01fd59809683317271017364179e1843c149e65
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
index 3db7c8f..9e94c2e 100644
--- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
@@ -965,6 +965,7 @@
RecordedRequest request = server.takeRequest();
assertContains(request.getHeaders(), "Accept-Encoding: gzip");
+ assertEquals("gzip", connection.getContentEncoding());
}
public void testGzipAndConnectionReuseWithFixedLength() throws Exception {
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
index d52b033..5307cf4 100644
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
@@ -438,39 +438,6 @@
}
/**
- * @throws IOException
- * {@link java.net.URLConnection#getContentEncoding()}
- */
- // broken test - Fails in CTS, passes in CoreTestRunner
- public void test_getContentEncoding() throws IOException {
- // faulty setup
- try {
-
- fileURLCon.getContentEncoding();
- fail("Exception expected");
- } catch (Throwable e) {
- //ok
- }
-
- // positive case
-
- URL url = new URL("http://www.amazon.com/");
-
- URLConnection con = url.openConnection();
- con.setRequestProperty("Accept-Encoding", "gzip");
- con.connect();
-
- assertEquals(con.getContentEncoding(), "gzip");
-
-
- uc2.setRequestProperty("Accept-Encoding", "bla");
- uc2.connect();
-
- assertNull(uc2.getContentEncoding());
-
- }
-
- /**
* {@link java.net.URLConnection#getContentLength()}
*/
public void test_getContentLength() throws Exception {
@@ -833,34 +800,6 @@
}
}
- /**
- * @throws IOException
- * {@link java.net.URLConnection#getLastModified()}
- */
- public void test_getLastModified() throws IOException {
-
- URL url4 = new URL(Support_Configuration.hTTPURLwLastModified);
- URLConnection uc4 = url4.openConnection();
-
- uc4.connect();
-
- if (uc4.getLastModified() == 0) {
- System.out
- .println("WARNING: Server does not support 'Last-Modified', test_getLastModified() not run");
- return;
- }
-
- long millis = uc4.getHeaderFieldDate("Last-Modified", 0);
-
- assertEquals(
- "Returned wrong getLastModified value. Wanted: "
- + " got: " + uc4.getLastModified(),
- millis, uc4.getLastModified());
-
-
- ((HttpURLConnection) uc).disconnect();
- }
-
public void test_getOutputStream_failAfterDisconnect() throws IOException {
((HttpURLConnection) uc2).disconnect();
diff --git a/support/src/test/java/tests/support/Support_Configuration.java b/support/src/test/java/tests/support/Support_Configuration.java
index 0658d54..8058315 100644
--- a/support/src/test/java/tests/support/Support_Configuration.java
+++ b/support/src/test/java/tests/support/Support_Configuration.java
@@ -86,8 +86,6 @@
// than one addresses returned for this host name as needed by a test
// END android-changed
- public static String hTTPURLwLastModified = "http://www.php.net/manual/en/function.explode.php";
-
public static int SpecialInetTestAddressNumber = 4;
/**