geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [27/35] geode git commit: GEODE-2395: use random ports when starting the jmx manager and http services
Date Tue, 28 Mar 2017 16:46:55 GMT
GEODE-2395: use random ports when starting the jmx manager and http services

* be able to configure the various aspects of the rules before starting the server when declaring the rules.
* delete the unnecessary abstract test classes
* allowing tests to use default ports if needed
* created HttpClientRule to ease the connection to to pulse server


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/69dbc10f
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/69dbc10f
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/69dbc10f

Branch: refs/heads/feature/GEODE-2420
Commit: 69dbc10f792dbb5123028346e365bfc0b2022416
Parents: 834235a
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Fri Mar 17 18:40:01 2017 -0700
Committer: Ken Howe <khowe@pivotal.io>
Committed: Mon Mar 27 14:01:45 2017 -0700

----------------------------------------------------------------------
 .../web/RestSecurityIntegrationTest.java        |  27 +--
 .../web/RestSecurityPostProcessorTest.java      |  29 +---
 .../internal/web/RestSecurityWithSSLTest.java   |   2 +-
 .../rest/internal/web/RestServersJUnitTest.java |  33 ++--
 .../internal/web/SwaggerVerificationTest.java   |  29 +---
 .../geode/test/dunit/rules/HttpClientRule.java  | 102 ++++++++++++
 .../geode/tools/pulse/PulseDataExportTest.java  | 134 ++-------------
 .../tools/pulse/PulseVerificationTest.java      | 116 ++-----------
 .../cli/commands/DeployCommandsDUnitTest.java   |   4 +-
 .../cli/commands/ExportLogsIntegrationTest.java |  20 +--
 .../ExportLogsOnServerManagerDUnit.java         |  16 +-
 .../cli/shell/GfshMultilineCommandTest.java     |  50 ++++++
 .../cli/util/LogExporterIntegrationTest.java    |  14 +-
 .../security/AccessControlMBeanJUnitTest.java   |  28 ++--
 ...CacheServerMBeanAuthenticationJUnitTest.java |  27 +--
 .../CacheServerMBeanAuthorizationJUnitTest.java |  33 ++--
 .../CacheServerMBeanShiroJUnitTest.java         |  24 +--
 .../security/CacheServerStartupRule.java        |  74 ---------
 .../security/CliCommandsSecurityTest.java       |  35 ++--
 .../security/DataCommandsSecurityTest.java      |  40 +++--
 .../security/DeployCommandsSecurityTest.java    |  16 +-
 .../DiskStoreMXBeanSecurityJUnitTest.java       |  38 +++--
 .../GatewayReceiverMBeanSecurityTest.java       |  37 +++--
 .../GatewaySenderMBeanSecurityTest.java         |  40 ++---
 .../security/GfshCommandsPostProcessorTest.java |  28 +---
 .../security/GfshCommandsSecurityTest.java      |  41 +----
 .../security/JavaRmiServerNameTest.java         |  27 +--
 .../LockServiceMBeanAuthorizationJUnitTest.java |  36 ++--
 .../security/MBeanSecurityJUnitTest.java        |  52 +++---
 .../ManagerMBeanAuthorizationJUnitTest.java     |  39 ++---
 .../security/MemberMBeanSecurityJUnitTest.java  |  25 ++-
 .../security/AbstractSecureServerDUnitTest.java | 119 -------------
 .../geode/security/ClientAuthDUnitTest.java     |  60 +++++++
 .../ClientContainsKeyAuthDUnitTest.java         |  82 +++++++++
 .../ClientDestroyInvalidateAuthDUnitTest.java   | 108 ++++++++++++
 .../ClientDestroyRegionAuthDUnitTest.java       |  81 +++++++++
 .../ClientExecuteFunctionAuthDUnitTest.java     |  91 ++++++++++
 ...lientExecuteRegionFunctionAuthDUnitTest.java |  84 ++++++++++
 .../security/ClientGetAllAuthDUnitTest.java     |  76 +++++++++
 .../security/ClientGetEntryAuthDUnitTest.java   |  98 +++++++++++
 .../security/ClientGetPutAuthDUnitTest.java     | 146 ++++++++++++++++
 .../ClientRegionClearAuthDUnitTest.java         |  76 +++++++++
 .../ClientRegisterInterestAuthDUnitTest.java    | 158 ++++++++++++++++++
 .../security/ClientRemoveAllAuthDUnitTest.java  |  78 +++++++++
 .../ClientUnregisterInterestAuthDUnitTest.java  |  63 +++++++
 .../security/IntegratedClientAuthDUnitTest.java |  50 ------
 ...tedClientContainsKeyAuthDistributedTest.java |  53 ------
 ...entDestroyInvalidateAuthDistributedTest.java |  84 ----------
 ...dClientDestroyRegionAuthDistributedTest.java |  65 --------
 ...lientExecuteFunctionAuthDistributedTest.java |  69 --------
 ...xecuteRegionFunctionAuthDistributedTest.java |  58 -------
 ...tegratedClientGetAllAuthDistributedTest.java |  55 -------
 ...tGetClientPRMetaDataAuthDistributedTest.java |  67 --------
 ...ientPartitionAttrCmdAuthDistributedTest.java |  52 ------
 ...gratedClientGetEntryAuthDistributedTest.java |  75 ---------
 ...tegratedClientGetPutAuthDistributedTest.java | 114 -------------
 ...tedClientRegionClearAuthDistributedTest.java |  64 -------
 ...ientRegisterInterestAuthDistributedTest.java | 165 -------------------
 ...ratedClientRemoveAllAuthDistributedTest.java |  66 --------
 ...IntegratedClientSizeAuthDistributedTest.java |  54 ------
 ...ntUnregisterInterestAuthDistributedTest.java |  48 ------
 .../NoShowValue1PostProcessorDUnitTest.java     |  59 +++++--
 .../PDXGfshPostProcessorOnRemoteServerTest.java | 141 ++++++----------
 .../security/PDXPostProcessorDUnitTest.java     | 145 ++++++++--------
 .../security/PeerAuthenticatorDUnitTest.java    |   1 -
 ...eerSecurityWithEmbeddedLocatorDUnitTest.java |   2 -
 .../geode/security/PostProcessorDUnitTest.java  |  72 +++++---
 .../apache/geode/security/SecurityTestUtil.java |  54 ++++++
 .../SecurityWithoutClusterConfigDUnitTest.java  |   8 +-
 .../dunit/rules/GfshShellConnectionRule.java    |  35 +++-
 .../dunit/rules/LocatorServerStartupRule.java   |  56 +++----
 .../test/dunit/rules/LocatorStarterRule.java    |  50 ++----
 .../apache/geode/test/dunit/rules/Member.java   |   2 +
 .../test/dunit/rules/MemberStarterRule.java     | 124 +++++++++++++-
 .../apache/geode/test/dunit/rules/MemberVM.java |   7 +-
 .../apache/geode/test/dunit/rules/Server.java   |   2 +
 .../test/dunit/rules/ServerStarterRule.java     | 105 +++++-------
 .../geode/security/CQClientAuthDUnitTest.java   | 114 +++++++++++++
 .../geode/security/CQClientAuthDunitTest.java   |  92 -----------
 .../security/CQPDXPostProcessorDUnitTest.java   |  76 +++++----
 .../security/CQPostProcessorDunitTest.java      |  56 +++++--
 .../security/ClientQueryAuthDUnitTest.java      | 145 ++++++++++++++++
 .../ClientQueryAuthDistributedTest.java         | 121 --------------
 .../ExportLogsOverHttpIntegrationTest.java      |   2 +-
 .../commands/QueryNamesOverHttpDUnitTest.java   |  22 +--
 .../GfshCommandsOverHttpSecurityTest.java       |   3 +-
 86 files changed, 2539 insertions(+), 2630 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
