RFR: 8273507: Using TestNG for unit testing ChannelInputStream::transferTo [v2]

Markus KARG github.com+1701815+mkarg at openjdk.java.net
Thu Sep 9 06:26:34 UTC 2021


On Wed, 8 Sep 2021 18:45:02 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Using assert* methods instead of fail() and expectedExceptions
>>   
>>   Signed-off-by: Markus Karg <markus at headcrashing.eu>
>
> test/jdk/java/nio/channels/Channels/TransferTo.java line 75:
> 
>> 73:     }
>> 74: 
>> 75:     @Test(dataProvider = "streamCombinations", expectedExceptions = NullPointerException.class)
> 
> We have been moving away from using the  expectedExceptions annotation element and using the assertThrows method instead, example:
> 
> assertThrows(NullPointerException.class, () -> inputStreamProvider.input().transferTo(null));

Done in https://github.com/openjdk/jdk/pull/5421/commits/b37ad6b39ffc78af7ca8c487125b7e4e0c1ff141.

> test/jdk/java/nio/channels/Channels/TransferTo.java line 135:
> 
>> 133: 
>> 134:             if (reported != count)
>> 135:                 fail(format("reported %d bytes but should report %d", reported, count));
> 
> I would consider using
> 
>  assertTrue( reported == count, format("reported %d bytes but should report %d", reported, count));

Done in https://github.com/openjdk/jdk/pull/5421/commits/b37ad6b39ffc78af7ca8c487125b7e4e0c1ff141.

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

PR: https://git.openjdk.java.net/jdk/pull/5421


More information about the nio-dev mailing list