提交 e9fc2bc5 编写于 作者: W weijun

7054918: jdk_security1 test target cleanup

Reviewed-by: alanb, smarks, vinnie
上级 4969a1ad
...@@ -502,10 +502,6 @@ sun/security/pkcs11/ec/TestECDSA.java solaris-i586 ...@@ -502,10 +502,6 @@ sun/security/pkcs11/ec/TestECDSA.java solaris-i586
sun/security/pkcs11/ec/TestECGenSpec.java solaris-i586 sun/security/pkcs11/ec/TestECGenSpec.java solaris-i586
sun/security/pkcs11/ec/TestKeyFactory.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: # Failing on Solaris X64 (-d64 -server) with:
# GSSException: Failure unspecified at GSS-API level # GSSException: Failure unspecified at GSS-API level
# (Mechanism level: Specified version of key is not available (44)) # (Mechanism level: Specified version of key is not available (44))
...@@ -600,27 +596,6 @@ sun/security/tools/keytool/emptysubject.sh generic-all ...@@ -600,27 +596,6 @@ sun/security/tools/keytool/emptysubject.sh generic-all
# Timeout on solaris-sparcv9 or exception thrown # Timeout on solaris-sparcv9 or exception thrown
com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java solaris-all 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 # Fails on OpenSolaris, missing classes, slow on Solaris sparc
sun/security/ec/TestEC.java generic-all sun/security/ec/TestEC.java generic-all
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4511601 * @bug 4511601 7054918
* @summary BasicPermissionCollection does not set permClass * @summary BasicPermissionCollection does not set permClass
* during deserialization * during deserialization
*/ */
...@@ -55,8 +55,8 @@ public class PermClass { ...@@ -55,8 +55,8 @@ public class PermClass {
// read in a 1.2.1 BasicPermissionCollection // read in a 1.2.1 BasicPermissionCollection
File sFile = new File(dir, "PermClass.1.2.1"); File sFile = new File(dir, "PermClass.1.2.1");
ObjectInputStream ois = new ObjectInputStream try (FileInputStream fis = new FileInputStream(sFile);
(new FileInputStream(sFile)); ObjectInputStream ois = new ObjectInputStream(fis)) {
PermissionCollection pc = (PermissionCollection)ois.readObject(); PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("1.2.1 collection = " + pc); System.out.println("1.2.1 collection = " + pc);
...@@ -65,11 +65,13 @@ public class PermClass { ...@@ -65,11 +65,13 @@ public class PermClass {
} else { } else {
throw new Exception("JDK 1.2.1 test failed"); throw new Exception("JDK 1.2.1 test failed");
} }
}
// read in a 1.3.1 BasicPermissionCollection // read in a 1.3.1 BasicPermissionCollection
sFile = new File(dir, "PermClass.1.3.1"); sFile = new File(dir, "PermClass.1.3.1");
ois = new ObjectInputStream(new FileInputStream(sFile)); try (FileInputStream fis = new FileInputStream(sFile);
pc = (PermissionCollection)ois.readObject(); ObjectInputStream ois = new ObjectInputStream(fis)) {
PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("1.3.1 collection = " + pc); System.out.println("1.3.1 collection = " + pc);
if (pc.implies(mp)) { if (pc.implies(mp)) {
...@@ -77,11 +79,13 @@ public class PermClass { ...@@ -77,11 +79,13 @@ public class PermClass {
} else { } else {
throw new Exception("JDK 1.3.1 test failed"); throw new Exception("JDK 1.3.1 test failed");
} }
}
// read in a 1.4 BasicPermissionCollection // read in a 1.4 BasicPermissionCollection
sFile = new File(dir, "PermClass.1.4"); sFile = new File(dir, "PermClass.1.4");
ois = new ObjectInputStream(new FileInputStream(sFile)); try (FileInputStream fis = new FileInputStream(sFile);
pc = (PermissionCollection)ois.readObject(); ObjectInputStream ois = new ObjectInputStream(fis)) {
PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("1.4 collection = " + pc); System.out.println("1.4 collection = " + pc);
if (pc.implies(mp)) { if (pc.implies(mp)) {
...@@ -89,19 +93,21 @@ public class PermClass { ...@@ -89,19 +93,21 @@ public class PermClass {
} else { } else {
throw new Exception("JDK 1.4 test 1 failed"); throw new Exception("JDK 1.4 test 1 failed");
} }
}
// write out current BasicPermissionCollection // write out current BasicPermissionCollection
PermissionCollection bpc = mp.newPermissionCollection(); PermissionCollection bpc = mp.newPermissionCollection();
bpc.add(mp); bpc.add(mp);
sFile = new File(dir, "PermClass.current"); sFile = new File(dir, "PermClass.current");
ObjectOutputStream oos = new ObjectOutputStream try (FileOutputStream fos = new FileOutputStream("PermClass.current");
(new FileOutputStream("PermClass.current")); ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(bpc); oos.writeObject(bpc);
oos.close(); }
// read in current BasicPermissionCollection // read in current BasicPermissionCollection
ois = new ObjectInputStream(new FileInputStream("PermClass.current")); try (FileInputStream fis = new FileInputStream("PermClass.current");
pc = (PermissionCollection)ois.readObject(); ObjectInputStream ois = new ObjectInputStream(fis)) {
PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("current collection = " + pc); System.out.println("current collection = " + pc);
if (pc.implies(mp)) { if (pc.implies(mp)) {
...@@ -110,6 +116,7 @@ public class PermClass { ...@@ -110,6 +116,7 @@ public class PermClass {
throw new Exception("JDK 1.4 test 2 failed"); throw new Exception("JDK 1.4 test 2 failed");
} }
} }
}
} }
class MyPermission extends BasicPermission { class MyPermission extends BasicPermission {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4502729 * @bug 4502729 7054918
* @summary BasicPermissionCollection serial version UID incorrect * @summary BasicPermissionCollection serial version UID incorrect
*/ */
...@@ -36,41 +36,45 @@ public class SerialVersion { ...@@ -36,41 +36,45 @@ public class SerialVersion {
String dir = System.getProperty("test.src"); String dir = System.getProperty("test.src");
File sFile = new File (dir,"SerialVersion.1.2.1"); File sFile = new File (dir,"SerialVersion.1.2.1");
// read in a 1.2.1 BasicPermissionCollection // read in a 1.2.1 BasicPermissionCollection
ObjectInputStream ois = new ObjectInputStream try (FileInputStream fis = new FileInputStream(sFile);
(new FileInputStream(sFile)); ObjectInputStream ois = new ObjectInputStream(fis)) {
PermissionCollection pc = (PermissionCollection)ois.readObject(); PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("1.2.1 collection = " + pc); System.out.println("1.2.1 collection = " + pc);
}
// read in a 1.3.1 BasicPermissionCollection // read in a 1.3.1 BasicPermissionCollection
sFile = new File (dir,"SerialVersion.1.3.1"); sFile = new File (dir,"SerialVersion.1.3.1");
ois = new ObjectInputStream try (FileInputStream fis = new FileInputStream(sFile);
(new FileInputStream(sFile)); ObjectInputStream ois = new ObjectInputStream(fis)) {
pc = (PermissionCollection)ois.readObject(); PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("1.3.1 collection = " + pc); System.out.println("1.3.1 collection = " + pc);
}
// read in a 1.4 BasicPermissionCollection // read in a 1.4 BasicPermissionCollection
sFile = new File (dir,"SerialVersion.1.4"); sFile = new File (dir,"SerialVersion.1.4");
ois = new ObjectInputStream try (FileInputStream fis = new FileInputStream(sFile);
(new FileInputStream(sFile)); ObjectInputStream ois = new ObjectInputStream(fis)) {
pc = (PermissionCollection)ois.readObject(); PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("1.4 collection = " + pc); System.out.println("1.4 collection = " + pc);
}
// write out current BasicPermissionCollection // write out current BasicPermissionCollection
MyPermission mp = new MyPermission("SerialVersionTest"); MyPermission mp = new MyPermission("SerialVersionTest");
PermissionCollection bpc = mp.newPermissionCollection(); PermissionCollection bpc = mp.newPermissionCollection();
sFile = new File (dir,"SerialVersion.current"); sFile = new File (dir,"SerialVersion.current");
ObjectOutputStream oos = new ObjectOutputStream try (FileOutputStream fos = new FileOutputStream("SerialVersion.current");
(new FileOutputStream("SerialVersion.current")); ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(bpc); oos.writeObject(bpc);
oos.close(); }
// read in current BasicPermissionCollection // read in current BasicPermissionCollection
ois = new ObjectInputStream try (FileInputStream fis = new FileInputStream("SerialVersion.current");
(new FileInputStream("SerialVersion.current")); ObjectInputStream ois = new ObjectInputStream(fis)) {
pc = (PermissionCollection)ois.readObject(); PermissionCollection pc = (PermissionCollection)ois.readObject();
System.out.println("current collection = " + pc); System.out.println("current collection = " + pc);
} }
}
} }
class MyPermission extends BasicPermission { class MyPermission extends BasicPermission {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/** /**
* @test * @test
* @bug 4894125 * @bug 4894125 7054918
* @library ../testlibrary
* @summary test that failover for KeyFactory works * @summary test that failover for KeyFactory works
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -37,6 +38,15 @@ import java.security.spec.*; ...@@ -37,6 +38,15 @@ import java.security.spec.*;
public class Failover { public class Failover {
public static void main(String[] args) throws Exception { 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.insertProviderAt(new ProviderFail(), 1);
Security.addProvider(new ProviderPass()); Security.addProvider(new ProviderPass());
System.out.println(Arrays.asList(Security.getProviders())); System.out.println(Arrays.asList(Security.getProviders()));
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/** /**
* @test * @test
* @bug 4894125 * @bug 4894125 7054918
* @library ../testlibrary
* @summary test that failover for KeyPairGenerator works * @summary test that failover for KeyPairGenerator works
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -37,6 +38,15 @@ import java.security.spec.*; ...@@ -37,6 +38,15 @@ import java.security.spec.*;
public class Failover { public class Failover {
public static void main(String[] args) throws Exception { 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.insertProviderAt(new ProviderFail(), 1);
Security.addProvider(new ProviderPass()); Security.addProvider(new ProviderPass());
System.out.println(Arrays.asList(Security.getProviders())); System.out.println(Arrays.asList(Security.getProviders()));
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/* /*
* @test * @test
* @bug 4856968 * @bug 4856968 7054918
* @library ../testlibrary
* @summary make sure add/insert/removeProvider() work correctly * @summary make sure add/insert/removeProvider() work correctly
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -43,6 +44,15 @@ public class ChangeProviders extends Provider { ...@@ -43,6 +44,15 @@ public class ChangeProviders extends Provider {
} }
public static void main(String[] args) throws Exception { 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(); long start = System.currentTimeMillis();
Provider p = new ChangeProviders(); Provider p = new ChangeProviders();
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/* /*
* @test * @test
* @bug 4856968 * @bug 4856968 7054918
* @library ../testlibrary
* @summary make sure getInstance() works correctly, including failover * @summary make sure getInstance() works correctly, including failover
* and delayed provider selection for Signatures * and delayed provider selection for Signatures
* @author Andreas Sterbenz * @author Andreas Sterbenz
...@@ -43,6 +44,15 @@ public class GetInstance { ...@@ -43,6 +44,15 @@ public class GetInstance {
} }
public static void main(String[] args) throws Exception { 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(); long start = System.currentTimeMillis();
Provider foo = new FooProvider(); Provider foo = new FooProvider();
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/* /*
* @test * @test
* @bug 4190873 * @bug 4190873 7054918
* @library ../testlibrary
* @summary Make sure provider instance can be removed from list of registered * @summary Make sure provider instance can be removed from list of registered
* providers, and "entrySet", "keySet", and "values" methods don't loop * providers, and "entrySet", "keySet", and "values" methods don't loop
* indefinitely. * indefinitely.
...@@ -34,6 +35,15 @@ import java.util.*; ...@@ -34,6 +35,15 @@ import java.util.*;
public class RemoveProvider { public class RemoveProvider {
public static void main(String[] args) throws Exception { 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 // Add provider 1
Provider p1 = new MyProvider("name1",1,""); Provider p1 = new MyProvider("name1",1,"");
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,9 +23,8 @@ ...@@ -23,9 +23,8 @@
/** /**
* @test * @test
* @bug 6220064 * @bug 6220064 7054918
* @summary make sure everything works ok in the Turkish local (dotted/dotless i problem) * @summary make sure everything works ok in the Turkish local (dotted/dotless i problem)
* @run main/othervm Turkish
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -41,6 +40,8 @@ public class Turkish { ...@@ -41,6 +40,8 @@ public class Turkish {
Provider p1 = new TProvider("T1"); Provider p1 = new TProvider("T1");
System.out.println(p1.getServices()); // trigger service parsing System.out.println(p1.getServices()); // trigger service parsing
Locale loc = Locale.getDefault();
try {
Locale.setDefault(new Locale("tr", "TR")); Locale.setDefault(new Locale("tr", "TR"));
Provider p2 = new TProvider("T2"); Provider p2 = new TProvider("T2");
...@@ -89,6 +90,9 @@ public class Turkish { ...@@ -89,6 +90,9 @@ public class Turkish {
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 { private static void check(Service s1, Service s2) throws Exception {
......
#!/bin/sh #!/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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -58,6 +58,10 @@ case "$OS" in ...@@ -58,6 +58,10 @@ case "$OS" in
PATHSEP=":" PATHSEP=":"
FILESEP="/" FILESEP="/"
;; ;;
CYGWIN* )
PATHSEP=";"
FILESEP="/"
;;
Windows* ) Windows* )
PATHSEP=";" PATHSEP=";"
FILESEP="\\" FILESEP="\\"
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/* /*
* @test * @test
* @bug 4273454 * @bug 4273454 7054918
* @library ../testlibrary
* @summary Make sure getProviders(filter) doesn't throw NPE * @summary Make sure getProviders(filter) doesn't throw NPE
*/ */
...@@ -31,7 +32,16 @@ import java.security.*; ...@@ -31,7 +32,16 @@ import java.security.*;
public class NoInstalledProviders { 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(); Provider[] provs = Security.getProviders();
// make sure there are no providers in the system // make sure there are no providers in the system
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/* /*
* @test * @test
* @bug 4162583 * @bug 4162583 7054918
* @library ../testlibrary
* @summary Make sure Provider api implementations are synchronized properly * @summary Make sure Provider api implementations are synchronized properly
*/ */
...@@ -31,7 +32,16 @@ import java.security.*; ...@@ -31,7 +32,16 @@ import java.security.*;
public class SynchronizedAccess { 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]; AccessorThread[] acc = new AccessorThread[200];
for (int i=0; i < acc.length; i++) for (int i=0; i < acc.length; i++)
acc[i] = new AccessorThread("thread"+i); acc[i] = new AccessorThread("thread"+i);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
/** /**
* @test * @test
* @bug 4963416 * @bug 4963416 7054918
* @library ../../testlibrary
* @summary make sure removeProvider() always works correctly * @summary make sure removeProvider() always works correctly
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -35,6 +36,15 @@ import java.security.*; ...@@ -35,6 +36,15 @@ import java.security.*;
public class RemoveProviders { public class RemoveProviders {
public static void main(String[] args) throws Exception { 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(); Provider[] providers = Security.getProviders();
System.out.println("Providers: " + Arrays.asList(providers)); System.out.println("Providers: " + Arrays.asList(providers));
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 4513737 * @bug 4513737
* @run main/othervm Equals
* @summary UnresolvedPermission.equals() throws NullPointerException * @summary UnresolvedPermission.equals() throws NullPointerException
*/ */
......
...@@ -25,13 +25,12 @@ ...@@ -25,13 +25,12 @@
* @test * @test
* @bug 6738532 * @bug 6738532
* @summary Check EllipticCurve.equals() does not compare seed value of curve. * @summary Check EllipticCurve.equals() does not compare seed value of curve.
* @run main/othervm EllipticCurveMatch
* @author Mike StJohns * @author Mike StJohns
*/ */
import java.security.spec.*; import java.security.spec.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.SecureRandom; import java.util.Random;
public class EllipticCurveMatch { public class EllipticCurveMatch {
static String primeP256 = static String primeP256 =
...@@ -45,7 +44,7 @@ public class EllipticCurveMatch { ...@@ -45,7 +44,7 @@ public class EllipticCurveMatch {
private static EllipticCurve addSeedToCurve(EllipticCurve curve) private static EllipticCurve addSeedToCurve(EllipticCurve curve)
{ {
SecureRandom rand = new SecureRandom(); Random rand = new Random();
byte[] seed = new byte[12]; byte[] seed = new byte[12];
rand.nextBytes(seed); rand.nextBytes(seed);
......
/*
* 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);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册