< prev index next >
test/java/net/Socket/LinkLocal.java
Print this page
rev 14513 : 8177536: Avoid Apple Peer-to-Peer interfaces in networking tests
Reviewed-by: michaelm, rriggs
*** 24,36 ****
/*
* @test
* @bug 4469866
* @summary Connecting to a link-local IPv6 address should not
* causes a SocketException to be thrown.
*/
import java.net.*;
! import java.util.Enumeration;
public class LinkLocal {
static int testCount = 0;
static int failed = 0;
--- 24,42 ----
/*
* @test
* @bug 4469866
* @summary Connecting to a link-local IPv6 address should not
* causes a SocketException to be thrown.
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.NetworkConfiguration
+ * @run main LinkLocal
*/
+ import jdk.testlibrary.NetworkConfiguration;
+
import java.net.*;
! import java.util.List;
! import java.util.stream.Collectors;
public class LinkLocal {
static int testCount = 0;
static int failed = 0;
*** 132,159 ****
* If no argument is provided then enumerate the
* local addresses and run the test on each link-local
* IPv6 address.
*/
if (args.length == 0) {
! Enumeration nifs = NetworkInterface.getNetworkInterfaces();
! while (nifs.hasMoreElements()) {
! NetworkInterface ni = (NetworkInterface)nifs.nextElement();
! if (!ni.isUp())
! continue;
!
! Enumeration addrs = ni.getInetAddresses();
! while (addrs.hasMoreElements()) {
! InetAddress addr = (InetAddress)addrs.nextElement();
!
! if (addr instanceof Inet6Address &&
! addr.isLinkLocalAddress()) {
TestAddress(addr);
}
}
- }
- }
/*
* Print results
*/
if (testCount == 0) {
--- 138,156 ----
* If no argument is provided then enumerate the
* local addresses and run the test on each link-local
* IPv6 address.
*/
if (args.length == 0) {
! List<Inet6Address> addrs = NetworkConfiguration.probe()
! .ip6Addresses()
! .filter(Inet6Address::isLinkLocalAddress)
! .collect(Collectors.toList());
+ for (Inet6Address addr : addrs) {
TestAddress(addr);
}
}
/*
* Print results
*/
if (testCount == 0) {
< prev index next >