summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2014-05-20 15:59:23 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-20 15:59:23 +0000
commitb2cb51ec3efd30a7fc3add84dacdedc31ee29694 (patch)
treef50449fd27fd8dc7706a4c5be56bb07ddb11faf2
parent29764f8825a1f27c7d8f42594dd4faff4bb9f4f2 (diff)
parentf315df1cb0768bec10ada80d30d7069d15ac76ba (diff)
downloadlibcore-b2cb51ec3efd30a7fc3add84dacdedc31ee29694.zip
libcore-b2cb51ec3efd30a7fc3add84dacdedc31ee29694.tar.gz
libcore-b2cb51ec3efd30a7fc3add84dacdedc31ee29694.tar.bz2
am f315df1c: Merge "Fix OldURLClassLoaderTest#test_findResource_String"
* commit 'f315df1cb0768bec10ada80d30d7069d15ac76ba': Fix OldURLClassLoaderTest#test_findResource_String
-rw-r--r--luni/src/test/java/libcore/java/net/OldURLClassLoaderTest.java36
1 files changed, 10 insertions, 26 deletions
diff --git a/luni/src/test/java/libcore/java/net/OldURLClassLoaderTest.java b/luni/src/test/java/libcore/java/net/OldURLClassLoaderTest.java
index 3a5608c..3a40018 100644
--- a/luni/src/test/java/libcore/java/net/OldURLClassLoaderTest.java
+++ b/luni/src/test/java/libcore/java/net/OldURLClassLoaderTest.java
@@ -26,15 +26,11 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.CodeSource;
-import java.security.Permission;
import java.security.PermissionCollection;
-import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.Manifest;
-import org.apache.harmony.security.tests.support.TestCertUtils;
-import tests.support.Support_Configuration;
import tests.support.Support_TestWebData;
import tests.support.Support_TestWebServer;
import tests.support.resource.Support_Resources;
@@ -42,15 +38,6 @@ import tests.support.resource.Support_Resources;
public class OldURLClassLoaderTest extends junit.framework.TestCase {
URLClassLoader ucl;
- SecurityManager sm = new SecurityManager() {
-
- public void checkPermission(Permission perm) {
- }
-
- public void checkCreateClassLoader() {
- throw new SecurityException();
- }
- };
/**
* java.net.URLClassLoader#URLClassLoader(java.net.URL[])
@@ -58,8 +45,8 @@ public class OldURLClassLoaderTest extends junit.framework.TestCase {
public void test_Constructor$Ljava_net_URL() throws MalformedURLException {
URL[] u = new URL[0];
ucl = new URLClassLoader(u);
- assertTrue("Failed to set parent", ucl != null
- && ucl.getParent() == URLClassLoader.getSystemClassLoader());
+ assertTrue("Failed to set parent",
+ ucl.getParent() == URLClassLoader.getSystemClassLoader());
URL [] urls = {new URL("http://foo.com/foo"),
@@ -87,7 +74,6 @@ public class OldURLClassLoaderTest extends junit.framework.TestCase {
* java.net.URLClassLoader#findResources(java.lang.String)
*/
public void test_findResourcesLjava_lang_String() throws Exception {
- Enumeration<URL> res = null;
String[] resValues = { "This is a test resource file.",
"This is a resource from a subdir"};
@@ -115,7 +101,7 @@ public class OldURLClassLoaderTest extends junit.framework.TestCase {
urls[1] = new URL("file://" + subDir.getAbsolutePath() + "/");
ucl = new URLClassLoader(urls);
- res = ucl.findResources("test0");
+ Enumeration<URL> res = ucl.findResources("test0");
assertNotNull("Failed to locate resources", res);
int i = 0;
@@ -250,19 +236,17 @@ public class OldURLClassLoaderTest extends junit.framework.TestCase {
"/tests/resources/hyts_patch.jar");
Support_Resources.copyLocalFileto(tempFile2, is);
String tempPath2 = tempFile2.getAbsolutePath();
- String tempPath3 = "http://localhost:" + port + "/";
URLClassLoader urlLoader = getURLClassLoader(tempPath1, tempPath2);
- assertNull("Found inexistant resource",
- urlLoader.findResource("XXX"));
+ assertNull("Found nonexistent resource", urlLoader.findResource("XXX"));
assertNotNull("Couldn't find resource from directory",
urlLoader.findResource(tempFile1.getName()));
- assertNotNull("Couldn't find resource from jar",
- urlLoader.findResource("Blah.txt"));
+ assertNotNull("Couldn't find resource from jar", urlLoader.findResource("Blah.txt"));
+
+ String tempPath3 = "http://localhost:" + port + "/";
urlLoader = getURLClassLoader(tempPath1, tempPath2, tempPath3);
- assertNotNull("Couldn't find resource from web",
- urlLoader.findResource("test1"));
- assertNull("Found inexistant resource from web",
- urlLoader.findResource("test3"));
+ assertNotNull("Couldn't find resource from web", urlLoader.findResource("test1"));
+ // Attempt to find a resource using a URL that will produce a 404.
+ assertNull("Found nonexistent resource from web", urlLoader.findResource("test9999"));
} finally {
server.close();
}