From d7bace12ff72d9ab5be53cd1ef3a2b839ff9ddea Mon Sep 17 00:00:00 2001 From: Serhiy Sachkov Date: Wed, 8 Apr 2026 09:29:59 +0000 Subject: [PATCH] 8380990: Update testng and junit tests to use diagnoseConfigurationIssue() method and post processing Reviewed-by: dfuchs --- .../lang/ProcessBuilder/ReaderWriterTest.java | 5 ++--- .../net/DatagramSocket/SendReceiveMaxSize.java | 17 +++++++---------- .../java/net/InetSocketAddress/ToString.java | 12 +++++++++--- .../java/net/MulticastSocket/IPMulticastIF.java | 12 +++++++++--- .../NetworkInterfaceStreamTest.java | 11 ++++++++--- .../net/NetworkInterface/NullMacAddress.java | 12 +++++++++--- .../java/net/SocketOption/ImmutableOptions.java | 13 +++++++++---- .../net/httpclient/quic/VariableLengthTest.java | 5 ++--- .../LookupPolicyMappingTest.java | 4 +++- .../DatagramChannel/AfterDisconnect.java | 6 +++++- .../DatagramChannel/SendReceiveMaxSize.java | 8 ++++---- .../channels/etc/LocalSocketAddressType.java | 9 ++------- .../java/nio/channels/etc/OpenAndConnect.java | 8 +------- .../java/nio/channels/etc/ProtocolFamilies.java | 8 +------- .../text/Format/DecimalFormat/CloneTest.java | 8 ++++---- .../AsynchronousSocketChannelNAPITest.java | 10 +++++++--- .../DatagramChannelNAPITest.java | 10 +++++++--- .../DatagramSocketNAPITest.java | 10 +++++++--- .../SocketChannelNAPITest.java | 10 +++++++--- .../ExtendedSocketOption/SocketNAPITest.java | 10 +++++++--- 20 files changed, 110 insertions(+), 78 deletions(-) diff --git a/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java b/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java index 6bff8d5e592..0f5acf607ba 100644 --- a/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java +++ b/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java @@ -37,12 +37,11 @@ import java.nio.charset.StandardCharsets; import java.nio.charset.UnsupportedCharsetException; import java.util.stream.Stream; -import jtreg.SkippedException; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.opentest4j.TestAbortedException; /* * @test @@ -180,7 +179,7 @@ public class ReaderWriterTest { cs = Charset.forName(encoding); System.out.println("Charset: " + cs); } catch (UnsupportedCharsetException use) { - throw new SkippedException("Charset not supported: " + encoding); + throw new TestAbortedException("Charset not supported: " + encoding); } String cleanCSName = cleanCharsetName(cs); diff --git a/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java b/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java index 97a415dd6f8..2b68af9cbf2 100644 --- a/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java +++ b/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java @@ -87,8 +87,6 @@ import jdk.test.lib.RandomFactory; import jdk.test.lib.Platform; -import jdk.test.lib.net.IPSupport; -import jtreg.SkippedException; import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; @@ -102,9 +100,11 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MulticastSocket; import java.nio.channels.DatagramChannel; +import java.util.Optional; import java.util.Random; import static java.net.StandardSocketOptions.SO_RCVBUF; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.expectThrows; @@ -127,14 +127,11 @@ public class SendReceiveMaxSize { @BeforeTest public void setUp() throws IOException { - try { - // This method throws jtreg.SkippedException, which is - // interpreted as a test failure by testng - IPSupport.throwSkippedExceptionIfNonOperational(); - } catch (SkippedException skip) { - // throws the appropriate TestNG SkipException - throw new SkipException(skip.getMessage(), skip); - } + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); + HOST_ADDR = PREFER_LOOPBACK ? InetAddress.getLoopbackAddress() : InetAddress.getLocalHost(); BUF_LIMIT = (HOST_ADDR instanceof Inet6Address) ? IPV6_SNDBUF : IPV4_SNDBUF; System.out.printf("Host address: %s, Buffer limit: %d%n", HOST_ADDR, BUF_LIMIT); diff --git a/test/jdk/java/net/InetSocketAddress/ToString.java b/test/jdk/java/net/InetSocketAddress/ToString.java index 33fd1dd6a73..12eb599b872 100644 --- a/test/jdk/java/net/InetSocketAddress/ToString.java +++ b/test/jdk/java/net/InetSocketAddress/ToString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -32,12 +32,15 @@ */ import java.net.*; +import java.util.Optional; -import jdk.test.lib.net.IPSupport; +import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; + public class ToString { private static final String loopbackAddr; @@ -74,7 +77,10 @@ public class ToString { @BeforeTest public void setup() { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); } @Test diff --git a/test/jdk/java/net/MulticastSocket/IPMulticastIF.java b/test/jdk/java/net/MulticastSocket/IPMulticastIF.java index 3909f6d6276..6f6e7dd1942 100644 --- a/test/jdk/java/net/MulticastSocket/IPMulticastIF.java +++ b/test/jdk/java/net/MulticastSocket/IPMulticastIF.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -27,8 +27,10 @@ import java.net.MulticastSocket; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.List; +import java.util.Optional; + import jdk.test.lib.NetworkConfiguration; -import jdk.test.lib.net.IPSupport; +import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -36,6 +38,7 @@ import static java.lang.String.format; import static java.lang.System.out; import static java.net.StandardSocketOptions.IP_MULTICAST_IF; import static java.util.stream.Collectors.toList; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -53,7 +56,10 @@ public class IPMulticastIF { @BeforeTest public void sanity() { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); NetworkConfiguration.printSystemConfiguration(out); } diff --git a/test/jdk/java/net/NetworkInterface/NetworkInterfaceStreamTest.java b/test/jdk/java/net/NetworkInterface/NetworkInterfaceStreamTest.java index 63093e4b9fa..000b802d9a9 100644 --- a/test/jdk/java/net/NetworkInterface/NetworkInterfaceStreamTest.java +++ b/test/jdk/java/net/NetworkInterface/NetworkInterfaceStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -30,6 +30,7 @@ * @run testng/othervm -Djava.net.preferIPv4Stack=true NetworkInterfaceStreamTest */ +import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -39,12 +40,13 @@ import java.net.SocketException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Optional; import java.util.function.Supplier; import java.util.stream.OpTestCase; import java.util.stream.Stream; import java.util.stream.TestData; -import jdk.test.lib.net.IPSupport; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; public class NetworkInterfaceStreamTest extends OpTestCase { @@ -52,7 +54,10 @@ public class NetworkInterfaceStreamTest extends OpTestCase { @BeforeTest void setup() { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); } @Test diff --git a/test/jdk/java/net/NetworkInterface/NullMacAddress.java b/test/jdk/java/net/NetworkInterface/NullMacAddress.java index b31e93d39f2..8161670860e 100644 --- a/test/jdk/java/net/NetworkInterface/NullMacAddress.java +++ b/test/jdk/java/net/NetworkInterface/NullMacAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -31,8 +31,11 @@ * @run testng/othervm -Djava.net.preferIPv4Stack=true NullMacAddress */ +import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; + +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.*; import java.io.UncheckedIOException; @@ -40,14 +43,17 @@ import java.math.BigInteger; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Locale; +import java.util.Optional; -import jdk.test.lib.net.IPSupport; public class NullMacAddress { @BeforeTest void setup() { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); } @Test diff --git a/test/jdk/java/net/SocketOption/ImmutableOptions.java b/test/jdk/java/net/SocketOption/ImmutableOptions.java index f15734edddc..372a0322a35 100644 --- a/test/jdk/java/net/SocketOption/ImmutableOptions.java +++ b/test/jdk/java/net/SocketOption/ImmutableOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -33,18 +33,23 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.*; +import java.util.Optional; import java.util.Set; -import jdk.test.lib.net.IPSupport; - +import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; + public class ImmutableOptions { @BeforeTest void setupServerSocketFactory() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); ServerSocket.setSocketFactory(new ServerSocketImplFactory()); } diff --git a/test/jdk/java/net/httpclient/quic/VariableLengthTest.java b/test/jdk/java/net/httpclient/quic/VariableLengthTest.java index cf05b91b18f..6d805fbad5a 100644 --- a/test/jdk/java/net/httpclient/quic/VariableLengthTest.java +++ b/test/jdk/java/net/httpclient/quic/VariableLengthTest.java @@ -21,7 +21,6 @@ * questions. */ import jdk.internal.net.http.quic.VariableLengthEncoder; -import jtreg.SkippedException; import java.io.IOException; import java.nio.ByteBuffer; @@ -31,9 +30,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import org.opentest4j.TestAbortedException; /* * @test @@ -345,7 +344,7 @@ public class VariableLengthTest { case 2 -> ByteBuffer.allocate(capacity).putShort((short) length); case 4 -> ByteBuffer.allocate(capacity).putInt((int) length); case 8 -> ByteBuffer.allocate(capacity).putLong(length); - default -> throw new SkippedException("bad value used for capacity"); + default -> throw new TestAbortedException("bad value used for capacity"); }; } } diff --git a/test/jdk/java/net/spi/InetAddressResolverProvider/LookupPolicyMappingTest.java b/test/jdk/java/net/spi/InetAddressResolverProvider/LookupPolicyMappingTest.java index bbfa9f5555c..13ca6e50aaf 100644 --- a/test/jdk/java/net/spi/InetAddressResolverProvider/LookupPolicyMappingTest.java +++ b/test/jdk/java/net/spi/InetAddressResolverProvider/LookupPolicyMappingTest.java @@ -31,9 +31,11 @@ import static java.net.spi.InetAddressResolver.LookupPolicy.IPV4; import static java.net.spi.InetAddressResolver.LookupPolicy.IPV4_FIRST; import static java.net.spi.InetAddressResolver.LookupPolicy.IPV6; import static java.net.spi.InetAddressResolver.LookupPolicy.IPV6_FIRST; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import jdk.test.lib.net.IPSupport; import jdk.test.lib.NetworkConfiguration; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -95,7 +97,7 @@ public class LookupPolicyMappingTest { // Throws SkipException if platform doesn't support required IP address types static void checkPlatformNetworkConfiguration() { - IPSupport.throwSkippedExceptionIfNonOperational(); + diagnoseConfigurationIssue().ifPresent(Assumptions::abort); IPSupport.printPlatformSupport(System.err); NetworkConfiguration.printSystemConfiguration(System.err); // If preferIPv4=true and no IPv4 - skip diff --git a/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java b/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java index 44a34ea3e55..285e98c0fc6 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java +++ b/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java @@ -49,8 +49,11 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; + import jdk.test.lib.net.IPSupport; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import static java.nio.charset.StandardCharsets.UTF_8; @@ -92,7 +95,8 @@ public class AfterDisconnect { @Test public void execute() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + diagnoseConfigurationIssue().ifPresent(Assumptions::abort); + boolean preferIPv6 = Boolean.getBoolean("java.net.preferIPv6Addresses"); InetAddress lb = InetAddress.getLoopbackAddress(); diff --git a/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java b/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java index cb6e66dd5de..7d41382cf65 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java @@ -83,14 +83,14 @@ import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; import static java.net.StandardSocketOptions.SO_SNDBUF; import static java.net.StandardSocketOptions.SO_RCVBUF; -import static jdk.test.lib.net.IPSupport.hasIPv4; -import static jdk.test.lib.net.IPSupport.hasIPv6; -import static jdk.test.lib.net.IPSupport.preferIPv4Stack; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.api.Assumptions; + +import static jdk.test.lib.net.IPSupport.*; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -107,7 +107,7 @@ public class SendReceiveMaxSize { @BeforeAll public static void setUp() { - IPSupport.throwSkippedExceptionIfNonOperational(); + diagnoseConfigurationIssue().ifPresent(Assumptions::abort); } public static List testCases() throws IOException { diff --git a/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java b/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java index 60e41af6288..7439c7e436b 100644 --- a/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java +++ b/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java @@ -42,9 +42,9 @@ import java.util.Iterator; import java.util.stream.Stream; import static java.lang.System.out; + import static jdk.test.lib.net.IPSupport.*; -import jtreg.SkippedException; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; @@ -56,12 +56,7 @@ public class LocalSocketAddressType { @BeforeAll() public static void setup() { IPSupport.printPlatformSupport(out); - try { - throwSkippedExceptionIfNonOperational(); - } catch (SkippedException skippedException) { - // jtreg.SkippedException would cause a JUnit test to fail - Assumptions.assumeTrue(false, skippedException.getMessage()); - } + diagnoseConfigurationIssue().ifPresent(Assumptions::abort); } public static Iterator addresses() throws Exception { diff --git a/test/jdk/java/nio/channels/etc/OpenAndConnect.java b/test/jdk/java/nio/channels/etc/OpenAndConnect.java index 0e0347ebb57..ffdbebcc9a5 100644 --- a/test/jdk/java/nio/channels/etc/OpenAndConnect.java +++ b/test/jdk/java/nio/channels/etc/OpenAndConnect.java @@ -42,7 +42,6 @@ import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; import static jdk.test.lib.net.IPSupport.*; -import jtreg.SkippedException; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; @@ -89,12 +88,7 @@ public class OpenAndConnect { public static void setup() { NetworkConfiguration.printSystemConfiguration(out); IPSupport.printPlatformSupport(out); - try { - throwSkippedExceptionIfNonOperational(); - } catch (SkippedException skippedException) { - // jtreg.SkippedException would cause a JUnit test to fail - Assumptions.assumeTrue(false, skippedException.getMessage()); - } + diagnoseConfigurationIssue().ifPresent(Assumptions::abort); out.println("IA4LOCAL: " + IA4LOCAL); out.println("IA6LOCAL: " + IA6LOCAL); diff --git a/test/jdk/java/nio/channels/etc/ProtocolFamilies.java b/test/jdk/java/nio/channels/etc/ProtocolFamilies.java index 7f823ff35a8..2419cdd73cf 100644 --- a/test/jdk/java/nio/channels/etc/ProtocolFamilies.java +++ b/test/jdk/java/nio/channels/etc/ProtocolFamilies.java @@ -45,7 +45,6 @@ import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; import static jdk.test.lib.net.IPSupport.*; -import jtreg.SkippedException; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -77,12 +76,7 @@ public class ProtocolFamilies { public static void setup() throws Exception { NetworkConfiguration.printSystemConfiguration(out); IPSupport.printPlatformSupport(out); - try { - throwSkippedExceptionIfNonOperational(); - } catch (SkippedException skippedException) { - // jtreg.SkippedException would cause a JUnit test to fail - Assumptions.assumeTrue(false, skippedException.getMessage()); - } + diagnoseConfigurationIssue().ifPresent(Assumptions::abort); ia4 = getLocalIPv4Address(); ia6 = getLocalIPv6Address(); diff --git a/test/jdk/java/text/Format/DecimalFormat/CloneTest.java b/test/jdk/java/text/Format/DecimalFormat/CloneTest.java index dabdd137f5f..1a6821777be 100644 --- a/test/jdk/java/text/Format/DecimalFormat/CloneTest.java +++ b/test/jdk/java/text/Format/DecimalFormat/CloneTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -29,8 +29,8 @@ * @run junit/othervm --add-opens=java.base/java.text=ALL-UNNAMED CloneTest */ -import jtreg.SkippedException; import org.junit.jupiter.api.Test; +import org.opentest4j.TestAbortedException; import java.lang.reflect.Field; import java.math.BigDecimal; @@ -78,7 +78,7 @@ public class CloneTest { digitListClass = digitList.getClass(); } catch (ReflectiveOperationException e) { - throw new SkippedException("reflective access in white-box test failed", e); + throw new TestAbortedException("reflective access in white-box test failed", e); } } @@ -91,7 +91,7 @@ public class CloneTest { assertEquals(digitListField.get(original), digitListField.get(dfClone)); } catch (ReflectiveOperationException e) { - throw new SkippedException("reflective access in white-box test failed", e); + throw new TestAbortedException("reflective access in white-box test failed", e); } } diff --git a/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java b/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java index d5994ce0add..7fc86ff9f8f 100644 --- a/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java +++ b/test/jdk/jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -32,7 +32,6 @@ * @run testng/othervm -Djava.net.preferIPv4Stack=true AsynchronousSocketChannelNAPITest */ -import jdk.test.lib.net.IPSupport; import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -44,7 +43,9 @@ import java.net.SocketException; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousSocketChannel; +import java.util.Optional; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; @@ -59,7 +60,10 @@ public class AsynchronousSocketChannelNAPITest { @BeforeTest public void setup() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); try (var sc = AsynchronousSocketChannel.open(); var ssc = AsynchronousServerSocketChannel.open()) { if (!sc.supportedOptions().contains(SO_INCOMING_NAPI_ID)) { diff --git a/test/jdk/jdk/net/ExtendedSocketOption/DatagramChannelNAPITest.java b/test/jdk/jdk/net/ExtendedSocketOption/DatagramChannelNAPITest.java index 24623e52cf1..d38b0c5da88 100644 --- a/test/jdk/jdk/net/ExtendedSocketOption/DatagramChannelNAPITest.java +++ b/test/jdk/jdk/net/ExtendedSocketOption/DatagramChannelNAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -31,7 +31,6 @@ * @run testng/othervm -Djava.net.preferIPv4Stack=true DatagramChannelNAPITest */ -import jdk.test.lib.net.IPSupport; import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -42,7 +41,9 @@ import java.net.InetSocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; import java.nio.channels.DatagramChannel; +import java.util.Optional; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; @@ -56,7 +57,10 @@ public class DatagramChannelNAPITest { @BeforeTest public void setup() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); try (var dc = DatagramChannel.open()) { if (!dc.supportedOptions().contains(SO_INCOMING_NAPI_ID)) { assertThrows(UOE, () -> dc.getOption(SO_INCOMING_NAPI_ID)); diff --git a/test/jdk/jdk/net/ExtendedSocketOption/DatagramSocketNAPITest.java b/test/jdk/jdk/net/ExtendedSocketOption/DatagramSocketNAPITest.java index 446b74355b6..1ece78adec1 100644 --- a/test/jdk/jdk/net/ExtendedSocketOption/DatagramSocketNAPITest.java +++ b/test/jdk/jdk/net/ExtendedSocketOption/DatagramSocketNAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -37,12 +37,13 @@ import java.net.DatagramPacket; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketException; +import java.util.Optional; -import jdk.test.lib.net.IPSupport; import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertThrows; @@ -56,7 +57,10 @@ public class DatagramSocketNAPITest { @BeforeTest public void setup() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); try (var ds = new DatagramSocket()) { if (!ds.supportedOptions().contains(SO_INCOMING_NAPI_ID)) { assertThrows(UOE, () -> ds.getOption(SO_INCOMING_NAPI_ID)); diff --git a/test/jdk/jdk/net/ExtendedSocketOption/SocketChannelNAPITest.java b/test/jdk/jdk/net/ExtendedSocketOption/SocketChannelNAPITest.java index 898b9725310..b1427d22db6 100644 --- a/test/jdk/jdk/net/ExtendedSocketOption/SocketChannelNAPITest.java +++ b/test/jdk/jdk/net/ExtendedSocketOption/SocketChannelNAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -32,7 +32,6 @@ * @run testng/othervm -Djava.net.preferIPv4Stack=true SocketChannelNAPITest */ -import jdk.test.lib.net.IPSupport; import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -44,7 +43,9 @@ import java.net.SocketException; import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; +import java.util.Optional; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; @@ -59,7 +60,10 @@ public class SocketChannelNAPITest { @BeforeTest public void setup() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); try (var s = SocketChannel.open(); var ssc = ServerSocketChannel.open()) { if (!s.supportedOptions().contains(SO_INCOMING_NAPI_ID)) { diff --git a/test/jdk/jdk/net/ExtendedSocketOption/SocketNAPITest.java b/test/jdk/jdk/net/ExtendedSocketOption/SocketNAPITest.java index 2947c6ce878..057bf7cc91d 100644 --- a/test/jdk/jdk/net/ExtendedSocketOption/SocketNAPITest.java +++ b/test/jdk/jdk/net/ExtendedSocketOption/SocketNAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -41,12 +41,13 @@ import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; +import java.util.Optional; -import jdk.test.lib.net.IPSupport; import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import static jdk.test.lib.net.IPSupport.diagnoseConfigurationIssue; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; @@ -61,7 +62,10 @@ public class SocketNAPITest { @BeforeTest public void setup() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + Optional configurationIssue = diagnoseConfigurationIssue(); + configurationIssue.map(SkipException::new).ifPresent(x -> { + throw x; + }); try (var s = new Socket(); var ss = new ServerSocket()) { if (!s.supportedOptions().contains(SO_INCOMING_NAPI_ID)) {