summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Whyte <awhyte@google.com>2014-11-21 17:03:26 -0800
committerAaron Whyte <awhyte@google.com>2014-11-24 13:12:00 -0800
commit939e6a1aceff448445928ad5d815479e84e84383 (patch)
treeeeb1577b700575d1bae1f74b38dfa746805f3d3a
parentfd7ab0e2f9626ca5233eea7373e99e3fbd4e83f1 (diff)
downloadlibcore-939e6a1aceff448445928ad5d815479e84e84383.zip
libcore-939e6a1aceff448445928ad5d815479e84e84383.tar.gz
libcore-939e6a1aceff448445928ad5d815479e84e84383.tar.bz2
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 Change-Id: I21ffc5c9c72eb4379478c11687d197dab176a851
-rw-r--r--luni/src/test/java/libcore/java/net/URLConnectionTest.java1
-rw-r--r--luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java61
-rw-r--r--support/src/test/java/tests/support/Support_Configuration.java2
3 files changed, 1 insertions, 63 deletions
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
index 40c9f5e..f438d1b 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 @@ public final class URLConnectionTest extends AbstractResourceLeakageDetectorTest
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 @@ public class URLConnectionTest extends TestCase {
}
/**
- * @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 @@ public class URLConnectionTest extends TestCase {
}
}
- /**
- * @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 9cb617d..313a448 100644
--- a/support/src/test/java/tests/support/Support_Configuration.java
+++ b/support/src/test/java/tests/support/Support_Configuration.java
@@ -91,8 +91,6 @@ public class Support_Configuration {
// 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;
/**