CrazyHZM commented on code in PR #15089:
URL: https://github.com/apache/dubbo/pull/15089#discussion_r1928823637
##########
dubbo-metadata/dubbo-metadata-report-zookeeper/src/test/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportTest.java:
##########
@@ -30,47 +29,79 @@
import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier;
import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
import
org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient;
+import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
import static
org.apache.dubbo.metadata.ServiceNameMapping.DEFAULT_MAPPING_GROUP;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ZookeeperMetadataReportTest {
-/**
- * 2018/10/9
- */
-class ZookeeperMetadataReportTest {
private ZookeeperMetadataReport zookeeperMetadataReport;
- private URL registryUrl;
- private ZookeeperMetadataReportFactory zookeeperMetadataReportFactory;
- private static String zookeeperConnectionAddress1;
- @BeforeAll
- public static void beforeAll() {
- zookeeperConnectionAddress1 =
System.getProperty("zookeeper.connection.address.1");
- }
+ /**
+ * Uses Map<String, String> to simulate ZK node storage:
+ * key corresponds to the ZK node path, and value corresponds to the node
content.
+ */
+ private final Map<String, String> zkDataStore = new ConcurrentHashMap<>();
Review Comment:
Now that we've mocked `ZookeeperClient`, I think we can simulate the return
result directly without actually storing it and spread the `setUp` logic across
each unit test.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]