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

3.x: Clean up the mocks after DnsEndpointTest #432

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
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 @@ -7,11 +7,17 @@
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

public class DnsEndpointTests {
public class DnsEndpointTest {

private static final Logger logger = LoggerFactory.getLogger(DnsEndpointTests.class);
private static final Logger logger = LoggerFactory.getLogger(DnsEndpointTest.class);

@AfterClass(alwaysRun = true)
public void clearMocks() {
MappedHostResolverProvider.unsetResolver();
}

@Test(groups = "long")
public void replace_cluster_test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ public static synchronized boolean setResolver(MappedHostResolver newResolver) {
return true;
}

public static synchronized boolean unsetResolver() {
if (resolver == null) {
return false;
}
resolver = null;
HostResolutionRequestInterceptor.INSTANCE.uninstall();
return true;
}

public static synchronized void addResolverEntry(String hostname, String address) {
if (resolver == null) {
setResolver(new MappedHostResolver());
Expand Down
Loading