lhotari commented on code in PR #22329:
URL: https://github.com/apache/pulsar/pull/22329#discussion_r1537241090
##########
pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/DnsResolverTest.java:
##########
@@ -18,13 +18,52 @@
*/
package org.apache.pulsar.common.util.netty;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.testng.Assert.assertEquals;
import io.netty.channel.EventLoop;
import io.netty.resolver.dns.DnsNameResolverBuilder;
+import java.security.Security;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class DnsResolverTest {
+ private static final int MIN_TTL = 0;
+ private static final int TTL = 101;
+ private static final int NEGATIVE_TTL = 121;
+ private static final String CACHE_POLICY_PROP = "networkaddress.cache.ttl";
+ private static final String NEGATIVE_CACHE_POLICY_PROP =
"networkaddress.cache.negative.ttl";
+
+ @BeforeClass(alwaysRun = true)
+ public void beforeClass() {
+ Security.setProperty(CACHE_POLICY_PROP, Integer.toString(TTL));
+ Security.setProperty(NEGATIVE_CACHE_POLICY_PROP,
Integer.toString(NEGATIVE_TTL));
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void afterClass() {
+ // The current test cannot restore to its original settings; it has
been modified to default values.
+ Security.setProperty(CACHE_POLICY_PROP, "60");
+ Security.setProperty(NEGATIVE_CACHE_POLICY_PROP, "10");
+ }
Review Comment:
in "beforeClass", record the values. restore the original values in
"afterClass"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]