8381842: Refactor remaining TestNG tests under java/net/ to use JUnit#30681
8381842: Refactor remaining TestNG tests under java/net/ to use JUnit#30681dfuch wants to merge 1 commit intoopenjdk:masterfrom
Conversation
|
👋 Welcome back dfuchs! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
| @@ -53,8 +54,7 @@ public void testSetAddress() throws Exception { | |||
| assertTrue(pkt.getAddress() == null); | |||
| .map(InetAddress::getHostAddress).toArray(String[]::new); | ||
| String [] expectedAddresses = getExpectedAddressesArray(); | ||
|
|
||
| if (Arrays.deepEquals(resolvedAddresses, expectedAddresses)) { |
There was a problem hiding this comment.
Could use assertArrayEquals? (unless you want to keep the custom error messages)
| } | ||
|
|
||
| @Test | ||
| // InetSocketAddress.toString() throws NPE with unresolved address |
There was a problem hiding this comment.
This comment is wrong / misleading; it was the behavior before https://bugs.openjdk.org/browse/JDK-4464064 was fixed
Maybe would also be good to rename the method then from NPETest to unresolvedTest or similar?
| // InetSocketAddress.toString() throws NPE with unresolved address | ||
| public static void NPETest() { | ||
| public void NPETest() { | ||
| System.out.println(new InetSocketAddress("unresolved", 12345)); |
There was a problem hiding this comment.
Replace with assertDoesNotThrow / assertNotNull?
|
|
||
| @DataProvider(name = "hostPortArgs") | ||
| public Object[][] createArgs1() { | ||
| public static Object[][] createArgs1() { |
There was a problem hiding this comment.
Would it make sense to apply the provider name as method name (i.e. hostPortArgs) to make it more expressive?
(same also for the other argument methods here)
| static private HttpServer server; | ||
| static private SocksServer socks; |
There was a problem hiding this comment.
Should be private static instead of static private to be conventional?
| private String response = "Hello."; | ||
| static private HttpServer server; | ||
| static private SocksServer socks; | ||
| private static String response = "Hello."; |
| try (ServerSocket ss = new ServerSocket(port, backlog, InetAddress.getLoopbackAddress()); | ||
| Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort()); | ||
| Socket s2 = ss.accept()) { | ||
| Assert.fail("IOException was expected to be thrown, but wasn't"); | ||
| fail("IOException was expected to be thrown, but wasn't"); | ||
| } catch (IOException ioe) { | ||
| // expected | ||
| // now verify the IOE was thrown for the correct expected reason | ||
| if (!(ioe.getCause() instanceof IllegalArgumentException)) { |
There was a problem hiding this comment.
Use assertThrows? E.g.:
var e = assertThrows(IOException.class, ...);
assertInstanceOf(IllegalArgumentException.class, e.getCause());That would also make it clearer which of the calls is expected to throw the IOException.
| if (namelen == -1) | ||
| return new Object[][] {new String[]{""}}; | ||
| return List.of(""); |
There was a problem hiding this comment.
Remove this namelen == -1 check because it is always false?
| new String(new char[100]).replaceAll("\0", "x"), | ||
| new String(new char[namelen]).replaceAll("\0", "x"), | ||
| new String(new char[namelen-1]).replaceAll("\0", "x") |
There was a problem hiding this comment.
Can simplify these?
| new String(new char[100]).replaceAll("\0", "x"), | |
| new String(new char[namelen]).replaceAll("\0", "x"), | |
| new String(new char[namelen-1]).replaceAll("\0", "x") | |
| "x".repeat(100), | |
| "x".repeat(namelen), | |
| "x".repeat(namelen - 1) |
Hi, may I get a review for this change that converts the remaining TestNG tests under test/jdk/java/net to JUnit.
An exception is
java/net/NetworkInterface/NetworkInterfaceStreamTest.javawhich depends on library classes depending on TestNG. Converting that test is not done here but is tracked by JDK-8381848Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30681/head:pull/30681$ git checkout pull/30681Update a local copy of the PR:
$ git checkout pull/30681$ git pull https://git.openjdk.org/jdk.git pull/30681/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30681View PR using the GUI difftool:
$ git pr show -t 30681Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30681.diff
Using Webrev
Link to Webrev Comment