From 025aac7d500051a32f9cae2327db6a0d9a5d035c Mon Sep 17 00:00:00 2001 From: Heesung Sohn Date: Fri, 27 Oct 2023 14:51:43 -0700 Subject: [PATCH] Resolved comments --- .../extensions/ExtensibleLoadManagerImplTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java index 2c2d665362730c..8e1b9b6ab0137c 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java @@ -147,6 +147,8 @@ public class ExtensibleLoadManagerImplTest extends MockedPulsarServiceBaseTest { private final String defaultTestNamespace = "public/test"; + private LookupService lookupService; + @BeforeClass @Override public void setup() throws Exception { @@ -195,7 +197,7 @@ public void setup() throws Exception { admin.namespaces().createNamespace(defaultTestNamespace); admin.namespaces().setNamespaceReplicationClusters(defaultTestNamespace, Sets.newHashSet(this.conf.getClusterName())); - } + lookupService = (LookupService) FieldUtils.readDeclaredField(pulsarClient, "lookup", true); } @Override @@ -208,9 +210,10 @@ protected void cleanup() throws Exception { } @BeforeMethod(alwaysRun = true) - protected void initializeState() throws PulsarAdminException { + protected void initializeState() throws PulsarAdminException, IllegalAccessException { admin.namespaces().unload(defaultTestNamespace); reset(primaryLoadManager, secondaryLoadManager); + FieldUtils.writeDeclaredField(pulsarClient, "lookup", lookupService, true); } @Test @@ -506,8 +509,7 @@ public void testUnloadClientReconnectionWithLookup(boolean isPersistentTopicTest private LookupService spyLookupService(AtomicInteger lookupCount, TopicName topicName) throws IllegalAccessException { - var lookup = spy((LookupService) - FieldUtils.readDeclaredField(pulsarClient, "lookup", true)); + var lookup = spy(lookupService); FieldUtils.writeDeclaredField(pulsarClient, "lookup", lookup, true); doAnswer(invocationOnMock -> { lookupCount.incrementAndGet();