index dee004f..819315f 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
@@ -14,17 +14,13 @@
  */
 package org.apache.geode.rest.internal.web;
 
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
@@ -38,29 +34,20 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.springframework.http.MediaType;
 
-import java.util.Properties;
-
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class RestSecurityIntegrationTest {
 
   protected static final String REGION_NAME = "AuthRegion";
 
-  private static int restPort = AvailablePortHelper.getRandomAvailableTCPPort();
-  static Properties properties = new Properties() {
-    {
-      setProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/clientServer.json");
-      setProperty(SECURITY_MANAGER, TestSecurityManager.class.getName());
-      setProperty(START_DEV_REST_API, "true");
-      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-      setProperty(HTTP_SERVICE_PORT, restPort + "");
-    }
-  };
-
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
-  private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
+  public static ServerStarterRule serverStarter = new ServerStarterRule()
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/clientServer.json")
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName()).withRestService()
+      .startServer();
+  private final GeodeRestClient restClient =
+      new GeodeRestClient("localhost", serverStarter.getHttpPort());
 
   @BeforeClass
   public static void before() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
index ab21094..3da514f 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
@@ -14,11 +14,8 @@
  */
 package org.apache.geode.rest.internal.web;
 
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
-import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 import static org.apache.geode.rest.internal.web.GeodeRestClient.getCode;
 import static org.apache.geode.rest.internal.web.GeodeRestClient.getJsonArray;
 import static org.apache.geode.rest.internal.web.GeodeRestClient.getJsonObject;
@@ -28,7 +25,6 @@ import static org.junit.Assert.assertTrue;
 
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.rest.internal.web.controllers.Customer;
 import org.apache.geode.rest.internal.web.controllers.RedactingPostProcessor;
 import org.apache.geode.security.TestSecurityManager;
@@ -45,28 +41,21 @@ import org.junit.experimental.categories.Category;
 import org.springframework.http.MediaType;
 
 import java.net.URLEncoder;
