jinmeiliao commented on a change in pull request #5843:
URL: https://github.com/apache/geode/pull/5843#discussion_r564854356



##########
File path: 
geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/misc/WanLocatorDiscoveryDUnitTest.java
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.wan.misc;
+
+import static 
org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static 
org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import 
org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.admin.remote.DistributionLocatorId;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+
+public class WanLocatorDiscoveryDUnitTest {
+
+  private static MemberVM locator_ln1;
+  private static MemberVM locator_ln2;
+
+  private static MemberVM locator_ny1;
+  private static MemberVM locator_ny2;
+  private int[] ports;
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @Before
+  public void setupCluster() throws Exception {
+    IgnoredException.addIgnoredException("Connection reset");
+    IgnoredException.addIgnoredException("Broken pipe");
+    IgnoredException.addIgnoredException("Connection refused");
+    IgnoredException.addIgnoredException("could not get remote locator 
information");
+    IgnoredException.addIgnoredException("Unexpected IOException");
+  }
+
+  private void setupWanSites() throws IOException {
+    ports = AvailablePortHelper.getRandomAvailableTCPPorts(5);
+    int site1Port =
+        setupWanSite1();
+    setupWanSite2(site1Port);
+  }
+
+  private int setupWanSite1() throws IOException {
+    Properties locator_ln_props = new Properties();
+    // create a cluster
+    locator_ln_props.setProperty(MCAST_PORT, "0");

Review comment:
       You don't need all these when you use ClusterStartupRule. The rule sets 
those properties for you already so that you can avoid all these boiler code.
   
   The rule also allocates the available ports for you so that you don't need 
to pre-allocate them.
   
   use something like:
   
   locator = cluster.startLocatorVM(index, 
l->l.withPropety(....).withConnectionToLocator(port0, port1, port2));




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to