1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /** |
24 /** |
25 * @test |
25 * @test |
26 * @bug 8179559 |
26 * @bug 8179559 8225239 |
|
27 * @library /test/lib |
|
28 * @modules java.base/java.net:open |
27 */ |
29 */ |
28 |
30 |
29 import java.net.InetAddress; |
31 import java.net.InetAddress; |
30 import java.net.NetworkInterface; |
32 import java.net.NetworkInterface; |
31 import java.util.Enumeration; |
33 import java.util.Enumeration; |
|
34 import java.lang.reflect.Method; |
|
35 import jdk.test.lib.Platform; |
32 |
36 |
33 public class NetworkInterfaceRetrievalTests { |
37 public class NetworkInterfaceRetrievalTests { |
34 public static void main(String[] args) throws Exception { |
38 public static void main(String[] args) throws Exception { |
35 int checkFailureCount = 0; |
39 int checkFailureCount = 0; |
|
40 |
|
41 Method isBound = NetworkInterface.class.getDeclaredMethod("isBoundInetAddress", InetAddress.class); |
|
42 isBound.setAccessible(true); |
36 |
43 |
37 try { |
44 try { |
38 Enumeration<NetworkInterface> en = NetworkInterface |
45 Enumeration<NetworkInterface> en = NetworkInterface |
39 .getNetworkInterfaces(); |
46 .getNetworkInterfaces(); |
40 while (en.hasMoreElements()) { |
47 while (en.hasMoreElements()) { |
41 NetworkInterface ni = en.nextElement(); |
48 NetworkInterface ni = en.nextElement(); |
|
49 |
|
50 //JDK-8230132: Should not test on Windows with Teredo Tunneling Pseudo-Interface |
|
51 String dName = ni.getDisplayName(); |
|
52 if (Platform.isWindows() && dName != null && dName.contains("Teredo")) |
|
53 continue; |
|
54 |
42 Enumeration<InetAddress> addrs = ni.getInetAddresses(); |
55 Enumeration<InetAddress> addrs = ni.getInetAddresses(); |
43 System.out.println("############ Checking network interface + " |
56 System.out.println("############ Checking network interface + " |
44 + ni + " #############"); |
57 + ni + " #############"); |
45 while (addrs.hasMoreElements()) { |
58 while (addrs.hasMoreElements()) { |
46 InetAddress addr = addrs.nextElement(); |
59 InetAddress addr = addrs.nextElement(); |