Fix URLConnection test cases.
- Have Support_TestWebServer send down an explicit timezone so
there's no ambiguity in the parse. HttpURLConnection coerces all
timezones into GMT.
- getFileNameMap always constructs a new FileNameMap if the default
is null. This implies that setFileNameMap(null) now sets things back
to the default.
- getRequestProperty / setRequestProperty on URLConnection subclasses
that don't override those methods behave as if they were backed by
a map.
bug: 26023804
Change-Id: I75abd114f0dcbd8afbfa1786b7d5142e0b071bed
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 5307cf4..a768863 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
@@ -864,7 +864,7 @@
URL url = new URL("http", "test", 80, "index.html", new NewHandler());
URLConnection urlCon = url.openConnection();
urlCon.setRequestProperty("test", "testProperty");
- assertNull(urlCon.getRequestProperty("test"));
+ assertEquals("testProperty", urlCon.getRequestProperty("test"));
urlCon.connect();
try {
diff --git a/ojluni/src/main/java/java/net/URLConnection.java b/ojluni/src/main/java/java/net/URLConnection.java
index 48cf9bc..1cd64b0 100755
--- a/ojluni/src/main/java/java/net/URLConnection.java
+++ b/ojluni/src/main/java/java/net/URLConnection.java
@@ -297,11 +297,6 @@
private static FileNameMap fileNameMap;
/**
- * @since 1.2.2
- */
- private static boolean fileNameMapLoaded = false;
-
- /**
* Loads filename map (a mimetable) from a data file. It will
* first try to load the user-specific table, defined
* by "content.types.user.table" property. If that fails,
@@ -313,23 +308,8 @@
* @see #setFileNameMap(java.net.FileNameMap)
*/
public static synchronized FileNameMap getFileNameMap() {
- /* ----- BEGIN android -----
- if ((fileNameMap == null) && !fileNameMapLoaded) {
- fileNameMap = sun.net.www.MimeTable.loadTable();
- fileNameMapLoaded = true;
- }
-
- return new FileNameMap() {
- private FileNameMap map = fileNameMap;
- public String getContentTypeFor(String fileName) {
- return map.getContentTypeFor(fileName);
- }
- };
- ----- END android -----*/
-
- if ((fileNameMap == null) && !fileNameMapLoaded) {
+ if (fileNameMap == null) {
fileNameMap = new DefaultFileNameMap();
- fileNameMapLoaded = true;
}
return fileNameMap;
}
diff --git a/support/src/test/java/tests/support/Support_TestWebServer.java b/support/src/test/java/tests/support/Support_TestWebServer.java
index 5f3cd85..33216a7 100644
--- a/support/src/test/java/tests/support/Support_TestWebServer.java
+++ b/support/src/test/java/tests/support/Support_TestWebServer.java
@@ -732,7 +732,8 @@
// 404 status already sent
return;
}
- SimpleDateFormat df = new SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss");
+ SimpleDateFormat df = new SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss z");
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
psPrint(ps,"Server: TestWebServer"+mPort);
psWriteEOL(ps);