提交 97031c7e 编写于 作者: V valeriep

7035115: sun/security/pkcs11/Provider/ConfigShortPath.java compilation failed

Summary: Updated the test to use reflection and skip when SunPKCS11 provider not present.
Reviewed-by: weijun
上级 5cf9e3af
......@@ -29,23 +29,36 @@
import java.security.*;
import java.io.*;
import java.lang.reflect.*;
public class ConfigShortPath {
private static final String[] configNames = { "csp.cfg", "cspPlus.cfg" };
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Constructor cons = null;
try {
Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11");
cons = clazz.getConstructor(String.class);
} catch (Exception ex) {
System.out.println("Skipping test - no PKCS11 provider available");
return;
}
String testSrc = System.getProperty("test.src", ".");
for (int i = 0; i < configNames.length; i++) {
String configFile = testSrc + File.separator + configNames[i];
System.out.println("Testing against " + configFile);
try {
Provider p = new sun.security.pkcs11.SunPKCS11(configFile);
} catch (ProviderException pe) {
String cause = pe.getCause().getMessage();
if (cause.indexOf("Unexpected token") != -1) {
// re-throw to indicate test failure
throw pe;
Object obj = cons.newInstance(configFile);
} catch (InvocationTargetException ite) {
Throwable cause = ite.getCause();
if (cause instanceof ProviderException) {
String causeMsg = cause.getCause().getMessage();
// Indicate failure if due to parsing config
if (causeMsg.indexOf("Unexpected token") != -1) {
throw (ProviderException) cause;
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册