Skip to content

Commit c64541f

Browse files
committed
JDK-8365861: test/jdk/sun/security/pkcs11/Provider/ tests skipped without SkippedException
1 parent 0ad919c commit c64541f

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

test/jdk/sun/security/pkcs11/Provider/Absolute.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
2828
* @summary load DLLs and launch executables using fully qualified path
2929
*/
3030

31+
import jtreg.SkippedException;
32+
3133
import java.security.InvalidParameterException;
3234
import java.security.Provider;
3335

@@ -40,12 +42,11 @@ public static void main(String[] args) throws Exception {
4042
try {
4143
Provider p = PKCS11Test.getSunPKCS11(config);
4244
if (p == null) {
43-
System.out.println("Skipping test - no PKCS11 provider available");
45+
throw new SkippedException("Skipping test - no PKCS11 provider available");
4446
}
4547
} catch (InvalidParameterException ipe) {
4648
Throwable ex = ipe.getCause();
47-
if (ex.getMessage().indexOf(
48-
"Absolute path required for library value:") != -1) {
49+
if (ex.getMessage().contains("Absolute path required for library value:")) {
4950
System.out.println("Test Passed: expected exception thrown");
5051
} else {
5152
// rethrow

test/jdk/sun/security/pkcs11/Provider/ConfigShortPath.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,17 @@
2525
* @bug 6581254 6986789 7196009 8062170
2626
* @summary Allow '~', '+', and quoted paths in config file
2727
* @author Valerie Peng
28+
* @library /test/lib
2829
*/
2930

30-
import java.security.*;
31-
import java.io.*;
32-
import java.lang.reflect.*;
31+
import jtreg.SkippedException;
32+
33+
import java.io.File;
34+
import java.io.IOException;
35+
import java.security.InvalidParameterException;
36+
import java.security.Provider;
37+
import java.security.ProviderException;
38+
import java.security.Security;
3339

3440
public class ConfigShortPath {
3541

@@ -43,8 +49,7 @@ public class ConfigShortPath {
4349
public static void main(String[] args) throws Exception {
4450
Provider p = Security.getProvider("SunPKCS11");
4551
if (p == null) {
46-
System.out.println("Skipping test - no PKCS11 provider available");
47-
return;
52+
throw new SkippedException("Skipping test - no PKCS11 provider available");
4853
}
4954

5055
String osInfo = System.getProperty("os.name", "");
@@ -65,7 +70,7 @@ public static void main(String[] args) throws Exception {
6570
if (cause.getClass().getName().equals
6671
("sun.security.pkcs11.ConfigurationException")) {
6772
// Error occurred during parsing
68-
if (cause.getMessage().indexOf("Unexpected") != -1) {
73+
if (cause.getMessage().contains("Unexpected")) {
6974
throw (ProviderException) cause;
7075
}
7176
}

test/jdk/sun/security/pkcs11/Provider/LoginISE.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,25 +21,30 @@
2121
* questions.
2222
*/
2323

24-
import java.io.*;
25-
import java.util.*;
26-
import java.security.*;
27-
import javax.security.auth.callback.*;
24+
import jtreg.SkippedException;
25+
26+
import java.io.IOException;
27+
import java.security.AuthProvider;
28+
import java.security.Provider;
29+
import java.security.Security;
30+
import javax.security.auth.callback.Callback;
31+
import javax.security.auth.callback.CallbackHandler;
32+
import javax.security.auth.callback.UnsupportedCallbackException;
2833

2934
/**
3035
* @test
3136
* @bug 8130648
3237
* @summary make sure IllegalStateException is thrown for uninitialized
3338
* SunPKCS11 provider instance
39+
* @library /test/lib
3440
*/
3541
public class LoginISE {
3642

3743
public static void main(String[] args) throws Exception {
3844

3945
Provider p = Security.getProvider("SunPKCS11");
4046
if (p == null) {
41-
System.out.println("No un-initialized PKCS11 provider available; skip");
42-
return;
47+
throw new SkippedException("No un-initialized PKCS11 provider available; skip");
4348
}
4449
if (!(p instanceof AuthProvider)) {
4550
throw new RuntimeException("Error: expect AuthProvider!");

0 commit comments

Comments
 (0)