diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 8a1136981159fdcc191f3bca64c84213297a23dc..201f68abbcce2c9e3cb47a7913cd09dcc5a23e7a 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -502,10 +502,6 @@ sun/security/pkcs11/ec/TestECDSA.java solaris-i586 sun/security/pkcs11/ec/TestECGenSpec.java solaris-i586 sun/security/pkcs11/ec/TestKeyFactory.java solaris-i586 -# Unknown problem, could be a jtreg -samevm issue? -# Error while cleaning up threads after test -java/security/Security/SynchronizedAccess.java generic-all - # Failing on Solaris X64 (-d64 -server) with: # GSSException: Failure unspecified at GSS-API level # (Mechanism level: Specified version of key is not available (44)) @@ -600,27 +596,6 @@ sun/security/tools/keytool/emptysubject.sh generic-all # Timeout on solaris-sparcv9 or exception thrown com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java solaris-all -# Leaving file open: SerialVersion.current, windows samevm -java/security/BasicPermission/SerialVersion.java generic-all - -# Solaris 11 i586, these all fail with samevm, need to be othervm??? -java/security/BasicPermission/NullOrEmptyName.java generic-all - -# Suspect missing close() on file PermClass.current, windows samevm cascade -java/security/BasicPermission/PermClass.java generic-all - -# Solaris 11 i586, these all fail with samevm, need to be othervm??? -java/security/KeyPairGenerator/Failover.java generic-all -java/security/Provider/DefaultPKCS11.java generic-all -java/security/SecureRandom/GetAlgorithm.java generic-all -java/security/Security/removing/RemoveProviders.java generic-all -java/security/Signature/ByteBuffers.java generic-all -java/security/Signature/NONEwithRSA.java generic-all -java/security/Signature/SignWithOutputBuffer.java generic-all -java/security/Signature/TestInitSignWithMyOwnRandom.java generic-all -java/security/UnresolvedPermission/AccessorMethods.java generic-all -java/security/UnresolvedPermission/Equals.java generic-all - # Fails on OpenSolaris, missing classes, slow on Solaris sparc sun/security/ec/TestEC.java generic-all diff --git a/test/java/security/BasicPermission/PermClass.java b/test/java/security/BasicPermission/PermClass.java index bfbf99900c0511725e556f205b5060cf66870a2c..71bd33b4ee828779a43aab6c71241f6d3f18ea6b 100644 --- a/test/java/security/BasicPermission/PermClass.java +++ b/test/java/security/BasicPermission/PermClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4511601 + * @bug 4511601 7054918 * @summary BasicPermissionCollection does not set permClass * during deserialization */ @@ -55,59 +55,66 @@ public class PermClass { // read in a 1.2.1 BasicPermissionCollection File sFile = new File(dir, "PermClass.1.2.1"); - ObjectInputStream ois = new ObjectInputStream - (new FileInputStream(sFile)); - PermissionCollection pc = (PermissionCollection)ois.readObject(); - System.out.println("1.2.1 collection = " + pc); - - if (pc.implies(mp)) { - System.out.println("JDK 1.2.1 test passed"); - } else { - throw new Exception("JDK 1.2.1 test failed"); + try (FileInputStream fis = new FileInputStream(sFile); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("1.2.1 collection = " + pc); + + if (pc.implies(mp)) { + System.out.println("JDK 1.2.1 test passed"); + } else { + throw new Exception("JDK 1.2.1 test failed"); + } } // read in a 1.3.1 BasicPermissionCollection sFile = new File(dir, "PermClass.1.3.1"); - ois = new ObjectInputStream(new FileInputStream(sFile)); - pc = (PermissionCollection)ois.readObject(); - System.out.println("1.3.1 collection = " + pc); - - if (pc.implies(mp)) { - System.out.println("JDK 1.3.1 test passed"); - } else { - throw new Exception("JDK 1.3.1 test failed"); + try (FileInputStream fis = new FileInputStream(sFile); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("1.3.1 collection = " + pc); + + if (pc.implies(mp)) { + System.out.println("JDK 1.3.1 test passed"); + } else { + throw new Exception("JDK 1.3.1 test failed"); + } } // read in a 1.4 BasicPermissionCollection sFile = new File(dir, "PermClass.1.4"); - ois = new ObjectInputStream(new FileInputStream(sFile)); - pc = (PermissionCollection)ois.readObject(); - System.out.println("1.4 collection = " + pc); - - if (pc.implies(mp)) { - System.out.println("JDK 1.4 test 1 passed"); - } else { - throw new Exception("JDK 1.4 test 1 failed"); + try (FileInputStream fis = new FileInputStream(sFile); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("1.4 collection = " + pc); + + if (pc.implies(mp)) { + System.out.println("JDK 1.4 test 1 passed"); + } else { + throw new Exception("JDK 1.4 test 1 failed"); + } } // write out current BasicPermissionCollection PermissionCollection bpc = mp.newPermissionCollection(); bpc.add(mp); sFile = new File(dir, "PermClass.current"); - ObjectOutputStream oos = new ObjectOutputStream - (new FileOutputStream("PermClass.current")); - oos.writeObject(bpc); - oos.close(); + try (FileOutputStream fos = new FileOutputStream("PermClass.current"); + ObjectOutputStream oos = new ObjectOutputStream(fos)) { + oos.writeObject(bpc); + } // read in current BasicPermissionCollection - ois = new ObjectInputStream(new FileInputStream("PermClass.current")); - pc = (PermissionCollection)ois.readObject(); - System.out.println("current collection = " + pc); - - if (pc.implies(mp)) { - System.out.println("JDK 1.4 test 2 passed"); - } else { - throw new Exception("JDK 1.4 test 2 failed"); + try (FileInputStream fis = new FileInputStream("PermClass.current"); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("current collection = " + pc); + + if (pc.implies(mp)) { + System.out.println("JDK 1.4 test 2 passed"); + } else { + throw new Exception("JDK 1.4 test 2 failed"); + } } } } diff --git a/test/java/security/BasicPermission/SerialVersion.java b/test/java/security/BasicPermission/SerialVersion.java index 4ef0757497417b5bbf36a7fa813e5fa6e8878ad2..8c134c8688deead3ea18ec7a27c93bd95c5e49d6 100644 --- a/test/java/security/BasicPermission/SerialVersion.java +++ b/test/java/security/BasicPermission/SerialVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4502729 + * @bug 4502729 7054918 * @summary BasicPermissionCollection serial version UID incorrect */ @@ -36,40 +36,44 @@ public class SerialVersion { String dir = System.getProperty("test.src"); File sFile = new File (dir,"SerialVersion.1.2.1"); // read in a 1.2.1 BasicPermissionCollection - ObjectInputStream ois = new ObjectInputStream - (new FileInputStream(sFile)); - PermissionCollection pc = (PermissionCollection)ois.readObject(); - System.out.println("1.2.1 collection = " + pc); + try (FileInputStream fis = new FileInputStream(sFile); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("1.2.1 collection = " + pc); + } // read in a 1.3.1 BasicPermissionCollection sFile = new File (dir,"SerialVersion.1.3.1"); - ois = new ObjectInputStream - (new FileInputStream(sFile)); - pc = (PermissionCollection)ois.readObject(); - System.out.println("1.3.1 collection = " + pc); + try (FileInputStream fis = new FileInputStream(sFile); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("1.3.1 collection = " + pc); + } // read in a 1.4 BasicPermissionCollection sFile = new File (dir,"SerialVersion.1.4"); - ois = new ObjectInputStream - (new FileInputStream(sFile)); - pc = (PermissionCollection)ois.readObject(); - System.out.println("1.4 collection = " + pc); + try (FileInputStream fis = new FileInputStream(sFile); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("1.4 collection = " + pc); + } // write out current BasicPermissionCollection MyPermission mp = new MyPermission("SerialVersionTest"); PermissionCollection bpc = mp.newPermissionCollection(); sFile = new File (dir,"SerialVersion.current"); - ObjectOutputStream oos = new ObjectOutputStream - (new FileOutputStream("SerialVersion.current")); - oos.writeObject(bpc); - oos.close(); + try (FileOutputStream fos = new FileOutputStream("SerialVersion.current"); + ObjectOutputStream oos = new ObjectOutputStream(fos)) { + oos.writeObject(bpc); + } // read in current BasicPermissionCollection - ois = new ObjectInputStream - (new FileInputStream("SerialVersion.current")); - pc = (PermissionCollection)ois.readObject(); - System.out.println("current collection = " + pc); + try (FileInputStream fis = new FileInputStream("SerialVersion.current"); + ObjectInputStream ois = new ObjectInputStream(fis)) { + PermissionCollection pc = (PermissionCollection)ois.readObject(); + System.out.println("current collection = " + pc); + } } } diff --git a/test/java/security/KeyFactory/Failover.java b/test/java/security/KeyFactory/Failover.java index 4f27e9602fe5bfb729e31f44fd3c0014286ccdf6..1bb9dff64f7046a40ab0f23672044345c51f2f7a 100644 --- a/test/java/security/KeyFactory/Failover.java +++ b/test/java/security/KeyFactory/Failover.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /** * @test - * @bug 4894125 + * @bug 4894125 7054918 + * @library ../testlibrary * @summary test that failover for KeyFactory works * @author Andreas Sterbenz */ @@ -37,6 +38,15 @@ import java.security.spec.*; public class Failover { public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { Security.insertProviderAt(new ProviderFail(), 1); Security.addProvider(new ProviderPass()); System.out.println(Arrays.asList(Security.getProviders())); diff --git a/test/java/security/KeyPairGenerator/Failover.java b/test/java/security/KeyPairGenerator/Failover.java index adb32ae71e7827588189503966cba5448262ced5..7366a7dd3f1417252608cc14fb39a596ac67570f 100644 --- a/test/java/security/KeyPairGenerator/Failover.java +++ b/test/java/security/KeyPairGenerator/Failover.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /** * @test - * @bug 4894125 + * @bug 4894125 7054918 + * @library ../testlibrary * @summary test that failover for KeyPairGenerator works * @author Andreas Sterbenz */ @@ -37,6 +38,15 @@ import java.security.spec.*; public class Failover { public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { Security.insertProviderAt(new ProviderFail(), 1); Security.addProvider(new ProviderPass()); System.out.println(Arrays.asList(Security.getProviders())); diff --git a/test/java/security/Provider/ChangeProviders.java b/test/java/security/Provider/ChangeProviders.java index e373ede10bd491a5e62b60267d8c6673d9ee55b3..8bfec8b3418198577734ccc33d3a4c19ed666d23 100644 --- a/test/java/security/Provider/ChangeProviders.java +++ b/test/java/security/Provider/ChangeProviders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /* * @test - * @bug 4856968 + * @bug 4856968 7054918 + * @library ../testlibrary * @summary make sure add/insert/removeProvider() work correctly * @author Andreas Sterbenz */ @@ -43,6 +44,15 @@ public class ChangeProviders extends Provider { } public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { long start = System.currentTimeMillis(); Provider p = new ChangeProviders(); diff --git a/test/java/security/Provider/GetInstance.java b/test/java/security/Provider/GetInstance.java index 362ee49ef1d7703983bb3ba6fd63d51dda160323..7440b99bf394e956e57035462d25ccdfb1dd85e8 100644 --- a/test/java/security/Provider/GetInstance.java +++ b/test/java/security/Provider/GetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /* * @test - * @bug 4856968 + * @bug 4856968 7054918 + * @library ../testlibrary * @summary make sure getInstance() works correctly, including failover * and delayed provider selection for Signatures * @author Andreas Sterbenz @@ -43,6 +44,15 @@ public class GetInstance { } public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { long start = System.currentTimeMillis(); Provider foo = new FooProvider(); diff --git a/test/java/security/Provider/RemoveProvider.java b/test/java/security/Provider/RemoveProvider.java index 1628dada9a66a5d1a20816baa23953bb07d3c0fa..6b1bb0d323ec3591d0d0e13f165bd61e2cd1afd2 100644 --- a/test/java/security/Provider/RemoveProvider.java +++ b/test/java/security/Provider/RemoveProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /* * @test - * @bug 4190873 + * @bug 4190873 7054918 + * @library ../testlibrary * @summary Make sure provider instance can be removed from list of registered * providers, and "entrySet", "keySet", and "values" methods don't loop * indefinitely. @@ -34,6 +35,15 @@ import java.util.*; public class RemoveProvider { public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { // Add provider 1 Provider p1 = new MyProvider("name1",1,""); diff --git a/test/java/security/Provider/Turkish.java b/test/java/security/Provider/Turkish.java index 071c58f224bad81e1679bca321131d789659d5cd..21ac4136b56e11c274fd47a3f4b912f59518c194 100644 --- a/test/java/security/Provider/Turkish.java +++ b/test/java/security/Provider/Turkish.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,8 @@ /** * @test - * @bug 6220064 + * @bug 6220064 7054918 * @summary make sure everything works ok in the Turkish local (dotted/dotless i problem) - * @run main/othervm Turkish * @author Andreas Sterbenz */ @@ -41,54 +40,59 @@ public class Turkish { Provider p1 = new TProvider("T1"); System.out.println(p1.getServices()); // trigger service parsing - Locale.setDefault(new Locale("tr", "TR")); + Locale loc = Locale.getDefault(); + try { + Locale.setDefault(new Locale("tr", "TR")); - Provider p2 = new TProvider("T2"); - System.out.println(p2.getServices()); // trigger service parsing + Provider p2 = new TProvider("T2"); + System.out.println(p2.getServices()); // trigger service parsing - System.out.println(Signature.getInstance("MD5withRSA")); - System.out.println(Signature.getInstance("md5withrsa")); - System.out.println(Signature.getInstance("MD5WITHRSA")); - Service s1, s2; - s1 = p1.getService("Signature", "MD5withRSA"); - check(s1, null); - check(s1, p1.getService("Signature", "md5withrsa")); - check(s1, p1.getService("Signature", "MD5WITHRSA")); - check(s1, p1.getService("Signature", "MD5RSA")); - check(s1, p1.getService("Signature", "md5rsa")); - check(s1, p1.getService("Signature", "MD5rsa")); + System.out.println(Signature.getInstance("MD5withRSA")); + System.out.println(Signature.getInstance("md5withrsa")); + System.out.println(Signature.getInstance("MD5WITHRSA")); + Service s1, s2; + s1 = p1.getService("Signature", "MD5withRSA"); + check(s1, null); + check(s1, p1.getService("Signature", "md5withrsa")); + check(s1, p1.getService("Signature", "MD5WITHRSA")); + check(s1, p1.getService("Signature", "MD5RSA")); + check(s1, p1.getService("Signature", "md5rsa")); + check(s1, p1.getService("Signature", "MD5rsa")); - s1 = p1.getService("Signature", "SHAwithRSA"); - check(s1, null); - check(s1, p1.getService("Signature", "shawithrsa")); - check(s1, p1.getService("Signature", "SHAWITHRSA")); - check(s1, p1.getService("Signature", "SHARSA")); - check(s1, p1.getService("Signature", "sharsa")); - check(s1, p1.getService("Signature", "SHArsa")); - check(s1, p1.getService("Signature", "SHA1RSA")); - check(s1, p1.getService("Signature", "sha1rsa")); - check(s1, p1.getService("Signature", "SHA1rsa")); + s1 = p1.getService("Signature", "SHAwithRSA"); + check(s1, null); + check(s1, p1.getService("Signature", "shawithrsa")); + check(s1, p1.getService("Signature", "SHAWITHRSA")); + check(s1, p1.getService("Signature", "SHARSA")); + check(s1, p1.getService("Signature", "sharsa")); + check(s1, p1.getService("Signature", "SHArsa")); + check(s1, p1.getService("Signature", "SHA1RSA")); + check(s1, p1.getService("Signature", "sha1rsa")); + check(s1, p1.getService("Signature", "SHA1rsa")); - s1 = p2.getService("Signature", "MD5withRSA"); - check(s1, null); - check(s1, p2.getService("Signature", "md5withrsa")); - check(s1, p2.getService("Signature", "MD5WITHRSA")); - check(s1, p2.getService("Signature", "MD5RSA")); - check(s1, p2.getService("Signature", "md5rsa")); - check(s1, p2.getService("Signature", "MD5rsa")); + s1 = p2.getService("Signature", "MD5withRSA"); + check(s1, null); + check(s1, p2.getService("Signature", "md5withrsa")); + check(s1, p2.getService("Signature", "MD5WITHRSA")); + check(s1, p2.getService("Signature", "MD5RSA")); + check(s1, p2.getService("Signature", "md5rsa")); + check(s1, p2.getService("Signature", "MD5rsa")); - s1 = p2.getService("Signature", "SHAwithRSA"); - check(s1, null); - check(s1, p2.getService("Signature", "shawithrsa")); - check(s1, p2.getService("Signature", "SHAWITHRSA")); - check(s1, p2.getService("Signature", "SHARSA")); - check(s1, p2.getService("Signature", "sharsa")); - check(s1, p2.getService("Signature", "SHArsa")); - check(s1, p2.getService("Signature", "SHA1RSA")); - check(s1, p2.getService("Signature", "sha1rsa")); - check(s1, p2.getService("Signature", "SHA1rsa")); + s1 = p2.getService("Signature", "SHAwithRSA"); + check(s1, null); + check(s1, p2.getService("Signature", "shawithrsa")); + check(s1, p2.getService("Signature", "SHAWITHRSA")); + check(s1, p2.getService("Signature", "SHARSA")); + check(s1, p2.getService("Signature", "sharsa")); + check(s1, p2.getService("Signature", "SHArsa")); + check(s1, p2.getService("Signature", "SHA1RSA")); + check(s1, p2.getService("Signature", "sha1rsa")); + check(s1, p2.getService("Signature", "SHA1rsa")); - System.out.println("OK"); + System.out.println("OK"); + } finally { + Locale.setDefault(loc); + } } private static void check(Service s1, Service s2) throws Exception { diff --git a/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh b/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh index e067300ba4fd54156afb0e9bebe6eba25a640f30..bf25695c4df2a9127a0dfa9b8216e8ebe71bec5e 100644 --- a/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh +++ b/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + CYGWIN* ) + PATHSEP=";" + FILESEP="/" + ;; Windows* ) PATHSEP=";" FILESEP="\\" diff --git a/test/java/security/Security/NoInstalledProviders.java b/test/java/security/Security/NoInstalledProviders.java index f586df6e7bb52fb9c3230e57b4ef11a006111717..c60eaae47c05e836702af72f715da76b24a99455 100644 --- a/test/java/security/Security/NoInstalledProviders.java +++ b/test/java/security/Security/NoInstalledProviders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /* * @test - * @bug 4273454 + * @bug 4273454 7054918 + * @library ../testlibrary * @summary Make sure getProviders(filter) doesn't throw NPE */ @@ -31,7 +32,16 @@ import java.security.*; public class NoInstalledProviders { - public static void main(String[] argv) { + public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { Provider[] provs = Security.getProviders(); // make sure there are no providers in the system diff --git a/test/java/security/Security/SynchronizedAccess.java b/test/java/security/Security/SynchronizedAccess.java index 8ab8dab416a075ed98eeac897bb77cdd336e8374..c615ae9e574c35bb597002aeb242425d59bfdc60 100644 --- a/test/java/security/Security/SynchronizedAccess.java +++ b/test/java/security/Security/SynchronizedAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /* * @test - * @bug 4162583 + * @bug 4162583 7054918 + * @library ../testlibrary * @summary Make sure Provider api implementations are synchronized properly */ @@ -31,7 +32,16 @@ import java.security.*; public class SynchronizedAccess { - public static void main(String[] args) { + public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { AccessorThread[] acc = new AccessorThread[200]; for (int i=0; i < acc.length; i++) acc[i] = new AccessorThread("thread"+i); diff --git a/test/java/security/Security/removing/RemoveProviders.java b/test/java/security/Security/removing/RemoveProviders.java index cd2bd130a9a4bff4cb74d244edbc58228f2d837f..0d9f6b207c595ab202c09e77447d27e2761b7c14 100644 --- a/test/java/security/Security/removing/RemoveProviders.java +++ b/test/java/security/Security/removing/RemoveProviders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /** * @test - * @bug 4963416 + * @bug 4963416 7054918 + * @library ../../testlibrary * @summary make sure removeProvider() always works correctly * @author Andreas Sterbenz */ @@ -35,6 +36,15 @@ import java.security.*; public class RemoveProviders { public static void main(String[] args) throws Exception { + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); + try { + main0(args); + } finally { + snapshot.restore(); + } + } + + public static void main0(String[] args) throws Exception { Provider[] providers = Security.getProviders(); System.out.println("Providers: " + Arrays.asList(providers)); diff --git a/test/java/security/UnresolvedPermission/Equals.java b/test/java/security/UnresolvedPermission/Equals.java index 3a89e685d48b48af48c862b39c68a76871da7337..a88a77b49ac583be8e594b50df4980289c0367e8 100644 --- a/test/java/security/UnresolvedPermission/Equals.java +++ b/test/java/security/UnresolvedPermission/Equals.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 4513737 + * @run main/othervm Equals * @summary UnresolvedPermission.equals() throws NullPointerException */ diff --git a/test/java/security/spec/EllipticCurveMatch.java b/test/java/security/spec/EllipticCurveMatch.java index 51908658e4bb744596af9fa4e529fda2dc2d708d..797f6d2e0f3da99f177f61dcd19b705e7b53b595 100644 --- a/test/java/security/spec/EllipticCurveMatch.java +++ b/test/java/security/spec/EllipticCurveMatch.java @@ -25,13 +25,12 @@ * @test * @bug 6738532 * @summary Check EllipticCurve.equals() does not compare seed value of curve. - * @run main/othervm EllipticCurveMatch * @author Mike StJohns */ import java.security.spec.*; import java.math.BigInteger; -import java.security.SecureRandom; +import java.util.Random; public class EllipticCurveMatch { static String primeP256 = @@ -45,7 +44,7 @@ public class EllipticCurveMatch { private static EllipticCurve addSeedToCurve(EllipticCurve curve) { - SecureRandom rand = new SecureRandom(); + Random rand = new Random(); byte[] seed = new byte[12]; rand.nextBytes(seed); diff --git a/test/java/security/testlibrary/ProvidersSnapshot.java b/test/java/security/testlibrary/ProvidersSnapshot.java new file mode 100644 index 0000000000000000000000000000000000000000..33c45329e3f488497666d8614d00d30e2ad2539d --- /dev/null +++ b/test/java/security/testlibrary/ProvidersSnapshot.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.security.Provider; +import java.security.Security; + +public class ProvidersSnapshot { + + private Provider[] oldProviders; + + private ProvidersSnapshot() { + oldProviders = Security.getProviders(); + } + + public static ProvidersSnapshot create() { + return new ProvidersSnapshot(); + } + + public void restore() { + Provider[] newProviders = Security.getProviders(); + for (Provider p: newProviders) { + Security.removeProvider(p.getName()); + } + for (Provider p: oldProviders) { + Security.addProvider(p); + } + } +}