summaryrefslogtreecommitdiffstats
path: root/luni/src/test/java/tests
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2013-11-13 13:05:58 +0000
committerNarayan Kamath <narayan@google.com>2013-11-14 18:36:15 +0000
commit1399e0b42af7a565f34b9a2441f0a079e6ab3854 (patch)
treedcf9b8632f66ba364f58d12a7f69be0a6f22ffe5 /luni/src/test/java/tests
parentcb318c6f4fe5b0e20099fa85f1b95ccb2d24119f (diff)
downloadlibcore-1399e0b42af7a565f34b9a2441f0a079e6ab3854.zip
libcore-1399e0b42af7a565f34b9a2441f0a079e6ab3854.tar.gz
libcore-1399e0b42af7a565f34b9a2441f0a079e6ab3854.tar.bz2
Fix a few failures in FileURLConnectionTest.
Some tests still fail, but they appear to be valid tests. There are at least two separate issues here : - ClassLoader#getResource seems to be constructing a bogus URL (at least in this context). findResource returns a non null URL, but URL#openStream throws. - URLs with fragments (#foo) don't appear to work correctly. Change-Id: Iabf03e49c56659039feb85a0e528efcaaed0b49d
Diffstat (limited to 'luni/src/test/java/tests')
-rw-r--r--luni/src/test/java/tests/api/internal/net/www/protocol/file/FileURLConnectionTest.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/luni/src/test/java/tests/api/internal/net/www/protocol/file/FileURLConnectionTest.java b/luni/src/test/java/tests/api/internal/net/www/protocol/file/FileURLConnectionTest.java
index 8ba38a0..41f4b39 100644
--- a/luni/src/test/java/tests/api/internal/net/www/protocol/file/FileURLConnectionTest.java
+++ b/luni/src/test/java/tests/api/internal/net/www/protocol/file/FileURLConnectionTest.java
@@ -16,12 +16,10 @@
*/
package tests.api.internal.net.www.protocol.file;
+import junit.framework.TestCase;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
-
-import junit.framework.TestCase;
-
import libcore.net.url.FileURLConnection;
/**
@@ -30,7 +28,7 @@ import libcore.net.url.FileURLConnection;
public class FileURLConnectionTest extends TestCase {
static String getContentType(String fileName) throws IOException {
- String resourceName = "org/apache/harmony/luni/tests/" + fileName;
+ String resourceName = "resources/" + fileName;
URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
assertNotNull("Cannot find test resource " + resourceName, url);
return new FileURLConnection(url).getContentType();
@@ -49,8 +47,9 @@ public class FileURLConnectionTest extends TestCase {
public void testGetInputStream() throws IOException {
// Regression for Harmony-5737
- String resourceName = "org/apache/harmony/luni/tests/" + "test.rtf";
+ String resourceName = "resources/" + "test.rtf";
URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
+ assertNotNull(url);
URL anchorUrl = new URL(url, "#anchor");
assertNotNull("Cannot find test resource " + resourceName, anchorUrl);
@@ -66,14 +65,13 @@ public class FileURLConnectionTest extends TestCase {
}
public void testHeaderFunctions() throws IOException {
- String resourceName = "org/apache/harmony/luni/tests/"; //folder name
+ String resourceName = "resources/test.rtf"; //folder name
URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
FileURLConnection conn = new FileURLConnection(url);
assertNotNull(conn.getInputStream());
assertEquals(conn.getContentType(), conn.getHeaderField("content-type"));
- resourceName = "org/apache/harmony/luni/tests/" + "test.rtf";
- ; //folder name
+ resourceName = "resources/" + "test.rtf";
url = ClassLoader.getSystemClassLoader().getResource(resourceName);
conn = new FileURLConnection(url);
assertNotNull(conn.getInputStream());
@@ -88,7 +86,7 @@ public class FileURLConnectionTest extends TestCase {
}
public void testHeader_BoundaryCheck() throws IOException {
- String resourceName = "org/apache/harmony/luni/tests/";
+ String resourceName = "resources/test.rtf";
URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
URLConnection urlConnection = url.openConnection();
assertNull(urlConnection.getHeaderField(Integer.MIN_VALUE));