Skip to content

Commit 041f6f1

Browse files
author
duke
committed
Backport e13dfd3ec39b0550eede83aa766deaad105995fc
1 parent bbd99cb commit 041f6f1

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

test/jdk/java/security/Provider/NewInstance.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 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
@@ -26,21 +26,34 @@
2626
* @bug 8039853
2727
* @summary Provider.Service.newInstance() does not work with current
2828
JDK JGSS Mechanisms
29+
* @library /test/lib
2930
*/
3031

31-
import java.security.*;
32-
import java.util.*;
32+
33+
import jtreg.SkippedException;
34+
35+
import java.security.InvalidAlgorithmParameterException;
36+
import java.security.NoSuchAlgorithmException;
37+
import java.security.Provider;
38+
import java.security.Security;
39+
import java.util.Arrays;
40+
import java.util.Iterator;
41+
import java.util.List;
42+
import java.util.Set;
43+
import java.util.stream.Collectors;
3344

3445
public class NewInstance {
3546

3647
public static void main(String[] args) throws Exception {
37-
for (Provider p : Security.getProviders()) {
48+
49+
System.out.println("Removing SunPCSC provider from the list (A smartcard might not be installed).");
50+
final List<Provider> providers = Arrays.stream(Security.getProviders())
51+
.filter(provider -> !provider.getName().equals("SunPCSC"))
52+
.collect(Collectors.toList());
53+
54+
for (Provider p : providers) {
3855
System.out.println("---------");
3956
System.out.println(p.getName() + ":" + p.getInfo());
40-
if (p.getName().equals("SunPCSC")) {
41-
System.out.println("A smartcard might not be installed. Skip test.");
42-
continue;
43-
}
4457
Set<Provider.Service> set = p.getServices();
4558
Iterator<Provider.Service> i = set.iterator();
4659

test/jdk/java/security/cert/CertStore/NoLDAP.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 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,20 +25,23 @@
2525
* @bug 8004502
2626
* @summary Sanity check that NoSuchAlgorithmException is thrown when requesting
2727
* a CertStore of type "LDAP" and LDAP is not available.
28+
* @library /test/lib
2829
*/
2930

3031
import java.security.NoSuchAlgorithmException;
3132
import java.security.cert.CertStore;
3233
import java.security.cert.LDAPCertStoreParameters;
34+
import jtreg.SkippedException;
3335

3436

3537
public class NoLDAP {
3638
public static void main(String[] args) throws Exception {
3739
try {
3840
Class.forName("javax.naming.ldap.LdapName");
39-
System.out.println("LDAP is present, test skipped");
40-
return;
41-
} catch (ClassNotFoundException ignore) { }
41+
throw new SkippedException("LDAP is present");
42+
} catch (ClassNotFoundException ignore) {
43+
System.err.println("Expected: class not found exception " + ignore.getMessage());
44+
}
4245

4346
try {
4447
CertStore.getInstance("LDAP", new LDAPCertStoreParameters());

0 commit comments

Comments
 (0)