|
21 | 21 | * questions.
|
22 | 22 | */
|
23 | 23 |
|
24 |
| -import org.junit.jupiter.api.AfterAll; |
| 24 | +import org.junit.jupiter.api.Assumptions; |
25 | 25 | import org.junit.jupiter.api.BeforeAll;
|
| 26 | +import org.junit.jupiter.api.Test; |
26 | 27 | import org.junit.jupiter.params.ParameterizedTest;
|
27 | 28 | import org.junit.jupiter.params.provider.MethodSource;
|
28 | 29 |
|
29 | 30 | import java.io.IOException;
|
| 31 | +import java.net.Inet6Address; |
30 | 32 | import java.net.InetAddress;
|
31 | 33 | import java.net.NetworkInterface;
|
32 | 34 | import java.net.Proxy;
|
@@ -76,6 +78,7 @@ public static Stream<String> linkLocalIpv6Literals() throws SocketException {
|
76 | 78 | return NetworkInterface.networkInterfaces()
|
77 | 79 | .flatMap(NetworkInterface::inetAddresses)
|
78 | 80 | .filter(InetAddress::isLinkLocalAddress)
|
| 81 | + .filter(Inet6Address.class::isInstance) |
79 | 82 | .map(InetAddress::getHostAddress);
|
80 | 83 | }
|
81 | 84 |
|
@@ -135,9 +138,12 @@ public void testShortIpv6Literals(String host) throws Exception {
|
135 | 138 | }
|
136 | 139 | }
|
137 | 140 |
|
138 |
| - @ParameterizedTest |
139 |
| - @MethodSource("linkLocalIpv6Literals") |
140 |
| - public void testLinkLocalIpv6Literals(String host) throws Exception { |
| 141 | + @Test |
| 142 | + public void testLinkLocalIpv6Literals() throws Exception { |
| 143 | + String host = linkLocalIpv6Literals() |
| 144 | + .findFirst() |
| 145 | + .orElseGet(() -> Assumptions.abort("No IPv6 link-local addresses found")); |
| 146 | + System.err.println(host); |
141 | 147 | try (Socket s1 = new Socket(host, 80)) {
|
142 | 148 | fail("IOException was expected to be thrown, but wasn't");
|
143 | 149 | } catch (IOException ioe) {
|
|
0 commit comments