On Thu, 5 Nov 2020 13:59:18 GMT, Chris Hegarty <che...@openjdk.org> wrote:

>> The primary goal of this fix was to refactor 
>> NetworkInterface/UniqueMacAddressesTest.java to make use of the 
>> jdk.test.lib.NetworkConfiguration class instead of 
>> java.net.NetworkInterface. This was due to the original failure being 
>> related to the use of the 'awdl' interface on macOS, which should be skipped 
>> for functional tests. The NetworkConfiguration class accounts for this when 
>> returning the list of present interfaces (originally retrieved using 
>> NetworkInterface.getNetworkInterfaces()) as well as for other OS specific 
>> properties. The effects of these changes can be seen on L59 and L101-106.
>> 
>> In addition to these changes, some modifications were made to the test in 
>> the interest of keeping it concise and readable but were made bearing in 
>> mind the original logging of the test was already up to a good standard (and 
>> I sought to keep it that way). To summarize the other changes:
>> 
>> - When using NetworkConfiguration::interfaces to read in a stream of 
>> NetworkInterface objects, the objects are collected into a list of records 
>> (see [JEP 395](https://openjdk.java.net/jeps/395)) to avoid multiple calls 
>> to NetworkInterface::getHardwareAddress  (which can throw a SocketException) 
>> throughout the test.
>> - When checking if the MAC addresses are unique, the testMacAddressesEqual() 
>> method is not called unless the interface names are different. If 
>> testMacAddressesEqual() returns true, the calling method will simply return 
>> instead of updating the value of a boolean variable.
>> - Majority of logging was moved to the testMacAddressesEqualMethod() so that 
>> only logs for comparisons are carried out. There is scope for additional 
>> logging of, for example, the list of present interfaces returned by 
>> createNetworkInterfaceList() if deemed necessary by review.
>
> LGTM.

Great work, Conor. The test looks much better! 

Did you consider using testNG? Might help you condense things a bit more

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

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

Reply via email to