RFR: 8301701 : java/net/DatagramSocket/DatagramSocketMulticasting.java should be hardened

Darragh Clarke duke at openjdk.org
Fri Feb 10 16:31:50 UTC 2023


On Fri, 10 Feb 2023 15:58:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Updated `DatagramSocketMulticasting` to use Junit and also hardened the test to avoid occasional interference from other tests.
>> 
>> - Test now uses Junit Assertions, in general if the assertion used had been `assertTrue(foo==bar)` I replaced it with `assertEquals(foo,bar)` though there are some cases where I used `assertTrue` or `assertFalse`
>> - `testSendReceive` now retries up to 3 times if a message from an unexpected port is received
>> - Both `testSendReceive` and `testSendNoReceive` both have messages that use the methods name instead of just "hello"
>> 
>> Ran tiers 1-3 of tests as well as running this updated test to make sure it was stable
>
> test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java line 75:
> 
>> 73:     @Test
>> 74:     public void main() throws IOException {
>> 75:         IPSupport.throwSkippedExceptionIfNonOperational();
> 
> This can throw jtreg.SkippedException, do you know if the JUnit test runner handles this?

Good point, I'll look into that

> test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java line 146:
> 
>> 144: 
>> 145:         // check network interface not set
>> 146:         assertEquals(s.getOption(IP_MULTICAST_IF), null);
> 
> It's possible to use assertNull and assertNoNull if you want, it doesn't matter of course.

That would probably be cleaner, I'll make that change

-------------

PR: https://git.openjdk.org/jdk/pull/12513


More information about the net-dev mailing list