8370942: test/jdk/java/security/Provider/NewInstance.java and /test/jdk/java/security/cert/CertStore/NoLDAP.java may skip without notifying

Reviewed-by: myankelevich, rhalade
This commit is contained in:
Neha Joshi 2025-11-26 05:53:58 +00:00 committed by SendaoYan
parent 7cc584fbe6
commit e13dfd3ec3
2 changed files with 28 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, 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
@ -26,21 +26,34 @@
* @bug 8039853
* @summary Provider.Service.newInstance() does not work with current
JDK JGSS Mechanisms
* @library /test/lib
*/
import java.security.*;
import java.util.*;
import jtreg.SkippedException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class NewInstance {
public static void main(String[] args) throws Exception {
for (Provider p : Security.getProviders()) {
System.out.println("Removing SunPCSC provider from the list (A smartcard might not be installed).");
final List<Provider> providers = Arrays.stream(Security.getProviders())
.filter(provider -> !provider.getName().equals("SunPCSC"))
.collect(Collectors.toList());
for (Provider p : providers) {
System.out.println("---------");
System.out.println(p.getName() + ":" + p.getInfo());
if (p.getName().equals("SunPCSC")) {
System.out.println("A smartcard might not be installed. Skip test.");
continue;
}
Set<Provider.Service> set = p.getServices();
Iterator<Provider.Service> i = set.iterator();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2025, 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
@ -25,20 +25,23 @@
* @bug 8004502
* @summary Sanity check that NoSuchAlgorithmException is thrown when requesting
* a CertStore of type "LDAP" and LDAP is not available.
* @library /test/lib
*/
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertStore;
import java.security.cert.LDAPCertStoreParameters;
import jtreg.SkippedException;
public class NoLDAP {
public static void main(String[] args) throws Exception {
try {
Class.forName("javax.naming.ldap.LdapName");
System.out.println("LDAP is present, test skipped");
return;
} catch (ClassNotFoundException ignore) { }
throw new SkippedException("LDAP is present");
} catch (ClassNotFoundException ignore) {
System.err.println("Expected: class not found exception " + ignore.getMessage());
}
try {
CertStore.getInstance("LDAP", new LDAPCertStoreParameters());