7054918: jdk_security1 test target cleanup
authorweijun
Mon, 20 Jun 2011 19:17:47 +0800
changeset 10057 03ae05289550
parent 10056 7464dc04ae22
child 10058 356295f8ee47
7054918: jdk_security1 test target cleanup Reviewed-by: alanb, smarks, vinnie
jdk/test/ProblemList.txt
jdk/test/java/security/BasicPermission/PermClass.java
jdk/test/java/security/BasicPermission/SerialVersion.java
jdk/test/java/security/KeyFactory/Failover.java
jdk/test/java/security/KeyPairGenerator/Failover.java
jdk/test/java/security/Provider/ChangeProviders.java
jdk/test/java/security/Provider/GetInstance.java
jdk/test/java/security/Provider/RemoveProvider.java
jdk/test/java/security/Provider/Turkish.java
jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh
jdk/test/java/security/Security/NoInstalledProviders.java
jdk/test/java/security/Security/SynchronizedAccess.java
jdk/test/java/security/Security/removing/RemoveProviders.java
jdk/test/java/security/UnresolvedPermission/Equals.java
jdk/test/java/security/spec/EllipticCurveMatch.java
jdk/test/java/security/testlibrary/ProvidersSnapshot.java
--- a/jdk/test/ProblemList.txt	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/ProblemList.txt	Mon Jun 20 19:17:47 2011 +0800
@@ -502,10 +502,6 @@
 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 @@
 # 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
 
--- a/jdk/test/java/security/BasicPermission/PermClass.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/BasicPermission/PermClass.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 
         // 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);
+        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");
+            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);
+        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");
+            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);
+        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");
+            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);
+        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");
+            if (pc.implies(mp)) {
+                System.out.println("JDK 1.4 test 2 passed");
+            } else {
+                throw new Exception("JDK 1.4 test 2 failed");
+            }
         }
     }
 }
--- a/jdk/test/java/security/BasicPermission/SerialVersion.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/BasicPermission/SerialVersion.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
         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);
+        }
     }
 }
 
--- a/jdk/test/java/security/KeyFactory/Failover.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/KeyFactory/Failover.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 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()));
--- a/jdk/test/java/security/KeyPairGenerator/Failover.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/KeyPairGenerator/Failover.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 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()));
--- a/jdk/test/java/security/Provider/ChangeProviders.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Provider/ChangeProviders.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 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();
 
--- a/jdk/test/java/security/Provider/GetInstance.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Provider/GetInstance.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 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();
--- a/jdk/test/java/security/Provider/RemoveProvider.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Provider/RemoveProvider.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 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,"");
--- a/jdk/test/java/security/Provider/Turkish.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Provider/Turkish.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
         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 {
--- a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
     PATHSEP=":"
     FILESEP="/"
     ;;
+  CYGWIN* )
+    PATHSEP=";"
+    FILESEP="/"
+    ;;
   Windows* )
     PATHSEP=";"
     FILESEP="\\"
--- a/jdk/test/java/security/Security/NoInstalledProviders.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Security/NoInstalledProviders.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 
 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
--- a/jdk/test/java/security/Security/SynchronizedAccess.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Security/SynchronizedAccess.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 
 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);
--- a/jdk/test/java/security/Security/removing/RemoveProviders.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/Security/removing/RemoveProviders.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 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));
 
--- a/jdk/test/java/security/UnresolvedPermission/Equals.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/UnresolvedPermission/Equals.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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
  */
 
--- a/jdk/test/java/security/spec/EllipticCurveMatch.java	Mon Jun 20 12:27:20 2011 +0100
+++ b/jdk/test/java/security/spec/EllipticCurveMatch.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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 @@
 
     private static EllipticCurve addSeedToCurve(EllipticCurve curve)
     {
-        SecureRandom rand = new SecureRandom();
+        Random rand = new Random();
         byte[] seed = new byte[12];
         rand.nextBytes(seed);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/testlibrary/ProvidersSnapshot.java	Mon Jun 20 19:17:47 2011 +0800
@@ -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);
+        }
+    }
+}