Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test execution conditional to IPv6 being configured for localhost #8388

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
Loading