Note
Sub-task 8381862: Refactor remaining TestNG tests under jdk/net/ExtendedSocketOption to use JUnit
I migrated the TestNG-based NAPI tests that were remaining under jdk/net/ExtendedSocketOption to JUnit.
Summary#
There were TestNG-based tests left under jdk/net/ExtendedSocketOption to verify the behavior of SO_INCOMING_NAPI_ID.
In this fix, I migrated 5 files to JUnit1:
AsynchronousSocketChannelNAPITest.javaDatagramChannelNAPITest.javaDatagramSocketNAPITest.javaSocketChannelNAPITest.javaSocketNAPITest.java
The basic replacement involved changing @run testng to @run junit, @BeforeTest to @BeforeAll, and SkipException to Assumptions.abort(...).
Since the initialization process only needs to be done once for each test class, it was expressed as a static @BeforeAll in JUnit.
- * @run testng SocketChannelNAPITest
- * @run testng/othervm -Djava.net.preferIPv4Stack=true SocketChannelNAPITest
+ * @run junit ${test.main.class}
+ * @run junit/othervm -Djava.net.preferIPv4Stack=true ${test.main.class}
Additionally, the order of arguments in assertEquals was adjusted to match JUnit conventions,
with expected values first and actual values second.
-assertEquals(socketID, 0, "AsynchronousSocketChannel: Sender");
+assertEquals(0, socketID, "AsynchronousSocketChannel: Sender");
Beyond just migrating the framework, I also reviewed how initialRun and temporary variables were handled for consistency checks of NAPI IDs.
The initial received value is now stored as originalID, and subsequent values are compared against this. This was simply a bug that needed fixing.
2026/04/28 PR Created#
In the PR, I explained that remaining TestNG tests were migrated to JUnit,
and @BeforeTest was replaced with static @BeforeAll as appropriate2.
Additionally, in SocketNAPITest, initialRun was initially set to false,
while other tests updated tempID every time.
This weakened the intention of verifying that "the first observed ID matches subsequent IDs."
Therefore, I modified it to save the initial value to originalID and then compare.
2026/04/28-29 Review Responses#
Alan Bateman3 pointed out that there might still be places where the order of arguments in assertEquals had not been swapped.
Daniel Fuchs4 suggested using ${test.main.class} instead of directly writing the target class name for @run junit.
Marcono12345 noted insufficient spacing around an if(initialRun) condition.
I addressed each review point accordingly.
2026/04/29-30 Additional Fixes#
Afterward, Fuchs4 approved the changes and I proceeded with /integrate.
2026/05/05 Integration#
With approval from Fuchs4, it was integrated into JDK as commit 91933ed6.
Footnotes#
-
8381862: Refactor remaining TestNG tests under jdk/net/ExtendedSocketOption to use JUnit by PeyaPeyaPeyang · Pull Reque…Hi all, I have migrated these classes to JUnit: jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java jdk/net/ExtendedSocketOption/DatagramChannelNAPITest.java jdk/n…GitHub
↩
-
8381862: Refactor remaining TestNG tests under jdk/net/ExtendedSocketOption to use JUnit by PeyaPeyaPeyang · Pull Reque…JDK main-line development https://openjdk.org/projects/jdk - 8381862: Refactor remaining TestNG tests under jdk/net/ExtendedSocketOption to use JUnit by PeyaPeyaPeyang · Pull Requ…GitHub
↩
-
https://openjdk.org/census#alanbopenjdk.org↩
-
https://openjdk.org/census#dfuchsopenjdk.org↩ ↩2 ↩3
-
Marcono1234 - OverviewMarcono1234 has 89 repositories available. Follow their code on GitHub.GitHub
↩
-
8381862: Refactor remaining TestNG tests under jdk/net/ExtendedSocket… · openjdk/jdk@91933edJDK main-line development https://openjdk.org/projects/jdk - 8381862: Refactor remaining TestNG tests under jdk/net/ExtendedSocket… · openjdk/jdk@91933edGitHub
↩