Ensure we fail if native lib can not be loaded on macos (#11261)

Motivation:

ccca3959fd fixed a regression which caused the native resolver code to not be loaded but this was not reported by the tests.

Modifications:

Adjust tests to actually fail the build if we cant load the native lib

Result:

Ensure we don't introduce another regression in the future
This commit is contained in:
Norman Maurer 2021-05-18 08:13:39 +02:00
parent e38ca870ae
commit 5ec9406c14

View File

@ -18,24 +18,21 @@ package io.netty.resolver.dns.macos;
import io.netty.resolver.dns.DnsServerAddressStream; import io.netty.resolver.dns.DnsServerAddressStream;
import io.netty.resolver.dns.DnsServerAddressStreamProvider; import io.netty.resolver.dns.DnsServerAddressStreamProvider;
import io.netty.resolver.dns.DnsServerAddressStreamProviders; import io.netty.resolver.dns.DnsServerAddressStreamProviders;
import org.junit.Assume; import org.junit.jupiter.api.Test;
import org.junit.BeforeClass; import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.Test; import org.junit.jupiter.api.condition.OS;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class MacOSDnsServerAddressStreamProviderTest { @EnabledOnOs(OS.MAC)
class MacOSDnsServerAddressStreamProviderTest {
@BeforeClass
public static void assume() {
Assume.assumeTrue(MacOSDnsServerAddressStreamProvider.isAvailable());
}
@Test @Test
public void testStream() { void testStream() {
MacOSDnsServerAddressStreamProvider.ensureAvailability();
DnsServerAddressStreamProvider provider = new MacOSDnsServerAddressStreamProvider(); DnsServerAddressStreamProvider provider = new MacOSDnsServerAddressStreamProvider();
DnsServerAddressStream stream = provider.nameServerAddressStream("netty.io"); DnsServerAddressStream stream = provider.nameServerAddressStream("netty.io");
assertNotNull(stream); assertNotNull(stream);
@ -47,9 +44,10 @@ public class MacOSDnsServerAddressStreamProviderTest {
} }
@Test @Test
public void testDefaultUseCorrectInstance() { @EnabledOnOs(OS.MAC)
void testDefaultUseCorrectInstance() {
MacOSDnsServerAddressStreamProvider.ensureAvailability();
assertThat(DnsServerAddressStreamProviders.platformDefault(), assertThat(DnsServerAddressStreamProviders.platformDefault(),
instanceOf(MacOSDnsServerAddressStreamProvider.class)); instanceOf(MacOSDnsServerAddressStreamProvider.class));
} }
} }