diff options
10 files changed, 126 insertions, 91 deletions
diff --git a/luni/src/test/java/tests/api/java/io/SerializationStressTest4.java b/luni/src/test/java/tests/api/java/io/SerializationStressTest4.java index ef73192..9b589c5 100644 --- a/luni/src/test/java/tests/api/java/io/SerializationStressTest4.java +++ b/luni/src/test/java/tests/api/java/io/SerializationStressTest4.java @@ -17,12 +17,6 @@ package tests.api.java.io; -import dalvik.annotation.BrokenTest; -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - import java.io.File; import java.io.FilePermission; import java.io.IOException; @@ -53,6 +47,10 @@ import java.util.TimeZone; import tests.support.Support_Configuration; import tests.support.Support_Proxy_I1; +import dalvik.annotation.KnownFailure; +import dalvik.annotation.TestLevel; +import dalvik.annotation.TestTargetClass; +import dalvik.annotation.TestTargetNew; @TestTargetClass(java.io.Serializable.class) public class SerializationStressTest4 extends SerializationStressTest { @@ -2668,6 +2666,7 @@ public class SerializationStressTest4 extends SerializationStressTest { method = "!Serialization", args = {} ) + @KnownFailure("Proxy support broken when user classloader involved") public void test_writeObject_Proxy() { // Test for method void // java.io.ObjectOutputStream.writeObject(java.security.GuardedObject) diff --git a/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java b/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java index e0cc466..3f35b29 100644 --- a/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java +++ b/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java @@ -194,7 +194,9 @@ public class DatagramSocketTest extends SocketTestCase { try { DatagramSocket ds = new java.net.DatagramSocket(1); - fail("SocketException was not thrown."); + if (!("root".equals(System.getProperty("user.name")))) { + fail("SocketException was not thrown."); + } } catch (SocketException e) { //expected } diff --git a/luni/src/test/java/tests/api/java/util/FormatterTest.java b/luni/src/test/java/tests/api/java/util/FormatterTest.java index 1d6a4bb..636f1bd 100644 --- a/luni/src/test/java/tests/api/java/util/FormatterTest.java +++ b/luni/src/test/java/tests/api/java/util/FormatterTest.java @@ -284,10 +284,11 @@ public class FormatterTest extends TestCase { assertEquals(0, fileWithContent.length()); f.close(); - // FIXME This exception will not be thrown on linux if the user is root. try { f = new Formatter(readOnly.getPath()); - fail("should throw FileNotFoundException"); + if (!("root".equals(System.getProperty("user.name")))) { + fail("should throw FileNotFoundException"); + } } catch (FileNotFoundException e) { // expected } @@ -345,10 +346,11 @@ public class FormatterTest extends TestCase { assertEquals(0, fileWithContent.length()); f.close(); - // FIXME This exception will not be thrown on linux if the user is root. try { f = new Formatter(readOnly.getPath(), "UTF-16BE"); - fail("should throw FileNotFoundException"); + if (!("root".equals(System.getProperty("user.name")))) { + fail("should throw FileNotFoundException"); + } } catch (FileNotFoundException e) { // expected } @@ -414,11 +416,12 @@ public class FormatterTest extends TestCase { assertEquals(0, fileWithContent.length()); f.close(); - // FIXME This exception will not be thrown on linux if the user is root. try { f = new Formatter(readOnly.getPath(), Charset.defaultCharset() .name(), Locale.ITALY); - fail("should throw FileNotFoundException"); + if (!("root".equals(System.getProperty("user.name")))) { + fail("should throw FileNotFoundException"); + } } catch (FileNotFoundException e) { // expected } @@ -462,10 +465,11 @@ public class FormatterTest extends TestCase { assertEquals(0, fileWithContent.length()); f.close(); - // FIXME This exception will not be thrown on linux if the user is root. try { f = new Formatter(readOnly); - fail("should throw FileNotFoundException"); + if (!("root".equals(System.getProperty("user.name")))) { + fail("should throw FileNotFoundException"); + } } catch (FileNotFoundException e) { // expected } @@ -509,10 +513,11 @@ public class FormatterTest extends TestCase { assertEquals(0, fileWithContent.length()); f.close(); - // FIXME This exception will not be thrown on linux if the user is root. try { f = new Formatter(readOnly, Charset.defaultCharset().name()); - fail("should throw FileNotFoundException"); + if (!("root".equals(System.getProperty("user.name")))) { + fail("should throw FileNotFoundException"); + } } catch (FileNotFoundException e) { // expected } @@ -602,11 +607,12 @@ public class FormatterTest extends TestCase { assertEquals(0, fileWithContent.length()); f.close(); - // FIXME This exception will not be thrown on linux if the user is root. try { f = new Formatter(readOnly.getPath(), Charset.defaultCharset() .name(), Locale.ITALY); - fail("should throw FileNotFoundException"); + if (!("root".equals(System.getProperty("user.name")))) { + fail("should throw FileNotFoundException"); + } } catch (FileNotFoundException e) { // expected } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java index c5d91cb..407438d 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java @@ -17,10 +17,6 @@ package org.apache.harmony.security.tests.java.security; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - import java.math.BigInteger; import java.security.AlgorithmParameterGenerator; import java.security.AlgorithmParameters; @@ -31,6 +27,11 @@ import java.security.SecureRandom; import java.security.Security; import java.security.spec.DSAParameterSpec; +import dalvik.annotation.BrokenTest; +import dalvik.annotation.TestLevel; +import dalvik.annotation.TestTargetClass; +import dalvik.annotation.TestTargetNew; + @TestTargetClass(AlgorithmParameterGenerator.class) public class AlgorithmParameterGenerator3Test extends junit.framework.TestCase { @@ -43,10 +44,8 @@ public class AlgorithmParameterGenerator3Test extends junit.framework.TestCase { method = "generateParameters", args = {} ) + @BrokenTest("Takes too long due to math implementation, disabling for now") public void test_generateParameters() throws Exception { - - //fail("Takes ages. Problem with SecureRandom and stub math ?"); - // Test for method java.security.AlgorithmParameters // java.security.AlgorithmParameterGenerator.generateParameters() AlgorithmParameterGenerator gen = AlgorithmParameterGenerator diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java index d82bdff..78038b5 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java @@ -393,7 +393,8 @@ public class PolicyTest extends TestCase { // Regression for HARMONY-1963 and HARMONY-2910 - String policyFile = ClassLoader.getSystemClassLoader().getResource("PolicyTest.txt").toString(); + String policyFile = getClass().getClassLoader().getResource( + "PolicyTest.txt").toString(); String oldSysProp = System.getProperty(JAVA_SECURITY_POLICY); Policy oldPolicy = Policy.getPolicy(); diff --git a/security/src/test/java/tests/security/AllTests.java b/security/src/test/java/tests/security/AllTests.java index 2ce2db0..2a69b59 100644 --- a/security/src/test/java/tests/security/AllTests.java +++ b/security/src/test/java/tests/security/AllTests.java @@ -40,7 +40,7 @@ public class AllTests { suite.addTest(tests.security.interfaces.AllTests.suite()); suite.addTest(tests.security.spec.AllTests.suite()); - suite.addTest(tests.security.SecurityPermissionsTest.suite()); + suite.addTest(tests.security.permissions.AllTests.suite()); suite.addTest(tests.api.javax.security.cert.AllTests.suite()); diff --git a/security/src/test/java/tests/security/SecurityPermissionsTest.java b/security/src/test/java/tests/security/SecurityPermissionsTest.java deleted file mode 100644 index 2a98998..0000000 --- a/security/src/test/java/tests/security/SecurityPermissionsTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2007 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.security; - -import dalvik.annotation.TestTargetClass; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -@TestTargetClass(java.security.Permissions.class) -/* - * This class tests the secrity permissions which are documented in - * http://java.sun.com/j2se/1.5.0/docs/guide/security/permissions.html#PermsAndMethods - */ -public class SecurityPermissionsTest extends TestCase { - - public static final Test suite() { - TestSuite suite = new TestSuite("Tests for security permissions"); - - suite.addTestSuite(tests.security.permissions.JavaIoFileInputStreamTest.class); - suite.addTestSuite(tests.security.permissions.JavaIoFileOutputStreamTest.class); - suite.addTestSuite(tests.security.permissions.JavaIoFileTest.class); - suite.addTestSuite(tests.security.permissions.JavaIoObjectInputStreamTest.class); - suite.addTestSuite(tests.security.permissions.JavaIoObjectOutputStreamTest.class); - suite.addTestSuite(tests.security.permissions.JavaIoRandomAccessFileTest.class); - suite.addTestSuite(tests.security.permissions.JavaLangClassLoaderTest.class); - suite.addTestSuite(tests.security.permissions.JavaLangClassTest.class); - suite.addTestSuite(tests.security.permissions.JavaLangRuntimeTest.class); - suite.addTestSuite(tests.security.permissions.JavaLangSystemTest.class); - suite.addTestSuite(tests.security.permissions.JavaLangThreadTest.class); - suite.addTestSuite(tests.security.permissions.JavaNetDatagramSocketTest.class); - suite.addTestSuite(tests.security.permissions.JavaNetMulticastSocketTest.class); - suite.addTestSuite(tests.security.permissions.JavaNetServerSocketTest.class); - suite.addTestSuite(tests.security.permissions.JavaNetSocketTest.class); - suite.addTestSuite(tests.security.permissions.JavaSecurityPolicyTest.class); - suite.addTestSuite(tests.security.permissions.JavaSecuritySecurityTest.class); - suite.addTestSuite(tests.security.permissions.JavaUtilLocale.class); - suite.addTestSuite(tests.security.permissions.JavaUtilZipZipFile.class); - suite.addTestSuite(tests.security.permissions.JavaxSecurityAuthSubjectDomainCombiner.class); - suite.addTestSuite(tests.security.permissions.JavaxSecurityAuthSubject.class); - suite.addTestSuite(tests.security.permissions.JavaLangReflectAccessibleObjectTest.class); - - return suite; - } - -} - diff --git a/security/src/test/java/tests/security/permissions/AllTests.java b/security/src/test/java/tests/security/permissions/AllTests.java new file mode 100644 index 0000000..c3d235b --- /dev/null +++ b/security/src/test/java/tests/security/permissions/AllTests.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007 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.security.permissions; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import dalvik.annotation.TestTargetClass; + +@TestTargetClass(java.security.Permissions.class) +/* + * This class tests the secrity permissions which are documented in + * http://java.sun.com/j2se/1.5.0/docs/guide/security/permissions.html#PermsAndMethods + */ +public class AllTests extends TestCase { + + public static final Test suite() { + TestSuite suite = new TestSuite("Tests for security permissions"); + + suite.addTestSuite(JavaIoFileInputStreamTest.class); + suite.addTestSuite(JavaIoFileOutputStreamTest.class); + suite.addTestSuite(JavaIoFileTest.class); + suite.addTestSuite(JavaIoObjectInputStreamTest.class); + suite.addTestSuite(JavaIoObjectOutputStreamTest.class); + suite.addTestSuite(JavaIoRandomAccessFileTest.class); + suite.addTestSuite(JavaLangClassLoaderTest.class); + suite.addTestSuite(JavaLangClassTest.class); + suite.addTestSuite(JavaLangRuntimeTest.class); + suite.addTestSuite(JavaLangSystemTest.class); + suite.addTestSuite(JavaLangThreadTest.class); + suite.addTestSuite(JavaNetDatagramSocketTest.class); + suite.addTestSuite(JavaNetMulticastSocketTest.class); + suite.addTestSuite(JavaNetServerSocketTest.class); + suite.addTestSuite(JavaNetSocketTest.class); + suite.addTestSuite(JavaSecurityPolicyTest.class); + suite.addTestSuite(JavaSecuritySecurityTest.class); + suite.addTestSuite(JavaUtilLocale.class); + suite.addTestSuite(JavaUtilZipZipFile.class); + suite.addTestSuite(JavaxSecurityAuthSubjectDomainCombiner.class); + suite.addTestSuite(JavaxSecurityAuthSubject.class); + suite.addTestSuite(JavaLangReflectAccessibleObjectTest.class); + + return suite; + } + +} + diff --git a/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java b/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java index ddcf7ca..0e5b43c 100644 --- a/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java +++ b/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java @@ -23,9 +23,10 @@ import java.security.Permission; import junit.framework.TestCase; import tests.support.Support_ClassLoader; import dalvik.annotation.AndroidOnly; +import dalvik.annotation.BrokenTest; +import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestLevel; /* * This class tests the security permissions which are documented in @@ -142,6 +143,8 @@ public class JavaLangThreadTest extends TestCase { args = {} ) @AndroidOnly("RI impl differs from RI spec, Android impl does not.") + @BrokenTest("Suffers from endless loop in getClassLoader(), actually a" + + "@KnownFailure, but we don't want to hang the test harness") public void test_getContextClassLoader() { class TestSecurityManager extends SecurityManager { boolean called; diff --git a/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestDH.java b/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestDH.java index 5aa4a20..7999b92 100644 --- a/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestDH.java +++ b/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestDH.java @@ -15,7 +15,11 @@ */ package tests.targets.security; +import dalvik.annotation.BrokenTest; +import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; +import dalvik.annotation.TestTargetNew; +import dalvik.annotation.TestTargets; @TestTargetClass(targets.AlgorithmParameterGenerators.DH.class) public class AlgorithmParameterGeneratorTestDH extends @@ -25,4 +29,26 @@ public class AlgorithmParameterGeneratorTestDH extends super("DH", new AlgorithmParameterKeyAgreementHelper("DH")); } + @TestTargets({ + @TestTargetNew( + level=TestLevel.ADDITIONAL, + method="getInstance", + args={String.class} + ), + @TestTargetNew( + level=TestLevel.ADDITIONAL, + method="init", + args={int.class} + ), + @TestTargetNew( + level=TestLevel.COMPLETE, + method="method", + args={} + ) + }) + @BrokenTest("Suffers from DH slowness, disabling for now") + public void testAlgorithmParameterGenerator() { + super.testAlgorithmParameterGenerator(); + } + } |