geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject [52/83] [abbrv] incubator-geode git commit: GEODE-37 renamed pulse package
Date Fri, 09 Sep 2016 21:43:49 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
new file mode 100644
index 0000000..d66d1c8
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
@@ -0,0 +1,254 @@
+/*
+ *
+ * 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.tools.pulse.tests.junit;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.geode.test.junit.categories.UITest;
+import com.google.gson.JsonObject;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * Base class to be extended by other JUnit test classes. This class defines and automatically invokes test for testing server login-logout so no need to add
+ * this test in each sub-class. It also provides doLogin(), doLogout() and print error functionality as protected
+ * functions.
+ *
+ * <b>Sub-classes should ensure that they call doLogin() in @BeforeClass and doLogout() in @AfterClass otherwise tests will fail.</b>
+ *
+ *
+ */
+@Ignore
+@Category(UITest.class)
+public abstract class BaseServiceTest {
+
+  protected static Properties propsForJUnit = new Properties();
+  protected static String strHost = null;
+  protected static String strPort = null;
+  protected static String LOGIN_URL;
+  protected static String LOGOUT_URL;
+  protected static String IS_AUTHENTICATED_USER_URL;
+  protected static String PULSE_UPDATE_URL;
+
+  protected static final String PULSE_UPDATE_PARAM = "pulseData";
+  protected static final String PULSE_UPDATE_1_VALUE = "{'ClusterSelectedRegion':{'regionFullPath':'/GlobalVilage_2/GlobalVilage_9'}}";
+  protected static final String PULSE_UPDATE_2_VALUE = "{'ClusterSelectedRegion':{'regionFullPath':'/Rubbish'}}";
+
+  protected static final String PULSE_UPDATE_3_VALUE = "{'ClusterSelectedRegionsMember':{'regionFullPath':'/GlobalVilage_2/GlobalVilage_9'}}";
+  protected static final String PULSE_UPDATE_4_VALUE = "{'ClusterSelectedRegionsMember':{'regionFullPath':'/Rubbish'}}";
+
+  protected static final String PULSE_UPDATE_5_VALUE = "{'MemberGatewayHub':{'memberName':'pnq-visitor1'}}";
+  protected static final String PULSE_UPDATE_6_VALUE = "{'MemberGatewayHub':{'memberName':'pnq-visitor2'}}";
+  protected static CloseableHttpClient httpclient = null;
+
+  private final ObjectMapper mapper = new ObjectMapper();
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    InputStream stream = BaseServiceTest.class.getClassLoader().getResourceAsStream("pulse.properties");
+
+    try {
+      propsForJUnit.load(stream);
+    } catch (Exception exProps) {
+      System.out.println("BaseServiceTest :: Error loading properties from pulse.properties in classpath");
+    }
+    strHost = propsForJUnit.getProperty("pulse.host");
+    strPort = propsForJUnit.getProperty("pulse.port");
+    System.out.println(
+        "BaseServiceTest :: Loaded properties from classpath. Checking properties for hostname. Hostname found = " + strHost);
+    LOGIN_URL = "http://" + strHost + ":" + strPort + "/pulse/j_spring_security_check";
+    LOGOUT_URL = "http://" + strHost + ":" + strPort + "/pulse/clusterLogout";
+    IS_AUTHENTICATED_USER_URL = "http://" + strHost + ":" + strPort + "/pulse/authenticateUser";
+    PULSE_UPDATE_URL = "http://" + strHost + ":" + strPort + "/pulse/pulseUpdate";
+
+  }
+  /**
+  *
+  * @throws java.lang.Exception
+  */
+  @Before
+  public void setUp() throws Exception {
+    doLogout();
+    System.out.println("BaseServiceTest :: Setup done");
+  }
+
+  /**
+  *
+  * @throws java.lang.Exception
+  */
+  @After
+  public void tearDown() throws Exception {
+    doLogin();
+    System.out.println("BaseServiceTest :: Teardown done");
+  }
+
+  /**
+   * Login to pulse server and setup httpClient for tests
+   * To be called from setupBeforeClass in each test class
+   */
+  protected static void doLogin() throws Exception {
+    System.out.println("BaseServiceTest ::  Executing doLogin with user : admin, password : admin.");
+
+    CloseableHttpResponse loginResponse = null;
+    try{
+      BasicCookieStore cookieStore = new BasicCookieStore();
+      httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
+      HttpUriRequest login = RequestBuilder.post().setUri(new URI(LOGIN_URL))
+        .addParameter("j_username", "admin").addParameter("j_password", "admin")
+        .build();
+      loginResponse = httpclient.execute(login);
+      try {
+           HttpEntity entity = loginResponse.getEntity();
+           EntityUtils.consume(entity);
+           System.out.println("BaseServiceTest :: HTTP request status : " + loginResponse.getStatusLine());
+
+           List<Cookie> cookies = cookieStore.getCookies();
+           if (cookies.isEmpty()) {
+           } else {
+               for (int i = 0; i < cookies.size(); i++) {
+               }
+           }
+      } finally {
+         if(loginResponse != null)
+           loginResponse.close();
+      }
+    } catch(Exception failed) {
+      logException(failed);
+      throw failed;
+    }
+
+    System.out.println("BaseServiceTest ::  Executed doLogin");
+  }
+
+  /**
+   * Logout to pulse server and close httpClient
+   * To be called from setupAfterClass in each test class
+   */
+  protected static void doLogout() throws Exception {
+    System.out.println("BaseServiceTest ::  Executing doLogout with user : admin, password : admin.");
+    if(httpclient != null){
+      CloseableHttpResponse logoutResponse = null;
+      try{
+        HttpUriRequest logout = RequestBuilder.get().setUri(new URI(LOGOUT_URL))
+            .build();
+        logoutResponse = httpclient.execute(logout);
+        try {
+             HttpEntity entity = logoutResponse.getEntity();
+             EntityUtils.consume(entity);
+        } finally {
+           if(logoutResponse != null)
+             logoutResponse.close();
+           httpclient.close();
+           httpclient = null;
+        }
+      } catch(Exception failed) {
+        logException(failed);
+        throw failed;
+      }
+      System.out.println("BaseServiceTest ::  Executed doLogout");
+    } else{
+      System.out.println("BaseServiceTest ::  User NOT logged-in");
+    }
+  }
+
+  /**
+   * Print exception string to system.out
+   *
+   * @param failed
+   */
+  protected static void logException(Exception failed){
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw);
+    failed.printStackTrace(pw);
+    System.out.println("BaseServiceTest :: Logging exception details : " + sw.getBuffer().toString());
+  }
+
+  /**
+  *
+  * Tests that service returns json object
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+  */
+  @Test
+  public void testServerLoginLogout() {
+      System.out.println("BaseServiceTest ::  ------TESTCASE BEGIN : SERVER LOGIN-LOGOUT------");
+      try{
+          doLogin();
+
+          HttpUriRequest pulseupdate = RequestBuilder.get()
+            .setUri(new URI(IS_AUTHENTICATED_USER_URL))
+            .build();
+          CloseableHttpResponse response = httpclient.execute(pulseupdate);
+          try {
+            HttpEntity entity = response.getEntity();
+
+            System.out.println("BaseServiceTest :: HTTP request status : " + response.getStatusLine());
+
+            BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            String sz = null;
+            while((sz = respReader.readLine()) != null){
+              pw.print(sz);
+            }
+            String jsonResp = sw.getBuffer().toString();
+            System.out.println("BaseServiceTest :: JSON response returned : " + jsonResp);
+            EntityUtils.consume(entity);
+
+            JsonNode jsonObj = mapper.readTree(jsonResp);
+            boolean isUserLoggedIn = jsonObj.get("isUserLoggedIn").booleanValue();
+            Assert.assertNotNull("BaseServiceTest :: Server returned null response in 'isUserLoggedIn'", isUserLoggedIn);
+            Assert.assertTrue("BaseServiceTest :: User login failed for this username, password", (isUserLoggedIn == true));
+          } finally {
+            response.close();
+          }
+
+          doLogout();
+      } catch(Exception failed) {
+          logException(failed);
+          Assert.fail("Exception ! ");
+      }
+      System.out.println("BaseServiceTest ::  ------TESTCASE END : SERVER LOGIN-LOGOUT------");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
new file mode 100644
index 0000000..bfee425
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
@@ -0,0 +1,340 @@
+/*
+ *
+ * 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.tools.pulse.tests.junit;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.*;
+
+import org.apache.geode.tools.pulse.internal.json.JSONArray;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
+
+/**
+ * JUnit Tests for ClusterSelectedRegionService in the back-end server for region detail page
+ *
+ *
+ */
+@Ignore
+public class ClusterSelectedRegionServiceTest extends BaseServiceTest {
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    doLogin();
+    System.out.println("\n\nClusterSelectedRegionServiceTest :: Setup done");
+  }
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    doLogout();
+    System.out.println("ClusterSelectedRegionServiceTest :: Teardown done");
+  }
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @Override
+  @Before
+  public void setUp() throws Exception {
+  }
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @Override
+  @After
+  public void tearDown() throws Exception {
+  }
+
+  /**
+   * Tests that service returns json object
+   *
+   */
+  @Test
+  public void testResponseNotNull() {
+    System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR CLUSTER REGIONS------");
+    if(httpclient != null){
+        try{
+            HttpUriRequest pulseupdate = RequestBuilder.post()
+                .setUri(new URI(PULSE_UPDATE_URL))
+                .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+                .build();
+            CloseableHttpResponse response = httpclient.execute(pulseupdate);
+            try {
+              HttpEntity entity = response.getEntity();
+
+              System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+              BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+              StringWriter sw = new StringWriter();
+              PrintWriter pw = new PrintWriter(sw);
+              String sz = null;
+              while((sz = respReader.readLine()) != null){
+                pw.print(sz);
+              }
+              String jsonResp = sw.getBuffer().toString();
+              System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+              EntityUtils.consume(entity);
+
+              JSONObject jsonObj = new JSONObject(jsonResp);
+              Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion", jsonObj.getJSONObject("ClusterSelectedRegion"));
+            } finally {
+              response.close();
+            }
+        } catch(Exception failed) {
+          logException(failed);
+          Assert.fail("Exception ! ");
+        }
+    } else {
+      Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+    }
+    System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE END : NULL RESPONSE CHECK FOR CLUSTER REGIONS------\n");
+  }
+
+  /**
+  *
+  * Tests that response is for same logged in user
+  *
+  */
+  @Test
+  public void testResponseUsername() {
+    System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE BEGIN : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGIONS------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+               Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion", clusterSelectedRegionObj);
+               String szUser = clusterSelectedRegionObj.getString("userName");
+               Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned wrong user name. Expected was admin. Server returned = " + szUser, szUser, "admin");
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE END : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGIONS------\n");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseRegionPathMatches() {
+    System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE BEGIN : REGION PATH IN RESPONSE CHECK FOR CLUSTER REGIONS------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+               Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion",clusterSelectedRegionObj);
+               JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
+               Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for selectedRegion",jsonObjRegion);
+               Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'path' of region",jsonObjRegion.has("path"));
+               String szPath = jsonObjRegion.getString("path");
+               Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned wrong region path. Expected region path = /GlobalVilage_2/GlobalVilage_9 , actual region path = " + szPath, szPath, "/GlobalVilage_2/GlobalVilage_9");
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE END : REGION PATH IN RESPONSE CHECK FOR CLUSTER REGIONS------\n");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseNonExistentRegion() {
+    System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE BEGIN : NON-EXISTENT REGION CHECK FOR CLUSTER REGIONS------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_2_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+               Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion",clusterSelectedRegionObj);
+               JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
+               Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for selectedRegion",jsonObjRegion);
+               Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return error on non-existent region",jsonObjRegion.has("errorOnRegion"));
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE END : NON-EXISTENT REGION CHECK FOR CLUSTER REGIONS------\n");
+  }
+
+  /**
+  *
+  * Tests that service returns json object
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseMemerberCount() {
+   System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE BEGIN : MISMATCHED MEMBERCOUNT FOR REGION CHECK FOR CLUSTER REGIONS------");
+   if(httpclient != null){
+       try{
+           HttpUriRequest pulseupdate = RequestBuilder.post()
+               .setUri(new URI(PULSE_UPDATE_URL))
+               .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+               .build();
+           CloseableHttpResponse response = httpclient.execute(pulseupdate);
+           try {
+             HttpEntity entity = response.getEntity();
+
+             System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+             BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+             StringWriter sw = new StringWriter();
+             PrintWriter pw = new PrintWriter(sw);
+             String sz = null;
+             while((sz = respReader.readLine()) != null){
+               pw.print(sz);
+             }
+             String jsonResp = sw.getBuffer().toString();
+             System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+             EntityUtils.consume(entity);
+
+             JSONObject jsonObj = new JSONObject(jsonResp);
+             JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+             Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null ClusterSelectedRegion",clusterSelectedRegionObj);
+             JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
+             Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null for selectedRegion",jsonObjRegion);
+             Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'memberCount' of region",jsonObjRegion.has("memberCount"));
+             int memberCount = jsonObjRegion.getInt("memberCount");
+             Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'members' of region",jsonObjRegion.has("members"));
+             JSONArray arrMembers = jsonObjRegion.getJSONArray("members");
+             Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response in selectedRegion",arrMembers);
+             int members = arrMembers.length();
+             Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned mismatched member count and region members", members, memberCount);
+           } finally {
+             response.close();
+           }
+       } catch(Exception failed) {
+         logException(failed);
+         Assert.fail("Exception ! ");
+       }
+   } else {
+     Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+   }
+   System.out.println("ClusterSelectedRegionServiceTest ::  ------TESTCASE END : MISMATCHED MEMBERCOUNT FOR REGION CHECK FOR CLUSTER REGIONS------\n");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
new file mode 100644
index 0000000..f27f08a
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
@@ -0,0 +1,354 @@
+/*
+ *
+ * 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.tools.pulse.tests.junit;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Iterator;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.*;
+
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
+
+/**
+ * JUnit Tests for ClusterSelectedRegionsMemberService in the back-end server for region detail page
+ *
+ *
+ */
+@Ignore
+public class ClusterSelectedRegionsMemberServiceTest  extends BaseServiceTest {
+
+  /**
+   * @throws java.lang.Exception
+   *
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    doLogin();
+    System.out.println("\n\nClusterSelectedRegionsMemberServiceTest :: Setup done");
+  }
+
+  /**
+   * @throws java.lang.Exception
+   *
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    doLogout();
+    System.out.println("ClusterSelectedRegionsMemberServiceTest :: Teardown done");
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @Override
+  @Before
+  public void setUp() throws Exception {
+    System.out.println("running setup -- ClusterSelectedRegionsMemberServiceTest");
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @Override
+  @After
+  public void tearDown() throws Exception {
+    System.out.println("running teardown -- ClusterSelectedRegionsMemberServiceTest");
+  }
+
+  /**
+   * Tests that service returns json object
+   *
+   */
+  @Test
+  public void testResponseNotNull() {
+    System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+    if(httpclient != null){
+        try{
+            HttpUriRequest pulseupdate = RequestBuilder.post()
+                .setUri(new URI(PULSE_UPDATE_URL))
+                .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+                .build();
+            CloseableHttpResponse response = httpclient.execute(pulseupdate);
+            try {
+              HttpEntity entity = response.getEntity();
+
+              System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+              BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+              StringWriter sw = new StringWriter();
+              PrintWriter pw = new PrintWriter(sw);
+              String sz = null;
+              while((sz = respReader.readLine()) != null){
+                pw.print(sz);
+              }
+              String jsonResp = sw.getBuffer().toString();
+              System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+              EntityUtils.consume(entity);
+
+              JSONObject jsonObj = new JSONObject(jsonResp);
+              Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember", jsonObj.getJSONObject("ClusterSelectedRegionsMember"));
+            } finally {
+              response.close();
+            }
+        } catch(Exception failed) {
+          logException(failed);
+          Assert.fail("Exception ! ");
+        }
+    } else {
+      Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+    }
+    System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE END : NULL RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+  }
+
+  /**
+  *
+  * Tests that response is for same logged in user
+  *
+  */
+  @Test
+  public void testResponseUsername() {
+    System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE BEGIN : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember", clusterSelectedRegionObj);
+               Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'userName' in request",clusterSelectedRegionObj.has("userName"));
+               String szUser = clusterSelectedRegionObj.getString("userName");
+               Assert.assertEquals("ClusterSelectedRegionsMemberServiceTest :: Server returned wrong user name. Expected was admin. Server returned = " + szUser, szUser, "admin");
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE END : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  *
+  */
+  @Test
+  public void testResponseRegionOnMemberInfoMatches() {
+    System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE BEGIN : MEMBER INFO RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
+               JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for selectedRegionsMembers",jsonObjRegion);
+               Iterator<String> itrMemberNames = jsonObjRegion.keys();
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null region on member info", itrMemberNames);
+               while(itrMemberNames.hasNext()){
+                 String szMemberName = itrMemberNames.next();
+                 Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null member name", szMemberName);
+                 Assert.assertTrue("Server did not return member details",jsonObjRegion.has(szMemberName));
+                 JSONObject jsonMemberObj = jsonObjRegion.getJSONObject(szMemberName);
+
+                 Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'regionFullPath' of region on member",jsonMemberObj.has("regionFullPath"));
+                 String szPath = jsonMemberObj.getString("regionFullPath");
+                 Assert.assertEquals("ClusterSelectedRegionsMemberServiceTest :: Server returned wrong region path for region on member", szPath, "/GlobalVilage_2/GlobalVilage_9");
+               }
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE END : MEMBER INFO RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  *
+  */
+  @Test
+  public void testResponseNonExistentRegion() {
+    System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE BEGIN : NON-EXISTENT REGION CHECK FOR CLUSTER REGION MEMBERS------");
+     if(httpclient != null){
+         try{
+           System.out.println("Test for non-existent region : /Rubbish");
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_4_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
+               JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null for selectedRegionsMembers",jsonObjRegion);
+               Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return error on non-existent region",jsonObjRegion.has("errorOnRegion"));
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE END : NON-EXISTENT REGION CHECK FOR CLUSTER REGION MEMBERS------");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  *
+  */
+  @Test
+  public void testResponseRegionOnMemberAccessor() {
+    System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE BEGIN : ACCESSOR RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
+               JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for selectedRegionsMembers",jsonObjRegion);
+               Iterator<String> itrMemberNames = jsonObjRegion.keys();
+               Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null region on member info", itrMemberNames);
+               while(itrMemberNames.hasNext()){
+                 String szMemberName = itrMemberNames.next();
+                 Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null member name", szMemberName);
+                 Assert.assertTrue("Server did not return member details",jsonObjRegion.has(szMemberName));
+                 JSONObject jsonMemberObj = jsonObjRegion.getJSONObject(szMemberName);
+
+                 Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'accessor' of region on member",jsonMemberObj.has("accessor"));
+                 String szAccessor = jsonMemberObj.getString("accessor");
+                 Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server returned non-boolean value for accessor attribute", ((szAccessor.equalsIgnoreCase("True"))
+                         || (szAccessor.equalsIgnoreCase("False"))) );
+               }
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+     }
+     System.out.println("ClusterSelectedRegionsMemberServiceTest ::  ------TESTCASE END : ACCESSOR RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
new file mode 100644
index 0000000..be774b5
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
@@ -0,0 +1,412 @@
+/*
+ *
+ * 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.tools.pulse.tests.junit;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.*;
+
+import org.apache.geode.tools.pulse.internal.json.JSONArray;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
+
+/**
+ * JUnit Tests for MemberGatewayHubService in the back-end server for region detail page
+ *
+ *
+ */
+@Ignore
+public class MemberGatewayHubServiceTest extends BaseServiceTest {
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    doLogin();
+    System.out.println("\n\nMemberGatewayHubServiceTest :: Setup done");
+  }
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    doLogout();
+    System.out.println("MemberGatewayHubServiceTest :: Teardown done");
+  }
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @Override
+  @Before
+  public void setUp() throws Exception {
+  }
+
+  /**
+   *
+   * @throws java.lang.Exception
+   */
+  @Override
+  @After
+  public void tearDown() throws Exception {
+  }
+
+  /**
+   * Tests that service returns json object
+   *
+   */
+  @Test
+  public void testResponseNotNull() {
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE --------");
+    if(httpclient != null){
+        try{
+            HttpUriRequest pulseupdate = RequestBuilder.post()
+                .setUri(new URI(PULSE_UPDATE_URL))
+                .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+                .build();
+            CloseableHttpResponse response = httpclient.execute(pulseupdate);
+            try {
+              HttpEntity entity = response.getEntity();
+
+              System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+              BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+              StringWriter sw = new StringWriter();
+              PrintWriter pw = new PrintWriter(sw);
+              String sz = null;
+              while((sz = respReader.readLine()) != null){
+                pw.print(sz);
+              }
+              String jsonResp = sw.getBuffer().toString();
+              System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+              EntityUtils.consume(entity);
+
+              JSONObject jsonObj = new JSONObject(jsonResp);
+              Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", jsonObj.getJSONObject("MemberGatewayHub"));
+            } finally {
+              response.close();
+            }
+        } catch(Exception failed) {
+          logException(failed);
+          Assert.fail("Exception ! ");
+        }
+    } else {
+      Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+    }
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE END : NULL RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+  }
+
+ /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseIsGatewaySender() {
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE BEGIN : IS GATEWAY SENDER IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
+               Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
+               Assert.assertEquals("MemberGatewayHubServiceTest :: Server returned wrong value for 'isGatewaySender'. Expected 'isGatewaySender' = true, actual 'isGatewaySender' = " + boolIsGatewaySender, boolIsGatewaySender, true);
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+     }
+     System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE END : IS GATEWAY SENDER IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+  }
+
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseGatewaySenderCount() {
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE BEGIN : GATEWAY SENDER COUNT IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
+               Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
+
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'gatewaySenders' for member", memberGatewayHubObj.has("gatewaySenders"));
+               JSONArray arrGatewaySender = memberGatewayHubObj.getJSONArray("gatewaySenders");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'gatewaySenders'", arrGatewaySender);
+               Assert.assertTrue( "MemberGatewayHubServiceTest :: Server returned mis-matched values for 'isGatewaySender' and gateway senders array count", ((boolIsGatewaySender && (arrGatewaySender.length() > 0)) || ((! boolIsGatewaySender) && (arrGatewaySender.length() == 0))) );
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+     }
+     System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE END : GATEWAY SENDER COUNT IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseGatewaySenderProperties() {
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE BEGIN : GATEWAY SENDER PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
+               Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
+
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'gatewaySenders' for member", memberGatewayHubObj.has("gatewaySenders"));
+               JSONArray arrGatewaySender = memberGatewayHubObj.getJSONArray("gatewaySenders");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'gatewaySenders'", arrGatewaySender);
+               Assert.assertTrue( "MemberGatewayHubServiceTest :: Server returned mis-matched values for 'isGatewaySender' and gateway senders array count", ((boolIsGatewaySender && (arrGatewaySender.length() > 0)) || ((! boolIsGatewaySender) && (arrGatewaySender.length() == 0))) );
+
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'remoteDSId' for member", ((JSONObject)arrGatewaySender.get(0)).has("remoteDSId"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'eventsExceedingAlertThreshold' for member", ((JSONObject)arrGatewaySender.get(0)).has("eventsExceedingAlertThreshold"));
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+     }
+     System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE END : GATEWAY SENDER PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseAsyncEventQueueProperties() {
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE BEGIN : ASYNC EVENT QUEUE PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventQueues' for member", memberGatewayHubObj.has("asyncEventQueues"));
+               JSONArray arrAsyncEventQueues = memberGatewayHubObj.getJSONArray("asyncEventQueues");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'asyncEventQueues'", arrAsyncEventQueues);
+
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'id' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("id"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'primary' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("primary"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'senderType' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("senderType"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchSize' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchSize"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchTimeInterval' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchTimeInterval"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchConflationEnabled' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchConflationEnabled"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventListener' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("asyncEventListener"));
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'queueSize' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("queueSize"));
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+     }
+     System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE END : ASYNC EVENT QUEUE PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+  }
+
+  /**
+  *
+  * Tests that response is for same region
+  *
+  * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+  *
+  */
+  @Test
+  public void testResponseNoAsyncEventQueues() {
+    System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE BEGIN : NO ASYNC EVENT QUEUES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+     if(httpclient != null){
+         try{
+             HttpUriRequest pulseupdate = RequestBuilder.post()
+                 .setUri(new URI(PULSE_UPDATE_URL))
+                 .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_6_VALUE)
+                 .build();
+             CloseableHttpResponse response = httpclient.execute(pulseupdate);
+             try {
+               HttpEntity entity = response.getEntity();
+
+               System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+               BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+               StringWriter sw = new StringWriter();
+               PrintWriter pw = new PrintWriter(sw);
+               String sz = null;
+               while((sz = respReader.readLine()) != null){
+                 pw.print(sz);
+               }
+               String jsonResp = sw.getBuffer().toString();
+               System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+               EntityUtils.consume(entity);
+
+               JSONObject jsonObj = new JSONObject(jsonResp);
+               JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventQueues' for member", memberGatewayHubObj.has("asyncEventQueues"));
+               JSONArray arrAsyncEventQueues = memberGatewayHubObj.getJSONArray("asyncEventQueues");
+               Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'asyncEventQueues'", arrAsyncEventQueues);
+               Assert.assertTrue("MemberGatewayHubServiceTest :: Server returned non-empty array for member 'pnq-visitor2' which has no event queues", (arrAsyncEventQueues.length() == 0));
+             } finally {
+               response.close();
+             }
+         } catch(Exception failed) {
+           logException(failed);
+           Assert.fail("Exception ! ");
+         }
+     } else {
+       Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+     }
+     System.out.println("MemberGatewayHubServiceTest ::  ------TESTCASE END : NO ASYNC EVENT QUEUES PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+  }
+
+
+}


Mime
View raw message