Skip to content

Commit

Permalink
Make test execution conditional to IPv6 being configured for localhos…
Browse files Browse the repository at this point in the history
…t. See issue 8330.

Signed-off-by: Santiago Pericas-Geertsen <[email protected]>
  • Loading branch information
spericas committed Feb 15, 2024
1 parent 1b73963 commit 7953573
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
*/
package io.helidon.webclient.api;

import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.stream.Stream;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

class DefaultDnsResolverTest {

Expand All @@ -32,9 +36,19 @@ void testIpv4Resolution() {
}

@Test
@EnabledIf("isIPv6Configured")
void testIpv6Resolution() {
DefaultDnsResolver resolver = DefaultDnsResolver.create();
InetAddress inetAddress = resolver.resolveAddress("localhost", DnsAddressLookup.IPV6_PREFERRED);
assertThat(inetAddress.getHostAddress(), is("0:0:0:0:0:0:0:1"));
}

private boolean isIPv6Configured() {
try {
InetAddress[] address = InetAddress.getAllByName("localhost");
return Stream.of(address).anyMatch(a -> a instanceof Inet6Address);
} catch (UnknownHostException e) {
return false;
}
}
}

0 comments on commit 7953573

Please sign in to comment.