diff options
12 files changed, 112 insertions, 35 deletions
diff --git a/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java b/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java index eed8d3a..7102c14 100644 --- a/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java +++ b/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java @@ -1044,9 +1044,11 @@ public class AbstractQueuedSynchronizerTest extends JSR166TestCase { try { t.start(); - Thread.sleep(SHORT_DELAY_MS); + // BEGIN android-changed + Thread.sleep(SMALL_DELAY_MS); // SHORT_DELAY_MS was flaky on Android t.interrupt(); - t.join(SHORT_DELAY_MS); + t.join(SMALL_DELAY_MS); // SHORT_DELAY_MS was flaky on Android + // END android-changed assertFalse(t.isAlive()); } catch (Exception ex) { diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java index c33a8e3..b0fa733 100644 --- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java +++ b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java @@ -45,13 +45,13 @@ import java.util.Collection; import java.util.List; import java.util.Vector; +import tests.support.Support_ClassLoader; import tests.support.resource.Support_Resources; import dalvik.annotation.AndroidOnly; import dalvik.annotation.BrokenTest; -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; +import dalvik.annotation.TestLevel; @SuppressWarnings("deprecation") @TestTargetClass(Class.class) @@ -578,9 +578,9 @@ public class ClassTest extends junit.framework.TestCase { URL resourceURL = new URL("file:/" + resPath + "/Package/" + hyts_package_name); - ClassLoader cl = new dalvik.system.PathClassLoader( - resourceURL.getPath(), getClass().getClassLoader()); - + ClassLoader cl = Support_ClassLoader.getInstance(resourceURL, + getClass().getClassLoader()); + Class clazz = cl.loadClass("C"); assertNull("getPackage for C.class should return null", clazz.getPackage()); diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java index b1b7408..19cc341 100644 --- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java +++ b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java @@ -29,6 +29,7 @@ import java.lang.annotation.Annotation; import java.lang.annotation.Annotation; +import tests.support.Support_ClassLoader; import tests.support.resource.Support_Resources; @TestTargetClass(Package.class) @@ -40,14 +41,10 @@ public class PackageTest extends junit.framework.TestCase { Class clazz; - // URLClassLoader doesn't load classes from jar. - // use PathClassLoader - boolean USE_PATH_CLASS_LOADER = true; - Package getTestPackage(String resourceJar, String className) throws Exception { - if (USE_PATH_CLASS_LOADER) { + if ("Dalvik".equals(System.getProperty("java.vm.name"))) { resourceJar = resourceJar.substring(0, resourceJar.indexOf(".")) + "_dex.jar"; } @@ -55,14 +52,9 @@ public class PackageTest extends junit.framework.TestCase { URL resourceURL = new URL("file:/" + resPath + "/Package/" + resourceJar); - ClassLoader cl = null; - if(USE_PATH_CLASS_LOADER) { - cl = new dalvik.system.PathClassLoader( - resourceURL.getPath(), getClass().getClassLoader()); - } else { - cl = new URLClassLoader(new URL[] { resourceURL }, - getClass().getClassLoader()); - } + ClassLoader cl = Support_ClassLoader.getInstance(resourceURL, + getClass().getClassLoader()); + clazz = cl.loadClass(className); return clazz.getPackage(); } diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java index 2c65f52..f17c3d8 100644 --- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java +++ b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java @@ -17,6 +17,7 @@ package org.apache.harmony.luni.tests.java.lang; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; @@ -1079,6 +1080,7 @@ public class SystemTest extends junit.framework.TestCase { method = "load", args = {java.lang.String.class} ) + @AndroidOnly("No x86 version of this library") public void test_load() { try { new TestLibrary().checkString(); diff --git a/luni/src/test/java/tests/api/java/lang/reflect/GenericSignatureFormatErrorTest.java b/luni/src/test/java/tests/api/java/lang/reflect/GenericSignatureFormatErrorTest.java index eb5cead..e66e44e 100644 --- a/luni/src/test/java/tests/api/java/lang/reflect/GenericSignatureFormatErrorTest.java +++ b/luni/src/test/java/tests/api/java/lang/reflect/GenericSignatureFormatErrorTest.java @@ -16,6 +16,8 @@ import java.io.OutputStream; import java.lang.reflect.GenericSignatureFormatError; import java.lang.reflect.TypeVariable; +import tests.support.Support_ClassLoader; + @TestTargetClass(GenericSignatureFormatError.class) public class GenericSignatureFormatErrorTest extends TestCase{ @@ -84,8 +86,14 @@ public class GenericSignatureFormatErrorTest extends TestCase{ // class signature string "<U:" was changed to "<<:" //System.out.println("file length:"+tf.length()); try { - DexFile df = new DexFile(tf); - Class clazz = df.loadClass("demo/HelloWorld", this.getClass().getClassLoader()); + // Was: + // DexFile df = new DexFile(tf); + // Class clazz = df.loadClass("demo/HelloWorld", this.getClass().getClassLoader()); + + ClassLoader cl = Support_ClassLoader.getInstance(tf.toURL(), + getClass().getClassLoader()); + + Class clazz = cl.loadClass("demo/HelloWorld"); TypeVariable[] tvs = clazz.getTypeParameters(); fail("expecting a GenericSignatureFormatError"); // for (TypeVariable tv : tvs) { diff --git a/luni/src/test/java/tests/api/java/net/SocketTest.java b/luni/src/test/java/tests/api/java/net/SocketTest.java index 94e7d09..3d6fbeb 100644 --- a/luni/src/test/java/tests/api/java/net/SocketTest.java +++ b/luni/src/test/java/tests/api/java/net/SocketTest.java @@ -494,6 +494,8 @@ public class SocketTest extends SocketTestCase { args = {} ) public void test_getInputStream() throws IOException { + System.setSecurityManager(null); + // Test for method java.io.InputStream java.net.Socket.getInputStream() int sport = startServer("SServer getInputStream"); int portNumber = Support_PortManager.getNextPort(); diff --git a/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java b/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java index 26672d3..82fa799 100644 --- a/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java +++ b/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java @@ -504,7 +504,8 @@ public class URLClassLoaderTest extends junit.framework.TestCase { try { Class.forName("bpack.Bart", true, ucl); fail("InvalidJarIndexException should be thrown"); - } catch (InvalidJarIndexException e) { + } catch (RuntimeException e) { + e.printStackTrace(); // expected } diff --git a/run-core-tests b/run-core-tests index 25e53ee..62b3c51 100755 --- a/run-core-tests +++ b/run-core-tests @@ -27,4 +27,4 @@ chmod 777 $tmp exec dalvikvm -Duser.language=en -Duser.region=US -Djava.io.tmpdir=$tmp \ -Xbootclasspath:$BOOTCLASSPATH:/system/framework/core-tests.jar \ - com.google.coretests.Main "$@" + -Xmx64M com.google.coretests.Main "$@" diff --git a/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java b/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java index 2c9af67..ddcf7ca 100644 --- a/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java +++ b/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java @@ -16,15 +16,16 @@ package tests.security.permissions; -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.Permission; import junit.framework.TestCase; - -import java.security.Permission; +import tests.support.Support_ClassLoader; +import dalvik.annotation.AndroidOnly; +import dalvik.annotation.TestTargetClass; +import dalvik.annotation.TestTargetNew; +import dalvik.annotation.TestLevel; /* * This class tests the security permissions which are documented in @@ -167,13 +168,21 @@ public class JavaLangThreadTest extends TestCase { assertNotNull("test assumption: caller's class loader must not be null", this.getClass().getClassLoader()); + + URL url; + + try { + url = new URL("file:"); + } catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } t1.setContextClassLoader(null); t2.setContextClassLoader(this.getClass().getClassLoader()); t3.setContextClassLoader(this.getClass().getClassLoader().getParent()); t4.setContextClassLoader( - new dalvik.system.PathClassLoader("", - this.getClass().getClassLoader())); + Support_ClassLoader.getInstance(url, + getClass().getClassLoader())); t5.setContextClassLoader( new ClassLoader(this.getClass().getClassLoader()) {}); diff --git a/sql/src/test/resources/connection.properties b/sql/src/test/resources/connection.properties index 2e49346..d514e85 100644 --- a/sql/src/test/resources/connection.properties +++ b/sql/src/test/resources/connection.properties @@ -6,4 +6,4 @@ sqlUrlPrefix = jdbc:sqlite: sqlPassword = sqlUser = sqlMaxConnections = 30 -sqlMaxTasks = 10000 +sqlMaxTasks = 1000 diff --git a/support/src/test/java/tests/support/Support_ClassLoader.java b/support/src/test/java/tests/support/Support_ClassLoader.java new file mode 100644 index 0000000..12bbdf3 --- /dev/null +++ b/support/src/test/java/tests/support/Support_ClassLoader.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package tests.support; + +import java.net.URL; +import java.net.URLClassLoader; + +import dalvik.system.PathClassLoader; + +/** + * Support class for creating a file-based ClassLoader. Delegates to either + * Dalvik's PathClassLoader or the RI's URLClassLoader, but does so by-name. + * This allows us to run corresponding tests in both environments. + */ +public abstract class Support_ClassLoader { + + public abstract ClassLoader getClassLoader(URL url, ClassLoader parent); + + public static ClassLoader getInstance(URL url, ClassLoader parent) { + try { + Support_ClassLoader factory; + + if ("Dalvik".equals(System.getProperty("java.vm.name"))) { + factory = (Support_ClassLoader)Class.forName( + "tests.support.Support_ClassLoader$Dalvik").newInstance(); + } else { + factory = (Support_ClassLoader)Class.forName( + "tests.support.Support_ClassLoader$RefImpl").newInstance(); + } + + return factory.getClassLoader(url, parent); + } catch (Exception ex) { + throw new RuntimeException("Unable to create ClassLoader", ex); + } + } + + class Dalvik extends Support_ClassLoader { + public ClassLoader getClassLoader(URL url, ClassLoader parent) { + return new PathClassLoader(url.getPath(), parent); + } + } + + class RefImpl extends Support_ClassLoader { + public ClassLoader getClassLoader(URL url, ClassLoader parent) { + return new URLClassLoader(new URL[] { url }, parent); + } + } +} diff --git a/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/FileClientSessionCache.java b/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/FileClientSessionCache.java index ab097e4..d438779 100644 --- a/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/FileClientSessionCache.java +++ b/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/FileClientSessionCache.java @@ -38,7 +38,7 @@ import java.io.IOException; */ public class FileClientSessionCache { - static final int MAX_SIZE = 20; + static final int MAX_SIZE = 12; // ~72k static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger( |