-import java.util.Properties;
 
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class RestSecurityPostProcessorTest {
 
-  static int restPort = AvailablePortHelper.getRandomAvailableTCPPort();
-  static Properties properties = new Properties() {
-    {
-      setProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/clientServer.json");
-      setProperty(SECURITY_MANAGER, TestSecurityManager.class.getName());
-      setProperty(START_DEV_REST_API, "true");
-      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-      setProperty(HTTP_SERVICE_PORT, restPort + "");
-      setProperty(SECURITY_POST_PROCESSOR, RedactingPostProcessor.class.getName());
-    }
-  };
-
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
-  private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
+  public static ServerStarterRule serverStarter = new ServerStarterRule()
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/clientServer.json")
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(SECURITY_POST_PROCESSOR, RedactingPostProcessor.class.getName())
+      .withRestService().startServer();
+
+  private final GeodeRestClient restClient =
+      new GeodeRestClient("localhost", serverStarter.getHttpPort());
 
   @BeforeClass
   public static void before() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java
index 09c3e35..4d142bd 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityWithSSLTest.java
@@ -67,7 +67,7 @@ public class RestSecurityWithSSLTest {
     properties.setProperty(SSL_TRUSTSTORE_PASSWORD, "password");
     properties.setProperty(SSL_PROTOCOLS, "TLSv1.2,TLSv1.1");
 
-    serverStarter.startServer(properties);
+    serverStarter.withProperties(properties).startServer();
 
     GeodeRestClient restClient = new GeodeRestClient("localhost", restPort, true);
     HttpResponse response = restClient.doGet("/servers", "cluster", "cluster");

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
index d97bede..a6ba2b0 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
@@ -15,10 +15,8 @@
 
 package org.apache.geode.rest.internal.web;
 
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
-import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
+import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.geode.test.dunit.Assert;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.RestAPITest;
@@ -29,41 +27,32 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.util.Properties;
-
 @Category({IntegrationTest.class, RestAPITest.class})
 public class RestServersJUnitTest {
 
-  private static int defaultPort = 7070;
-  static Properties properties = new Properties() {
-    {
-      setProperty(START_DEV_REST_API, "true");
-      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-    }
-  };
-
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter =
+      new ServerStarterRule().withRestService(true).startServer();
+
   private static GeodeRestClient restClient;
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
-    restClient = new GeodeRestClient("localhost", defaultPort);
+    assertThat(serverStarter.getHttpPort()).isEqualTo(7070);
+    restClient = new GeodeRestClient("localhost", serverStarter.getHttpPort());
   }
 
   @Test
-  public void testDefaultPort() throws Exception {
-    // make sure the server is started on the default port and we can connect using the default port
+  public void testGet() throws Exception {
     HttpResponse response = restClient.doGet("/", null, null);
-    Assert.assertEquals(200, GeodeRestClient.getCode(response));
+    assertThat(GeodeRestClient.getCode(response)).isEqualTo(200);
   }
 
   @Test
-  public void testServers() throws Exception {
+  public void testServerStartedOnDefaultPort() throws Exception {
     HttpResponse response = restClient.doGet("/servers", null, null);
     JSONArray body = GeodeRestClient.getJsonArray(response);
-    Assert.assertEquals(1, body.length());
-    Assert.assertEquals("http://localhost:7070", body.getString(0));
+    assertThat(body.length()).isEqualTo(1);
+    assertThat(body.getString(0)).isEqualTo("http://localhost:7070");
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
index 43960a8..b163d5c 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
@@ -15,14 +15,10 @@
 package org.apache.geode.rest.internal.web;
 
 
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
@@ -30,38 +26,23 @@ import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.RestAPITest;
 import org.apache.http.HttpResponse;
 import org.json.JSONObject;
-import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.util.Properties;
-
 @Category({IntegrationTest.class, RestAPITest.class})
 public class SwaggerVerificationTest {
 
-  private static int restPort = AvailablePortHelper.getRandomAvailableTCPPort();
-  static Properties properties = new Properties() {
-    {
-      setProperty(START_DEV_REST_API, "true");
-      setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
-      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-      setProperty(HTTP_SERVICE_PORT, restPort + "");
-    }
-  };
-
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
-  private GeodeRestClient restClient;
+  public static ServerStarterRule serverStarter = new ServerStarterRule()
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withRestService()
+      .startServer();
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-  }
+  private GeodeRestClient restClient;
 
   @Test
   public void isSwaggerRunning() throws Exception {
-    GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
+    GeodeRestClient restClient = new GeodeRestClient("localhost", serverStarter.getHttpPort());
     // Check the UI
     HttpResponse response = restClient.doGetRequest("/geode/swagger-ui.html");
     assertThat(GeodeRestClient.getCode(response), is(200));

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/HttpClientRule.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/HttpClientRule.java b/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/HttpClientRule.java
new file mode 100644
index 0000000..d0b54b9
--- /dev/null
+++ b/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/HttpClientRule.java
@@ -0,0 +1,102 @@
+/*
+ * 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.test.dunit.rules;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
+import org.junit.Before;
+import org.junit.rules.ExternalResource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HttpClientRule extends ExternalResource {
+  private String hostName;
+  private int port;
+  private HttpHost host;
+  private HttpClient httpClient;
+  private HttpContext context;
+
+  public HttpClientRule(int port) {
+    this("localhost", port);
+  }
+
+  public HttpClientRule(String hostName, int port) {
+    this.hostName = hostName;
+    this.port = port;
+  }
+
+  @Before
+  protected void before() {
+    host = new HttpHost(hostName, port);
+    httpClient = HttpClients.createDefault();
+    context = new BasicHttpContext();
+  }
+
+  public HttpResponse loginToPulse(String username, String password) throws Exception {
+    return post("/pulse/login", "username", username, "password", password);
+  }
+
+  public void loginToPulseAndVerify(String username, String password) throws Exception {
+    HttpResponse response = loginToPulse(username, password);
+    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(302);
+    assertThat(response.getFirstHeader("Location").getValue())
+        .contains("/pulse/clusterDetail.html");
+  }
+
+
+  public HttpResponse get(String uri, String... params) throws Exception {
+    return httpClient.execute(host, buildHttpGet(uri, params));
+  }
+
+  public HttpResponse post(String uri, String... params) throws Exception {
+    return httpClient.execute(host, buildHttpPost(uri, params));
+  }
+
+  private HttpPost buildHttpPost(String uri, String... params) throws Exception {
+    HttpPost post = new HttpPost(uri);
+    List<NameValuePair> nvps = new ArrayList<>();
+    for (int i = 0; i < params.length; i += 2) {
+      nvps.add(new BasicNameValuePair(params[i], params[i + 1]));
+    }
+    post.setEntity(new UrlEncodedFormEntity(nvps));
+    return post;
+  }
+
+  private HttpGet buildHttpGet(String uri, String... params) throws Exception {
+    URIBuilder builder = new URIBuilder();
+    builder.setPath(uri);
+    for (int i = 0; i < params.length; i += 2) {
+      builder.setParameter(params[i], params[i + 1]);
+    }
+    return new HttpGet(builder.build());
+  }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
index b9e90b6..5d716f3 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
@@ -17,96 +17,43 @@
 package org.apache.geode.tools.pulse;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.awaitility.Awaitility.await;
 
-import org.apache.geode.cache.client.ClientCacheFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.apache.http.Consts;
-import org.apache.http.Header;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.test.dunit.rules.HttpClientRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.EntityUtils;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-@Category(DistributedTest.class)
+@Category(IntegrationTest.class)
 public class PulseDataExportTest {
 
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  public ServerStarterRule server = new ServerStarterRule().withJMXManager().startServer()
+      .createRegion(RegionShortcut.REPLICATE, "regionA");
 
-  private MemberVM locator;
-  private MemberVM server;
   @Rule
-  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
-  private HttpClient httpClient;
-  private CookieStore cookieStore;
+  public HttpClientRule client = new HttpClientRule(server.getHttpPort());
 
   @Before
   public void before() throws Exception {
-    IgnoredException
-        .addIgnoredException("Failed to properly release resources held by the HTTP service:");
-    IgnoredException.addIgnoredException("!STOPPED");
-
-    locator = lsRule.startLocatorVM(0, new Properties());
-
-    gfshConnector.connect(locator);
-    assertThat(gfshConnector.isConnected()).isTrue();
-
-    server = lsRule.startServerVM(1, locator.getPort());
-
-    gfshConnector.executeAndVerifyCommand("create region --name=regionA --type=REPLICATE");
-    org.apache.geode.cache.Region<String, String> region = new ClientCacheFactory()
-        .addPoolLocator("localhost", locator.getPort()).create()
-        .<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY).create("regionA");
-
+    Region region = server.getCache().getRegion("regionA");
     region.put("key1", "value1");
     region.put("key2", "value2");
     region.put("key3", "value3");
-    cookieStore = new BasicCookieStore();
-    httpClient = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();
-
-    await().atMost(2, TimeUnit.MINUTES).until(this::pulseServerHasStarted);
   }
 
-  @Category(FlakyTest.class) // GEODE-2395
   @Test
   public void dataBrowserExportWorksAsExpected() throws Exception {
-    getAuthenticatedJSESSIONID();
-    HttpContext authenticatedHttpContext = buildAuthenticatedHttpContext();
+    client.loginToPulseAndVerify("admin", "admin");
 
-    HttpGet dataExportGET = buildDataExportGET();
-
-    HttpResponse response = httpClient.execute(dataExportGET, authenticatedHttpContext);
+    HttpResponse response =
+        client.get("/pulse/dataBrowserExport", "query", "select * from /regionA a order by a");
     assertThat(response.getStatusLine().getStatusCode()).describedAs(response.toString())
         .isEqualTo(200);
 
@@ -114,59 +61,4 @@ public class PulseDataExportTest {
     assertThat(responseBody).describedAs(response.toString()).isEqualTo(
         "{\"result\":[[\"java.lang.String\",\"value1\"],[\"java.lang.String\",\"value2\"],[\"java.lang.String\",\"value3\"]]}");
   }
-
-  private HttpPost buildLoginPOST() {
-    HttpPost httpPost = new HttpPost("http://localhost:7070/pulse/login");
-
-    List<NameValuePair> formData = new ArrayList<>();
-    formData.add(new BasicNameValuePair("username", "admin"));
-    formData.add(new BasicNameValuePair("password", "admin"));
-
-    httpPost.setEntity(new UrlEncodedFormEntity(formData, Consts.UTF_8));
-
-    return httpPost;
-  }
-
-  private HttpGet buildDataExportGET() throws URISyntaxException {
-    URIBuilder builder = new URIBuilder();
-    builder.setScheme("http").setHost("localhost").setPort(7070).setPath("/pulse/dataBrowserExport")
-        .setParameter("query", "select * from /regionA a order by a");
-    return new HttpGet(builder.build());
-  }
-
-  private HttpContext buildAuthenticatedHttpContext() {
-    HttpContext localContext = new BasicHttpContext();
-    localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
-
-    return localContext;
-  }
-
-  private void getAuthenticatedJSESSIONID() throws IOException {
-    HttpResponse loginResponse = httpClient.execute(buildLoginPOST());
-    assertThat(loginResponse.getStatusLine().getStatusCode()).describedAs(loginResponse.toString())
-        .isEqualTo(302);
-
-    String JSESSIONIDFromSetCookieHeader = Arrays.stream(loginResponse.getHeaders("SET-COOKIE"))
-        .map(Header::getValue).filter(setCookie -> setCookie.contains("JSESSIONID")).findAny()
-        .orElseThrow(() -> new AssertionError(
-            "No JSESSIONID cookie was set in the login response: " + loginResponse.toString()));
-
-    Cookie JESSIONIDFromCookieStore = cookieStore.getCookies().stream()
-        .filter(cookie -> cookie.getName().equalsIgnoreCase("JSESSIONID")).findFirst()
-        .orElseThrow(() -> new AssertionError("No JSESSIONID cookie was set in the cookie store"));
-
-    assertThat(JSESSIONIDFromSetCookieHeader).contains(JESSIONIDFromCookieStore.getValue());
-  }
-
-  private boolean pulseServerHasStarted() {
-    try {
-      httpClient.execute(buildLoginPOST());
-    } catch (IOException e) {
-      e.printStackTrace();
-      return false;
-    }
-
-    return true;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseVerificationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseVerificationTest.java b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseVerificationTest.java
index a8fca32..0b3b1ce 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseVerificationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseVerificationTest.java
@@ -15,154 +15,74 @@
 
 package org.apache.geode.tools.pulse;
 
-import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.HttpClientRule;
 import org.apache.geode.test.dunit.rules.LocatorStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.ClassRule;
+import org.junit.Rule;
 import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
 
 @Category(IntegrationTest.class)
 public class PulseVerificationTest {
 
   @ClassRule
-  public static LocatorStarterRule locatorStarterRule = new LocatorStarterRule();
-
-  @ClassRule
-  public static RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
-  private static int httpPort = AvailablePortHelper.getRandomAvailableTCPPort();
-
-  // use a random port when fixing GEODE-2671
-  private static int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
-
-  private static HttpHost host;
+  public static LocatorStarterRule locator = new LocatorStarterRule()
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).startLocator();
 
-  private HttpClient httpClient;
-  private HttpContext context;
-
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    Properties properties = new Properties();
-    properties.setProperty(HTTP_SERVICE_PORT, httpPort + "");
-    properties.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
-    properties.setProperty(JMX_MANAGER_PORT, jmxPort + "");
-
-    locatorStarterRule.startLocator(properties);
-    host = new HttpHost("localhost", httpPort);
-  }
-
-  @Before
-  public void before() throws Exception {
-    httpClient = HttpClients.createDefault();
-    context = new BasicHttpContext();
-  }
+  @Rule
+  public HttpClientRule client = new HttpClientRule(locator.getHttpPort());
 
   @Test
   public void loginWithIncorrectPassword() throws Exception {
-    HttpPost request = new HttpPost("/pulse/login");
-    List<NameValuePair> nvps = new ArrayList<>();
-    nvps.add(new BasicNameValuePair("username", "data"));
-    nvps.add(new BasicNameValuePair("password", "wrongPassword"));
-    request.setEntity(new UrlEncodedFormEntity(nvps));
-    HttpResponse response = httpClient.execute(host, request, context);
+    HttpResponse response = client.loginToPulse("data", "wrongPassword");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(302);
     assertThat(response.getFirstHeader("Location").getValue())
         .contains("/pulse/login.html?error=BAD_CREDS");
+
+    client.loginToPulseAndVerify("data", "data");
   }
 
   @Test
   public void loginWithDataOnly() throws Exception {
-    HttpPost post = new HttpPost("/pulse/login");
-    List<NameValuePair> nvps = new ArrayList<>();
-    nvps.add(new BasicNameValuePair("username", "data"));
-    nvps.add(new BasicNameValuePair("password", "data"));
-    post.setEntity(new UrlEncodedFormEntity(nvps));
-
-    HttpResponse response = httpClient.execute(host, post, context);
-    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(302);
-    assertThat(response.getFirstHeader("Location").getValue())
-        .contains("/pulse/clusterDetail.html");
+    client.loginToPulseAndVerify("data", "data");
 
     // this would requiest cluster permission
-    HttpGet get = new HttpGet("/pulse/clusterDetail.html");
-    response = httpClient.execute(host, get);
+    HttpResponse response = client.get("/pulse/clusterDetail.html");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(403);
 
     // this would require both cluster and data permission
-    get = new HttpGet("/pulse/dataBrowser.html");
-    response = httpClient.execute(host, get);
+    response = client.get("/pulse/dataBrowser.html");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(403);
   }
 
 
   @Test
   public void loginAllAccess() throws Exception {
-    HttpPost post = new HttpPost("/pulse/login");
-    List<NameValuePair> nvps = new ArrayList<>();
-    nvps.add(new BasicNameValuePair("username", "CLUSTER,DATA"));
-    nvps.add(new BasicNameValuePair("password", "CLUSTER,DATA"));
-    post.setEntity(new UrlEncodedFormEntity(nvps));
-
-    HttpResponse response = httpClient.execute(host, post, context);
-    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(302);
-    assertThat(response.getFirstHeader("Location").getValue())
-        .contains("/pulse/clusterDetail.html");
+    client.loginToPulseAndVerify("CLUSTER,DATA", "CLUSTER,DATA");
 
-    HttpGet get = new HttpGet("/pulse/clusterDetail.html");
-    response = httpClient.execute(host, get);
+    HttpResponse response = client.get("/pulse/clusterDetail.html");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
 
-    get = new HttpGet("/pulse/dataBrowser.html");
-    response = httpClient.execute(host, get);
+    response = client.get("/pulse/dataBrowser.html");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
   }
 
   @Test
   public void loginWithClusterOnly() throws Exception {
-    HttpPost post = new HttpPost("/pulse/login");
-    List<NameValuePair> nvps = new ArrayList<>();
-    nvps.add(new BasicNameValuePair("username", "cluster"));
-    nvps.add(new BasicNameValuePair("password", "cluster"));
-    post.setEntity(new UrlEncodedFormEntity(nvps));
-
-    HttpResponse response = httpClient.execute(host, post, context);
-    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(302);
-    assertThat(response.getFirstHeader("Location").getValue())
-        .contains("/pulse/clusterDetail.html");
+    client.loginToPulseAndVerify("cluster", "cluster");
 
-    HttpGet get = new HttpGet("/pulse/clusterDetail.html");
-    response = httpClient.execute(host, get);
+    HttpResponse response = client.get("/pulse/clusterDetail.html");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
 
     // accessing data browser will be denied
-    get = new HttpGet("/pulse/dataBrowser.html");
-    response = httpClient.execute(host, get);
+    response = client.get("/pulse/dataBrowser.html");
     assertThat(response.getStatusLine().getStatusCode()).isEqualTo(403);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
index 5568743..7b0823b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
@@ -396,8 +396,8 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
       properties.setProperty("name", "Manager");
       properties.setProperty("groups", groupName);
       ServerStarterRule serverStarterRule = new ServerStarterRule();
-      serverStarterRule.before();
-      serverStarterRule.startServer(properties, locatorPort);
+      serverStarterRule.withProperties(properties).withConnectionToLocator(locatorPort)
+          .startServer();
     });
 
     // Create a JAR file

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
index 46a07ad..268fa39 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
@@ -17,40 +17,24 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.util.Properties;
-
 @Category(IntegrationTest.class)
 public class ExportLogsIntegrationTest {
 
   @ClassRule
-  public static LocatorStarterRule locator = new LocatorStarterRule();
+  public static LocatorStarterRule locator =
+      new LocatorStarterRule().withJMXManager().startLocator();
 
   @Rule
   public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
 
-  private static int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-  protected static int httpPort = ports[0];
-  protected static int jmxPort = ports[1];
-
-  @BeforeClass
-  public static void before() throws Exception {
-    Properties properties = new Properties();
-    properties.setProperty(ConfigurationProperties.HTTP_SERVICE_PORT, httpPort + "");
-    properties.setProperty(ConfigurationProperties.JMX_MANAGER_PORT, jmxPort + "");
-    locator.startLocator(properties);
-  }
-
   protected void connect() throws Exception {
     gfsh.connectAndVerify(locator);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index c2fde4d..a78b26f 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import com.google.common.collect.Sets;
 
-import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
@@ -46,9 +45,8 @@ public class ExportLogsOnServerManagerDUnit {
 
   @Test
   public void testExportWithOneServer() throws Exception {
-    int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    MemberVM server0 = lsRule.startServerAsJmxManager(0, jmxPort);
-    gfshConnector.connect(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
+    MemberVM server0 = lsRule.startServerAsJmxManager(0);
+    gfshConnector.connect(server0.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
     gfshConnector.executeAndVerifyCommand("export logs");
 
     String message = gfshConnector.getGfshOutput();
@@ -64,12 +62,10 @@ public class ExportLogsOnServerManagerDUnit {
 
   @Test
   public void testExportWithPeerLocator() throws Exception {
-    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    int locatorPort = ports[0];
-    int jmxPort = ports[1];
-    MemberVM server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
-    MemberVM server1 = lsRule.startServerVM(1, locatorPort);
-    gfshConnector.connect(locatorPort, GfshShellConnectionRule.PortType.locator);
+    MemberVM<Server> server0 = lsRule.startServerAsEmbededLocator(0);
+    lsRule.startServerVM(1, server0.getMember().getEmbeddedLocatorPort());
+    gfshConnector.connect(server0.getMember().getEmbeddedLocatorPort(),
+        GfshShellConnectionRule.PortType.locator);
     gfshConnector.executeAndVerifyCommand("export logs");
 
     String message = gfshConnector.getGfshOutput();

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java
new file mode 100644
index 0000000..0fc7d1b
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java
@@ -0,0 +1,50 @@
+/*
+ * ================================================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved. This product is protected by
+ * U.S. and international copyright and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ * ================================================================================================
+ */
+package org.apache.geode.management.internal.cli.shell;
+
+import static org.apache.geode.management.internal.cli.i18n.CliStrings.LIST_MEMBER;
+import static org.apache.geode.management.internal.cli.i18n.CliStrings.LIST_MEMBER__GROUP;
+import static org.apache.geode.management.internal.cli.i18n.CliStrings.NO_MEMBERS_FOUND_MESSAGE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+
+@Category(IntegrationTest.class)
+public class GfshMultilineCommandTest {
+
+  @Rule
+  public ServerStarterRule server = new ServerStarterRule().withJMXManager().startServer();
+
+
+  @Rule
+  public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+
+  @Test
+  public void testMultiLineCommand() throws Exception {
+    gfsh.connectAndVerify(server.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+    // Execute a command
+    CommandStringBuilder csb = new CommandStringBuilder(LIST_MEMBER);
+    csb.addOption(LIST_MEMBER__GROUP, "nogroup");
+    gfsh.executeAndVerifyCommand(csb.getCommandString());
+    assertThat(gfsh.getGfshOutput().trim()).isEqualTo(NO_MEMBERS_FOUND_MESSAGE);
+
+    // Now execute same command with a new Continuation on new line
+    csb =
+        new CommandStringBuilder(LIST_MEMBER).addNewLine().addOption(LIST_MEMBER__GROUP, "nogroup");
+    gfsh.executeAndVerifyCommand(csb.getCommandString());
+    assertThat(gfsh.getGfshOutput().trim()).isEqualTo(NO_MEMBERS_FOUND_MESSAGE);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
index 0df00b0..5ef93de 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
@@ -60,7 +60,7 @@ public class LogExporterIntegrationTest {
   public void serverStartedWithWrongSuffix() throws Exception {
     properties.setProperty(LOG_FILE, new File("test.txt").getAbsolutePath());
     properties.setProperty(STATISTIC_ARCHIVE_FILE, "archive.archive");
-    Server server = serverStarterRule.startServer(properties);
+    Server server = serverStarterRule.withProperties(properties).startServer();
     File serverWorkingDir = server.getWorkingDir();
 
     logExporter = new LogExporter(filter, new File(serverWorkingDir, "test.log"),
@@ -77,7 +77,7 @@ public class LogExporterIntegrationTest {
     // ("relative log file is problematic in the test environment")
     properties.setProperty(LOG_FILE, new File("test.log").getAbsolutePath());
     properties.setProperty(STATISTIC_ARCHIVE_FILE, "archive.gfs");
-    Server server = serverStarterRule.startServer(properties);
+    Server server = serverStarterRule.withProperties(properties).startServer();
     File serverWorkingDir = server.getWorkingDir();
 
     logExporter = new LogExporter(filter, new File(serverWorkingDir, "test.log"),
@@ -96,7 +96,7 @@ public class LogExporterIntegrationTest {
   public void serverStartedWithGZSuffix() throws Exception {
     properties.setProperty(LOG_FILE, "test.log.gz");
     properties.setProperty(STATISTIC_ARCHIVE_FILE, "archive.gfs.gz");
-    Server server = serverStarterRule.startServer(properties);
+    Server server = serverStarterRule.withProperties(properties).startServer();
     File serverWorkingDir = server.getWorkingDir();
 
     logExporter = new LogExporter(filter, new File(serverWorkingDir, "test.log"),
@@ -112,7 +112,7 @@ public class LogExporterIntegrationTest {
   public void testNoStatsFile() throws Throwable {
     Path logsFile = Files.createTempFile("server", ".log");
     properties.setProperty(LOG_FILE, logsFile.toString());
-    serverStarterRule.startServer(properties);
+    serverStarterRule.withProperties(properties).startServer();
 
     ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
   }
@@ -123,7 +123,7 @@ public class LogExporterIntegrationTest {
     // Path statsFile = Files.createTempFile("stats", ".gfs");
     properties.setProperty(LOG_FILE, logsFile.toString());
     properties.setProperty(STATISTIC_ARCHIVE_FILE, "stats.gfs");
-    serverStarterRule.startServer(properties);
+    serverStarterRule.withProperties(properties).startServer();
 
     ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
   }
@@ -133,7 +133,7 @@ public class LogExporterIntegrationTest {
     Path statsFile = Files.createTempFile("stats", ".gfs");
     properties.setProperty(LOG_FILE, "sever.log");
     properties.setProperty(STATISTIC_ARCHIVE_FILE, statsFile.toString());
-    Server server = serverStarterRule.startServer(properties);
+    Server server = serverStarterRule.withProperties(properties).startServer();
 
     ExportLogsFunctionIntegrationTest.verifyExportLogsFunctionDoesNotBlowUp();
   }
@@ -149,7 +149,7 @@ public class LogExporterIntegrationTest {
     properties.setProperty(LOG_FILE, logFile.getAbsolutePath());
     properties.setProperty(STATISTIC_ARCHIVE_FILE, statsFile.getAbsolutePath());
 
-    serverStarterRule.startServer(properties);
+    serverStarterRule.withProperties(properties).startServer();
 
     logExporter = new LogExporter(filter, logFile, statsFile);
     Path exportedZip = logExporter.export();

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
index f8aa0bd..614d90c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/AccessControlMBeanJUnitTest.java
@@ -14,33 +14,35 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.assertj.core.api.Assertions.*;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
-
 @Category({IntegrationTest.class, SecurityTest.class})
 public class AccessControlMBeanJUnitTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private AccessControlMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
index 31a4d77..14781d5 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
@@ -14,31 +14,34 @@
  */
 package org.apache.geode.management.internal.security;
 
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 
-import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.management.CacheServerMXBean;
+import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 @Category(IntegrationTest.class)
 public class CacheServerMBeanAuthenticationJUnitTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private CacheServerMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
index 45a4b6d..1e899e0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
@@ -14,35 +14,36 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.assertj.core.api.Assertions.*;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.management.CacheServerMXBean;
+import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.junit.categories.FlakyTest;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
-@Category({IntegrationTest.class, SecurityTest.class, FlakyTest.class}) // GEODE-1953
+@Category({IntegrationTest.class, SecurityTest.class})
 public class CacheServerMBeanAuthorizationJUnitTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private CacheServerMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
index 3167931..34ac46c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
@@ -14,11 +14,9 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.management.CacheServerMXBean;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
@@ -26,36 +24,22 @@ import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.util.Properties;
-
 @Category({IntegrationTest.class, SecurityTest.class})
 public class CacheServerMBeanShiroJUnitTest {
-  static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-  static Properties properties = new Properties() {
-    {
-      setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
-      setProperty(SECURITY_SHIRO_INIT, "shiro.ini");
-    }
-  };
-
   private CacheServerMXBean bean;
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
-
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-  }
+  public static ServerStarterRule server = new ServerStarterRule()
+      .withProperty(SECURITY_SHIRO_INIT, "shiro.ini").withJMXManager().startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
deleted file mode 100644
index 1107779..0000000
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.management.internal.security;
-
-import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.rules.ExternalResource;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * this rule would help you start up a cache server with the given properties in the current VM
- */
-public class CacheServerStartupRule extends ExternalResource implements Serializable {
-
-  private ServerStarterRule serverStarter = new ServerStarterRule();
-  private Properties properties = new Properties();
-
-  public static CacheServerStartupRule withDefaultSecurityJson(int jmxManagerPort) {
-    return new CacheServerStartupRule(jmxManagerPort,
-        "org/apache/geode/management/internal/security/cacheServer.json");
-  }
-
-  public CacheServerStartupRule(int jmxManagerPort, String jsonFile) {
-    properties = new Properties();
-    if (jmxManagerPort > 0) {
-      properties.put(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort));
-    }
-    if (jsonFile != null) {
-      properties.put(SECURITY_MANAGER, TestSecurityManager.class.getName());
-      properties.put(TestSecurityManager.SECURITY_JSON, jsonFile);
-    }
-  }
-
-  @Before
-  public void before() throws Throwable {
-    serverStarter.before();
-    serverStarter.startServer(properties);
-    serverStarter.getCache().createRegionFactory().create("region1");
-  }
-
-  @After
-  public void after() {
-    serverStarter.after();
-  }
-
-  public Cache getCache() {
-    return serverStarter.getCache();
-  }
-
-  public int getServerPort() {
-    return serverStarter.getPort();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
index 1e092ff..eab5517 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
@@ -14,40 +14,43 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.junit.Assert.*;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.MemberMXBean;
 import org.apache.geode.security.NotAuthorizedException;
+import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.List;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class CliCommandsSecurityTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private MemberMXBean bean;
 
   private List<TestCommand> commands = TestCommand.getCommands();
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
index f403c21..d4910af 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
@@ -14,35 +14,47 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.assertj.core.api.Assertions.*;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.AvailablePort;
+import org.apache.geode.cache.Cache;
 import org.apache.geode.management.MemberMXBean;
 import org.apache.geode.security.GemFireSecurityException;
+import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class DataCommandsSecurityTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private MemberMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    Cache cache = server.getCache();
+    cache.createRegionFactory().create("region1");
+    cache.createRegionFactory().create("region2");
+    cache.createRegionFactory().create("secureRegion");
+  }
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
index 88cbfe9..01c3a45 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
@@ -14,12 +14,10 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.management.MemberMXBean;
 import org.apache.geode.security.NotAuthorizedException;
 import org.apache.geode.security.SimpleTestSecurityManager;
@@ -37,17 +35,16 @@ import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
 import java.io.File;
-import java.util.Properties;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class DeployCommandsSecurityTest {
 
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private MemberMXBean bean;
 
   @ClassRule
-  public static ServerStarterRule serverRule = new ServerStarterRule();
+  public static ServerStarterRule server = new ServerStarterRule()
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withJMXManager()
+      .startServer();
 
   @ClassRule
   public static TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -56,16 +53,13 @@ public class DeployCommandsSecurityTest {
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    Properties properties = new Properties();
-    properties.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
-    properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
-    serverRule.startServer(properties);
     File zipFile = temporaryFolder.newFile(zipFileName);
     deployCommand = "deploy --jar=" + zipFile.getAbsolutePath();
   }
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
index 0187f80..8fcaaa0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
@@ -14,8 +14,16 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.assertj.core.api.Assertions.*;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.apache.geode.management.DiskStoreMXBean;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -23,32 +31,26 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.management.DiskStoreMXBean;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
-
 @Category({IntegrationTest.class, SecurityTest.class})
 public class DiskStoreMXBeanSecurityJUnitTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private DiskStoreMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
-
-  @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @BeforeClass
-  public static void beforeClass() {
-    serverRule.getCache().createDiskStoreFactory().create("diskstore");
+  public static void beforeClass() throws Exception {
+    server.getCache().createDiskStoreFactory().create("diskstore");
   }
 
+  @Rule
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
+
   @Before
   public void setUp() throws Exception {
     bean = connectionRule.getProxyMBean(DiskStoreMXBean.class);

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
index 7cc2f29..3bd2266 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
@@ -14,11 +14,18 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.assertj.core.api.Assertions.*;
-import static org.mockito.Mockito.*;
-
-import javax.management.ObjectName;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
 
+import org.apache.geode.management.GatewayReceiverMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -27,19 +34,11 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.management.GatewayReceiverMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import javax.management.ObjectName;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GatewayReceiverMBeanSecurityTest {
 
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private static GatewayReceiverMXBean mock = mock(GatewayReceiverMXBean.class);
   private static ObjectName mockBeanName = null;
   private static ManagementService service = null;
@@ -47,17 +46,21 @@ public class GatewayReceiverMBeanSecurityTest {
   private GatewayReceiverMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @BeforeClass
   public static void beforeClass() throws Exception {
     // the server does not have a GAtewayReceiverMXBean registered initially, has to register a mock
     // one.
-    service = ManagementService.getManagementService(serverRule.getCache());
+    service = ManagementService.getManagementService(server.getCache());
     mockBeanName = ObjectName.getInstance("GemFire", "key", "value");
     service.registerMBean(mock, mockBeanName);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/69dbc10f/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
index 676243e..9829e27 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
@@ -14,11 +14,19 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.assertj.core.api.Assertions.*;
-import static org.mockito.Mockito.*;
-
-import javax.management.ObjectName;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
 
+import org.apache.geode.management.GatewaySenderMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.internal.beans.GatewaySenderMBean;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -27,20 +35,10 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.management.GatewaySenderMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.internal.beans.GatewaySenderMBean;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import javax.management.ObjectName;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GatewaySenderMBeanSecurityTest {
-
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
   private static GatewaySenderMBean mock = mock(GatewaySenderMBean.class);
   private static ObjectName mockBeanName = null;
   private static ManagementService service = null;
@@ -48,17 +46,21 @@ public class GatewaySenderMBeanSecurityTest {
   private GatewaySenderMXBean bean;
 
   @ClassRule
-  public static CacheServerStartupRule serverRule =
-      CacheServerStartupRule.withDefaultSecurityJson(jmxManagerPort);
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withProperty(TestSecurityManager.SECURITY_JSON,
+          "org/apache/geode/management/internal/security/cacheServer.json")
+      .startServer();
 
   @Rule
-  public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server.getJmxPort());
 
   @BeforeClass
   public static void beforeClass() throws Exception {
     // the server does not have a GAtewaySenderMXBean registered initially, has to register a mock
     // one.
-    service = ManagementService.getManagementService(serverRule.getCache());
+    service = ManagementService.getManagementService(server.getCache());
     mockBeanName = ObjectName.getInstance("GemFire", "key", "value");
     service.registerMBean(mock, mockBeanName);
   }


Mime
View raw message