From 998421c91bc71aa3677dd91ac4a6b106f4bd297b Mon Sep 17 00:00:00 2001 From: Jorg Pleumann <> Date: Tue, 28 Apr 2009 10:12:13 -0700 Subject: AI 147896: Some more fixes for tests that failed in the CTS, but worked fine in run-core-tests: - One cert test needs isolation, because it destroys the security provider. - The Thread.sleep() tests were too flaky. - Tests that tried to open a temporary DEX file failed in the CTS because we do not have access to the system DEX cache. We are now simply creating our own. The Java plan in the CTS should now pass fully. Yippie! BUG=1285921 Automated import of CL 147896 --- .../tests/api/javax/security/cert/X509CertificateTest.java | 13 +------------ .../tests/security/permissions/JavaLangClassLoaderTest.java | 10 ++++++---- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'security/src') diff --git a/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java b/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java index e12842a..4af8dc8 100644 --- a/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java +++ b/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java @@ -177,18 +177,6 @@ public class X509CertificateTest extends TestCase { } } - @Override - protected void tearDown() throws Exception { - if (myProvider != null) { -// Security.removeProvider(myProvider.getName()); - } - if (mySSProvider != null) { -// Security.removeProvider(mySSProvider.getName()); - } - - super.tearDown(); - } - /** * X509Certificate() constructor testing. * @tests {@link X509Certificate#X509Certificate() } @@ -875,6 +863,7 @@ public class X509CertificateTest extends TestCase { method = "verify", args = {java.security.PublicKey.class, java.lang.String.class} ) + @SideEffect("Destroys MD5 provider, hurts succeeding tests") public void testVerifyPublicKeyString() throws InvalidKeyException, java.security.cert.CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, IOException, diff --git a/security/src/test/java/tests/security/permissions/JavaLangClassLoaderTest.java b/security/src/test/java/tests/security/permissions/JavaLangClassLoaderTest.java index b21bece..66302ed 100644 --- a/security/src/test/java/tests/security/permissions/JavaLangClassLoaderTest.java +++ b/security/src/test/java/tests/security/permissions/JavaLangClassLoaderTest.java @@ -23,15 +23,16 @@ import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; import dalvik.system.DexFile; -import dalvik.system.PathClassLoader; import junit.framework.TestCase; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.security.Permission; +import tests.support.Support_ClassLoader; import tests.support.resource.Support_Resources; /* @@ -118,7 +119,7 @@ public class JavaLangClassLoaderTest extends TestCase { args = {} ) }) - @AndroidOnly("uses PathClassLoader and DexFile") + @AndroidOnly("uses DexFile") @BrokenTest("Endless loop in ClassLoader. Actually a known failure.") public void test_getSystemClassLoader () throws IOException, IllegalAccessException, InstantiationException { @@ -129,7 +130,8 @@ public class JavaLangClassLoaderTest extends TestCase { } @Override public void checkPermission(Permission permission){ - if(permission instanceof RuntimePermission && "getClassLoader".equals(permission.getName())){ + if(permission instanceof RuntimePermission && + "getClassLoader".equals(permission.getName())){ called = true; } } @@ -166,7 +168,7 @@ public class JavaLangClassLoaderTest extends TestCase { InputStream is = Support_Resources.getResourceStream("testdex.jar"); Support_Resources.copyLocalFileto(tempFile, is); DexFile dexfile = new DexFile(tempFile); - PathClassLoader pcl = new PathClassLoader("", + ClassLoader pcl = Support_ClassLoader.getInstance(new URL(""), ClassLoader.getSystemClassLoader()); Class testClass = dexfile.loadClass( -- cgit v1.1