You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/02/26 19:34:13 UTC

[01/11] incubator-geode git commit: adding unit tests for REST API

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-953 247b7a8b3 -> eb20383a5


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java
deleted file mode 100644
index 0406831..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java
+++ /dev/null
@@ -1,110 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.net.URI;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import org.springframework.http.converter.ByteArrayHttpMessageConverter;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.ResourceHttpMessageConverter;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.util.UriComponentsBuilder;
-
-
-/**
- * The RestTestUtils class contains core functionality for Spring REST Template
- * <p/>
- * 
- * @author Nilkanth Patel
- * @see org.springframework.context.ApplicationContext
- * @see org.springframework.data.gemfire.GemfireTemplate
- * @since 8.0
- */
-public class RestTestUtils  {
-
-  public static final String BASE_URL = "http://localhost:8080";
-  public static final String GEMFIRE_REST_API_CONTEXT = "/gemfire-api";
-  public static final String GEMFIRE_REST_API_VERSION = "/v1";
-
-  public static final URI GEMFIRE_REST_API_WEB_SERVICE_URL = URI
-      .create(BASE_URL + GEMFIRE_REST_API_CONTEXT + GEMFIRE_REST_API_VERSION);
-
-  private static RestTemplate restTemplate;
-
-  public static RestTemplate getRestTemplate() {
-    if (restTemplate == null) {
-      restTemplate = new RestTemplate();
-
-      final List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
-
-      messageConverters.add(new ByteArrayHttpMessageConverter());
-      messageConverters.add(new ResourceHttpMessageConverter());
-      messageConverters.add(new StringHttpMessageConverter());
-      messageConverters.add(createMappingJackson2HttpMessageConverter());
-      
-      restTemplate.setMessageConverters(messageConverters);
-    }
-    return restTemplate;
-  }
-
-  public static HttpMessageConverter<Object> createMappingJackson2HttpMessageConverter() {
-    final Jackson2ObjectMapperFactoryBean objectMapperFactoryBean = new Jackson2ObjectMapperFactoryBean();
-
-    objectMapperFactoryBean.setFailOnEmptyBeans(true);
-    objectMapperFactoryBean.setIndentOutput(true);
-    objectMapperFactoryBean.setDateFormat(new SimpleDateFormat("MM/dd/yyyy"));
-    objectMapperFactoryBean
-        .setFeaturesToDisable(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-    objectMapperFactoryBean
-        .setFeaturesToEnable(
-            com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_COMMENTS,
-            com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_SINGLE_QUOTES,
-            com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-    objectMapperFactoryBean.afterPropertiesSet();
-
-    final MappingJackson2HttpMessageConverter httpMessageConverter = new MappingJackson2HttpMessageConverter();
-    httpMessageConverter.setObjectMapper(objectMapperFactoryBean.getObject());
-    return httpMessageConverter;
-  }
-  
-  /*
-  protected static HttpMessageConverter<Object> createMarshallingHttpMessageConverter() {
-    final Jaxb2Marshaller jaxbMarshaller = new Jaxb2Marshaller();
-
-    jaxbMarshaller.setContextPaths("com.gemstone.gemfire.web.rest.domain",
-        "com.gemstone.gemfire.web.controllers.support");
-    jaxbMarshaller.setMarshallerProperties(Collections.singletonMap(
-        "jaxb.formatted.output", Boolean.TRUE));
-
-    return new MarshallingHttpMessageConverter(jaxbMarshaller);
-  }
-  */
-  
-  public static URI toUri(final String... pathSegments) {
-    return toUri(GEMFIRE_REST_API_WEB_SERVICE_URL, pathSegments);
-  }
-
-  public static URI toUri(final URI baseUrl, final String... pathSegments) {
-    return UriComponentsBuilder.fromUri(baseUrl).pathSegment(pathSegments)
-        .build().toUri();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 5012608..8a533f6 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -45,6 +45,8 @@ hamcrest-all.version = 1.3
 hbase.version = 0.94.27
 hibernate.version = 3.5.5-Final
 hibernate-commons-annotations.version = 3.2.0.Final
+httpclient.version = 4.3.3
+httpcore.version = 4.3.3
 httpunit.version = 1.7.2
 hsqldb.version = 2.0.0
 jackson.version = 2.2.0


[03/11] incubator-geode git commit: adding unit tests for REST API

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
new file mode 100644
index 0000000..adb2b55
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java
@@ -0,0 +1,328 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.cache30.CacheTestCase;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
+import com.gemstone.gemfire.test.dunit.VM;
+
+/**
+ * 
+ * @author Nilkanth Patel
+ */
+
+public class RestAPIsOnMembersFunctionExecutionDUnitTest extends CacheTestCase { 
+  
+  private static final long serialVersionUID = 1L;
+  
+  VM member1 = null;
+  VM member2 = null;
+  VM member3 = null;
+  VM member4 = null;
+  
+  static InternalDistributedSystem ds = null;
+
+  public RestAPIsOnMembersFunctionExecutionDUnitTest(String name) {
+    super(name);
+  }
+  
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    Host host = Host.getHost(0);
+    member1 = host.getVM(0);
+    member2 = host.getVM(1);
+    member3 = host.getVM(2);
+    member4 = host.getVM(3);
+  }
+  
+  static class OnMembersFunction implements Function {
+    private static final long serialVersionUID = -1032915440862585532L;
+    public static final String Id = "OnMembersFunction";
+    public static int invocationCount;
+
+    @Override
+    public void execute(FunctionContext context) {
+      
+      LogWriterUtils.getLogWriter().fine("SWAP:1:executing OnMembersFunction:"+invocationCount);
+      InternalDistributedSystem ds = InternalDistributedSystem.getConnectedInstance();
+      invocationCount++;
+      
+      context.getResultSender().lastResult(Boolean.TRUE);
+    }
+    
+    @Override
+    public String getId() {
+      return Id;
+    }
+
+    @Override
+    public boolean hasResult() {
+      return true;
+    }
+
+    @Override
+    public boolean optimizeForWrite() {
+      return false;
+    }
+
+    @Override
+    public boolean isHA() {
+      return false;
+    }
+  }
+  
+  private void verifyAndResetInvocationCount(VM vm, final int count) {
+    vm.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        OnMembersFunction f = (OnMembersFunction) FunctionService.getFunction(OnMembersFunction.Id);
+        assertEquals(count, f.invocationCount);
+        // assert succeeded, reset count
+        f.invocationCount = 0;
+        return null;
+      }
+    });
+  }
+  
+  private InternalDistributedSystem createSystem(Properties props){
+    try {
+      ds = getSystem(props);
+      assertNotNull(ds);
+      FunctionService.registerFunction(new OnMembersFunction());
+      
+    }
+    catch (Exception e) {
+      Assert.fail("Failed while creating the Distribued System", e);
+    }
+    return ds;
+  }
+  
+  public static String createCacheAndRegisterFunction(VM vm, String memberName) {
+    final String hostName = vm.getHost().getHostName(); 
+    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.NAME_NAME, memberName);
+    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
+    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(serverPort));
+    
+    Cache c = null;
+    try {
+      c = CacheFactory.getInstance( new RestAPIsOnMembersFunctionExecutionDUnitTest("temp").getSystem(props));
+      c.close();
+    } catch (CacheClosedException cce) {
+    }
+    
+    c = CacheFactory.create(new RestAPIsOnMembersFunctionExecutionDUnitTest("temp").getSystem(props));
+    FunctionService.registerFunction(new OnMembersFunction());
+    
+    String restEndPoint =  "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+    return restEndPoint;
+   
+  }
+  
+  public static void executeFunctionOnAllMembersThroughRestCall(List<String> restURLs) {
+    Random randomGenerator = new Random();
+    int index = randomGenerator.nextInt(restURLs.size());
+    
+    //Testcase: onMembers Function execution with No groups specified
+    try {
+      
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnMembersFunction");
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      
+      LogWriterUtils.getLogWriter().info("Request POST : " + post.toString());
+      
+      response = httpclient.execute(post);
+      
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(
+          content));
+      String line;
+      StringBuffer sb = new StringBuffer();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }
+      LogWriterUtils.getLogWriter().info("Response : " + sb.toString());
+            
+      
+      //verify response status code
+      assertEquals(200, response.getStatusLine().getStatusCode());
+      
+      //verify response hasbody flag
+      assertNotNull(response.getEntity());
+      
+      
+      response.close();      
+     
+      JSONArray resultArray = new JSONArray(sb.toString());
+      assertEquals(resultArray.length(), 4);
+      
+      //fail("Expected exception while executing function onMembers without any members ");
+      
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+  }
+ 
+  public static void executeFunctionOnGivenMembersThroughRestCall(List<String> restURLs) {
+    Random randomGenerator = new Random();
+    int index = randomGenerator.nextInt(restURLs.size());
+    
+    //Testcase: onMembers Function execution with valid groups
+    try {
+      
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnMembersFunction?onMembers=m1,m2,m3");
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      response = httpclient.execute(post);
+    
+      //verify response status code. expected status code is 200 OK.
+      assertEquals(response.getStatusLine().getStatusCode(), 200);
+      
+      //verify response hasbody flag, expected is true.
+      assertNotNull(response.getEntity());
+      
+      
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(
+          content));
+      String line;
+      StringBuffer sb = new StringBuffer();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }
+      response.close();
+      
+      //verify function execution result
+      JSONArray resultArray = new JSONArray(sb.toString());
+      assertEquals(resultArray.length(), 3);
+      
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+  }
+  
+  public void testFunctionExecutionOnAllMembers()  {
+    
+    List<String> restURLs = new ArrayList<String>(); 
+    
+    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
+    //         Connect to DS and Register function. Add Rest end-point into the restURLs list.
+    
+    String url1 = (String)member1.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member1, "m1"));
+    restURLs.add(url1);
+    
+    String url2 = (String)member2.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member2, "m2"));
+    restURLs.add(url2);
+    
+    String url3 = (String)member3.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member3, "m3"));
+    restURLs.add(url3);
+    
+    String url4 = (String)member4.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member4, "m4"));
+    restURLs.add(url4);
+    
+    //default case, execute function on all members, register the function in controller VM
+    //FunctionService.registerFunction(new OnMembersFunction());
+    
+    //Step-2 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+    for (int i=0; i< 10; i++) {
+      executeFunctionOnAllMembersThroughRestCall(restURLs);
+    }
+    
+    //Verify that each node (m1, m2, m3) has run the function
+    verifyAndResetInvocationCount(member1, 10);
+    verifyAndResetInvocationCount(member2, 10);
+    verifyAndResetInvocationCount(member3, 10);
+    verifyAndResetInvocationCount(member4, 10);
+
+    restURLs.clear();
+  }
+  
+  public void testFunctionExecutionEOnSelectedMembers()  {
+    
+    List<String> restURLs = new ArrayList<String>(); 
+    
+    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
+    //         Connect to DS and Register function. Add Rest end-point into the restURLs list.
+    
+    String url1 = (String)member1.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member1, "m1"));
+    restURLs.add(url1);
+    
+    String url2 = (String)member2.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member2, "m2"));
+    restURLs.add(url2);
+    
+    String url3 = (String)member3.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member3, "m3"));
+    restURLs.add(url3);
+    
+    String url4 = (String)member4.invoke(() -> RestAPIsOnMembersFunctionExecutionDUnitTest.createCacheAndRegisterFunction(member4, "m4"));
+    restURLs.add(url4);
+    
+    //default case, execute function on all members, register the function in controller VM
+    //FunctionService.registerFunction(new OnMembersFunction());
+    
+    //Step-2 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+    for (int i=0; i< 10; i++) {
+      executeFunctionOnGivenMembersThroughRestCall(restURLs);
+    }
+    
+    //Verify that each node (m1, m2, m3) has run the function
+    verifyAndResetInvocationCount(member1, 10);
+    verifyAndResetInvocationCount(member2, 10);
+    verifyAndResetInvocationCount(member3, 10);
+    
+
+    restURLs.clear();
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
new file mode 100644
index 0000000..d6889a7
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsQueryAndFEJUnitTest.java
@@ -0,0 +1,1715 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheLoader;
+import com.gemstone.gemfire.cache.CacheWriter;
+import com.gemstone.gemfire.cache.CacheWriterException;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Declarable;
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.LoaderHelper;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.RegionDestroyedException;
+import com.gemstone.gemfire.cache.RegionEvent;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.TimeoutException;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.distributed.ServerLauncher;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.management.internal.AgentUtil;
+import com.gemstone.gemfire.management.internal.ManagementConstants;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.experimental.categories.Category;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpServerErrorException;
+
+@Category(IntegrationTest.class)
+public class RestAPIsQueryAndFEJUnitTest extends TestCase {
+
+  private Cache c;
+
+  private String hostName;
+  
+  private String baseURL;
+  
+  private int restServicePort;
+  
+  private final String CUSTOMER_REGION = "customers";
+  
+  //DEBUG code
+  //private final String PEOPLE_REGION = "People";
+  
+  private final String ITEM_REGION = "items";
+  private final String ORDER_REGION = "orders";
+  private final String PRIMITIVE_KV_STORE_REGION = "primitiveKVStore";
+  private final String UNKNOWN_REGION = "unknown_region";
+  private final String EMPTY_REGION = "empty_region";
+  
+  private Map<Integer, QueryResultData> queryResultByIndex;
+ 
+  private final String ORDER1_AS_JSON = "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 111," + "\"customerId\": 101,"
+      + "\"description\": \"Purchase order for company - A\"," + "\"orderDate\": \"01/10/2014\"," + "\"deliveryDate\": \"01/20/2014\","
+      + "\"contact\": \"Nilkanthkumar N Patel\","
+      + "\"email\": \"npatel@pivotal.io\"," + "\"phone\": \"020-2048096\"," + "\"totalPrice\": 205,"
+      + "\"items\":" + "[" + "{" + "\"itemNo\": 1,"
+      + "\"description\": \"Product-1\"," + "\"quantity\": 5,"
+      + "\"unitPrice\": 10," + "\"totalPrice\": 50" + "}," + "{"
+      + "\"itemNo\": 1," + "\"description\": \"Product-2\","
+      + "\"quantity\": 10," + "\"unitPrice\": 15.5," + "\"totalPrice\": 155"
+      + "}" + "]" + "}";
+  
+  private final String MALFORMED_JSON = "{"
+      + "\"@type\" \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 111," + "\"customerId\": 101,"
+      + "\"description\": \"Purchase order for company - A\"," + "\"orderDate\": \"01/10/2014\"," + "\"deliveryDate\": \"01/20/2014\","
+      + "\"contact\": \"Nilkanthkumar N Patel\","
+      + "\"email\": \"npatel@pivotal.io\"," + "\"phone\": \"020-2048096\"," + "\"totalPrice\": 205,"
+      + "\"items\":" + "[" + "{" + "\"itemNo\": 1,"
+      + "\"description\": \"Product-1\"," + "\"quantity\": 5,"
+      + "\"unitPrice\": 10," + "\"totalPrice\": 50" + "}," + "{"
+      + "\"itemNo\": 1," + "\"description\": \"Product-2\","
+      + "\"quantity\": 10," + "\"unitPrice\": 15.5," + "\"totalPrice\": 155"
+      + "}" + "]" + "}";
+  
+  private final String ORDER2_AS_JSON = "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 112," + "\"customerId\": 102,"
+      + "\"description\": \"Purchase order for company - B\"," + "\"orderDate\": \"02/10/2014\"," + "\"deliveryDate\": \"02/20/2014\","
+      + "\"contact\": \"John Blum\","
+      + "\"email\": \"jblum@pivotal.io\"," + "\"phone\": \"01-2048096\"," + "\"totalPrice\": 225,"
+      + "\"items\":" + "[" + "{" + "\"itemNo\": 1,"
+      + "\"description\": \"Product-3\"," + "\"quantity\": 6,"
+      + "\"unitPrice\": 20," + "\"totalPrice\": 120" + "}," + "{"
+      + "\"itemNo\": 2," + "\"description\": \"Product-4\","
+      + "\"quantity\": 10," + "\"unitPrice\": 10.5," + "\"totalPrice\": 105"
+      + "}" + "]" + "}";
+  
+  private final String ORDER2_UPDATED_AS_JSON = "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 1112," + "\"customerId\": 102,"
+      + "\"description\": \"Purchase order for company - B\","  + "\"orderDate\": \"02/10/2014\"," + "\"deliveryDate\": \"02/20/2014\","
+      + "\"contact\": \"John Blum\","
+      + "\"email\": \"jblum@pivotal.io\"," + "\"phone\": \"01-2048096\"," + "\"totalPrice\": 350,"
+      + "\"items\":" + "[" + "{" + "\"itemNo\": 1,"
+      + "\"description\": \"Product-AAAA\"," + "\"quantity\": 10,"
+      + "\"unitPrice\": 20," + "\"totalPrice\": 200" + "}," + "{"
+      + "\"itemNo\": 2," + "\"description\": \"Product-BBB\","
+      + "\"quantity\": 15," + "\"unitPrice\": 10," + "\"totalPrice\": 150"
+      + "}" + "]" + "}";
+  
+  final String CUSTOMER_LIST1_AS_JSON = "[" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 1,"
+      + " \"firstName\": \"Vishal\","
+      + " \"lastName\": \"Roa\"" 
+      + "},"
+      +"{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 2,"
+      + " \"firstName\": \"Nilkanth\","
+      + " \"lastName\": \"Patel\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 3,"
+      + " \"firstName\": \"Avinash Dongre\","
+      + " \"lastName\": \"Roa\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 4,"
+      + " \"firstName\": \"Avinash Dongre\","
+      + " \"lastName\": \"Roa\"" 
+      + "}"
+      + "]";
+      
+  final String CUSTOMER_LIST_AS_JSON = "[" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 101,"
+      + " \"firstName\": \"Vishal\","
+      + " \"lastName\": \"Roa\"" 
+      + "},"
+      +"{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 102,"
+      + " \"firstName\": \"Nilkanth\","
+      + " \"lastName\": \"Patel\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 103,"
+      + " \"firstName\": \"Avinash Dongre\","
+      + " \"lastName\": \"Roa\"" 
+      + "},"
+      +"{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 104,"
+      + " \"firstName\": \"John\","
+      + " \"lastName\": \"Blum\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 105,"
+      + " \"firstName\": \"Shankar\","
+      + " \"lastName\": \"Hundekar\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 106,"
+      + " \"firstName\": \"Amey\","
+      + " \"lastName\": \"Barve\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 107,"
+      + " \"firstName\": \"Vishal\","
+      + " \"lastName\": \"Roa\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 108,"
+      + " \"firstName\": \"Supriya\","
+      + " \"lastName\": \"Pillai\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 109,"
+      + " \"firstName\": \"Tushar\","
+      + " \"lastName\": \"khairnar\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 110,"
+      + " \"firstName\": \"Rishitesh\","
+      + " \"lastName\": \"Mishra\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 111,"
+      + " \"firstName\": \"Ajay\","
+      + " \"lastName\": \"Pandey\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 112,"
+      + " \"firstName\": \"Suyog\","
+      + " \"lastName\": \"Bokare\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 113,"
+      + " \"firstName\": \"Rajesh\","
+      + " \"lastName\": \"kumar\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 114,"
+      + " \"firstName\": \"swati\","
+      + " \"lastName\": \"sawant\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 115,"
+      + " \"firstName\": \"sonal\","
+      + " \"lastName\": \"Agrawal\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 116,"
+      + " \"firstName\": \"Amogh\","
+      + " \"lastName\": \"Shetkar\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 117,"
+      + " \"firstName\": \"Viren\","
+      + " \"lastName\": \"Balaut\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 118,"
+      + " \"firstName\": \"Namrata\","
+      + " \"lastName\": \"Tanvi\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 119,"
+      + " \"firstName\": \"Rahul\","
+      + " \"lastName\": \"Diyekar\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 120,"
+      + " \"firstName\": \"Varun\","
+      + " \"lastName\": \"Agrawal\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 121,"
+      + " \"firstName\": \"Hemant\","
+      + " \"lastName\": \"Bhanavat\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 122,"
+      + " \"firstName\": \"Sunil\","
+      + " \"lastName\": \"jigyasu\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 123,"
+      + " \"firstName\": \"Sumedh\","
+      + " \"lastName\": \"wale\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 124,"
+      + " \"firstName\": \"saobhik\","
+      + " \"lastName\": \"chaudhari\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 125,"
+      + " \"firstName\": \"Ketki\","
+      + " \"lastName\": \"Naidu\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 126,"
+      + " \"firstName\": \"YOgesh\","
+      + " \"lastName\": \"Mahajan\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 127,"
+      + " \"firstName\": \"Surinder\","
+      + " \"lastName\": \"Bindra\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 128,"
+      + " \"firstName\": \"sandip\","
+      + " \"lastName\": \"kasbe\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 129,"
+      + " \"firstName\": \"shivam\","
+      + " \"lastName\": \"Panada\"" 
+      + "},"
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Customer\","
+      +"\"customerId\": 130,"
+      + " \"firstName\": \"Preeti\","
+      + " \"lastName\": \"Kumari\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 131,"
+      + " \"firstName\": \"Vishal31\","
+      + " \"lastName\": \"Roa31\"" 
+      + "},"
+      +"{"
+      +"\"customerId\": 132,"
+      + " \"firstName\": \"Nilkanth32\","
+      + " \"lastName\": \"Patel32\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 133,"
+      + " \"firstName\": \"Avinash33\","
+      + " \"lastName\": \"Dongre33\"" 
+      + "},"
+      +"{"
+      +"\"customerId\": 134,"
+      + " \"firstName\": \"John34\","
+      + " \"lastName\": \"Blum34\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 135,"
+      + " \"firstName\": \"Shankar35\","
+      + " \"lastName\": \"Hundekar35\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 136,"
+      + " \"firstName\": \"Amey36\","
+      + " \"lastName\": \"Barve36\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 137,"
+      + " \"firstName\": \"Vishal37\","
+      + " \"lastName\": \"Roa37\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 138,"
+      + " \"firstName\": \"Supriya38\","
+      + " \"lastName\": \"Pillai38\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 139,"
+      + " \"firstName\": \"Tushar39\","
+      + " \"lastName\": \"khairnar39\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 140,"
+      + " \"firstName\": \"Rishitesh40\","
+      + " \"lastName\": \"Mishra40\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 141,"
+      + " \"firstName\": \"Ajay41\","
+      + " \"lastName\": \"Pandey41\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 142,"
+      + " \"firstName\": \"Suyog42\","
+      + " \"lastName\": \"Bokare42\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 143,"
+      + " \"firstName\": \"Rajesh43\","
+      + " \"lastName\": \"kumar43\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 144,"
+      + " \"firstName\": \"swati44\","
+      + " \"lastName\": \"sawant44\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 145,"
+      + " \"firstName\": \"sonal45\","
+      + " \"lastName\": \"Agrawal45\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 146,"
+      + " \"firstName\": \"Amogh46\","
+      + " \"lastName\": \"Shetkar46\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 147,"
+      + " \"firstName\": \"Viren47\","
+      + " \"lastName\": \"Balaut47\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 148,"
+      + " \"firstName\": \"Namrata48\","
+      + " \"lastName\": \"Tanvi48\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 149,"
+      + " \"firstName\": \"Rahul49\","
+      + " \"lastName\": \"Diyekar49\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 150,"
+      + " \"firstName\": \"Varun50\","
+      + " \"lastName\": \"Agrawal50\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 151,"
+      + " \"firstName\": \"Hemant50\","
+      + " \"lastName\": \"Bhanavat50\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 152,"
+      + " \"firstName\": \"Sunil52\","
+      + " \"lastName\": \"jigyasu52\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 153,"
+      + " \"firstName\": \"Sumedh53\","
+      + " \"lastName\": \"wale53\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 154,"
+      + " \"firstName\": \"saobhik54\","
+      + " \"lastName\": \"chaudhari54\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 155,"
+      + " \"firstName\": \"Ketki55\","
+      + " \"lastName\": \"Naidu55\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 156,"
+      + " \"firstName\": \"YOgesh56\","
+      + " \"lastName\": \"Mahajan56\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 157,"
+      + " \"firstName\": \"Surinder57\","
+      + " \"lastName\": \"Bindra57\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 158,"
+      + " \"firstName\": \"sandip58\","
+      + " \"lastName\": \"kasbe58\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 159,"
+      + " \"firstName\": \"shivam59\","
+      + " \"lastName\": \"Panada59\"" 
+      + "},"
+      + "{"
+      +"\"customerId\": 160,"
+      + " \"firstName\": \"Preeti60\","
+      + " \"lastName\": \"Kumari60\"" 
+      + "}"
+      + "]";
+  
+  private final String ORDER_AS_CASJSON = "{"
+      + "\"@old\" :" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 111," + "\"customerId\": 101,"
+      + "\"description\": \"Purchase order for company - A\"," + "\"orderDate\": \"01/10/2014\"," + "\"deliveryDate\": \"01/20/2014\","
+      + "\"contact\": \"Nilkanthkumar N Patel\","
+      + "\"email\": \"npatel@pivotal.io\"," + "\"phone\": \"020-2048096\"," + "\"totalPrice\": 205,"
+      + "\"items\":" + "[" + "{" + "\"itemNo\": 1,"
+      + "\"description\": \"Product-1\"," + "\"quantity\": 5,"
+      + "\"unitPrice\": 10," + "\"totalPrice\": 50" + "}," + "{"
+      + "\"itemNo\": 1," + "\"description\": \"Product-2\","
+      + "\"quantity\": 10," + "\"unitPrice\": 15.5," + "\"totalPrice\": 155"
+      + "}" + "]" 
+      + "},"
+      + "\"@new\" :" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 11101," + "\"customerId\": 101,"
+      + "\"description\": \"Purchase order for company - A\"," + "\"orderDate\": \"01/10/2014\"," + "\"deliveryDate\": \"01/20/2014\","
+      + "\"contact\": \"Nilkanthkumar N Patel\","
+      + "\"email\": \"npatel@pivotal.io\"," + "\"phone\": \"020-2048096\"," + "\"totalPrice\": 205,"
+      + "\"items\":" 
+      + "[" 
+        + "{" 
+          + "\"itemNo\": 1,"
+          +  "\"description\": \"Product-1\","
+          + "\"quantity\": 5,"
+          + "\"unitPrice\": 10,"
+          + "\"totalPrice\": 50" 
+        + "}," 
+          + "{" 
+          + "\"itemNo\": 3,"
+          +  "\"description\": \"Product-3\","
+          + "\"quantity\": 10,"
+          + "\"unitPrice\": 100,"
+          + "\"totalPrice\": 1000" 
+          + "}," 
+        + "{"
+          + "\"itemNo\": 1,"
+          + "\"description\": \"Product-2\","
+          + "\"quantity\": 10,"
+          + "\"unitPrice\": 15.5,"
+          + "\"totalPrice\": 155"
+        + "}"
+      + "]" 
+      + "}"
+      + "}";
+      
+  private final String MALFORMED_CAS_JSON = "{"
+      + "\"@old\" :" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 111," + "\"customerId\": 101,"
+      + "\"description\": \"Purchase order for company - A\"," + "\"orderDate\": \"01/10/2014\"," + "\"deliveryDate\": \"01/20/2014\","
+      + "\"contact\": \"Nilkanthkumar N Patel\","
+      + "\"email\": \"npatel@pivotal.io\"," + "\"phone\": \"020-2048096\"," + "\"totalPrice\": 205,"
+      + "\"items\":" + "[" + "{" + "\"itemNo\": 1,"
+      + "\"description\": \"Product-1\"," + "\"quantity\": 5,"
+      + "\"unitPrice\": 10," + "\"totalPrice\": 50" + "}," + "{"
+      + "\"itemNo\": 1," + "\"description\": \"Product-2\","
+      + "\"quantity\": 10," + "\"unitPrice\": 15.5," + "\"totalPrice\": 155"
+      + "}" + "]" 
+      + "},"
+       
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Order\","
+      + "\"purchaseOrderNo\": 11101," + "\"customerId\": 101,"
+      + "\"description\": \"Purchase order for company - A\"," + "\"orderDate\": \"01/10/2014\"," + "\"deliveryDate\": \"01/20/2014\","
+      + "\"contact\": \"Nilkanthkumar N Patel\","
+      + "\"email\": \"npatel@pivotal.io\"," + "\"phone\": \"020-2048096\"," + "\"totalPrice\": 205,"
+      + "\"items\":" 
+      + "[" 
+        + "{" 
+          + "\"itemNo\": 1,"
+          +  "\"description\": \"Product-1\","
+          + "\"quantity\": 5,"
+          + "\"unitPrice\": 10,"
+          + "\"totalPrice\": 50" 
+        + "}," 
+          + "{" 
+          + "\"itemNo\": 3,"
+          +  "\"description\": \"Product-3\","
+          + "\"quantity\": 10,"
+          + "\"unitPrice\": 100,"
+          + "\"totalPrice\": 1000" 
+          + "}," 
+        + "{"
+          + "\"itemNo\": 1,"
+          + "\"description\": \"Product-2\","
+          + "\"quantity\": 10,"
+          + "\"unitPrice\": 15.5,"
+          + "\"totalPrice\": 155"
+        + "}"
+      + "]" 
+      + "}"
+      + "}";
+  final String[][] PARAMETERIZED_QUERIES = new String[][] {
+      {
+        "selectOrders",
+        "SELECT DISTINCT o FROM /orders o, o.items item WHERE item.quantity > $1 AND item.totalPrice > $2" },
+      { 
+        "selectCustomer",
+        "SELECT c FROM /customers c WHERE c.customerId = $1" },
+      {
+        "selectHighRollers",
+        "SELECT DISTINCT c FROM /customers c, /orders o, o.items item WHERE item.totalprice > $1 AND c.customerId = o.customerId" 
+      },
+      {
+        "testQuery",
+        "SELECT DISTINCT c from /customers c where lastName=$1"
+      },
+      {
+        "findSelectedCustomers",
+        "SELECT * from /customers where customerId  IN SET ($1, $2, $3)"
+      },
+      {
+        "invalidQuery",
+        "This is invalid string"
+      }
+  };
+  
+  final String QUERY_ARGS2 = "{"
+      + "\"@type\": \"int\","
+      + "\"@value\": 101"
+      + "}";
+  
+  final String QUERY_ARGS1 = "["
+      +"{"
+      + "\"@type\": \"int\","
+      + "\"@value\": 2"
+      + "},"
+      +"{"
+      + "\"@type\": \"double\","
+      + "\"@value\": 110.00"
+      + "}"
+      + "]";
+
+  @SuppressWarnings("unused")
+  final String QUERY_ARGS3 = "["
+      +"{"
+      + "\"@type\": \"String\","
+      + "\"@value\": \"Agrawal\""
+      + "}"
+      + "]";
+
+  @SuppressWarnings("unused")
+  final String QUERY_ARGS4 = "["
+      +"{"
+      + "\"@type\": \"int\","
+      + "\"@value\": 20"
+      + "},"
+      +"{"
+      + "\"@type\": \"int\","
+      + "\"@value\": 120"
+      + "},"
+      +"{"
+      + "\"@type\": \"int\","
+      + "\"@value\": 130"
+      + "}"
+      + "]";
+  
+ 
+  final String FUNCTION_ARGS1 = "["
+    +    "{"
+    +        "\"@type\": \"double\","
+    +        "\"@value\": 210"
+    +    "},"
+    +    "{"
+    +        "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Item\","
+    +        "\"itemNo\": \"599\","
+    +        "\"description\": \"Part X Free on Bumper Offer\","
+    +        "\"quantity\": \"2\","
+    +        "\"unitprice\": \"5\","
+    +        "\"totalprice\": \"10.00\""
+    +    "}"
+    +"]";
+  
+  public final int METHOD_INDEX = 0;
+  public final int URL_INDEX = 1;
+  public final int REQUEST_BODY_INDEX = 2;
+  public final int STATUS_CODE_INDEX = 3;
+  public final int LOCATION_HEADER_INDEX = 4;
+  public final int RESPONSE_HAS_BODY_INDEX = 5;
+  public final int RESPONSE_HAS_EXCEPTION_INDEX = 6;
+  
+  final Object TEST_DATA[][]={ 
+    { //0. create - 200 ok
+      HttpMethod.POST,  
+      "/orders?key=1",  
+      ORDER1_AS_JSON, 
+      HttpStatus.CREATED,               
+      "/orders/1",
+      false, 
+      false
+    },
+    { //1. create - 409 conflict
+      HttpMethod.POST,  
+      "/orders?key=1", 
+      ORDER1_AS_JSON,  
+      HttpStatus.CONFLICT,              
+      "/orders/1",
+      true,
+      true
+    },
+    { //2. create - 400 bad Req for malformed Json
+      HttpMethod.POST,  
+      "/orders?key=k1", 
+      MALFORMED_JSON,   
+      HttpStatus.BAD_REQUEST,           
+      null,
+      true,
+      true
+    },    
+    { //3. create - 404, Not Found, for Region not exist
+      HttpMethod.POST,  
+      "/"+ UNKNOWN_REGION + "?key=k1",
+      ORDER1_AS_JSON,
+      HttpStatus.NOT_FOUND,             
+      null,
+      true,
+      true
+    },    
+    { //4. create - 500 creating entry on region having DataPolicy=Empty
+      HttpMethod.POST,  
+      "/"+ EMPTY_REGION + "?key=k1", 
+      ORDER1_AS_JSON, 
+      HttpStatus.INTERNAL_SERVER_ERROR, 
+      null,
+      true,
+      true
+    },    
+    { //5. Get data for key - 200 ok
+      HttpMethod.GET,   
+      "/orders/1", 
+      null,
+      HttpStatus.OK,                    
+      "/orders/1",
+      true,
+      false
+    },
+    { //6. Get data for key - 404 region not exist
+      HttpMethod.GET,   
+      "/"+ UNKNOWN_REGION + "/1",
+      null,
+      HttpStatus.NOT_FOUND,             
+      null,
+      true,
+      true
+    },
+    { //7. Get data for Non-existing key - 404, Resource NOT FOUND.
+      HttpMethod.GET,   
+      "/"+ EMPTY_REGION + "/unknown",
+      null,
+      HttpStatus.INTERNAL_SERVER_ERROR, 
+      null,
+      true,
+      true
+    },    
+    { //8.  Put - 200 Ok, successful
+      HttpMethod.PUT,   
+      "/orders/2", 
+      ORDER2_AS_JSON,
+      HttpStatus.OK,                    
+      "/orders/2",  
+      false,
+      false
+    },
+    { //9.  Put - 400 Bad Request, Malformed JSOn
+      HttpMethod.PUT,   
+      "/orders/3",
+      MALFORMED_JSON, 
+      HttpStatus.BAD_REQUEST,          
+      null,
+      true,
+      true
+    },
+    { //10. Put - 404 Not Found, Region does not exist
+      HttpMethod.PUT,   
+      "/"+ UNKNOWN_REGION + "/k1",
+      ORDER2_AS_JSON, 
+      HttpStatus.NOT_FOUND,        
+      null,
+      true,
+      true
+    },
+    { //11. Put - 500, Gemfire throws exception
+      HttpMethod.PUT,   
+      "/"+ EMPTY_REGION + "/k1",
+      ORDER2_AS_JSON,
+      HttpStatus.INTERNAL_SERVER_ERROR,
+      null,
+      true,
+      true
+    },    
+    { //12. putAll - 200 Ok
+      HttpMethod.PUT,   
+      "/customers/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60",
+      CUSTOMER_LIST_AS_JSON,
+      HttpStatus.OK,   
+      "/customers/3,4,5,6",
+      false,
+      false
+    },
+    { //13. putAll - 400 bad Request, amlformed Json
+      HttpMethod.PUT,   
+      "/customers/3,4,5,6",
+      MALFORMED_JSON,
+      HttpStatus.BAD_REQUEST,  
+      null,
+      true,
+      true
+    },
+    { //14. putAll - 404 Not Found, Region Does not exist
+      HttpMethod.PUT,   
+      "/"+ UNKNOWN_REGION + "/3,4,5,6",
+      CUSTOMER_LIST1_AS_JSON,
+      HttpStatus.NOT_FOUND,     
+      null,
+      true,
+      true
+    },
+    { //15. putAll - 500, Gemfire throws exception
+      HttpMethod.PUT,   
+      "/"+ EMPTY_REGION + "/3,4,5,6",
+      CUSTOMER_LIST1_AS_JSON,
+      HttpStatus.INTERNAL_SERVER_ERROR, 
+      null,
+      true,
+      true   
+    },
+    { //16. PUT?op=REPLACE, 200 Ok test case
+      HttpMethod.PUT,
+      "/orders/2?op=REPLACE",
+      ORDER2_UPDATED_AS_JSON,
+      HttpStatus.OK,
+      "/orders/2",
+      false,
+      false		
+    },
+    { //17. Put?op=REPLACE, 400 Bad Request, Malformed JSOn
+      HttpMethod.PUT,   
+      "/orders/2?op=REPLACE",
+      MALFORMED_JSON, 
+      HttpStatus.BAD_REQUEST,          
+      null,
+      true,
+      true
+    },
+    { //18. Put?op=REPLACE, 404 Not Found, Region does not exist
+      HttpMethod.PUT,   
+      "/"+ UNKNOWN_REGION + "/k1?op=rePlace",
+      ORDER2_AS_JSON, 
+      HttpStatus.NOT_FOUND,        
+      null,
+      true,
+      true
+    },
+    { //19. Put?op=REPLACE, 500 testcase, Gemfire exception
+      HttpMethod.PUT,   
+      "/"+ EMPTY_REGION + "/k1?op=REPLACE",
+      ORDER2_AS_JSON,
+      HttpStatus.INTERNAL_SERVER_ERROR,
+      null,
+      true,
+      true
+    },
+    { //20. Put?op=CAS, 200 OK testcase.
+      HttpMethod.PUT,   
+      "/orders/1?op=CAS",
+      ORDER_AS_CASJSON,
+      HttpStatus.OK,
+      "/orders/1",
+      false,
+      false
+    },
+    { //21. Put?op=CAS, 409 OK testcase.
+      HttpMethod.PUT,   
+      "/orders/2?op=CAS",
+      ORDER_AS_CASJSON,
+      HttpStatus.CONFLICT,
+      "/orders/2",
+      true,
+      true
+    },
+    { //22. Put?op=CAS, 400 Bad Request, Malformed JSOn
+      HttpMethod.PUT,   
+      "/orders/2?op=cas",
+      MALFORMED_CAS_JSON, 
+      HttpStatus.BAD_REQUEST,          
+      null,
+      true,
+      true
+    },
+    { //23. Put?op=CAS, 404 Not Found, Region does not exist
+      HttpMethod.PUT,   
+      "/"+ UNKNOWN_REGION + "/k1?op=CAS",
+      ORDER_AS_CASJSON, 
+      HttpStatus.NOT_FOUND,        
+      null,
+      true,
+      true
+    },
+    { //24. Put?op=cAs, 500 testcase, Gemfire exception
+      HttpMethod.PUT,   
+      "/"+ EMPTY_REGION + "/k1?op=cAs",
+      ORDER_AS_CASJSON,
+      HttpStatus.INTERNAL_SERVER_ERROR,
+      null,
+      true,
+      true
+    },
+    { //25. Get - List all regions/resources - 200 ok testcase
+      HttpMethod.GET,   
+      "",
+      null,
+      HttpStatus.OK,
+      RestTestUtils.GEMFIRE_REST_API_WEB_SERVICE_URL,
+      true,
+      true
+    },
+    { //26. List all regions/resources - 405 testcase.
+      HttpMethod.POST,   
+      "",
+      null,
+      HttpStatus.METHOD_NOT_ALLOWED,
+      null,
+      true,
+      true
+    },   
+    { //27. GetAll - read all data for region - 200 ok, Default test case [No limit param specified].
+      HttpMethod.GET,   
+      "/customers",
+      null,
+      HttpStatus.OK,
+      "/customers",
+      true,
+      false
+    },
+    { //28 GetAll - read all data for region - 404 NOT FOUND testcase.
+      HttpMethod.GET,   
+      "/" + UNKNOWN_REGION,
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //29 GetAll - read all data for region - limit=ALL testcase.
+      HttpMethod.GET,   
+      "/customers?limit=ALL",
+      null,
+      HttpStatus.OK,
+      null,
+      true,
+      false
+    },
+    { //30 GetAll - read data for fixed number of keys - limit=<NUMBER> testcase.
+      HttpMethod.GET,   
+      "/customers?limit=10",
+      null,
+      HttpStatus.OK,
+      null,
+      true,
+      false
+    },
+    { //31. Get keys - List all keys in region - 200 ok testcase
+      HttpMethod.GET,   
+      "/customers/keys",
+      null,
+      HttpStatus.OK,
+      "/customers/keys",
+      true,
+      false
+    },
+    { //32. Get keys - List all keys for region which does not exist - 404 NOt Found testcase
+      HttpMethod.GET,   
+      "/"+ UNKNOWN_REGION +"/keys",
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //33. Get keys - 405 testcase, if any HTTP request method other than GET (e.g. only POST, NOT PUT, DELETE, as for them its a valid op) is used
+      HttpMethod.POST,   
+      "/customers/keys",
+      null,
+      HttpStatus.METHOD_NOT_ALLOWED,
+      null,
+      true,
+      true
+    },
+    { //34. Read data for the specific keys. 200 Ok testcase.
+      HttpMethod.GET,   
+      "/customers/1,2,3,4,5,6,7,8,9,10",
+      null,
+      HttpStatus.OK,
+      null,
+      true,
+      false
+    },
+    {
+    //35. Read data for the specific keys. 404 Ok testcase.
+      HttpMethod.GET,   
+      "/" + UNKNOWN_REGION + "/1,2,3,4,5,6,7,8,9,10",
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //36. delete data for key in region. 200 Ok testcase
+      HttpMethod.DELETE,   
+      "/customers/1",
+      null,
+      HttpStatus.OK,
+      "/customers/1",
+      false,
+      false
+    },
+    { //37. delete data for key with non-existing region. 404 Not Found, testcase.
+      HttpMethod.DELETE,   
+      "/" + UNKNOWN_REGION + "/1",
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //38. delete data for key, 500 - Gemfire throws exception testcase.
+      HttpMethod.DELETE,   
+      "/" + EMPTY_REGION + "/1",
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //39. delete data for set of keys, 200 Ok, testcase.
+      HttpMethod.DELETE,   
+      "/customers/2,3,4,5",
+      null,
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { //40. delete data for set of keys, 404 Region NOT Found, testcase.
+      HttpMethod.DELETE,   
+      "/" + UNKNOWN_REGION + "/2,3,4,5",
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //41. delete data for set of keys, 500 Gemfire throws exception testcase.
+      HttpMethod.DELETE,   
+      "/" + EMPTY_REGION + "/2,3,4,5",
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //42. create parameterized named query
+      HttpMethod.POST,
+      "/queries?id=" +  PARAMETERIZED_QUERIES[0][0] + "&q=" + PARAMETERIZED_QUERIES[0][1],
+      null,
+      HttpStatus.CREATED,
+      "/queries/" + PARAMETERIZED_QUERIES[0][0],
+      false,
+      false
+    },
+    { //43. create parameterized named query 
+      HttpMethod.POST,
+      "/queries?id=" +  PARAMETERIZED_QUERIES[1][0] + "&q=" + PARAMETERIZED_QUERIES[1][1],
+      null,
+      HttpStatus.CREATED,
+      "/queries/" + PARAMETERIZED_QUERIES[1][0],
+      false,
+      false
+    },
+    { //44. create parameterized named query
+      HttpMethod.POST,
+      "/queries?id=" +  PARAMETERIZED_QUERIES[2][0] + "&q=" + PARAMETERIZED_QUERIES[2][1],
+      null,
+      HttpStatus.CREATED,
+      "/queries/" + PARAMETERIZED_QUERIES[2][0],
+      false,
+      false
+    },
+    { //45. list all named/parameterized queries
+      //NOTE: query result = 3. old index=8.
+      HttpMethod.GET,
+      "/queries",
+      null,
+      HttpStatus.OK,
+      "/queries",
+      true,
+      false
+    },
+    { //46. Run the specified named query passing in args for query parameters in request body
+      //Note: Query Result = 2, Old index=9
+      HttpMethod.POST,
+      "/queries/" + PARAMETERIZED_QUERIES[0][0],
+      QUERY_ARGS1,
+      HttpStatus.OK,
+      "/queries/" + PARAMETERIZED_QUERIES[0][0],
+      true,
+      false
+    },
+    { //47. Run the specified named query passing in args for query parameters in request body
+      //Note: Query size = 1, old index = 10
+      HttpMethod.POST,
+      "/queries/" + PARAMETERIZED_QUERIES[1][0],
+      QUERY_ARGS2,
+      HttpStatus.OK,
+      "/queries/" + PARAMETERIZED_QUERIES[1][0],
+      true,
+      false
+    },
+    { //48. Run an unnamed (unidentified), ad-hoc query passed as a URL parameter
+      HttpMethod.GET,
+      "/queries/adhoc?q=SELECT * FROM /customers", 
+      null,
+      HttpStatus.OK,
+      null,
+      true,
+      false
+    },
+    { //49. list all functions available in the GemFire cluster
+      HttpMethod.GET,
+      "/functions",
+      null,
+      HttpStatus.OK,
+      "/functions",
+      true,
+      false
+    },
+    { //50. Execute function with args on availabl nodes in the GemFire cluster
+      HttpMethod.POST,
+      "/functions/AddFreeItemToOrders?onRegion=orders",
+      FUNCTION_ARGS1,
+      HttpStatus.OK,
+      "/functions/AddFreeItemToOrders",
+      true,
+      false
+    },
+    { //51. create parameterized named query "testQuery"
+      HttpMethod.POST,
+      "/queries?id=" +  PARAMETERIZED_QUERIES[3][0] + "&q=" + PARAMETERIZED_QUERIES[3][1],
+      null,
+      HttpStatus.CREATED,
+      "/queries/" + PARAMETERIZED_QUERIES[3][0],
+      false,
+      false
+    },
+    { //52. update parameterized named query "testQuery"
+      HttpMethod.PUT,
+      "/queries/" +  PARAMETERIZED_QUERIES[0][0] + "?q=" + PARAMETERIZED_QUERIES[4][1],
+      null,
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { //53. Run the updated named query passing in args for query parameters in request body
+      HttpMethod.POST,
+      "/queries/" + PARAMETERIZED_QUERIES[0][0],
+      QUERY_ARGS1,
+      HttpStatus.INTERNAL_SERVER_ERROR,
+      null,
+      true,
+      false
+    },
+    { //54. update unknown parameterized named query 
+      HttpMethod.PUT,
+      "/queries/" +  "invalidQuery" + "?q=" + PARAMETERIZED_QUERIES[4][1],
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //55. DELETE parameterized named query with invalid queryString
+      HttpMethod.DELETE,
+      "/queries/" + PARAMETERIZED_QUERIES[3][0] ,
+      null,
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { //56. DELETE Non-existing parameterized named
+      HttpMethod.DELETE,
+      "/queries/" + PARAMETERIZED_QUERIES[3][0] ,
+      null,
+      HttpStatus.NOT_FOUND,
+      null,
+      true,
+      true
+    },
+    { //57. Ping the REST service using HTTP HEAD
+      HttpMethod.HEAD,
+      "/ping",
+      null,
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { //58. Ping the REST service using HTTP GET
+      HttpMethod.GET,
+      "/ping",
+      null,
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { //59. Get the total number of entries in region
+      HttpMethod.HEAD,
+      "/customers",
+      null,
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { //60. create parameterized named query "testQuery", passing it in request-body 
+      HttpMethod.POST,
+      "/queries?id=" +  PARAMETERIZED_QUERIES[3][0],
+      PARAMETERIZED_QUERIES[3][1],
+      HttpStatus.CREATED,
+      "/queries/" + PARAMETERIZED_QUERIES[3][0],
+      false,
+      false
+    },
+    { //61. update parameterized named query, passing it in request-body 
+      HttpMethod.PUT,
+      "/queries/" +  PARAMETERIZED_QUERIES[3][0],
+      PARAMETERIZED_QUERIES[4][1],
+      HttpStatus.OK,
+      null,
+      false,
+      false
+    },
+    { // 52.5. update parameterized named query "testQuery"
+      HttpMethod.GET,
+      "/queries",
+      null,
+      HttpStatus.OK,
+      null,
+      true,
+      false
+    },
+  };
+  //TEST_DATA_END
+  
+  final int LIST_ALL_NAMED_QUERIES_INDEX = 45;
+  final List<Integer> VALID_400_URL_INDEXS = Arrays.asList(2, 9, 13, 17,22);
+  final List<Integer> VALID_404_URL_INDEXS = Arrays.asList(3, 6, 7, 10, 14, 18, 23, 28, 32, 35, 37, 38, 40, 41, 54, 56);
+  final List<Integer> VALID_409_URL_INDEXS = Arrays.asList(1, 21);
+  final List<Integer> VALID_405_URL_INDEXS = Arrays.asList(26, 33);
+  final List<Integer> Query_URL_INDEXS = Arrays.asList(LIST_ALL_NAMED_QUERIES_INDEX, 46, 47, 48);
+  
+  public String createRestURL(String baseURL, Object requestPart) {
+    if(StringUtils.isEmpty(requestPart)) {
+      return baseURL + RestTestUtils.GEMFIRE_REST_API_CONTEXT + RestTestUtils.GEMFIRE_REST_API_VERSION;
+    }else {
+      return baseURL + RestTestUtils.GEMFIRE_REST_API_CONTEXT + RestTestUtils.GEMFIRE_REST_API_VERSION + requestPart;
+    }
+  }
+  public void initializeQueryTestData() {
+    
+    //LIST_ALL_NAMED_QUERY 
+    int size = PARAMETERIZED_QUERIES.length;
+    List<String> queryIds = new ArrayList<>();
+    for (int i=0; i < size; i++ ){
+      queryIds.add(PARAMETERIZED_QUERIES[i][0]) ;
+    }
+      
+    QueryResultData qIndex45_resultData = new QueryResultData();
+    qIndex45_resultData.setQueryIndex(45);
+    qIndex45_resultData.setType(QueryType.LIST_ALL_NAMED_QUERY);
+    qIndex45_resultData.setResultSize(2);
+    qIndex45_resultData.setResult(queryIds);
+    queryResultByIndex.put(45, qIndex45_resultData);
+    
+    //index=46
+    QueryResultData qIndex46_resultData = new QueryResultData();
+    qIndex46_resultData.setQueryIndex(46);
+    qIndex46_resultData.setType(QueryType.EXECUTE_NAMED_QUERY);
+    qIndex46_resultData.setResultSize(2);
+    qIndex46_resultData.setResult(null);
+    queryResultByIndex.put(46, qIndex46_resultData);
+    
+    //index=47
+    QueryResultData qIndex47_resultData = new QueryResultData();
+    qIndex47_resultData.setQueryIndex(47);
+    qIndex47_resultData.setType(QueryType.EXECUTE_NAMED_QUERY);
+    qIndex47_resultData.setResultSize(0);
+    qIndex47_resultData.setResult(null);
+    queryResultByIndex.put(47, qIndex47_resultData);
+    
+    //index=48
+    QueryResultData qIndex48_resultData = new QueryResultData();
+    qIndex48_resultData.setQueryIndex(48);
+    qIndex48_resultData.setType(QueryType.EXECUTE_ADHOC_QUERY);
+    qIndex48_resultData.setResultSize(55);
+    qIndex48_resultData.setResult(null);
+    queryResultByIndex.put(48, qIndex48_resultData);
+  }
+  
+  @Override
+  @SuppressWarnings("deprecation")
+  public void setUp() throws Exception {
+    
+    AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
+    if (agentUtil.findWarLocation("geode-web-api") == null) {
+      fail("unable to locate geode-web-api WAR file");
+    }
+
+    this.restServicePort = AvailablePortHelper.getRandomAvailableTCPPort();
+    
+    try {
+      InetAddress addr = SocketCreator.getLocalHost();
+      this.hostName = addr.getHostName();
+    } catch (UnknownHostException ex) {
+      this.hostName = ManagementConstants.DEFAULT_HOST_NAME;
+    }
+    
+    String workingDirectory = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
+    
+    ServerLauncher serverLauncher = new ServerLauncher.Builder()
+    .set("mcast-port", "0")
+    .setServerBindAddress(this.hostName)
+    .setServerPort(AvailablePortHelper.getRandomAvailableTCPPort())
+    .set("start-dev-rest-api", "true")
+    .set("http-service-port", String.valueOf(this.restServicePort))
+    .set("http-service-bind-address", this.hostName)
+    .setPdxReadSerialized(true)
+    .setWorkingDirectory(workingDirectory)
+    .build();
+    
+    serverLauncher.start();
+    
+    this.baseURL = "http://" + this.hostName + ":" + this.restServicePort;
+    this.c = CacheFactory.getAnyInstance();
+    
+    /*
+    //Debug code
+    this.baseURL = "http://" + "localhost" + ":" + "8080";
+   
+    this.c = (GemFireCacheImpl) new CacheFactory().set("mcast-port", "0")
+        .set("rest-service-http-port", String.valueOf(this.restServicePort))
+        .set("rest-service-bind-address", this.hostName)
+        //.set("log-file", "./restJunitLogs/my.log")
+        .setPdxReadSerialized(true).create();
+    */
+    
+    /*
+    this.c = (GemFireCacheImpl) new CacheFactory().set("mcast-port", "0")
+        .set("rest-service-http-port", "8080")
+        .set("rest-service-bind-address", "localhost")
+        //.set("log-file", "./restJunitLogs/my.log")
+        .setPdxReadSerialized(true).create();
+    */
+    
+    //start cache-server, Gemfire cache clients will connect it
+    /*
+    BridgeServer server = c.addCacheServer();
+    final int serverPort = 40405;
+    server.setPort(serverPort);
+    server.start();
+    */
+    
+    final AttributesFactory<String, String> attributesFactory = new AttributesFactory<>();
+    attributesFactory.setDataPolicy(DataPolicy.REPLICATE);
+
+    // Create region, customers
+    final RegionAttributes<String, String> regionAttributes = attributesFactory
+        .create();
+    c.createRegion(CUSTOMER_REGION, regionAttributes);
+    
+    //Debug code
+    //c.createRegion(PEOPLE_REGION, regionAttributes);
+    
+    // Create region, items
+    attributesFactory.setDataPolicy(DataPolicy.PARTITION);
+    c.createRegion(ITEM_REGION, regionAttributes);
+     
+    // Create region, /orders
+    final AttributesFactory<Object, Object> af2 = new AttributesFactory<>();
+    af2.setDataPolicy(DataPolicy.PARTITION);
+    final RegionAttributes<Object, Object> rAttributes2 = af2.create();
+    
+    c.createRegion(ORDER_REGION, rAttributes2);
+   
+    // Create region, primitiveKVStore
+    final AttributesFactory<Object, Object> af1 = new AttributesFactory<>();
+    af1.setDataPolicy(DataPolicy.PARTITION);
+    final RegionAttributes<Object, Object> rAttributes = af1.create();
+    
+    c.createRegion(PRIMITIVE_KV_STORE_REGION, rAttributes);
+   
+    RegionFactory<String,Object> rf = c.createRegionFactory(RegionShortcut.REPLICATE);
+    rf.setDataPolicy(DataPolicy.EMPTY);
+    rf.setCacheLoader(new SimpleCacheLoader());
+    rf.setCacheWriter(new SampleCacheWriter());
+    rf.create(EMPTY_REGION);
+    
+    // Register functions here
+    FunctionService.registerFunction(new GetAllEntries());
+    FunctionService.registerFunction(new GetRegions());
+    FunctionService.registerFunction(new PutKeyFunction());
+    FunctionService.registerFunction(new GetDeliveredOrders());
+    FunctionService.registerFunction(new AddFreeItemToOrders());
+  }
+
+  @Override
+  public void tearDown() {
+    // shutdown and clean up the manager node.
+    //this.c.close();
+    ServerLauncher.getInstance().stop();
+  }
+  
+  private HttpHeaders setAcceptAndContentTypeHeaders() {
+    List<MediaType> acceptableMediaTypes = new ArrayList<>();
+    acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
+
+    HttpHeaders headers = new HttpHeaders();
+    headers.setAccept(acceptableMediaTypes);
+    headers.setContentType(MediaType.APPLICATION_JSON);
+    return headers;
+  }
+
+ 
+  public void testCreateAsJson() { 
+    executeQueryTestCases();
+  }
+    
+  private void validateGetAllResult(int index, ResponseEntity<String> result){
+    if(index == 27  || index == 29  || index == 30) {
+      try {
+        new JSONObject(result.getBody()).getJSONArray("customers");
+      } catch (JSONException e) {
+        fail("Caught JSONException in validateGetAllResult :: " + e.getMessage());
+      }
+    }
+  }
+  
+  private void verifyRegionSize(int index, ResponseEntity<String> result) {
+    
+    if(index == 59 ) {
+      HttpHeaders headers = result.getHeaders();
+      String value = headers.getFirst("Resource-Count");
+      assertEquals(Integer.parseInt(value), 55);
+    }
+  }
+  
+  private void validateQueryResult(int index, ResponseEntity<String> result){
+    
+    if(Query_URL_INDEXS.contains(index)) {
+      queryResultByIndex = new HashMap<>();
+      initializeQueryTestData();  
+      QueryResultData queryResult =  queryResultByIndex.get(index);   
+
+      //Check whether received response contains expected query IDs.
+      if(index == 45 ) { 
+        
+        try {
+          JSONObject jsonObject = new JSONObject(result.getBody());
+          JSONArray jsonArray = new JSONArray(jsonObject.get("queries").toString());
+          
+          for (int i=0; i< jsonArray.length(); i++) {  
+            assertTrue("PREPARE_PARAMETERIZED_QUERY: function IDs are not matched", queryResult.getResult().contains(jsonArray.getJSONObject(i).getString("id")));
+          }
+        } catch (JSONException e) {
+          fail("Caught JSONException in validateQueryResult :: " + e.getMessage());
+        }
+      }
+      else if (index == 46 || index == 47 || index == 48) {
+        
+        JSONArray jsonArray;
+        try {
+          jsonArray = new JSONArray(result.getBody());
+          //verify query result size
+          assertEquals(queryResult.getResultSize(), jsonArray.length());
+        } catch (JSONException e) {
+          fail("Caught JSONException in validateQueryResult :: " + e.getMessage());
+        }
+        
+      }
+        
+    }
+  }
+  
+  private String addExpectedException (int index) {
+  
+    String expectedEx =  "appears to have started a thread named";
+    if (index == 4 || index == 5 || index == 24) {
+      expectedEx = "java.lang.UnsupportedOperationException";
+      c.getLogger().info("<ExpectedException action=add>" + expectedEx + "</ExpectedException>");
+      return expectedEx;
+    } else if (index == 7) {
+      expectedEx = "com.gemstone.gemfire.cache.TimeoutException";
+      c.getLogger().info("<ExpectedException action=add>" + expectedEx + "</ExpectedException>");
+      return expectedEx;
+    } else if (index == 11 || index == 15) {
+      expectedEx = "com.gemstone.gemfire.cache.CacheWriterException";
+      c.getLogger().info("<ExpectedException action=add>" + expectedEx + "</ExpectedException>");
+      return expectedEx;
+    }else if (index == 19) {
+      expectedEx = "java.lang.IllegalArgumentException";
+      c.getLogger().info("<ExpectedException action=add>" + expectedEx + "</ExpectedException>");
+      return expectedEx;
+    }else if (index == 38 || index == 41 ) {
+      expectedEx = "com.gemstone.gemfire.cache.RegionDestroyedException";
+      c.getLogger().info("<ExpectedException action=add>" + expectedEx + "</ExpectedException>");
+      return expectedEx;
+    }
+    
+    return expectedEx;
+    
+  }
+  private void executeQueryTestCases() {
+
+    HttpHeaders headers = setAcceptAndContentTypeHeaders();
+    HttpEntity<Object> entity;
+    
+    int totalRequests = TEST_DATA.length;
+    String expectedEx = null;
+      
+      for (int index=0; index < totalRequests; index++) { 
+      //Debug code
+      /*
+      c.getLogger().info("-------------------------------");
+      c.getLogger().info("Index:" + index+ " " +  TEST_DATA[index][METHOD_INDEX] + " " + TEST_DATA[index][URL_INDEX]);
+                 
+       if(index == 50){
+         System.out.println("Debug Here...!!");
+       }
+       */
+       try {    
+          expectedEx = addExpectedException(index);
+          final String restRequestUrl = createRestURL(this.baseURL, TEST_DATA[index][URL_INDEX]);  
+          
+          entity = new HttpEntity<>(TEST_DATA[index][REQUEST_BODY_INDEX], headers);
+          ResponseEntity<String> result = RestTestUtils.getRestTemplate().exchange(
+              restRequestUrl,
+              (HttpMethod)TEST_DATA[index][METHOD_INDEX], entity, String.class);
+        
+          validateGetAllResult(index, result);
+          validateQueryResult(index, result);
+          
+          assertEquals(result.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
+          assertEquals(result.hasBody(), ((Boolean)TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
+          
+          verifyRegionSize(index, result);
+          //TODO:
+          //verify location header
+          
+        } catch (HttpClientErrorException e) {
+          
+          if( VALID_409_URL_INDEXS.contains(index)) { 
+            //create-409, conflict testcase. [create on already existing key]
+            
+            assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
+            assertEquals(StringUtils.hasText(e.getResponseBodyAsString()),((Boolean)TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
+            
+          }else if (VALID_400_URL_INDEXS.contains(index)) { 
+            // 400, Bad Request testcases. [create with malformed Json]
+            
+            assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
+            assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean)TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
+            
+          }
+          else if(VALID_404_URL_INDEXS.contains(index) ) { 
+            // create-404, Not Found testcase. [create on not-existing region]
+            
+            assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
+            assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean)TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
+           
+          }
+          else if(VALID_405_URL_INDEXS.contains(index) ) { 
+            // create-404, Not Found testcase. [create on not-existing region]
+            
+            assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
+            assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean)TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
+          }
+          else {
+          fail( "Index:" + index+ " " +  TEST_DATA[index][METHOD_INDEX] + " " + TEST_DATA[index][URL_INDEX] + " should not have thrown exception ");
+          }
+          
+        }catch (HttpServerErrorException se) { 
+          //index=4, create- 500, INTERNAL_SERVER_ERROR testcase. [create on Region with DataPolicy=Empty set]
+          //index=7, create- 500, INTERNAL_SERVER_ERROR testcase. [Get, attached cache loader throws Timeout exception]
+          //index=11, put- 500, [While doing R.put, CacheWriter.beforeCreate() has thrown CacheWriterException]
+          //.... and more test cases
+          assertEquals(se.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
+          assertEquals(StringUtils.hasText(se.getResponseBodyAsString()), ((Boolean)TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
+          
+        }
+        catch (Exception e) {
+          throw new RuntimeException("caught Exception in executeQueryTestCases " + "Index:" + index+ " " +  TEST_DATA[index][METHOD_INDEX] + " " + TEST_DATA[index][URL_INDEX] + " :: Unexpected ERROR...!!", e);
+        }finally {
+          c.getLogger().info("<ExpectedException action=remove>" + expectedEx + "</ExpectedException>");
+        }
+        
+      } 
+    
+  }
+  
+}
+
+class SimpleCacheLoader implements CacheLoader<String, Object>, Declarable {
+	  
+  public Object load(LoaderHelper helper) {
+    //throws TimeoutException  
+    throw new TimeoutException("Could not load, Request Timedout...!!");
+  }
+  public void close() {  
+  
+  }
+  @Override
+  public void init(Properties props) {
+    
+  }
+}
+
+class SampleCacheWriter  implements CacheWriter<String, Object> {
+
+  @Override
+  public void close() { }
+
+  @Override
+  public void beforeUpdate(EntryEvent event) throws CacheWriterException { }
+
+  @Override
+  public void beforeCreate(EntryEvent event) throws CacheWriterException {
+    throw new CacheWriterException("Put request failed as gemfire has thrown error...!!");
+  }
+
+  @Override
+  public void beforeDestroy(EntryEvent event) throws CacheWriterException {
+    throw new RegionDestroyedException("Region has been destroyed already...!!", "dummyRegion");
+  }
+
+  @Override
+  public void beforeRegionDestroy(RegionEvent event) throws CacheWriterException { }
+
+  @Override
+  public void beforeRegionClear(RegionEvent event) throws CacheWriterException { } 
+}
+
+enum QueryType {LIST_ALL_NAMED_QUERY, EXECUTE_NAMED_QUERY, EXECUTE_ADHOC_QUERY }
+
+class QueryResultData
+{
+  private int queryIndex;
+  private QueryType type; 
+  private int resultSize;
+  private List<String> result;
+  
+  public QueryResultData() {
+  }
+
+  @SuppressWarnings("unused")
+  public QueryResultData(int index, QueryType type, int size, List<String> result){
+    this.queryIndex = index;
+    this.type = type;
+    this.resultSize = size;
+    this.result = result;
+  }
+
+  public QueryType getType() {
+    return type;
+  }
+
+  public void setType(QueryType type) {
+    this.type = type;
+  }
+
+  public int getQueryIndex() {
+    return queryIndex;
+  }
+
+  public void setQueryIndex(int queryIndex) {
+    this.queryIndex = queryIndex;
+  }
+
+  public int getResultSize() {
+    return resultSize;
+  }
+
+  public void setResultSize(int resultSize) {
+    this.resultSize = resultSize;
+  }
+
+  public List<String> getResult() {
+    return result;
+  }
+
+  public void setResult(List<String> result) {
+    this.result = result;
+  }
+  
+}


[05/11] incubator-geode git commit: adding unit tests for REST API

Posted by kl...@apache.org.
adding unit tests for REST API

A number of unit tests were still sitting in the work queue to be moved to
open-source including all of the REST API tests.  This change set shows the
build changes and AgentUtil changes needed to accomodate the new tests but
does not show the new tests.  The tests are being added to the
geode-assembly project, and all of the support classes in geode-core's
com.gemstone.gemfire.rest.internal.web.controllers package are being moved
to that project.

The tests will not run in Eclipse since a WAR file is not being created by
the Eclipse projects.  I've opened a JIRA ticket about that.


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

Branch: refs/heads/feature/GEODE-953
Commit: 9b55879e872a52282b10a279cd8e9aa9669147ef
Parents: 5f98f31
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Thu Feb 25 15:46:31 2016 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Thu Feb 25 15:49:13 2016 -0800

----------------------------------------------------------------------
 geode-assembly/build.gradle                     |    3 +
 .../internal/web/RestInterfaceJUnitTest.java    |  442 +++++
 .../web/controllers/AddFreeItemToOrders.java    |  153 ++
 .../rest/internal/web/controllers/Customer.java |  109 ++
 .../internal/web/controllers/DateTimeUtils.java |   40 +
 .../rest/internal/web/controllers/Gender.java   |   30 +
 .../internal/web/controllers/GetAllEntries.java |   68 +
 .../web/controllers/GetDeliveredOrders.java     |  106 ++
 .../internal/web/controllers/GetRegions.java    |   76 +
 .../web/controllers/GetValueForKey.java         |   77 +
 .../rest/internal/web/controllers/Item.java     |  160 ++
 .../rest/internal/web/controllers/Order.java    |  189 ++
 .../rest/internal/web/controllers/Person.java   |  185 ++
 .../web/controllers/PutKeyFunction.java         |   63 +
 ...stAPIOnRegionFunctionExecutionDUnitTest.java |  617 +++++++
 .../web/controllers/RestAPITestBase.java        |  133 ++
 .../RestAPIsAndInterOpsDUnitTest.java           |  915 ++++++++++
 ...tAPIsOnGroupsFunctionExecutionDUnitTest.java |  306 ++++
 ...APIsOnMembersFunctionExecutionDUnitTest.java |  328 ++++
 .../RestAPIsQueryAndFEJUnitTest.java            | 1715 ++++++++++++++++++
 .../controllers/RestAPIsWithSSLDUnitTest.java   |  653 +++++++
 .../internal/web/controllers/RestTestUtils.java |  110 ++
 .../gemfire/management/internal/AgentUtil.java  |    0
 .../web/controllers/AddFreeItemToOrders.java    |  153 --
 .../rest/internal/web/controllers/Customer.java |  109 --
 .../internal/web/controllers/DateTimeUtils.java |   40 -
 .../rest/internal/web/controllers/Gender.java   |   30 -
 .../internal/web/controllers/GetAllEntries.java |   68 -
 .../web/controllers/GetDeliveredOrders.java     |  106 --
 .../internal/web/controllers/GetRegions.java    |   76 -
 .../web/controllers/GetValueForKey.java         |   77 -
 .../rest/internal/web/controllers/Item.java     |  160 --
 .../rest/internal/web/controllers/Order.java    |  189 --
 .../rest/internal/web/controllers/Person.java   |  185 --
 .../web/controllers/PutKeyFunction.java         |   63 -
 .../web/controllers/RestAPITestBase.java        |  123 --
 .../internal/web/controllers/RestTestUtils.java |  110 --
 gradle/dependency-versions.properties           |    2 +
 38 files changed, 6480 insertions(+), 1489 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index cf75135..14febbd 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -58,6 +58,9 @@ dependencies {
   testCompile project(':geode-junit')
   testCompile project(path: ':geode-core', configuration: 'testOutput')
 
+  testCompile 'org.apache.httpcomponents:httpclient:' + project.'httpclient.version'
+  testCompile 'org.apache.httpcomponents:httpcore:' + project.'httpcore.version'
+
   testRuntime files("${System.getProperty('java.home')}/../lib/tools.jar")
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
new file mode 100644
index 0000000..a1c843f
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
@@ -0,0 +1,442 @@
+package com.gemstone.gemfire.rest.internal.web;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.annotation.Resource;
+
+import com.fasterxml.jackson.core.JsonParser.Feature;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionService;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.util.IOUtils;
+import com.gemstone.gemfire.management.internal.AgentUtil;
+import com.gemstone.gemfire.pdx.PdxInstance;
+import com.gemstone.gemfire.pdx.PdxReader;
+import com.gemstone.gemfire.pdx.PdxSerializable;
+import com.gemstone.gemfire.pdx.PdxWriter;
+import com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.util.Assert;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.ResponseErrorHandler;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * The GemFireRestInterfaceTest class is a test suite of test cases testing the contract and functionality of the
+ * GemFire Developer REST API, mixing Java clients, this test GemFire's Cache Region API, along with
+ * a REST-based client, also this test using Spring's RestTemplate, testing the proper interaction, especially
+ * in the case of an application domain object type having a java.util.Date property.
+ *
+ * @author John Blum
+ * @see org.junit.Test
+ * @see org.junit.runner.RunWith
+ * @see org.springframework.test.context.ContextConfiguration
+ * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
+ * @see org.springframework.web.client.RestTemplate
+ * @see com.gemstone.gemfire.cache.Cache
+ * @see com.gemstone.gemfire.cache.Region
+ * @see com.gemstone.gemfire.pdx.PdxInstance
+ * @see com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer
+ * @since 1.0.0
+ */
+//@RunWith(SpringJUnit4ClassRunner.class)
+//@ContextConfiguration
+@SuppressWarnings("unused")
+@Category(IntegrationTest.class)
+public class RestInterfaceJUnitTest {
+
+  protected static int DEFAULT_HTTP_SERVICE_PORT = 8189;
+
+  protected static final String REST_API_SERVICE_ENDPOINT = "http://localhost:%1$d/gemfire-api/v1/%2$s/%3$s";
+  protected static final String UTF_8 = "UTF-8";
+
+  @Autowired
+  private Cache gemfireCache;
+
+  @Autowired
+  private ObjectMapper objectMapper;
+
+  @Resource(name = "gemfireProperties")
+  private Properties gemfireProperties;
+
+  @Resource(name = "People")
+  private Region<String, Object> people;
+
+  @Before
+  public void setupGemFire() {
+    AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
+    if (agentUtil.findWarLocation("geode-web-api") == null) {
+      fail("unable to locate geode-web-api WAR file");
+    }
+
+    if (gemfireCache == null) {
+      gemfireProperties = (gemfireProperties != null ? gemfireProperties : new Properties());
+
+      gemfireCache = new CacheFactory()
+        //.setPdxSerializer(new ReflectionBasedAutoSerializer(Person.class.getPackage().getName().concat(".*")))
+        .setPdxSerializer(new ReflectionBasedAutoSerializer(Person.class.getName().replaceAll("\\$", ".")))
+        .setPdxReadSerialized(true)
+        .setPdxIgnoreUnreadFields(false)
+        .set("name", getClass().getSimpleName())
+        .set("mcast-port", "0")
+        .set("log-level", "config")
+        .set("http-service-bind-address", "localhost")
+        .set("http-service-port", String.valueOf(getHttpServicePort()))
+        //.set("http-service-ssl-enabled", "false")
+        .set("start-dev-rest-api", "true")
+        .create();
+
+      RegionFactory<String, Object> peopleRegionFactory = gemfireCache.createRegionFactory();
+
+      peopleRegionFactory.setDataPolicy(DataPolicy.PARTITION);
+      peopleRegionFactory.setKeyConstraint(String.class);
+      peopleRegionFactory.setValueConstraint(Object.class);
+
+      people = peopleRegionFactory.create("People");
+    }
+  }
+
+  @After
+  public void tearDown() {
+    gemfireCache.close();
+  }
+
+  protected synchronized int getHttpServicePort() {
+    try {
+      return Integer.parseInt(StringUtils.trimWhitespace(gemfireProperties.getProperty("http-service-port")));
+    }
+    catch (NumberFormatException ignore) {
+      int httpServicePort = getHttpServicePort(DEFAULT_HTTP_SERVICE_PORT);
+      gemfireProperties.setProperty("http-service-port", String.valueOf(httpServicePort));
+      return httpServicePort;
+    }
+  }
+
+  private int getHttpServicePort(final int defaultHttpServicePort) {
+    int httpServicePort = AvailablePortHelper.getRandomAvailableTCPPort();
+    return (httpServicePort > 1024 && httpServicePort < 65536 ? httpServicePort : defaultHttpServicePort);
+  }
+
+  protected ObjectMapper getObjectMapper() {
+    if (objectMapper == null) {
+      Jackson2ObjectMapperFactoryBean objectMapperFactoryBean = new Jackson2ObjectMapperFactoryBean();
+
+      objectMapperFactoryBean.setFailOnEmptyBeans(true);
+      objectMapperFactoryBean.setFeaturesToEnable(Feature.ALLOW_COMMENTS);
+      objectMapperFactoryBean.setFeaturesToEnable(Feature.ALLOW_SINGLE_QUOTES);
+      objectMapperFactoryBean.setFeaturesToEnable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
+      objectMapperFactoryBean.setFeaturesToDisable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+      objectMapperFactoryBean.setIndentOutput(true);
+      objectMapperFactoryBean.setSimpleDateFormat("MM/dd/yyyy");
+      objectMapperFactoryBean.afterPropertiesSet();
+
+      objectMapper = objectMapperFactoryBean.getObject();
+    }
+
+    return objectMapper;
+  }
+
+  protected Region<String, Object> getPeopleRegion() {
+    assertNotNull("The 'People' Region was not properly initialized!", people);
+    return people;
+  }
+
+  protected String getAdhocQueryRestApiEndpoint(final String query) {
+    return getAdhocQueryRestApiEndpoint(getHttpServicePort(), query);
+  }
+
+  protected String getAdhocQueryRestApiEndpoint(final int httpServicePort, final String query) {
+    return String.format(REST_API_SERVICE_ENDPOINT, httpServicePort, "queries", String.format("adhoc?q=%1$s", query));
+  }
+
+  protected String getRegionGetRestApiEndpoint(final Region<?, ?> region, final String key) {
+    return getRegionGetRestApiEndpoint(getHttpServicePort(), region, key);
+  }
+
+  protected String getRegionGetRestApiEndpoint(final int httpServicePort, final Region<?, ?> region, final String key) {
+    return String.format(REST_API_SERVICE_ENDPOINT, httpServicePort, region.getName(), key);
+  }
+
+  protected Date createDate(final int year, final int month, final int dayOfMonth) {
+    Calendar dateTime = Calendar.getInstance();
+    dateTime.clear();
+    dateTime.set(Calendar.YEAR, year);
+    dateTime.set(Calendar.MONTH, month);
+    dateTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+    return dateTime.getTime();
+  }
+
+  protected Person createPerson(final String firstName, final String lastName) {
+    return createPerson(firstName, lastName, null);
+  }
+
+  protected Person createPerson(final String firstName, final String lastName, final Date birthDate) {
+    return new Person(firstName, lastName, birthDate);
+  }
+
+  protected RestTemplate createRestTemplate() {
+    MappingJackson2HttpMessageConverter httpMessageConverter = new MappingJackson2HttpMessageConverter();
+
+    httpMessageConverter.setObjectMapper(getObjectMapper());
+
+    return setErrorHandler(new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(
+      httpMessageConverter)));
+  }
+
+  private RestTemplate setErrorHandler(final RestTemplate restTemplate) {
+    restTemplate.setErrorHandler(new ResponseErrorHandler() {
+      private final Set<HttpStatus> errorStatuses = new HashSet<>();
+
+      /* non-static */ {
+        errorStatuses.add(HttpStatus.BAD_REQUEST);
+        errorStatuses.add(HttpStatus.UNAUTHORIZED);
+        errorStatuses.add(HttpStatus.FORBIDDEN);
+        errorStatuses.add(HttpStatus.NOT_FOUND);
+        errorStatuses.add(HttpStatus.METHOD_NOT_ALLOWED);
+        errorStatuses.add(HttpStatus.NOT_ACCEPTABLE);
+        errorStatuses.add(HttpStatus.REQUEST_TIMEOUT);
+        errorStatuses.add(HttpStatus.CONFLICT);
+        errorStatuses.add(HttpStatus.REQUEST_ENTITY_TOO_LARGE);
+        errorStatuses.add(HttpStatus.REQUEST_URI_TOO_LONG);
+        errorStatuses.add(HttpStatus.UNSUPPORTED_MEDIA_TYPE);
+        errorStatuses.add(HttpStatus.TOO_MANY_REQUESTS);
+        errorStatuses.add(HttpStatus.INTERNAL_SERVER_ERROR);
+        errorStatuses.add(HttpStatus.NOT_IMPLEMENTED);
+        errorStatuses.add(HttpStatus.BAD_GATEWAY);
+        errorStatuses.add(HttpStatus.SERVICE_UNAVAILABLE);
+      }
+
+      @Override
+      public boolean hasError(final ClientHttpResponse response) throws IOException {
+        return errorStatuses.contains(response.getStatusCode());
+      }
+
+      @Override
+      public void handleError(final ClientHttpResponse response) throws IOException {
+        System.err.printf("%1$d - %2$s%n", response.getRawStatusCode(),
+          response.getStatusText());
+        System.err.println(readBody(response));
+      }
+
+      private String readBody(final ClientHttpResponse response) throws IOException {
+        BufferedReader responseBodyReader = null;
+
+        try {
+          responseBodyReader = new BufferedReader(new InputStreamReader(response.getBody()));
+
+          StringBuilder buffer = new StringBuilder();
+          String line;
+
+          while ((line = responseBodyReader.readLine()) != null) {
+            buffer.append(line).append(System.getProperty("line.separator"));
+          }
+
+          return buffer.toString().trim();
+        }
+        finally {
+          IOUtils.close(responseBodyReader);
+        }
+      }
+    });
+
+    return restTemplate;
+  }
+
+  @Test
+  public void testRegionObjectWithDatePropertyAccessedWithRestApi() throws Exception {
+    String key = "1";
+    Person jonDoe = createPerson("Jon", "Doe", createDate(1977, Calendar.OCTOBER, 31));
+
+    assertTrue(getPeopleRegion().isEmpty());
+
+    getPeopleRegion().put(key, jonDoe);
+
+    assertFalse(getPeopleRegion().isEmpty());
+    assertEquals(1, getPeopleRegion().size());
+    assertTrue(getPeopleRegion().containsKey(key));
+
+    Object jonDoeRef = getPeopleRegion().get(key);
+
+    assertTrue(jonDoeRef instanceof PdxInstance);
+    assertEquals(jonDoe.getClass().getName(), ((PdxInstance) jonDoeRef).getClassName());
+    assertEquals(jonDoe.getFirstName(), ((PdxInstance) jonDoeRef).getField("firstName"));
+    assertEquals(jonDoe.getLastName(), ((PdxInstance) jonDoeRef).getField("lastName"));
+    assertEquals(jonDoe.getBirthDate(), ((PdxInstance) jonDoeRef).getField("birthDate"));
+
+    RestTemplate restTemplate = createRestTemplate();
+
+    Person jonDoeResource = restTemplate.getForObject(getRegionGetRestApiEndpoint(getPeopleRegion(), key), Person.class);
+
+    assertNotNull(jonDoeResource);
+    assertNotSame(jonDoe, jonDoeResource);
+    assertEquals(jonDoe, jonDoeResource);
+
+    /*
+    Object result = runQueryUsingApi(getPeopleRegion().getRegionService(), String.format("SELECT * FROM %1$s",
+      getPeopleRegion().getFullPath()));
+
+    System.out.printf("(OQL Query using API) Person is (%1$s)%n", result);
+    */
+
+    String url = getAdhocQueryRestApiEndpoint(String.format("SELECT * FROM %1$s", getPeopleRegion().getFullPath()));
+
+    System.out.printf("URL (%1$s)%n", url);
+
+    List<?> queryResults = restTemplate.getForObject(url, List.class);
+
+    assertNotNull(queryResults);
+    assertFalse(queryResults.isEmpty());
+    assertEquals(1, queryResults.size());
+
+    jonDoeResource = objectMapper.convertValue(queryResults.get(0), Person.class);
+
+    assertNotNull(jonDoeResource);
+    assertNotSame(jonDoe, jonDoeResource);
+    assertEquals(jonDoe, jonDoeResource);
+  }
+
+  private Object runQueryUsingApi(final RegionService regionService, final String queryString) throws Exception {
+    return regionService.getQueryService().newQuery(queryString).execute();
+  }
+
+  //@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
+  //@JsonIgnoreProperties(ignoreUnknown = true)
+  //@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@type")
+  public static class Person implements PdxSerializable {
+
+    protected static final String DEFAULT_BIRTH_DATE_FORMAT_PATTERN = "MM/dd/yyyy";
+
+    private Date birthDate;
+
+    private String firstName;
+    private String lastName;
+
+    public Person() {
+    }
+
+    public Person(final String firstName, final String lastName) {
+      this(firstName, lastName, null);
+    }
+
+    public Person(final String firstName, final String lastName, final Date birthDate) {
+      setFirstName(firstName);
+      setLastName(lastName);
+      setBirthDate(birthDate);
+    }
+
+    public Date getBirthDate() {
+      return birthDate;
+    }
+
+    public void setBirthDate(final Date birthDate) {
+      Assert.isTrue(birthDate == null || birthDate.compareTo(Calendar.getInstance().getTime()) <= 0,
+        "A Person's date of birth cannot be after today!");
+      this.birthDate = birthDate;
+    }
+
+    public String getFirstName() {
+      return firstName;
+    }
+
+    public void setFirstName(final String firstName) {
+      Assert.hasText(firstName, "The Person must have a first name!");
+      this.firstName = firstName;
+    }
+
+    public String getLastName() {
+      return lastName;
+    }
+
+    public void setLastName(final String lastName) {
+      Assert.hasText(firstName, "The Person must have a last name!");
+      this.lastName = lastName;
+    }
+
+    protected final String format(final Date dateTime) {
+      return format(dateTime, DEFAULT_BIRTH_DATE_FORMAT_PATTERN);
+    }
+
+    protected String format(final Date dateTime, final String dateFormatPattern) {
+      return (dateTime == null ? null : new SimpleDateFormat(StringUtils.hasText(dateFormatPattern) ? dateFormatPattern
+        : DEFAULT_BIRTH_DATE_FORMAT_PATTERN).format(dateTime));
+    }
+
+    @Override
+    public void toData(final PdxWriter writer) {
+      writer.writeString("firstName", getFirstName());
+      writer.writeString("lastName", getLastName());
+      writer.writeDate("birthDate", getBirthDate());
+    }
+
+    @Override
+    public void fromData(final PdxReader reader) {
+      setFirstName(reader.readString("firstName"));
+      setLastName(reader.readString("lastName"));
+      setBirthDate(reader.readDate("birthDate"));
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+      if (obj == this) {
+        return true;
+      }
+
+      if (!(obj instanceof Person)) {
+        return false;
+      }
+
+      Person that = (Person) obj;
+
+      return ObjectUtils.nullSafeEquals(this.getFirstName(), that.getFirstName())
+        && ObjectUtils.nullSafeEquals(this.getLastName(), that.getLastName())
+        && ObjectUtils.nullSafeEquals(this.getBirthDate(), that.getBirthDate());
+    }
+
+    @Override
+    public int hashCode() {
+      int hashValue = 17;
+      hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(getFirstName());
+      hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(getLastName());
+      hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(getBirthDate());
+      return hashValue;
+    }
+
+    @Override
+    public String toString() {
+      return String.format("{ @type = %1$s, firstName = %2$s, lastName = %3$s, birthDate = %4$s }",
+        getClass().getName(), getFirstName(), getLastName(), format(getBirthDate()));
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java
new file mode 100644
index 0000000..c8a2ce3
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java
@@ -0,0 +1,153 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Vector;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+import com.gemstone.gemfire.cache.query.FunctionDomainException;
+import com.gemstone.gemfire.cache.query.NameResolutionException;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.TypeMismatchException;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.pdx.PdxInstance;
+
+/**
+ * Gemfire function to add free items in the existing order
+ * if the total price for that order is greater then the argument
+ * @author Nilkanth Patel
+ */
+
+public class AddFreeItemToOrders implements Function  {
+  
+  public void execute(FunctionContext context) {
+
+    Cache c = null;
+    Region r = null;
+    List<Object> vals = new ArrayList<Object>();
+    List<Object> keys = new ArrayList<Object>();
+    List<Object> argsList = new ArrayList<Object>();
+    Object[] argsArray = null;
+    
+    if (context.getArguments() instanceof Boolean) {
+    
+    } else if (context.getArguments() instanceof String) {
+      String arg = (String) context.getArguments();
+    }else if(context.getArguments() instanceof Vector ) {
+      
+    }else if (context.getArguments() instanceof Object[]) {
+      argsArray = (Object[]) context.getArguments();
+      argsList = Arrays.asList(argsArray);
+    }else {
+      System.out.println("AddFreeItemToOrders : Invalid Arguments");
+    }
+    
+    try {
+      c = CacheFactory.getAnyInstance();
+      ((GemFireCacheImpl)c).getCacheConfig().setPdxReadSerialized(true);
+      r = c.getRegion("orders");
+    } catch (CacheClosedException ex) {
+      vals.add("NoCacheFoundResult");
+      context.getResultSender().lastResult(vals);
+    }
+
+    String oql = "SELECT DISTINCT entry.key FROM /orders.entries entry WHERE entry.value.totalPrice > $1";
+    Object queryArgs[] = new Object[1];
+    queryArgs[0] = argsList.get(0);
+    
+    final Query query = c.getQueryService().newQuery(oql);
+
+    SelectResults result = null;
+    try {
+      result = (SelectResults) query.execute(queryArgs);
+      int resultSize = result.size();
+      
+      if (result instanceof Collection<?>)  
+        for (Object item : result) {
+          keys.add(item);
+        }
+    } catch (FunctionDomainException e) {
+     if(c != null)
+      c.getLogger().info("Caught FunctionDomainException while executing function AddFreeItemToOrders: " + e.getMessage());
+      
+    } catch (TypeMismatchException e) {
+      if(c != null)
+        c.getLogger().info("Caught TypeMismatchException while executing function AddFreeItemToOrders: " + e.getMessage()); 
+    } catch (NameResolutionException e) {
+      if(c != null)
+        c.getLogger().info("Caught NameResolutionException while executing function AddFreeItemToOrders: "  + e.getMessage());
+    } catch (QueryInvocationTargetException e) {
+      if(c != null)
+        c.getLogger().info("Caught QueryInvocationTargetException while executing function AddFreeItemToOrders" + e.getMessage());
+    }
+    
+    //class has to be in classpath.
+    try {
+      Item it = (Item)(argsList.get(1));
+      for(Object key : keys)
+      {
+        Object obj = r.get(key);
+        if(obj instanceof PdxInstance) {
+          PdxInstance pi = (PdxInstance)obj;
+          Order receivedOrder = (Order)pi.getObject();
+          receivedOrder.addItem(it);
+              
+          r.put(key, receivedOrder);
+        }
+      }
+      
+      context.getResultSender().lastResult("success");
+      
+    }catch (ClassCastException e) {
+      
+      context.getResultSender().lastResult("failure");
+    }catch (Exception e) {
+      context.getResultSender().lastResult("failure");
+    }
+    
+  }
+
+  public String getId() {
+    return "AddFreeItemToOrders";
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java
new file mode 100644
index 0000000..93ac63d
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java
@@ -0,0 +1,109 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.Serializable;
+import com.gemstone.gemfire.internal.lang.ObjectUtils;
+
+/**
+ * The Customer class models a customer entity.
+ * <p/>
+ * @author Nilkanth Patel
+ * @since 8.0
+ */
+
+public class Customer implements Serializable {
+
+  private Long customerId;
+  private String firstName;
+  private String lastName;
+
+  public Customer() {
+  }
+
+  public Customer(final Long custId) {
+    this.customerId = custId;
+  }
+
+  public Customer(final Long custId, final String fname, final String lname) {
+    this.customerId = custId;
+    this.firstName = fname;
+    this.lastName = lname;
+  }
+
+  public Long getCustomerId() {
+    return customerId;
+  }
+
+  public void setCustomerId(Long customerId) {
+    this.customerId = customerId;
+  }
+
+  public String getFirstName() {
+    return firstName;
+  }
+
+  public void setFirstName(String firstName) {
+    this.firstName = firstName;
+  }
+
+  public String getLastName() {
+    return lastName;
+  }
+
+  public void setLastName(String lastName) {
+    this.lastName = lastName;
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    if (obj == this) {
+      return true;
+    }
+
+    if (!(obj instanceof Customer)) {
+      return false;
+    }
+
+    final Customer that = (Customer) obj;
+
+    return (ObjectUtils.equals(this.getCustomerId(), that.getCustomerId())
+        && ObjectUtils.equals(this.getLastName(), that.getLastName()) && ObjectUtils
+          .equals(this.getFirstName(), that.getFirstName()));
+  }
+
+  @Override
+  public int hashCode() {
+    int hashValue = 17;
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getCustomerId());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getLastName());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getFirstName());
+    return hashValue;
+  }
+
+  @Override
+  public String toString() {
+    final StringBuilder buffer = new StringBuilder("{ type = ");
+    buffer.append(getClass().getName());
+    buffer.append(", customerId = ").append(getCustomerId());
+    buffer.append(", firstName = ").append(getFirstName());
+    buffer.append(", lastName = ").append(getLastName());
+    buffer.append(" }");
+    return buffer.toString();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java
new file mode 100644
index 0000000..3a92df3
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java
@@ -0,0 +1,40 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateTimeUtils {
+  public static Calendar createCalendar(final int year, final int month, final int day) {
+    final Calendar dateTime = Calendar.getInstance();
+    dateTime.clear();
+    dateTime.set(Calendar.YEAR, year);
+    dateTime.set(Calendar.MONTH, month);
+    dateTime.set(Calendar.DAY_OF_MONTH, day);
+    return dateTime;
+  }
+
+  public static Date createDate(final int year, final int month, final int day) {
+    return createCalendar(year, month, day).getTime();
+  }
+
+  public static String format(final Date dateTime, final String formatPattern) {
+    return (dateTime != null ? new SimpleDateFormat(formatPattern).format(dateTime) : null);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java
new file mode 100644
index 0000000..9b00108
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java
@@ -0,0 +1,30 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+/**
+ * The Gender enum is a enumeration of genders (sexes).
+ * <p/>
+ * @author Nilkanth Patel, John Blum
+ * @since 8.0
+ */
+
+@SuppressWarnings("unused")
+public enum Gender {
+  FEMALE,
+  MALE
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java
new file mode 100644
index 0000000..cb85687
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java
@@ -0,0 +1,68 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+
+/**
+ * The GetAllEntries is function that will return a map as a result of its execution.
+ * <p/>
+ * @author Nilkanth Patel
+ * @since 8.0
+ */
+
+public class GetAllEntries implements Function {
+
+  @Override
+  public void execute(FunctionContext context) {
+    Map<String, String> myMap = new HashMap();
+    myMap.put("k11", "v1");
+    myMap.put("k12", "v2");
+    myMap.put("k13", "v3");
+    myMap.put("k14", "v4");
+    myMap.put("k15", "v5");
+     
+    //return map as a function result
+    context.getResultSender().lastResult(myMap);
+  }
+
+  @Override
+  public String getId() {
+    return "GetAllEntries";
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java
new file mode 100644
index 0000000..3a150a3
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java
@@ -0,0 +1,106 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+import com.gemstone.gemfire.cache.query.FunctionDomainException;
+import com.gemstone.gemfire.cache.query.NameResolutionException;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.TypeMismatchException;
+
+
+/**
+* The GetDeliveredOrders class is a gemfire function that gives details about delivered orders.
+* <p/>
+* @author Nilkanth Patel
+* @since 8.0
+*/
+
+public class GetDeliveredOrders  implements Function {
+  public void execute(FunctionContext context) {
+    
+    Cache c = null;
+    ArrayList<Object> vals = new ArrayList<Object>();
+    try {
+      c = CacheFactory.getAnyInstance();
+    } catch (CacheClosedException ex) {
+      vals.add("NoCacheFoundResult");
+      context.getResultSender().lastResult(vals);
+    }
+    
+    String oql = "SELECT o.purchaseOrderNo, o.deliveryDate  FROM /orders o WHERE o.deliveryDate != NULL";
+    final Query query = c.getQueryService().newQuery(oql);
+   
+    SelectResults result = null;
+    try {
+      result = (SelectResults) query.execute();
+      int resultSize = result.size();
+      
+      if(result instanceof Collection<?>)
+        for(Object item : result){
+          vals.add(item);
+        }
+    } catch (FunctionDomainException e) {
+      if(c != null)
+        c.getLogger().info("Caught FunctionDomainException while executing function GetDeliveredOrders: " + e.getMessage());
+        
+    } catch (TypeMismatchException e) {
+      if(c != null)
+        c.getLogger().info("Caught TypeMismatchException while executing function GetDeliveredOrders: " + e.getMessage());
+      
+    } catch (NameResolutionException e) {
+      if(c != null)
+        c.getLogger().info("Caught NameResolutionException while executing function GetDeliveredOrders: " + e.getMessage());
+      
+    } catch (QueryInvocationTargetException e) {
+      if(c != null)
+        c.getLogger().info("Caught QueryInvocationTargetException while executing function GetDeliveredOrders: " + e.getMessage());
+      
+    }
+    
+    context.getResultSender().lastResult(vals);
+  }
+
+  public String getId() {
+    return "GetDeliveredOrders";
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java
new file mode 100644
index 0000000..d9e039b
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java
@@ -0,0 +1,76 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+
+/**
+* The GetRegions class is an gemfire function that gives data about available regions.
+* <p/>
+* @author Nilkanth Patel
+* @since 8.0
+*/
+
+public class GetRegions implements Function  {
+
+  public void execute(FunctionContext context) {
+    
+    ArrayList<String> vals = new ArrayList<String>();
+    
+    Cache c = null;
+    try {
+      c = CacheFactory.getAnyInstance();
+    } catch (CacheClosedException ex) {
+      vals.add("NoCacheResult");
+      context.getResultSender().lastResult(vals);
+    }
+
+    final Set<Region<?, ?>> regionSet = c.rootRegions();
+    for (Region<?, ?> r : regionSet) {
+      vals.add(r.getName());
+    }
+    
+    context.getResultSender().lastResult(vals);
+  }
+
+  public String getId() {
+    return "GetRegions";
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+};

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java
new file mode 100644
index 0000000..25e87b6
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java
@@ -0,0 +1,77 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+
+public class GetValueForKey implements Function {
+  
+  @Override
+  public void execute(FunctionContext context) {  
+    Object args = context.getArguments();
+    
+    Cache cache = null;
+    
+    try{
+      cache = CacheFactory.getAnyInstance();
+      
+      if(args.toString().equalsIgnoreCase("1") ){
+        Region<String, Object> r = cache.getRegion("Products");
+        Object result = r.get("1");
+        context.getResultSender().lastResult(result);
+      
+      }else if(args.toString().equalsIgnoreCase("2")){
+        Region<String, Object> r = cache.getRegion("People");
+        Object result = r.get("2");
+        context.getResultSender().lastResult(result);      
+      }else{
+        //Default case
+        int i=10;
+        context.getResultSender().lastResult(i);
+      }
+    }catch(CacheClosedException e){
+      context.getResultSender().lastResult("Error: CacheClosedException");
+    }
+    
+  }
+
+  @Override
+  public String getId() {    
+    return "GetValueForKey";
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }      
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java
new file mode 100644
index 0000000..450ffda
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java
@@ -0,0 +1,160 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.Serializable;
+
+import com.gemstone.gemfire.internal.lang.ObjectUtils;
+import com.gemstone.gemfire.pdx.PdxReader;
+import com.gemstone.gemfire.pdx.PdxSerializable;
+import com.gemstone.gemfire.pdx.PdxWriter;
+
+/**
+ * The Item class models item entity in the real world.
+ * <p/>
+ * @author Nilkanth Patel
+ * @since 8.0
+ */
+
+
+public class Item implements PdxSerializable {
+
+  private Long itemNo;
+  private String description;
+  private int quantity;
+  private float unitPrice;
+  private float totalPrice;
+
+  public Long getItemNo() {
+    return itemNo;
+  }
+
+  public void setItemNo(Long itemNo) {
+    this.itemNo = itemNo;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public int getQuantity() {
+    return quantity;
+  }
+
+  public void setQuantity(int quantity) {
+    this.quantity = quantity;
+  }
+
+  public float getUnitPrice() {
+    return unitPrice;
+  }
+
+  public void setUnitPrice(final float unitprice) {
+    this.unitPrice = unitprice;
+  }
+
+  public float getTotalPrice() {
+    return totalPrice;
+  }
+
+  public void setTotalPrice(final float totalprice) {
+    this.totalPrice = totalprice;
+  }
+
+  public Item() {
+
+  }
+
+  public Item(final Long itemNumber) {
+    this.itemNo = itemNumber;
+  }
+
+  public Item(final Long itemNumber, final String desc, final int qty, final float uprice, final float tprice) {
+    this.itemNo = itemNumber;
+    this.description = desc;
+    this.quantity = qty;
+    this.unitPrice = uprice;
+    this.totalPrice = tprice;
+  }
+  
+  @Override
+  public boolean equals(final Object obj) {
+    if (obj == this) {
+      return true;
+    }
+
+    if (!(obj instanceof Item)) {
+      return false;
+    }
+
+    final Item that = (Item) obj;
+
+    return (ObjectUtils.equals(this.getItemNo(), that.getItemNo())
+        && ObjectUtils.equals(this.getDescription(), that.getDescription())
+        && ObjectUtils.equals(this.getQuantity(), that.getQuantity())
+        && ObjectUtils.equals(this.getQuantity(), that.getUnitPrice())
+        && ObjectUtils.equals(this.getQuantity(), that.getTotalPrice()));
+  }
+
+  @Override
+  public int hashCode() {
+    int hashValue = 17;
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getItemNo());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getDescription());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getQuantity());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getUnitPrice());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getTotalPrice());
+    return hashValue;
+  }
+
+  @Override
+  public String toString() {
+    final StringBuilder buffer = new StringBuilder("{ type = ");
+    buffer.append(getClass().getName());
+    buffer.append(", itemNo = ").append(getItemNo());
+    buffer.append(", description = ").append(getDescription());
+    buffer.append(", quantity = ").append(getQuantity());
+    buffer.append(", unitPrice = ").append(getUnitPrice());
+    buffer.append(", totalPrice = ").append(getTotalPrice());
+    buffer.append(" }");
+    return buffer.toString();
+  }
+
+  @Override
+  public void toData(PdxWriter writer) {
+    writer.writeLong("itemNo", itemNo);
+    writer.writeString("description", description);
+    writer.writeInt("quantity", quantity);
+    writer.writeFloat("unitPrice", unitPrice);
+    writer.writeFloat("totalPrice", totalPrice);
+  }
+
+  @Override
+  public void fromData(PdxReader reader) {
+    itemNo = reader.readLong("itemNo");
+    description = reader.readString("description");
+    quantity = reader.readInt("quantity");
+    unitPrice = reader.readFloat("unitPrice");
+    totalPrice = reader.readFloat("totalPrice");
+    
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java
new file mode 100644
index 0000000..34aefb2
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java
@@ -0,0 +1,189 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.gemstone.gemfire.pdx.PdxReader;
+import com.gemstone.gemfire.pdx.PdxSerializable;
+import com.gemstone.gemfire.pdx.PdxWriter;
+
+/**
+* The Order class is an abstraction modeling a order.
+* <p/>
+* @author Nilkanth Patel
+* @since 8.0
+*/
+
+public class Order implements PdxSerializable {
+  
+  private Long purchaseOrderNo;
+  private Long customerId;
+  private String description;
+  private Date orderDate;
+  private Date deliveryDate;
+  private String contact;
+  private String email;
+  private String phone;
+  private List<Item> items; 
+  private double totalPrice; 
+
+  public Order() {
+    items = new ArrayList<Item>();
+  }
+
+  public Order(final Long orderNo) {
+    this.purchaseOrderNo = orderNo;
+  }
+
+  public Order(final Long orderNo, final Long custId, final String desc,
+    final Date odate, final Date ddate, final String contact, final String email,
+    final String phone, final List<Item> items, final double tprice) {
+    this.purchaseOrderNo = orderNo;
+    this.customerId = custId;
+    this.description = desc;
+    this.orderDate = odate;
+    this.deliveryDate = ddate;
+    this.contact = contact;
+    this.email = email;
+    this.phone = phone;
+    this.items = items;
+    this.totalPrice = tprice;
+  }
+
+  public void addItem(final Item item) {
+    if (item != null)
+      this.items.add(item);
+  }
+
+  public Long getPurchaseOrderNo() {
+    return purchaseOrderNo;
+  }
+
+  public void setPurchaseOrderNo(Long purchaseOrderNo) {
+    this.purchaseOrderNo = purchaseOrderNo;
+  }
+
+  public Long getCustomerId() {
+    return customerId;
+  }
+
+  public void setCustomerId(Long customerId) {
+    this.customerId = customerId;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public Date getDeliveryDate() {
+    return deliveryDate;
+  }
+
+  public void setDeliveryDate(Date date) {
+    this.deliveryDate = date;
+  }
+
+  public String getContact() {
+    return contact;
+  }
+
+  public void setContact(String contact) {
+    this.contact = contact;
+  }
+
+  public String getEmail() {
+    return email;
+  }
+
+  public void setEmail(String email) {
+    this.email = email;
+  }
+
+  public String getPhone() {
+    return phone;
+  }
+
+  public void setPhone(String phone) {
+    this.phone = phone;
+  }
+
+  public List<Item> getItems() {
+    return items;
+  }
+  
+  public void setItems(List<Item> items) {
+    if(this.items == null)
+      this.items = new ArrayList<Item>();
+    
+    for (Item it : items)
+      this.items.add(it);
+  }
+
+  public Date getOrderDate() {
+    return orderDate;
+  }
+
+  public void setOrderDate(Date orderDate) {
+    this.orderDate = orderDate;
+  }
+
+  public double getTotalPrice() {
+    return totalPrice;
+  }
+
+  public void setTotalPrice(double totalPrice) {
+    this.totalPrice = totalPrice;
+  }
+
+  @Override
+  public void toData(PdxWriter writer) {
+    writer.writeLong("purchaseOrderNo", purchaseOrderNo);
+    writer.writeLong("customerId", customerId);
+    writer.writeString("description", description);
+    writer.writeDate("orderDate", orderDate);
+    writer.writeDate("deliveryDate", deliveryDate);
+    writer.writeString("contact", contact);
+    writer.writeString("email", email);
+    writer.writeString("phone", phone);
+    writer.writeObject("items", items);
+    writer.writeDouble("totalPrice", totalPrice);
+  }
+
+  @Override
+  public void fromData(PdxReader reader) {
+    purchaseOrderNo = reader.readLong("purchaseOrderNo");
+    customerId = reader.readLong("customerId");
+    description = reader.readString("description");
+    orderDate = reader.readDate("orderDate");
+    deliveryDate = reader.readDate("deliveryDate");
+    contact = reader.readString("contact");
+    email = reader.readString("email");
+    phone = reader.readString("phone");
+    items = (List<Item>)reader.readObject("items");
+    totalPrice = reader.readDouble("totalPrice");
+    
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java
new file mode 100644
index 0000000..b5b5459
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java
@@ -0,0 +1,185 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.Date;
+import com.gemstone.gemfire.internal.lang.ObjectUtils;
+import com.gemstone.gemfire.pdx.PdxReader;
+import com.gemstone.gemfire.pdx.PdxSerializable;
+import com.gemstone.gemfire.pdx.PdxWriter;
+
+import java.io.Serializable;
+
+/**
+* The Person class is an abstraction modeling a person.
+* <p/>
+* @author Nilkanth Patel, John Blum
+* @since 8.0
+*/
+@SuppressWarnings("unused")
+public class Person implements PdxSerializable {
+
+  private static final long serialVersionUID = 42108163264l;
+  
+  protected static final String DOB_FORMAT_PATTERN = "MM/dd/yyyy";
+  
+  private  Long id;
+  
+  private Date birthDate;
+  
+  private Gender gender;
+  
+  private String firstName;
+  private String middleName;
+  private String lastName;
+  
+  public Person() {
+  }
+  
+  public Person(final Long id) {
+    this.id = id;
+  }
+  
+  public Person(final String firstName, final String lastName) {
+    this.firstName = firstName;
+    this.lastName = lastName;
+  }
+  
+  public Person(Long id, String fn, String mn, String ln, Date bDate, Gender g) {
+    this.id = id;
+    this.firstName = fn;
+    this.middleName = mn;
+    this.lastName = ln;
+    this.birthDate = bDate;
+    this.gender = g;
+  }
+  
+  public Long getId() {
+    return id;
+  }
+  
+  public void setId(final Long id) {
+    this.id = id;
+  }
+  
+  public String getFirstName() {
+    return firstName;
+  }
+  
+  public void setFirstName(final String firstName) {
+    this.firstName = firstName;
+  }
+  
+  public String getLastName() {
+    return lastName;
+  }
+  
+  public void setLastName(final String lastName) {
+    this.lastName = lastName;
+  }
+  
+  public String getMiddleName() {
+    return middleName;
+  }
+  
+  public void setMiddleName(final String middleName) {
+    this.middleName = middleName;
+  }
+  
+  public Date getBirthDate() {
+    return birthDate;
+  }
+  
+  public void setBirthDate(final Date birthDate) {
+    this.birthDate = birthDate;
+  }
+  
+  public Gender getGender() {
+    return gender;
+  }
+  
+  public void setGender(final Gender gender) {
+    this.gender = gender;
+  }
+  
+  @Override
+  public boolean equals(final Object obj) {
+    if (obj == this) {
+      return true;
+    }
+  
+    if (!(obj instanceof Person)) {
+      return false;
+    }
+  
+    final Person that = (Person) obj;
+  
+    return (ObjectUtils.equals(this.getId(), that.getId())
+      || (ObjectUtils.equals(this.getBirthDate(), that.getBirthDate())
+      && ObjectUtils.equals(this.getLastName(), that.getLastName())
+      && ObjectUtils.equals(this.getFirstName(), that.getFirstName())));
+  }
+  
+  @Override
+  public int hashCode() {
+    int hashValue = 17;
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getId());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getBirthDate());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getLastName());
+    hashValue = 37 * hashValue + ObjectUtils.hashCode(getFirstName());
+    return hashValue;
+  }
+  
+  @Override
+  public String toString() {
+    final StringBuilder buffer = new StringBuilder("{ type = ");
+    buffer.append(getClass().getName());
+    buffer.append(", id = ").append(getId());
+    buffer.append(", firstName = ").append(getFirstName());
+    buffer.append(", middleName = ").append(getMiddleName());
+    buffer.append(", lastName = ").append(getLastName());
+    buffer.append(", birthDate = ").append(DateTimeUtils.format(getBirthDate(), DOB_FORMAT_PATTERN));
+    buffer.append(", gender = ").append(getGender());
+    buffer.append(" }");
+    return buffer.toString();
+  }
+  
+  @Override
+  public void toData(PdxWriter writer) {
+    writer.writeString("@type", getClass().getName());
+    writer.writeLong("id", id);
+    writer.writeString("firstName", firstName);
+    writer.writeString("middleName", middleName);
+    writer.writeString("lastName", lastName);
+    writer.writeObject("gender", gender);
+    writer.writeDate("birthDate", birthDate);
+    
+  }
+  
+  @Override
+  public void fromData(PdxReader reader) {
+    String type = reader.readString("@type");
+    id = reader.readLong("id");
+    firstName = reader.readString("firstName");
+    middleName = reader.readString("middleName");
+    lastName = reader.readString("lastName");
+    gender = (Gender)reader.readObject("gender");
+    birthDate = reader.readDate("birthDate");
+    
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java
new file mode 100644
index 0000000..e75d9fc
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java
@@ -0,0 +1,63 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
+
+
+/**
+ * Function that puts the value from the argument at the key passed in through
+ * the filter.
+ */
+
+public class PutKeyFunction implements Function {
+
+  private static final String ID = "PutKeyFunction";
+
+  public void execute(FunctionContext context) {
+    RegionFunctionContext regionContext = (RegionFunctionContext)context;
+    Region dataSet = regionContext.getDataSet();
+    Object key = regionContext.getFilter().iterator().next();
+    Object value = regionContext.getArguments();
+    dataSet.put(key, value);
+    context.getResultSender().lastResult(Boolean.TRUE);
+  }
+
+  public String getId() {
+    return ID;
+  }
+
+  public boolean hasResult() {
+    return true;
+  }
+
+  public void init(Properties p) {
+  }
+
+  public boolean optimizeForWrite() {
+    return true;
+  }
+  public boolean isHA() {
+    return true;
+  }
+}
+


[06/11] incubator-geode git commit: GEODE-992: Integrate with Travis CI

Posted by kl...@apache.org.
GEODE-992: Integrate with Travis CI

To assist in debugging, cat the rat file on error.


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

Branch: refs/heads/feature/GEODE-953
Commit: e666a8519ff306821e7af0c619800b492227f1bb
Parents: 9b55879
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Thu Feb 25 16:45:27 2016 -0800
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Thu Feb 25 16:45:27 2016 -0800

----------------------------------------------------------------------
 .travis.yml | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e666a851/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 2edbe6c..327c255 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,3 +25,6 @@ cache:
   directories:
     - $HOME/.gradle/caches/
     - $HOME/.gradle/wrapper/
+
+after_failure:
+  - cat build/reports/rat/rat-report.txt


[02/11] incubator-geode git commit: adding unit tests for REST API

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
new file mode 100644
index 0000000..29aab32
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
@@ -0,0 +1,653 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.KeyStore;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONObject;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.internal.LocatorTestBase;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.management.ManagementTestBase;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.util.test.TestUtil;
+
+/**
+ * 
+ * @author rishim
+ * @since 8.0
+ */
+public class RestAPIsWithSSLDUnitTest extends LocatorTestBase {
+
+  private static final long serialVersionUID = -254776154266339226L;
+
+  private ManagementTestBase helper;
+
+  public static final String PEOPLE_REGION_NAME = "People";
+  
+  private File jks;
+
+  public RestAPIsWithSSLDUnitTest(String name) {
+    super(name);
+    this.helper = new ManagementTestBase(name);
+    this.jks  = findTrustedJKS();
+
+  }
+
+  public void setUp() throws Exception {
+    disconnectAllFromDS();
+    super.setUp();
+  }
+
+  @Override
+  protected final void postTearDownLocatorTestBase() throws Exception {
+    closeInfra();
+    disconnectAllFromDS();
+  }
+
+  private static File findTrustedJKS() {
+    return new File(TestUtil.getResourcePath(RestAPIsWithSSLDUnitTest.class, "/ssl/trusted.keystore"));
+  }
+
+  public String startBridgeServerWithRestServiceOnInVM(final VM vm, final String locators, final String[] regions,
+      final Properties sslProperties, final boolean clusterLevel) {
+
+    SerializableCallable startBridge = new SerializableCallable("Start Bridge ") {
+      public Object call() throws IOException {
+        final String hostName = vm.getHost().getHostName();
+        final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+        startBridgeServer(hostName, serverPort, locators, regions, sslProperties, clusterLevel);
+        String restEndPoint = "https://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+        return restEndPoint;
+
+      }
+    };
+    String endpoint = (String) vm.invoke(startBridge);
+    return endpoint;
+
+  }
+
+  @SuppressWarnings("deprecation")
+  protected int startBridgeServer(String hostName, int restServicerPort, final String locators, final String[] regions,
+      final Properties sslProperties, boolean clusterLevel) {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.MCAST_PORT_NAME, String.valueOf(0));
+    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
+    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(restServicerPort));
+
+    System.setProperty("javax.net.debug", "ssl");
+    configureSSL(props, sslProperties, clusterLevel);
+
+    DistributedSystem ds = getSystem(props);
+    Cache cache = CacheFactory.create(ds);
+    ((GemFireCacheImpl) cache).setReadSerialized(true);
+    AttributesFactory factory = new AttributesFactory();
+
+    factory.setEnableBridgeConflation(true);
+    factory.setDataPolicy(DataPolicy.REPLICATE);
+    RegionAttributes attrs = factory.create();
+    for (int i = 0; i < regions.length; i++) {
+      cache.createRegion(regions[i], attrs);
+    }
+
+    CacheServer server = cache.addCacheServer();
+    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    server.setPort(serverPort);
+    try {
+      server.start();
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    remoteObjects.put(CACHE_KEY, cache);
+    return new Integer(serverPort);
+  }
+
+  public static void doPutsInClientCache() {
+    ClientCache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);
+
+    // put person object
+    final Person person1 = new Person(101L, "Mithali", "Dorai", "Raj", DateTimeUtils.createDate(1982,
+        Calendar.DECEMBER, 4), Gender.FEMALE);
+    final Person person2 = new Person(102L, "Sachin", "Ramesh", "Tendulkar", DateTimeUtils.createDate(1975,
+        Calendar.DECEMBER, 14), Gender.MALE);
+    final Person person3 = new Person(103L, "Saurabh", "Baburav", "Ganguly", DateTimeUtils.createDate(1972,
+        Calendar.AUGUST, 29), Gender.MALE);
+    final Person person4 = new Person(104L, "Rahul", "subrymanyam", "Dravid", DateTimeUtils.createDate(1979,
+        Calendar.MARCH, 17), Gender.MALE);
+    final Person person5 = new Person(105L, "Jhulan", "Chidambaram", "Goswami", DateTimeUtils.createDate(1983,
+        Calendar.NOVEMBER, 25), Gender.FEMALE);
+
+    region.put("1", person1);
+    region.put("2", person2);
+    region.put("3", person3);
+    region.put("4", person4);
+    region.put("5", person5);
+
+    final Person person6 = new Person(101L, "Rahul", "Rajiv", "Gndhi",
+        DateTimeUtils.createDate(1970, Calendar.MAY, 14), Gender.MALE);
+    final Person person7 = new Person(102L, "Narendra", "Damodar", "Modi", DateTimeUtils.createDate(1945,
+        Calendar.DECEMBER, 24), Gender.MALE);
+    final Person person8 = new Person(103L, "Atal", "Bihari", "Vajpayee", DateTimeUtils.createDate(1920,
+        Calendar.AUGUST, 9), Gender.MALE);
+    final Person person9 = new Person(104L, "Soniya", "Rajiv", "Gandhi", DateTimeUtils.createDate(1929, Calendar.MARCH,
+        27), Gender.FEMALE);
+    final Person person10 = new Person(104L, "Priyanka", "Robert", "Gandhi", DateTimeUtils.createDate(1973,
+        Calendar.APRIL, 15), Gender.FEMALE);
+
+    final Person person11 = new Person(104L, "Murali", "Manohar", "Joshi", DateTimeUtils.createDate(1923,
+        Calendar.APRIL, 25), Gender.MALE);
+    final Person person12 = new Person(104L, "Lalkrishna", "Parmhansh", "Advani", DateTimeUtils.createDate(1910,
+        Calendar.JANUARY, 01), Gender.MALE);
+    final Person person13 = new Person(104L, "Shushma", "kumari", "Swaraj", DateTimeUtils.createDate(1943,
+        Calendar.AUGUST, 10), Gender.FEMALE);
+    final Person person14 = new Person(104L, "Arun", "raman", "jetly", DateTimeUtils.createDate(1942, Calendar.OCTOBER,
+        27), Gender.MALE);
+    final Person person15 = new Person(104L, "Amit", "kumar", "shah", DateTimeUtils.createDate(1958, Calendar.DECEMBER,
+        21), Gender.MALE);
+    final Person person16 = new Person(104L, "Shila", "kumari", "Dixit", DateTimeUtils.createDate(1927,
+        Calendar.FEBRUARY, 15), Gender.FEMALE);
+
+    Map<String, Object> userMap = new HashMap<String, Object>();
+    userMap.put("6", person6);
+    userMap.put("7", person7);
+    userMap.put("8", person8);
+    userMap.put("9", person9);
+    userMap.put("10", person10);
+    userMap.put("11", person11);
+    userMap.put("12", person12);
+    userMap.put("13", person13);
+    userMap.put("14", person14);
+    userMap.put("15", person15);
+    userMap.put("16", person16);
+
+    region.putAll(userMap);
+
+    if (cache != null)
+      cache.getLogger().info("Gemfire Cache Client: Puts successfully done");
+
+  }
+
+  private String startInfraWithSSL(final Properties sslProperties, boolean clusterLevel) throws Exception {
+
+    final Host host = Host.getHost(0);
+    VM locator = host.getVM(0);
+    VM manager = host.getVM(1);
+    VM server = host.getVM(2);
+    VM client = host.getVM(3);
+
+    // start locator
+    int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+
+    startLocatorInVM(locator, locatorPort, "");
+
+    // find locators
+    String locators = NetworkUtils.getServerHostName(locator.getHost()) + "[" + locatorPort + "]";
+
+    // start manager (peer cache)
+    int managerPort = startManagerInVM(manager, locators, new String[] { REGION_NAME }, sslProperties);
+
+    // start startBridgeServer With RestService enabled
+    String restEndpoint = startBridgeServerWithRestServiceOnInVM(server, locators, new String[] { REGION_NAME },
+        sslProperties, clusterLevel);
+
+    // create a client cache
+    createClientCacheInVM(client, NetworkUtils.getServerHostName(locator.getHost()), locatorPort);
+
+    // create region in Manager, peer cache and Client cache nodes
+    manager.invoke(() -> RestAPIsWithSSLDUnitTest.createRegionInManager());
+    server.invoke(() -> RestAPIsWithSSLDUnitTest.createRegionInPeerServer());
+    client.invoke(() -> RestAPIsWithSSLDUnitTest.createRegionInClientCache());
+
+    // do some person puts from clientcache
+    client.invoke(() -> RestAPIsWithSSLDUnitTest.doPutsInClientCache());
+
+    return restEndpoint;
+
+  }
+
+  private void closeInfra() throws Exception {
+
+    final Host host = Host.getHost(0);
+    VM locator = host.getVM(0);
+    VM manager = host.getVM(1);
+    VM server = host.getVM(2);
+    VM client = host.getVM(3);
+
+    // stop the client and make sure the bridge server notifies
+    // stopBridgeMemberVM(client);
+    helper.closeCache(locator);
+    helper.closeCache(manager);
+    helper.closeCache(server);
+    helper.closeCache(client);
+  }
+
+  private void createClientCacheInVM(VM vm, final String host, final int port) throws Exception {
+    SerializableRunnable connect = new SerializableRunnable("Start Cache client") {
+      public void run() {
+        // Connect using the GemFire locator and create a Caching_Proxy cache
+        ClientCache c = new ClientCacheFactory().setPdxReadSerialized(true).addPoolLocator(host, port).create();
+
+        Region r = c.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
+      }
+    };
+
+    if (vm == null) {
+      connect.run();
+    } else {
+      vm.invoke(connect);
+    }
+  }
+
+  private void configureSSL(Properties props, Properties sslProperties, boolean clusterLevel) {
+
+    if(clusterLevel){
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_ENABLED_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_KEYSTORE_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_KEYSTORE_PASSWORD_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_KEYSTORE_TYPE_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_PROTOCOLS_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_REQUIRE_AUTHENTICATION_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_TRUSTSTORE_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME) != null) {
+        props.setProperty(DistributionConfig.CLUSTER_SSL_TRUSTSTORE_PASSWORD_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME));
+      }
+
+    }else{
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_NAME));
+      }
+      if (sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME) != null) {
+        props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME,
+            sslProperties.getProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME));
+      }
+
+    }
+    
+   
+  }
+
+  private int startManagerInVM(VM vm, final String locators, final String[] regions, final Properties sslProperties) {
+
+    SerializableCallable connect = new SerializableCallable("Start Manager ") {
+      public Object call() throws IOException {
+        Properties props = new Properties();
+        props.setProperty(DistributionConfig.MCAST_PORT_NAME, String.valueOf(0));
+        props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+        props.setProperty("jmx-manager", "true");
+        props.setProperty("jmx-manager-start", "true");
+        props.setProperty(DistributionConfig.JMX_MANAGER_HTTP_PORT_NAME, "0");
+
+        configureSSL(props, sslProperties, false);
+
+        DistributedSystem ds = getSystem(props);
+        Cache cache = CacheFactory.create(ds);
+        AttributesFactory factory = new AttributesFactory();
+
+        factory.setEnableBridgeConflation(true);
+        factory.setDataPolicy(DataPolicy.REPLICATE);
+        RegionAttributes attrs = factory.create();
+        for (int i = 0; i < regions.length; i++) {
+          cache.createRegion(regions[i], attrs);
+        }
+        CacheServer server = cache.addCacheServer();
+        final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+        server.setPort(serverPort);
+        server.start();
+
+        return new Integer(serverPort);
+      }
+    };
+    Integer port = (Integer) vm.invoke(connect);
+    return port.intValue();
+  }
+
+  public static void createRegionInClientCache() {
+    ClientCache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    ClientRegionFactory<String, Object> crf = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
+    Region<String, Object> region = crf.create(PEOPLE_REGION_NAME);
+
+  }
+
+  public static void createRegionInManager() {
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    RegionFactory<String, Object> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    Region<String, Object> region = rf.create(PEOPLE_REGION_NAME);
+  }
+
+  public static void createRegionInPeerServer() {
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    RegionFactory<String, Object> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    Region<String, Object> region = rf.create(PEOPLE_REGION_NAME);
+  }
+  
+  private static CloseableHttpClient getSSLBasedHTTPClient(String algo) throws Exception {
+    
+    File jks = findTrustedJKS();
+
+    KeyStore clientKeys = KeyStore.getInstance("JKS");
+    clientKeys.load(new FileInputStream(jks.getCanonicalPath()), "password".toCharArray());
+
+    KeyManagerFactory clientKeyManagerFactory = KeyManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+    clientKeyManagerFactory.init(clientKeys, "password".toCharArray());
+    // load server public key
+    KeyStore serverPub = KeyStore.getInstance("JKS");
+    serverPub.load(new FileInputStream(jks.getCanonicalPath()), "password".toCharArray());
+    TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+    trustManagerFactory.init(serverPub);
+
+    SSLContext context = SSLContext.getInstance(algo);
+
+    context.init(clientKeyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(),
+        new java.security.SecureRandom());
+
+    // Host checking is disabled here , as tests might run on multiple hosts and
+    // host entries can not be assumed
+    SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(context,
+        SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+    CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
+
+    return httpclient;
+  }
+
+  private static void validateConnection(String restEndpoint, String algo) {
+
+    try {
+      // 1. Get on key="1" and validate result.
+      {
+        HttpGet get = new HttpGet(restEndpoint + "/People/1");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+
+       
+        CloseableHttpClient httpclient = getSSLBasedHTTPClient(algo);
+        CloseableHttpResponse response = httpclient.execute(get);
+
+        HttpEntity entity = response.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+        String line;
+        StringBuffer str = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          str.append(line);
+        }
+
+        JSONObject jObject = new JSONObject(str.toString());
+
+        assertEquals(jObject.get("id"), 101);
+        assertEquals(jObject.get("firstName"), "Mithali");
+        assertEquals(jObject.get("middleName"), "Dorai");
+        assertEquals(jObject.get("lastName"), "Raj");
+        assertEquals(jObject.get("gender"), Gender.FEMALE.name());
+      }
+
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+  }
+  
+  // Actual Tests starts here.
+
+  public void testSimpleSSL() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME, "JKS");
+    String restEndpoint = startInfraWithSSL(props,false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "SSL");
+  }
+  
+  public void testSSLWithoutKeyStoreType() throws Exception {
+
+   
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+  
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "SSL");
+
+
+  }
+  
+  public void testSSLWithSSLProtocol() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"SSL");
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "SSL");
+
+  }
+  
+  public void testSSLWithTLSProtocol() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"TLS");
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "TLS");
+
+  }
+  
+  public void testSSLWithTLSv11Protocol() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"TLSv1.1");
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "TLSv1.1");
+
+  }
+  
+  public void testSSLWithTLSv12Protocol() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"TLSv1.2");
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "TLSv1.2");
+
+  }
+  
+  public void testWithMultipleProtocol() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"SSL,TLSv1.2");
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "TLSv1.2");
+
+  }
+  
+  public void testSSLWithCipherSuite() throws Exception {
+
+    System.setProperty("javax.net.debug", "ssl");
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"TLSv1.2");
+    
+    SSLContext ssl = SSLContext.getInstance("TLSv1.2");
+    
+    ssl.init(null, null, new java.security.SecureRandom());
+    String[] cipherSuites = ssl.getSocketFactory().getSupportedCipherSuites();
+    
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_CIPHERS_NAME,cipherSuites[0]);
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "TLSv1.2");
+
+  }
+  
+  public void testSSLWithMultipleCipherSuite() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"TLSv1.2");
+    
+    SSLContext ssl = SSLContext.getInstance("TLSv1.2");
+    
+    ssl.init(null, null, new java.security.SecureRandom());
+    String[] cipherSuites = ssl.getSocketFactory().getSupportedCipherSuites();
+    
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_CIPHERS_NAME,cipherSuites[0]+","+cipherSuites[1]);
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "TLSv1.2");
+
+  }
+  
+  
+  public void testMutualAuthentication() throws Exception {
+
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_NAME, jks.getCanonicalPath());
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, "password");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_PROTOCOLS_NAME,"SSL");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION_NAME,"true");
+
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_NAME,jks.getCanonicalPath());
+
+    props.setProperty(DistributionConfig.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME,"password");
+    
+    String restEndpoint = startInfraWithSSL(props, false);
+    RestAPIsWithSSLDUnitTest.validateConnection(restEndpoint, "SSL");
+
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java
new file mode 100644
index 0000000..0406831
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestTestUtils.java
@@ -0,0 +1,110 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.net.URI;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.http.converter.ByteArrayHttpMessageConverter;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.ResourceHttpMessageConverter;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+
+/**
+ * The RestTestUtils class contains core functionality for Spring REST Template
+ * <p/>
+ * 
+ * @author Nilkanth Patel
+ * @see org.springframework.context.ApplicationContext
+ * @see org.springframework.data.gemfire.GemfireTemplate
+ * @since 8.0
+ */
+public class RestTestUtils  {
+
+  public static final String BASE_URL = "http://localhost:8080";
+  public static final String GEMFIRE_REST_API_CONTEXT = "/gemfire-api";
+  public static final String GEMFIRE_REST_API_VERSION = "/v1";
+
+  public static final URI GEMFIRE_REST_API_WEB_SERVICE_URL = URI
+      .create(BASE_URL + GEMFIRE_REST_API_CONTEXT + GEMFIRE_REST_API_VERSION);
+
+  private static RestTemplate restTemplate;
+
+  public static RestTemplate getRestTemplate() {
+    if (restTemplate == null) {
+      restTemplate = new RestTemplate();
+
+      final List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
+
+      messageConverters.add(new ByteArrayHttpMessageConverter());
+      messageConverters.add(new ResourceHttpMessageConverter());
+      messageConverters.add(new StringHttpMessageConverter());
+      messageConverters.add(createMappingJackson2HttpMessageConverter());
+      
+      restTemplate.setMessageConverters(messageConverters);
+    }
+    return restTemplate;
+  }
+
+  public static HttpMessageConverter<Object> createMappingJackson2HttpMessageConverter() {
+    final Jackson2ObjectMapperFactoryBean objectMapperFactoryBean = new Jackson2ObjectMapperFactoryBean();
+
+    objectMapperFactoryBean.setFailOnEmptyBeans(true);
+    objectMapperFactoryBean.setIndentOutput(true);
+    objectMapperFactoryBean.setDateFormat(new SimpleDateFormat("MM/dd/yyyy"));
+    objectMapperFactoryBean
+        .setFeaturesToDisable(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+    objectMapperFactoryBean
+        .setFeaturesToEnable(
+            com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_COMMENTS,
+            com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_SINGLE_QUOTES,
+            com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
+    objectMapperFactoryBean.afterPropertiesSet();
+
+    final MappingJackson2HttpMessageConverter httpMessageConverter = new MappingJackson2HttpMessageConverter();
+    httpMessageConverter.setObjectMapper(objectMapperFactoryBean.getObject());
+    return httpMessageConverter;
+  }
+  
+  /*
+  protected static HttpMessageConverter<Object> createMarshallingHttpMessageConverter() {
+    final Jaxb2Marshaller jaxbMarshaller = new Jaxb2Marshaller();
+
+    jaxbMarshaller.setContextPaths("com.gemstone.gemfire.web.rest.domain",
+        "com.gemstone.gemfire.web.controllers.support");
+    jaxbMarshaller.setMarshallerProperties(Collections.singletonMap(
+        "jaxb.formatted.output", Boolean.TRUE));
+
+    return new MarshallingHttpMessageConverter(jaxbMarshaller);
+  }
+  */
+  
+  public static URI toUri(final String... pathSegments) {
+    return toUri(GEMFIRE_REST_API_WEB_SERVICE_URL, pathSegments);
+  }
+
+  public static URI toUri(final URI baseUrl, final String... pathSegments) {
+    return UriComponentsBuilder.fromUri(baseUrl).pathSegment(pathSegments)
+        .build().toUri();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/main/java/com/gemstone/gemfire/management/internal/AgentUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/AgentUtil.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/AgentUtil.java
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java
deleted file mode 100644
index c8a2ce3..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/AddFreeItemToOrders.java
+++ /dev/null
@@ -1,153 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionContext;
-import com.gemstone.gemfire.cache.query.FunctionDomainException;
-import com.gemstone.gemfire.cache.query.NameResolutionException;
-import com.gemstone.gemfire.cache.query.Query;
-import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.query.TypeMismatchException;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.pdx.PdxInstance;
-
-/**
- * Gemfire function to add free items in the existing order
- * if the total price for that order is greater then the argument
- * @author Nilkanth Patel
- */
-
-public class AddFreeItemToOrders implements Function  {
-  
-  public void execute(FunctionContext context) {
-
-    Cache c = null;
-    Region r = null;
-    List<Object> vals = new ArrayList<Object>();
-    List<Object> keys = new ArrayList<Object>();
-    List<Object> argsList = new ArrayList<Object>();
-    Object[] argsArray = null;
-    
-    if (context.getArguments() instanceof Boolean) {
-    
-    } else if (context.getArguments() instanceof String) {
-      String arg = (String) context.getArguments();
-    }else if(context.getArguments() instanceof Vector ) {
-      
-    }else if (context.getArguments() instanceof Object[]) {
-      argsArray = (Object[]) context.getArguments();
-      argsList = Arrays.asList(argsArray);
-    }else {
-      System.out.println("AddFreeItemToOrders : Invalid Arguments");
-    }
-    
-    try {
-      c = CacheFactory.getAnyInstance();
-      ((GemFireCacheImpl)c).getCacheConfig().setPdxReadSerialized(true);
-      r = c.getRegion("orders");
-    } catch (CacheClosedException ex) {
-      vals.add("NoCacheFoundResult");
-      context.getResultSender().lastResult(vals);
-    }
-
-    String oql = "SELECT DISTINCT entry.key FROM /orders.entries entry WHERE entry.value.totalPrice > $1";
-    Object queryArgs[] = new Object[1];
-    queryArgs[0] = argsList.get(0);
-    
-    final Query query = c.getQueryService().newQuery(oql);
-
-    SelectResults result = null;
-    try {
-      result = (SelectResults) query.execute(queryArgs);
-      int resultSize = result.size();
-      
-      if (result instanceof Collection<?>)  
-        for (Object item : result) {
-          keys.add(item);
-        }
-    } catch (FunctionDomainException e) {
-     if(c != null)
-      c.getLogger().info("Caught FunctionDomainException while executing function AddFreeItemToOrders: " + e.getMessage());
-      
-    } catch (TypeMismatchException e) {
-      if(c != null)
-        c.getLogger().info("Caught TypeMismatchException while executing function AddFreeItemToOrders: " + e.getMessage()); 
-    } catch (NameResolutionException e) {
-      if(c != null)
-        c.getLogger().info("Caught NameResolutionException while executing function AddFreeItemToOrders: "  + e.getMessage());
-    } catch (QueryInvocationTargetException e) {
-      if(c != null)
-        c.getLogger().info("Caught QueryInvocationTargetException while executing function AddFreeItemToOrders" + e.getMessage());
-    }
-    
-    //class has to be in classpath.
-    try {
-      Item it = (Item)(argsList.get(1));
-      for(Object key : keys)
-      {
-        Object obj = r.get(key);
-        if(obj instanceof PdxInstance) {
-          PdxInstance pi = (PdxInstance)obj;
-          Order receivedOrder = (Order)pi.getObject();
-          receivedOrder.addItem(it);
-              
-          r.put(key, receivedOrder);
-        }
-      }
-      
-      context.getResultSender().lastResult("success");
-      
-    }catch (ClassCastException e) {
-      
-      context.getResultSender().lastResult("failure");
-    }catch (Exception e) {
-      context.getResultSender().lastResult("failure");
-    }
-    
-  }
-
-  public String getId() {
-    return "AddFreeItemToOrders";
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java
deleted file mode 100644
index 93ac63d..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Customer.java
+++ /dev/null
@@ -1,109 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.io.Serializable;
-import com.gemstone.gemfire.internal.lang.ObjectUtils;
-
-/**
- * The Customer class models a customer entity.
- * <p/>
- * @author Nilkanth Patel
- * @since 8.0
- */
-
-public class Customer implements Serializable {
-
-  private Long customerId;
-  private String firstName;
-  private String lastName;
-
-  public Customer() {
-  }
-
-  public Customer(final Long custId) {
-    this.customerId = custId;
-  }
-
-  public Customer(final Long custId, final String fname, final String lname) {
-    this.customerId = custId;
-    this.firstName = fname;
-    this.lastName = lname;
-  }
-
-  public Long getCustomerId() {
-    return customerId;
-  }
-
-  public void setCustomerId(Long customerId) {
-    this.customerId = customerId;
-  }
-
-  public String getFirstName() {
-    return firstName;
-  }
-
-  public void setFirstName(String firstName) {
-    this.firstName = firstName;
-  }
-
-  public String getLastName() {
-    return lastName;
-  }
-
-  public void setLastName(String lastName) {
-    this.lastName = lastName;
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    if (obj == this) {
-      return true;
-    }
-
-    if (!(obj instanceof Customer)) {
-      return false;
-    }
-
-    final Customer that = (Customer) obj;
-
-    return (ObjectUtils.equals(this.getCustomerId(), that.getCustomerId())
-        && ObjectUtils.equals(this.getLastName(), that.getLastName()) && ObjectUtils
-          .equals(this.getFirstName(), that.getFirstName()));
-  }
-
-  @Override
-  public int hashCode() {
-    int hashValue = 17;
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getCustomerId());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getLastName());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getFirstName());
-    return hashValue;
-  }
-
-  @Override
-  public String toString() {
-    final StringBuilder buffer = new StringBuilder("{ type = ");
-    buffer.append(getClass().getName());
-    buffer.append(", customerId = ").append(getCustomerId());
-    buffer.append(", firstName = ").append(getFirstName());
-    buffer.append(", lastName = ").append(getLastName());
-    buffer.append(" }");
-    return buffer.toString();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java
deleted file mode 100644
index 3a92df3..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/DateTimeUtils.java
+++ /dev/null
@@ -1,40 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-public class DateTimeUtils {
-  public static Calendar createCalendar(final int year, final int month, final int day) {
-    final Calendar dateTime = Calendar.getInstance();
-    dateTime.clear();
-    dateTime.set(Calendar.YEAR, year);
-    dateTime.set(Calendar.MONTH, month);
-    dateTime.set(Calendar.DAY_OF_MONTH, day);
-    return dateTime;
-  }
-
-  public static Date createDate(final int year, final int month, final int day) {
-    return createCalendar(year, month, day).getTime();
-  }
-
-  public static String format(final Date dateTime, final String formatPattern) {
-    return (dateTime != null ? new SimpleDateFormat(formatPattern).format(dateTime) : null);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java
deleted file mode 100644
index 9b00108..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Gender.java
+++ /dev/null
@@ -1,30 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-/**
- * The Gender enum is a enumeration of genders (sexes).
- * <p/>
- * @author Nilkanth Patel, John Blum
- * @since 8.0
- */
-
-@SuppressWarnings("unused")
-public enum Gender {
-  FEMALE,
-  MALE
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java
deleted file mode 100644
index cb85687..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetAllEntries.java
+++ /dev/null
@@ -1,68 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionContext;
-
-/**
- * The GetAllEntries is function that will return a map as a result of its execution.
- * <p/>
- * @author Nilkanth Patel
- * @since 8.0
- */
-
-public class GetAllEntries implements Function {
-
-  @Override
-  public void execute(FunctionContext context) {
-    Map<String, String> myMap = new HashMap();
-    myMap.put("k11", "v1");
-    myMap.put("k12", "v2");
-    myMap.put("k13", "v3");
-    myMap.put("k14", "v4");
-    myMap.put("k15", "v5");
-     
-    //return map as a function result
-    context.getResultSender().lastResult(myMap);
-  }
-
-  @Override
-  public String getId() {
-    return "GetAllEntries";
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java
deleted file mode 100644
index 3a150a3..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetDeliveredOrders.java
+++ /dev/null
@@ -1,106 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionContext;
-import com.gemstone.gemfire.cache.query.FunctionDomainException;
-import com.gemstone.gemfire.cache.query.NameResolutionException;
-import com.gemstone.gemfire.cache.query.Query;
-import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.query.TypeMismatchException;
-
-
-/**
-* The GetDeliveredOrders class is a gemfire function that gives details about delivered orders.
-* <p/>
-* @author Nilkanth Patel
-* @since 8.0
-*/
-
-public class GetDeliveredOrders  implements Function {
-  public void execute(FunctionContext context) {
-    
-    Cache c = null;
-    ArrayList<Object> vals = new ArrayList<Object>();
-    try {
-      c = CacheFactory.getAnyInstance();
-    } catch (CacheClosedException ex) {
-      vals.add("NoCacheFoundResult");
-      context.getResultSender().lastResult(vals);
-    }
-    
-    String oql = "SELECT o.purchaseOrderNo, o.deliveryDate  FROM /orders o WHERE o.deliveryDate != NULL";
-    final Query query = c.getQueryService().newQuery(oql);
-   
-    SelectResults result = null;
-    try {
-      result = (SelectResults) query.execute();
-      int resultSize = result.size();
-      
-      if(result instanceof Collection<?>)
-        for(Object item : result){
-          vals.add(item);
-        }
-    } catch (FunctionDomainException e) {
-      if(c != null)
-        c.getLogger().info("Caught FunctionDomainException while executing function GetDeliveredOrders: " + e.getMessage());
-        
-    } catch (TypeMismatchException e) {
-      if(c != null)
-        c.getLogger().info("Caught TypeMismatchException while executing function GetDeliveredOrders: " + e.getMessage());
-      
-    } catch (NameResolutionException e) {
-      if(c != null)
-        c.getLogger().info("Caught NameResolutionException while executing function GetDeliveredOrders: " + e.getMessage());
-      
-    } catch (QueryInvocationTargetException e) {
-      if(c != null)
-        c.getLogger().info("Caught QueryInvocationTargetException while executing function GetDeliveredOrders: " + e.getMessage());
-      
-    }
-    
-    context.getResultSender().lastResult(vals);
-  }
-
-  public String getId() {
-    return "GetDeliveredOrders";
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java
deleted file mode 100644
index d9e039b..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetRegions.java
+++ /dev/null
@@ -1,76 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.ArrayList;
-import java.util.Set;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionContext;
-
-/**
-* The GetRegions class is an gemfire function that gives data about available regions.
-* <p/>
-* @author Nilkanth Patel
-* @since 8.0
-*/
-
-public class GetRegions implements Function  {
-
-  public void execute(FunctionContext context) {
-    
-    ArrayList<String> vals = new ArrayList<String>();
-    
-    Cache c = null;
-    try {
-      c = CacheFactory.getAnyInstance();
-    } catch (CacheClosedException ex) {
-      vals.add("NoCacheResult");
-      context.getResultSender().lastResult(vals);
-    }
-
-    final Set<Region<?, ?>> regionSet = c.rootRegions();
-    for (Region<?, ?> r : regionSet) {
-      vals.add(r.getName());
-    }
-    
-    context.getResultSender().lastResult(vals);
-  }
-
-  public String getId() {
-    return "GetRegions";
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-};

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java
deleted file mode 100644
index 25e87b6..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/GetValueForKey.java
+++ /dev/null
@@ -1,77 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionContext;
-
-public class GetValueForKey implements Function {
-  
-  @Override
-  public void execute(FunctionContext context) {  
-    Object args = context.getArguments();
-    
-    Cache cache = null;
-    
-    try{
-      cache = CacheFactory.getAnyInstance();
-      
-      if(args.toString().equalsIgnoreCase("1") ){
-        Region<String, Object> r = cache.getRegion("Products");
-        Object result = r.get("1");
-        context.getResultSender().lastResult(result);
-      
-      }else if(args.toString().equalsIgnoreCase("2")){
-        Region<String, Object> r = cache.getRegion("People");
-        Object result = r.get("2");
-        context.getResultSender().lastResult(result);      
-      }else{
-        //Default case
-        int i=10;
-        context.getResultSender().lastResult(i);
-      }
-    }catch(CacheClosedException e){
-      context.getResultSender().lastResult("Error: CacheClosedException");
-    }
-    
-  }
-
-  @Override
-  public String getId() {    
-    return "GetValueForKey";
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }      
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java
deleted file mode 100644
index 450ffda..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Item.java
+++ /dev/null
@@ -1,160 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.io.Serializable;
-
-import com.gemstone.gemfire.internal.lang.ObjectUtils;
-import com.gemstone.gemfire.pdx.PdxReader;
-import com.gemstone.gemfire.pdx.PdxSerializable;
-import com.gemstone.gemfire.pdx.PdxWriter;
-
-/**
- * The Item class models item entity in the real world.
- * <p/>
- * @author Nilkanth Patel
- * @since 8.0
- */
-
-
-public class Item implements PdxSerializable {
-
-  private Long itemNo;
-  private String description;
-  private int quantity;
-  private float unitPrice;
-  private float totalPrice;
-
-  public Long getItemNo() {
-    return itemNo;
-  }
-
-  public void setItemNo(Long itemNo) {
-    this.itemNo = itemNo;
-  }
-
-  public String getDescription() {
-    return description;
-  }
-
-  public void setDescription(String description) {
-    this.description = description;
-  }
-
-  public int getQuantity() {
-    return quantity;
-  }
-
-  public void setQuantity(int quantity) {
-    this.quantity = quantity;
-  }
-
-  public float getUnitPrice() {
-    return unitPrice;
-  }
-
-  public void setUnitPrice(final float unitprice) {
-    this.unitPrice = unitprice;
-  }
-
-  public float getTotalPrice() {
-    return totalPrice;
-  }
-
-  public void setTotalPrice(final float totalprice) {
-    this.totalPrice = totalprice;
-  }
-
-  public Item() {
-
-  }
-
-  public Item(final Long itemNumber) {
-    this.itemNo = itemNumber;
-  }
-
-  public Item(final Long itemNumber, final String desc, final int qty, final float uprice, final float tprice) {
-    this.itemNo = itemNumber;
-    this.description = desc;
-    this.quantity = qty;
-    this.unitPrice = uprice;
-    this.totalPrice = tprice;
-  }
-  
-  @Override
-  public boolean equals(final Object obj) {
-    if (obj == this) {
-      return true;
-    }
-
-    if (!(obj instanceof Item)) {
-      return false;
-    }
-
-    final Item that = (Item) obj;
-
-    return (ObjectUtils.equals(this.getItemNo(), that.getItemNo())
-        && ObjectUtils.equals(this.getDescription(), that.getDescription())
-        && ObjectUtils.equals(this.getQuantity(), that.getQuantity())
-        && ObjectUtils.equals(this.getQuantity(), that.getUnitPrice())
-        && ObjectUtils.equals(this.getQuantity(), that.getTotalPrice()));
-  }
-
-  @Override
-  public int hashCode() {
-    int hashValue = 17;
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getItemNo());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getDescription());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getQuantity());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getUnitPrice());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getTotalPrice());
-    return hashValue;
-  }
-
-  @Override
-  public String toString() {
-    final StringBuilder buffer = new StringBuilder("{ type = ");
-    buffer.append(getClass().getName());
-    buffer.append(", itemNo = ").append(getItemNo());
-    buffer.append(", description = ").append(getDescription());
-    buffer.append(", quantity = ").append(getQuantity());
-    buffer.append(", unitPrice = ").append(getUnitPrice());
-    buffer.append(", totalPrice = ").append(getTotalPrice());
-    buffer.append(" }");
-    return buffer.toString();
-  }
-
-  @Override
-  public void toData(PdxWriter writer) {
-    writer.writeLong("itemNo", itemNo);
-    writer.writeString("description", description);
-    writer.writeInt("quantity", quantity);
-    writer.writeFloat("unitPrice", unitPrice);
-    writer.writeFloat("totalPrice", totalPrice);
-  }
-
-  @Override
-  public void fromData(PdxReader reader) {
-    itemNo = reader.readLong("itemNo");
-    description = reader.readString("description");
-    quantity = reader.readInt("quantity");
-    unitPrice = reader.readFloat("unitPrice");
-    totalPrice = reader.readFloat("totalPrice");
-    
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java
deleted file mode 100644
index 34aefb2..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Order.java
+++ /dev/null
@@ -1,189 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.gemstone.gemfire.pdx.PdxReader;
-import com.gemstone.gemfire.pdx.PdxSerializable;
-import com.gemstone.gemfire.pdx.PdxWriter;
-
-/**
-* The Order class is an abstraction modeling a order.
-* <p/>
-* @author Nilkanth Patel
-* @since 8.0
-*/
-
-public class Order implements PdxSerializable {
-  
-  private Long purchaseOrderNo;
-  private Long customerId;
-  private String description;
-  private Date orderDate;
-  private Date deliveryDate;
-  private String contact;
-  private String email;
-  private String phone;
-  private List<Item> items; 
-  private double totalPrice; 
-
-  public Order() {
-    items = new ArrayList<Item>();
-  }
-
-  public Order(final Long orderNo) {
-    this.purchaseOrderNo = orderNo;
-  }
-
-  public Order(final Long orderNo, final Long custId, final String desc,
-    final Date odate, final Date ddate, final String contact, final String email,
-    final String phone, final List<Item> items, final double tprice) {
-    this.purchaseOrderNo = orderNo;
-    this.customerId = custId;
-    this.description = desc;
-    this.orderDate = odate;
-    this.deliveryDate = ddate;
-    this.contact = contact;
-    this.email = email;
-    this.phone = phone;
-    this.items = items;
-    this.totalPrice = tprice;
-  }
-
-  public void addItem(final Item item) {
-    if (item != null)
-      this.items.add(item);
-  }
-
-  public Long getPurchaseOrderNo() {
-    return purchaseOrderNo;
-  }
-
-  public void setPurchaseOrderNo(Long purchaseOrderNo) {
-    this.purchaseOrderNo = purchaseOrderNo;
-  }
-
-  public Long getCustomerId() {
-    return customerId;
-  }
-
-  public void setCustomerId(Long customerId) {
-    this.customerId = customerId;
-  }
-
-  public String getDescription() {
-    return description;
-  }
-
-  public void setDescription(String description) {
-    this.description = description;
-  }
-
-  public Date getDeliveryDate() {
-    return deliveryDate;
-  }
-
-  public void setDeliveryDate(Date date) {
-    this.deliveryDate = date;
-  }
-
-  public String getContact() {
-    return contact;
-  }
-
-  public void setContact(String contact) {
-    this.contact = contact;
-  }
-
-  public String getEmail() {
-    return email;
-  }
-
-  public void setEmail(String email) {
-    this.email = email;
-  }
-
-  public String getPhone() {
-    return phone;
-  }
-
-  public void setPhone(String phone) {
-    this.phone = phone;
-  }
-
-  public List<Item> getItems() {
-    return items;
-  }
-  
-  public void setItems(List<Item> items) {
-    if(this.items == null)
-      this.items = new ArrayList<Item>();
-    
-    for (Item it : items)
-      this.items.add(it);
-  }
-
-  public Date getOrderDate() {
-    return orderDate;
-  }
-
-  public void setOrderDate(Date orderDate) {
-    this.orderDate = orderDate;
-  }
-
-  public double getTotalPrice() {
-    return totalPrice;
-  }
-
-  public void setTotalPrice(double totalPrice) {
-    this.totalPrice = totalPrice;
-  }
-
-  @Override
-  public void toData(PdxWriter writer) {
-    writer.writeLong("purchaseOrderNo", purchaseOrderNo);
-    writer.writeLong("customerId", customerId);
-    writer.writeString("description", description);
-    writer.writeDate("orderDate", orderDate);
-    writer.writeDate("deliveryDate", deliveryDate);
-    writer.writeString("contact", contact);
-    writer.writeString("email", email);
-    writer.writeString("phone", phone);
-    writer.writeObject("items", items);
-    writer.writeDouble("totalPrice", totalPrice);
-  }
-
-  @Override
-  public void fromData(PdxReader reader) {
-    purchaseOrderNo = reader.readLong("purchaseOrderNo");
-    customerId = reader.readLong("customerId");
-    description = reader.readString("description");
-    orderDate = reader.readDate("orderDate");
-    deliveryDate = reader.readDate("deliveryDate");
-    contact = reader.readString("contact");
-    email = reader.readString("email");
-    phone = reader.readString("phone");
-    items = (List<Item>)reader.readObject("items");
-    totalPrice = reader.readDouble("totalPrice");
-    
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java
deleted file mode 100644
index b5b5459..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/Person.java
+++ /dev/null
@@ -1,185 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.Date;
-import com.gemstone.gemfire.internal.lang.ObjectUtils;
-import com.gemstone.gemfire.pdx.PdxReader;
-import com.gemstone.gemfire.pdx.PdxSerializable;
-import com.gemstone.gemfire.pdx.PdxWriter;
-
-import java.io.Serializable;
-
-/**
-* The Person class is an abstraction modeling a person.
-* <p/>
-* @author Nilkanth Patel, John Blum
-* @since 8.0
-*/
-@SuppressWarnings("unused")
-public class Person implements PdxSerializable {
-
-  private static final long serialVersionUID = 42108163264l;
-  
-  protected static final String DOB_FORMAT_PATTERN = "MM/dd/yyyy";
-  
-  private  Long id;
-  
-  private Date birthDate;
-  
-  private Gender gender;
-  
-  private String firstName;
-  private String middleName;
-  private String lastName;
-  
-  public Person() {
-  }
-  
-  public Person(final Long id) {
-    this.id = id;
-  }
-  
-  public Person(final String firstName, final String lastName) {
-    this.firstName = firstName;
-    this.lastName = lastName;
-  }
-  
-  public Person(Long id, String fn, String mn, String ln, Date bDate, Gender g) {
-    this.id = id;
-    this.firstName = fn;
-    this.middleName = mn;
-    this.lastName = ln;
-    this.birthDate = bDate;
-    this.gender = g;
-  }
-  
-  public Long getId() {
-    return id;
-  }
-  
-  public void setId(final Long id) {
-    this.id = id;
-  }
-  
-  public String getFirstName() {
-    return firstName;
-  }
-  
-  public void setFirstName(final String firstName) {
-    this.firstName = firstName;
-  }
-  
-  public String getLastName() {
-    return lastName;
-  }
-  
-  public void setLastName(final String lastName) {
-    this.lastName = lastName;
-  }
-  
-  public String getMiddleName() {
-    return middleName;
-  }
-  
-  public void setMiddleName(final String middleName) {
-    this.middleName = middleName;
-  }
-  
-  public Date getBirthDate() {
-    return birthDate;
-  }
-  
-  public void setBirthDate(final Date birthDate) {
-    this.birthDate = birthDate;
-  }
-  
-  public Gender getGender() {
-    return gender;
-  }
-  
-  public void setGender(final Gender gender) {
-    this.gender = gender;
-  }
-  
-  @Override
-  public boolean equals(final Object obj) {
-    if (obj == this) {
-      return true;
-    }
-  
-    if (!(obj instanceof Person)) {
-      return false;
-    }
-  
-    final Person that = (Person) obj;
-  
-    return (ObjectUtils.equals(this.getId(), that.getId())
-      || (ObjectUtils.equals(this.getBirthDate(), that.getBirthDate())
-      && ObjectUtils.equals(this.getLastName(), that.getLastName())
-      && ObjectUtils.equals(this.getFirstName(), that.getFirstName())));
-  }
-  
-  @Override
-  public int hashCode() {
-    int hashValue = 17;
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getId());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getBirthDate());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getLastName());
-    hashValue = 37 * hashValue + ObjectUtils.hashCode(getFirstName());
-    return hashValue;
-  }
-  
-  @Override
-  public String toString() {
-    final StringBuilder buffer = new StringBuilder("{ type = ");
-    buffer.append(getClass().getName());
-    buffer.append(", id = ").append(getId());
-    buffer.append(", firstName = ").append(getFirstName());
-    buffer.append(", middleName = ").append(getMiddleName());
-    buffer.append(", lastName = ").append(getLastName());
-    buffer.append(", birthDate = ").append(DateTimeUtils.format(getBirthDate(), DOB_FORMAT_PATTERN));
-    buffer.append(", gender = ").append(getGender());
-    buffer.append(" }");
-    return buffer.toString();
-  }
-  
-  @Override
-  public void toData(PdxWriter writer) {
-    writer.writeString("@type", getClass().getName());
-    writer.writeLong("id", id);
-    writer.writeString("firstName", firstName);
-    writer.writeString("middleName", middleName);
-    writer.writeString("lastName", lastName);
-    writer.writeObject("gender", gender);
-    writer.writeDate("birthDate", birthDate);
-    
-  }
-  
-  @Override
-  public void fromData(PdxReader reader) {
-    String type = reader.readString("@type");
-    id = reader.readLong("id");
-    firstName = reader.readString("firstName");
-    middleName = reader.readString("middleName");
-    lastName = reader.readString("lastName");
-    gender = (Gender)reader.readObject("gender");
-    birthDate = reader.readDate("birthDate");
-    
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java
deleted file mode 100644
index e75d9fc..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/PutKeyFunction.java
+++ /dev/null
@@ -1,63 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.Properties;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionContext;
-import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
-
-
-/**
- * Function that puts the value from the argument at the key passed in through
- * the filter.
- */
-
-public class PutKeyFunction implements Function {
-
-  private static final String ID = "PutKeyFunction";
-
-  public void execute(FunctionContext context) {
-    RegionFunctionContext regionContext = (RegionFunctionContext)context;
-    Region dataSet = regionContext.getDataSet();
-    Object key = regionContext.getFilter().iterator().next();
-    Object value = regionContext.getArguments();
-    dataSet.put(key, value);
-    context.getResultSender().lastResult(Boolean.TRUE);
-  }
-
-  public String getId() {
-    return ID;
-  }
-
-  public boolean hasResult() {
-    return true;
-  }
-
-  public void init(Properties p) {
-  }
-
-  public boolean optimizeForWrite() {
-    return true;
-  }
-  public boolean isHA() {
-    return true;
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
deleted file mode 100644
index 50965f6..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
+++ /dev/null
@@ -1,123 +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 com.gemstone.gemfire.rest.internal.web.controllers;
-
-import java.util.Properties;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
-
-public class RestAPITestBase extends DistributedTestCase {
-  private static final long serialVersionUID = 1L;
-  public static Cache cache = null;
-  VM vm0 = null;
-  VM vm1 = null;
-  VM vm2 = null;
-  VM vm3 = null;
-  
-  public RestAPITestBase(String name) {
-    super(name);
-  }
-  
-  
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
-    disconnectAllFromDS();
-    Wait.pause(5000);
-    final Host host = Host.getHost(0);
-    vm0 = host.getVM(0);
-    vm1 = host.getVM(1);
-    vm2 = host.getVM(2);
-    vm3 = host.getVM(3);
-  }  
-  
-  /**
-   * close the clients and teh servers
-   */
-  @Override
-  protected final void preTearDown() throws Exception {
-    vm0.invoke(() -> closeCache());
-    vm1.invoke(() -> closeCache());
-    vm2.invoke(() -> closeCache());
-    vm3.invoke(() -> closeCache());
-  }
-
-  /**
-   * close the cache
-   * 
-   */
-  public static void closeCache() {
-    if (cache != null && !cache.isClosed()) {
-      cache.close();
-      cache.getDistributedSystem().disconnect();
-    }
-  }
-  
-  protected static String createCache(VM currentVM) {
-    
-    RestAPITestBase test = new RestAPITestBase(getTestMethodName());
-    
-    final String hostName = currentVM.getHost().getHostName();
-    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    
-    Properties props = new Properties();
-    
-    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
-    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
-    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME,String.valueOf(serverPort));
-    
-
-    InternalDistributedSystem ds = test.getSystem(props);
-    cache = CacheFactory.create(ds);
-    return "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
-    
-  }
-  
-  public static String createCacheWithGroups (VM vm, final String groups, final String regionName ) {
-    RestAPITestBase test = new RestAPITestBase(getTestMethodName());
-    
-    final String hostName = vm.getHost().getHostName(); 
-    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    
-    Properties props = new Properties();
-    
-    if(groups != null) {
-      props.put("groups", groups);
-    }
-    
-    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
-    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
-    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(serverPort));
-    
-    InternalDistributedSystem ds = test.getSystem(props);
-    cache = CacheFactory.create(ds);
-    
-    String restEndPoint =  "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
-    return restEndPoint; 
-  }
-  
-}


[08/11] incubator-geode git commit: Merge remote-tracking branch 'origin/develop' into feature/GEODE-953

Posted by kl...@apache.org.
Merge remote-tracking branch 'origin/develop' into feature/GEODE-953


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

Branch: refs/heads/feature/GEODE-953
Commit: ed5394e35de8f5b4fd59759ec9f2e9f806ba0688
Parents: 247b7a8 3676826
Author: Kirk Lund <kl...@pivotal.io>
Authored: Thu Feb 25 17:09:35 2016 -0800
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Thu Feb 25 17:09:35 2016 -0800

----------------------------------------------------------------------
 .travis.yml                                     |    3 +
 geode-assembly/build.gradle                     |    3 +
 .../internal/web/RestInterfaceJUnitTest.java    |  458 +++++
 .../web/controllers/AddFreeItemToOrders.java    |  153 ++
 .../rest/internal/web/controllers/Customer.java |  109 ++
 .../internal/web/controllers/DateTimeUtils.java |   40 +
 .../rest/internal/web/controllers/Gender.java   |   30 +
 .../internal/web/controllers/GetAllEntries.java |   68 +
 .../web/controllers/GetDeliveredOrders.java     |  106 ++
 .../internal/web/controllers/GetRegions.java    |   76 +
 .../web/controllers/GetValueForKey.java         |   77 +
 .../rest/internal/web/controllers/Item.java     |  160 ++
 .../rest/internal/web/controllers/Order.java    |  189 ++
 .../rest/internal/web/controllers/Person.java   |  185 ++
 .../web/controllers/PutKeyFunction.java         |   63 +
 ...stAPIOnRegionFunctionExecutionDUnitTest.java |  617 +++++++
 .../web/controllers/RestAPITestBase.java        |  133 ++
 .../RestAPIsAndInterOpsDUnitTest.java           |  915 ++++++++++
 ...tAPIsOnGroupsFunctionExecutionDUnitTest.java |  306 ++++
 ...APIsOnMembersFunctionExecutionDUnitTest.java |  328 ++++
 .../RestAPIsQueryAndFEJUnitTest.java            | 1715 ++++++++++++++++++
 .../controllers/RestAPIsWithSSLDUnitTest.java   |  653 +++++++
 .../internal/web/controllers/RestTestUtils.java |  110 ++
 .../gemfire/management/internal/AgentUtil.java  |    0
 .../web/controllers/AddFreeItemToOrders.java    |  153 --
 .../rest/internal/web/controllers/Customer.java |  109 --
 .../internal/web/controllers/DateTimeUtils.java |   40 -
 .../rest/internal/web/controllers/Gender.java   |   30 -
 .../internal/web/controllers/GetAllEntries.java |   68 -
 .../web/controllers/GetDeliveredOrders.java     |  106 --
 .../internal/web/controllers/GetRegions.java    |   76 -
 .../web/controllers/GetValueForKey.java         |   77 -
 .../rest/internal/web/controllers/Item.java     |  160 --
 .../rest/internal/web/controllers/Order.java    |  189 --
 .../rest/internal/web/controllers/Person.java   |  185 --
 .../web/controllers/PutKeyFunction.java         |   63 -
 .../web/controllers/RestAPITestBase.java        |  123 --
 .../internal/web/controllers/RestTestUtils.java |  110 --
 gradle/dependency-versions.properties           |    2 +
 39 files changed, 6499 insertions(+), 1489 deletions(-)
----------------------------------------------------------------------



[07/11] incubator-geode git commit: adding ASF license header

Posted by kl...@apache.org.
adding ASF license header


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

Branch: refs/heads/feature/GEODE-953
Commit: 3676826a227ce0fe22a7d5cda184185a4c3c1c1e
Parents: e666a85
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Thu Feb 25 17:06:40 2016 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Thu Feb 25 17:07:15 2016 -0800

----------------------------------------------------------------------
 .../rest/internal/web/RestInterfaceJUnitTest.java   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3676826a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
index a1c843f..46ca146 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestInterfaceJUnitTest.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web;
 
 import static org.junit.Assert.*;


[10/11] incubator-geode git commit: avoid blocking a thread that is sending an Alert via UDP

Posted by kl...@apache.org.
avoid blocking a thread that is sending an Alert via UDP

This avoids the View Creator thread becoming blocked if there are problems
in view creation and flow-control limits are reached.  We already disable
flow-control for high-priority messages - this disables flow-control for
alert messages as well.


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

Branch: refs/heads/feature/GEODE-953
Commit: e40962cf67136db83e4fc38b5bba6d53ff2a1345
Parents: 2f69575
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Fri Feb 26 09:44:43 2016 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Fri Feb 26 09:47:46 2016 -0800

----------------------------------------------------------------------
 .../internal/membership/gms/messenger/JGroupsMessenger.java     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e40962cf/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index f3ba7a2..1db0c42 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -92,6 +92,7 @@ import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 import com.gemstone.gemfire.internal.cache.DirectReplyMessage;
 import com.gemstone.gemfire.internal.cache.DistributedCacheOperation;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.internal.logging.log4j.AlertAppender;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.tcp.MemberShunnedException;
 
@@ -787,9 +788,9 @@ public class JGroupsMessenger implements Messenger {
     // which is fairly rare
     msg.setFlag(Flag.DONT_BUNDLE);
 
-    //log.info("Creating message with payload " + gfmsg);
     if (gfmsg.getProcessorType() == DistributionManager.HIGH_PRIORITY_EXECUTOR
-        || gfmsg instanceof HighPriorityDistributionMessage) {
+        || gfmsg instanceof HighPriorityDistributionMessage
+        || AlertAppender.isThreadAlerting()) {
       msg.setFlag(Flag.NO_FC);
       msg.setFlag(Flag.SKIP_BARRIER);
     }


[09/11] incubator-geode git commit: GEODE-983: NPE with transactions on PR with overflow

Posted by kl...@apache.org.
GEODE-983: NPE with transactions on PR with overflow

making sure that the BucketRegion is created before trying to read/write from it.
Fixes tests failing in nightly build.


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

Branch: refs/heads/feature/GEODE-953
Commit: 2f695753cf145fca5f927cd0935cf2b82e5cf942
Parents: 3676826
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Fri Feb 26 07:43:16 2016 -0800
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Fri Feb 26 07:46:37 2016 -0800

----------------------------------------------------------------------
 .../src/main/java/com/gemstone/gemfire/internal/cache/TXState.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2f695753/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
index 02237b7..9b38d56 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
@@ -1351,7 +1351,7 @@ public class TXState implements TXStateInterface {
       boolean rememberRead, Object expectedOldValue, boolean createIfAbsent)
   throws EntryNotFoundException
   {
-    LocalRegion dataReg = localRegion.getDataRegionForRead(keyInfo);
+    LocalRegion dataReg = localRegion.getDataRegionForWrite(keyInfo);
     TXRegionState txr = txReadRegion(dataReg);
     TXEntryState result = null;
     if (txr != null) {


[11/11] incubator-geode git commit: Merge remote-tracking branch 'origin/develop' into feature/GEODE-953

Posted by kl...@apache.org.
Merge remote-tracking branch 'origin/develop' into feature/GEODE-953


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

Branch: refs/heads/feature/GEODE-953
Commit: eb20383a50b9d447577da344046a138e9c21eff6
Parents: ed5394e e40962c
Author: Kirk Lund <kl...@pivotal.io>
Authored: Fri Feb 26 10:16:46 2016 -0800
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Fri Feb 26 10:16:46 2016 -0800

----------------------------------------------------------------------
 .../internal/membership/gms/messenger/JGroupsMessenger.java     | 5 +++--
 .../main/java/com/gemstone/gemfire/internal/cache/TXState.java  | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[04/11] incubator-geode git commit: adding unit tests for REST API

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
new file mode 100644
index 0000000..4a958ce
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIOnRegionFunctionExecutionDUnitTest.java
@@ -0,0 +1,617 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.cache.execute.RegionFunctionContext;
+import com.gemstone.gemfire.cache.partition.PartitionRegionHelper;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.cache.PartitionAttributesImpl;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegionTestHelper;
+import com.gemstone.gemfire.internal.cache.functions.DistributedRegionFunction;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
+import com.gemstone.gemfire.test.dunit.VM;
+
+/**
+ * Dunit Test to validate OnRegion function execution with REST APIs
+ * 
+ * @author Nilkanth Patel
+ * @since 8.0
+ */
+
+public class RestAPIOnRegionFunctionExecutionDUnitTest extends RestAPITestBase {
+
+  private static final long serialVersionUID = 1L;
+
+  public static final String REGION_NAME = "DistributedRegionFunctionExecutionDUnitTest";
+
+  public static final String PR_REGION_NAME = "samplePRRegion";
+
+  public static Region region = null;
+
+  public static List<String> restURLs = new ArrayList<String>();
+
+  public static String restEndPoint = null;
+
+  public static String getRestEndPoint() {
+    return restEndPoint;
+  }
+
+  public static void setRestEndPoint(String restEndPoint) {
+    RestAPIOnRegionFunctionExecutionDUnitTest.restEndPoint = restEndPoint;
+  }
+
+  public static final Function function = new DistributedRegionFunction();
+
+  public static final Function functionWithNoResultThrowsException = new MyFunctionException();
+
+  public RestAPIOnRegionFunctionExecutionDUnitTest(String name) {
+    super(name);
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+    final Host host = Host.getHost(0);
+  }
+
+  static class FunctionWithNoLastResult implements Function {
+    private static final long serialVersionUID = -1032915440862585532L;
+    public static final String Id = "FunctionWithNoLastResult";
+    public static int invocationCount;
+
+    @Override
+    public void execute(FunctionContext context) {
+      invocationCount++;
+      InternalDistributedSystem
+          .getConnectedInstance()
+          .getLogWriter()
+          .info(
+              "<ExpectedException action=add>did not send last result"
+                  + "</ExpectedException>");
+      context.getResultSender().sendResult(
+          (Serializable) context.getArguments());
+    }
+
+    @Override
+    public String getId() {
+      return Id;
+    }
+
+    @Override
+    public boolean hasResult() {
+      return true;
+    }
+
+    @Override
+    public boolean optimizeForWrite() {
+      return false;
+    }
+
+    @Override
+    public boolean isHA() {
+      return false;
+    }
+  }
+
+  static class SampleFunction implements Function {
+    private static final long serialVersionUID = -1032915440862585534L;
+    public static final String Id = "SampleFunction";
+    public static int invocationCount;
+
+    @Override
+    public void execute(FunctionContext context) {
+      invocationCount++;
+      if (context instanceof RegionFunctionContext) {
+        RegionFunctionContext rfContext = (RegionFunctionContext) context;
+        rfContext.getDataSet().getCache().getLogger()
+            .info("Executing function :  TestFunction2.execute " + rfContext);
+        if (rfContext.getArguments() instanceof Boolean) {
+          /* return rfContext.getArguments(); */
+          if (hasResult()) {
+            rfContext.getResultSender().lastResult(
+                (Serializable) rfContext.getArguments());
+          } else {
+            rfContext
+                .getDataSet()
+                .getCache()
+                .getLogger()
+                .info(
+                    "Executing function :  TestFunction2.execute " + rfContext);
+            while (true && !rfContext.getDataSet().isDestroyed()) {
+              rfContext.getDataSet().getCache().getLogger()
+                  .info("For Bug43513 ");
+              try {
+                Thread.sleep(100);
+              } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
+                return;
+              }
+            }
+          }
+        } else if (rfContext.getArguments() instanceof String) {
+          String key = (String) rfContext.getArguments();
+          if (key.equals("TestingTimeOut")) { // for test
+                                              // PRFunctionExecutionDUnitTest#testRemoteMultiKeyExecution_timeout
+            try {
+              Thread.sleep(2000);
+            } catch (InterruptedException e) {
+              rfContext.getDataSet().getCache().getLogger()
+                  .warning("Got Exception : Thread Interrupted" + e);
+            }
+          }
+          if (PartitionRegionHelper.isPartitionedRegion(rfContext.getDataSet())) {
+            /*
+             * return
+             * (Serializable)PartitionRegionHelper.getLocalDataForContext(
+             * rfContext).get(key);
+             */
+            rfContext.getResultSender().lastResult(
+                (Serializable) PartitionRegionHelper.getLocalDataForContext(
+                    rfContext).get(key));
+          } else {
+            rfContext.getResultSender().lastResult(
+                (Serializable) rfContext.getDataSet().get(key));
+          }
+          /* return (Serializable)rfContext.getDataSet().get(key); */
+        } else if (rfContext.getArguments() instanceof Set) {
+          Set origKeys = (Set) rfContext.getArguments();
+          ArrayList vals = new ArrayList();
+          for (Object key : origKeys) {
+            Object val = PartitionRegionHelper
+                .getLocalDataForContext(rfContext).get(key);
+            if (val != null) {
+              vals.add(val);
+            }
+          }
+          rfContext.getResultSender().lastResult(vals);
+          /* return vals; */
+        } else if (rfContext.getArguments() instanceof HashMap) {
+          HashMap putData = (HashMap) rfContext.getArguments();
+          for (Iterator i = putData.entrySet().iterator(); i.hasNext();) {
+            Map.Entry me = (Map.Entry) i.next();
+            rfContext.getDataSet().put(me.getKey(), me.getValue());
+          }
+          rfContext.getResultSender().lastResult(Boolean.TRUE);
+        } else {
+          rfContext.getResultSender().lastResult(Boolean.FALSE);
+        }
+      } else {
+        if (hasResult()) {
+          context.getResultSender().lastResult(Boolean.FALSE);
+        } else {
+          DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
+          LogWriter logger = ds.getLogWriter();
+          logger.info("Executing in TestFunction on Server : "
+              + ds.getDistributedMember() + "with Context : " + context);
+          while (ds.isConnected()) {
+            logger
+                .fine("Just executing function in infinite loop for Bug43513");
+            try {
+              Thread.sleep(250);
+            } catch (InterruptedException e) {
+              return;
+            }
+          }
+        }
+      }
+    }
+
+    @Override
+    public String getId() {
+      return Id;
+    }
+
+    @Override
+    public boolean hasResult() {
+      return true;
+    }
+
+    @Override
+    public boolean optimizeForWrite() {
+      return false;
+    }
+
+    @Override
+    public boolean isHA() {
+      return false;
+    }
+  }
+
+  private int getInvocationCount(VM vm) {
+    return (Integer) vm.invoke(new SerializableCallable() {
+      /**
+       * 
+       */
+      private static final long serialVersionUID = 1L;
+
+      @Override
+      public Object call() throws Exception {
+        SampleFunction f = (SampleFunction) FunctionService
+            .getFunction(SampleFunction.Id);
+        int count = f.invocationCount;
+        f.invocationCount = 0;
+        return count;
+      }
+    });
+  }
+
+  private void verifyAndResetInvocationCount(VM vm, final int count) {
+    vm.invoke(new SerializableCallable() {
+      /**
+       * 
+       */
+      private static final long serialVersionUID = 1L;
+
+      @Override
+      public Object call() throws Exception {
+        SampleFunction f = (SampleFunction) FunctionService
+            .getFunction(SampleFunction.Id);
+        assertEquals(count, f.invocationCount);
+        // assert succeeded, reset count
+        f.invocationCount = 0;
+        return null;
+      }
+    });
+  }
+
+  public static void createPeer(DataPolicy policy) {
+    AttributesFactory factory = new AttributesFactory();
+    factory.setScope(Scope.DISTRIBUTED_ACK);
+    factory.setDataPolicy(policy);
+    assertNotNull(cache);
+    region = cache.createRegion(REGION_NAME, factory.create());
+    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Region Created :" + region);
+    assertNotNull(region);
+  }
+
+  public static boolean createPeerWithPR() {
+    RegionAttributes ra = PartitionedRegionTestHelper.createRegionAttrsForPR(0,
+        10);
+    AttributesFactory raf = new AttributesFactory(ra);
+    PartitionAttributesImpl pa = new PartitionAttributesImpl();
+    pa.setAll(ra.getPartitionAttributes());
+    pa.setTotalNumBuckets(17);
+    raf.setPartitionAttributes(pa);
+
+    if (cache == null || cache.isClosed()) {
+      // Cache not available
+    }
+    assertNotNull(cache);
+
+    region = cache.createRegion(PR_REGION_NAME, raf.create());
+    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Region Created :" + region);
+    assertNotNull(region);
+    return Boolean.TRUE;
+  }
+
+  public static void populateRegion() {
+    assertNotNull(cache);
+    region = cache.getRegion(REGION_NAME);
+    assertNotNull(region);
+    for (int i = 1; i <= 200; i++) {
+      region.put("execKey-" + i, new Integer(i));
+    }
+  }
+
+  public static void populatePRRegion() {
+    assertNotNull(cache);
+    region = cache.getRegion(REGION_NAME);
+
+    PartitionedRegion pr = (PartitionedRegion) cache.getRegion(PR_REGION_NAME);
+    DistributedSystem.setThreadsSocketPolicy(false);
+    final HashSet testKeys = new HashSet();
+
+    for (int i = (pr.getTotalNumberOfBuckets() * 3); i > 0; i--) {
+      testKeys.add("execKey-" + i);
+    }
+    int j = 0;
+    for (Iterator i = testKeys.iterator(); i.hasNext();) {
+      Integer val = new Integer(j++);
+      pr.put(i.next(), val);
+    }
+    // Assert there is data in each bucket
+    for (int bid = 0; bid < pr.getTotalNumberOfBuckets(); bid++) {
+      assertTrue(pr.getBucketKeys(bid).size() > 0);
+    }
+  }
+
+  public static void populateRRRegion() {
+    assertNotNull(cache);
+    region = cache.getRegion(REGION_NAME);
+    assertNotNull(region);
+
+    final HashSet testKeys = new HashSet();
+    for (int i = 17 * 3; i > 0; i--) {
+      testKeys.add("execKey-" + i);
+    }
+    int j = 0;
+    for (Iterator i = testKeys.iterator(); i.hasNext();) {
+      Integer val = new Integer(j++);
+      region.put(i.next(), val);
+    }
+
+  }
+
+  public static void executeFunction_NoLastResult(String regionName) {
+
+    try {
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      Random randomGenerator = new Random();
+      int index = randomGenerator.nextInt(restURLs.size());
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/"
+          + "FunctionWithNoLastResult" + "?onRegion=" + regionName);
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      response = httpclient.execute(post);
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+
+  }
+
+  public static void executeFunctionThroughRestCall(String regionName) {
+    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Entering executeFunctionThroughRestCall");
+    try {
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      Random randomGenerator = new Random();
+      int index = randomGenerator.nextInt(restURLs.size());
+      
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/"
+          + "SampleFunction" + "?onRegion=" + regionName);
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Request: POST " + post.toString());
+      response = httpclient.execute(post);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Response: POST " + response.toString());
+      
+      assertEquals(response.getStatusLine().getStatusCode(), 200);
+      assertNotNull(response.getEntity());
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Exiting executeFunctionThroughRestCall");
+
+  }
+
+  private void registerFunction(VM vm) {
+    vm.invoke(new SerializableCallable() {
+      private static final long serialVersionUID = 1L;
+      @Override
+      public Object call() throws Exception {
+        FunctionService.registerFunction(new FunctionWithNoLastResult());
+        return null;
+      }
+    });
+  }
+
+  private void registerSampleFunction(VM vm) {
+    vm.invoke(new SerializableCallable() {
+      private static final long serialVersionUID = 1L;
+
+      @Override
+      public Object call() throws Exception {
+        FunctionService.registerFunction(new SampleFunction());
+        return null;
+      }
+    });
+  }
+
+  public void __testOnRegionExecutionOnDataPolicyEmpty_NoLastResult() {
+    // Step-1 : create cache on each VM, this will start HTTP service in
+    // embedded mode and deploy REST APIs web app on it.
+
+    fail("This test is trying to invoke non existent methods");
+//    String url1 = (String) vm3.invoke(() -> createCacheInVm( vm3 ));
+//    restURLs.add(url1);
+//
+//    String url2 = (String) vm0.invoke(() -> createCacheInVm( vm0 ));
+//    restURLs.add(url2);
+//
+//    String url3 = (String) vm1.invoke(() -> createCacheInVm( vm1 ));
+//    restURLs.add(url3);
+//
+//    String url4 = (String) vm2.invoke(() -> createCacheInVm( vm2 ));
+//    restURLs.add(url4);
+
+    // Step-2: Register function in all VMs
+    registerFunction(vm3);
+    registerFunction(vm0);
+    registerFunction(vm1);
+    registerFunction(vm2);
+
+    // Step-3: Create and configure Region on all VMs
+    vm3.invoke(() -> createPeer( DataPolicy.EMPTY ));
+    vm0.invoke(() -> createPeer( DataPolicy.REPLICATE ));
+    vm1.invoke(() -> createPeer( DataPolicy.REPLICATE ));
+    vm2.invoke(() -> createPeer( DataPolicy.REPLICATE ));
+
+    // Step-4 : Do some puts on region created earlier
+    vm3.invoke(() -> populateRegion());
+
+    // add expected exception to avoid suspect strings
+    final IgnoredException ex = IgnoredException.addIgnoredException("did not send last result");
+
+    // Step-5 : Execute function randomly (in iteration) on all available (per
+    // VM) REST end-points and verify its result
+    for (int i = 0; i < 10; i++) {
+      executeFunction_NoLastResult(REGION_NAME);
+    }
+    ex.remove();
+
+    restURLs.clear();
+  }
+
+  public void testOnRegionExecutionWithRR() {
+    // Step-1 : create cache on each VM, this will start HTTP service in
+    // embedded mode and deploy REST APIs web app on it.
+    //
+    String url1 = (String) vm3.invoke(() -> RestAPITestBase.createCache( vm3 ));
+    restURLs.add(url1);
+
+    String url2 = (String) vm0.invoke(() -> RestAPITestBase.createCache( vm0 ));
+    restURLs.add(url2);
+
+    String url3 = (String) vm1.invoke(() -> RestAPITestBase.createCache( vm1 ));
+    restURLs.add(url3);
+
+    String url4 = (String) vm2.invoke(() -> RestAPITestBase.createCache( vm2 ));
+    restURLs.add(url4);
+
+    // Step-2: Register function in all VMs
+    registerSampleFunction(vm3);
+    registerSampleFunction(vm0);
+    registerSampleFunction(vm1);
+    registerSampleFunction(vm2);
+
+    // Step-3: Create and configure PR on all VMs
+    vm3.invoke(() -> createPeer( DataPolicy.EMPTY ));
+    vm0.invoke(() -> createPeer( DataPolicy.REPLICATE ));
+    vm1.invoke(() -> createPeer( DataPolicy.REPLICATE ));
+    vm2.invoke(() -> createPeer( DataPolicy.REPLICATE ));
+
+    // Step-4 : Do some puts in Replicated region on vm3
+    vm3.invoke(() -> populateRRRegion());
+
+    // Step-5 : Execute function randomly (in iteration) on all available (per
+    // VM) REST end-points and verify its result
+    executeFunctionThroughRestCall(REGION_NAME);
+    int c0 = getInvocationCount(vm0);
+    int c1 = getInvocationCount(vm1);
+    int c2 = getInvocationCount(vm2);
+    int c3 = getInvocationCount(vm3);
+
+    assertEquals(1, c0 + c1 + c2 + c3);
+
+    // remove the expected exception
+    restURLs.clear();
+  }
+
+  public void testOnRegionExecutionWithPR() throws Exception {
+    final String rName = getUniqueName();
+
+    // Step-1 : create cache on each VM, this will start HTTP service in
+    // embedded mode and deploy REST APIs web app on it.
+    String url1 = (String) vm3.invoke(() -> RestAPITestBase.createCache( vm3 ));
+    restURLs.add(url1);
+
+    String url2 = (String) vm0.invoke(() -> RestAPITestBase.createCache( vm0 ));
+    restURLs.add(url2);
+
+    String url3 = (String) vm1.invoke(() -> RestAPITestBase.createCache( vm1 ));
+    restURLs.add(url3);
+
+    String url4 = (String) vm2.invoke(() -> RestAPITestBase.createCache( vm2 ));
+    restURLs.add(url4);
+
+    // Step-2: Register function in all VMs
+    registerSampleFunction(vm3);
+    registerSampleFunction(vm0);
+    registerSampleFunction(vm1);
+    registerSampleFunction(vm2);
+
+    // Step-3: Create and configure PR on all VMs
+    vm3.invoke(() -> createPeerWithPR());
+    vm0.invoke(() -> createPeerWithPR());
+    vm1.invoke(() -> createPeerWithPR());
+    vm2.invoke(() -> createPeerWithPR());
+
+    // Step-4: Do some puts such that data exist in each bucket
+    vm3.invoke(() -> populatePRRegion());
+
+    // Step-5 : Execute function randomly (in iteration) on all available (per
+    // VM) REST end-points and verify its result
+    executeFunctionThroughRestCall(PR_REGION_NAME);
+
+    // Assert that each node has executed the function once.
+    verifyAndResetInvocationCount(vm0, 1);
+    verifyAndResetInvocationCount(vm1, 1);
+    verifyAndResetInvocationCount(vm2, 1);
+    verifyAndResetInvocationCount(vm3, 1);
+
+    int c0 = getInvocationCount(vm0);
+    int c1 = getInvocationCount(vm1);
+    int c2 = getInvocationCount(vm2);
+    int c3 = getInvocationCount(vm3);
+
+    restURLs.clear();
+  }
+
+}
+
+class MyFunctionException implements Function {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  @Override
+  public void execute(FunctionContext context) {
+    throw new RuntimeException("failure");
+  }
+
+  @Override
+  public String getId() {
+    return this.getClass().getName();
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
new file mode 100644
index 0000000..3709475
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPITestBase.java
@@ -0,0 +1,133 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.management.internal.AgentUtil;
+import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+
+public class RestAPITestBase extends DistributedTestCase {
+  private static final long serialVersionUID = 1L;
+  public static Cache cache = null;
+  VM vm0 = null;
+  VM vm1 = null;
+  VM vm2 = null;
+  VM vm3 = null;
+  
+  public RestAPITestBase(String name) {
+    super(name);
+  }
+  
+  
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    disconnectAllFromDS();
+    AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
+    if (agentUtil.findWarLocation("geode-web-api") == null) {
+      fail("unable to locate geode-web-api WAR file");
+    }
+    Wait.pause(5000);
+    final Host host = Host.getHost(0);
+    vm0 = host.getVM(0);
+    vm1 = host.getVM(1);
+    vm2 = host.getVM(2);
+    vm3 = host.getVM(3);
+    // gradle sets a property telling us where the build is located
+    final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
+    Invoke.invokeInEveryVM(()-> System.setProperty("geode.build.dir", buildDir));
+  }  
+  
+  /**
+   * close the clients and teh servers
+   */
+  @Override
+  protected final void preTearDown() throws Exception {
+    vm0.invoke(() -> closeCache());
+    vm1.invoke(() -> closeCache());
+    vm2.invoke(() -> closeCache());
+    vm3.invoke(() -> closeCache());
+  }
+
+  /**
+   * close the cache
+   * 
+   */
+  public static void closeCache() {
+    if (cache != null && !cache.isClosed()) {
+      cache.close();
+      cache.getDistributedSystem().disconnect();
+    }
+  }
+  
+  protected static String createCache(VM currentVM) {
+    
+    RestAPITestBase test = new RestAPITestBase(getTestMethodName());
+    
+    final String hostName = currentVM.getHost().getHostName();
+    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    
+    Properties props = new Properties();
+    
+    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
+    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME,String.valueOf(serverPort));
+    
+
+    InternalDistributedSystem ds = test.getSystem(props);
+    cache = CacheFactory.create(ds);
+    return "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+    
+  }
+  
+  public static String createCacheWithGroups (VM vm, final String groups, final String regionName ) {
+    RestAPITestBase test = new RestAPITestBase(getTestMethodName());
+    
+    final String hostName = vm.getHost().getHostName(); 
+    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    
+    Properties props = new Properties();
+    
+    if(groups != null) {
+      props.put("groups", groups);
+    }
+    
+    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
+    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(serverPort));
+    
+    InternalDistributedSystem ds = test.getSystem(props);
+    cache = CacheFactory.create(ds);
+    
+    String restEndPoint =  "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+    return restEndPoint; 
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
new file mode 100644
index 0000000..0245fa0
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
@@ -0,0 +1,915 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.internal.LocatorTestBase;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.cache.server.ServerLoadProbe;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.management.ManagementTestBase;
+import com.gemstone.gemfire.pdx.PdxInstance;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.VM;
+
+/**
+ * Dunit Test containing inter - operations between REST Client and Gemfire cache client
+ * @author Nilkanth Patel
+ * @since 8.0
+ */
+
+public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
+  
+  private static final long serialVersionUID = -254776154266339226L;
+
+  private ManagementTestBase helper;
+
+  public static final String PEOPLE_REGION_NAME = "People";
+
+  //private static RestTemplate restTemplate;
+
+  private static final String findAllPeopleQuery = "/queries?id=findAllPeople&q=SELECT%20*%20FROM%20/People";
+  private static final String findPeopleByGenderQuery = "/queries?id=filterByGender&q=SELECT%20*%20from%20/People%20where%20gender=$1";
+  private static final String findPeopleByLastNameQuery = "/queries?id=filterByLastName&q=SELECT%20*%20from%20/People%20where%20lastName=$1";
+
+  private static final String[] PARAM_QUERY_IDS_ARRAY = { "findAllPeople",
+      "filterByGender", "filterByLastName" };
+  
+  final static String QUERY_ARGS = "["
+      + "{"
+      + "\"@type\": \"string\","
+      + "\"@value\": \"Patel\""
+      + "}"
+      + "]";
+
+  final static String PERSON_AS_JSON_CAS = "{"
+      + "\"@old\" :" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 101," + " \"firstName\": \"Mithali\","
+      + " \"middleName\": \"Dorai\"," + " \"lastName\": \"Raj\","
+      + " \"birthDate\": \"12/04/1982\"," + "\"gender\": \"FEMALE\"" 
+      + "},"
+      + "\"@new\" :" 
+      + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 1101," + " \"firstName\": \"Virat\","
+      + " \"middleName\": \"Premkumar\"," + " \"lastName\": \"Kohli\","
+      + " \"birthDate\": \"08/11/1988\"," + "\"gender\": \"MALE\"" 
+      + "}"
+      + "}";
+    
+  final static String PERSON_AS_JSON_REPLACE = "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 501," + " \"firstName\": \"Barack\","
+      + " \"middleName\": \"Hussein\"," + " \"lastName\": \"Obama\","
+      + " \"birthDate\": \"04/08/1961\"," + "\"gender\": \"MALE\"" 
+      + "}";
+  
+  private static final String PERSON_LIST_AS_JSON = "[" + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 3," + " \"firstName\": \"Nishka3\","
+      + " \"middleName\": \"Nilkanth3\"," + " \"lastName\": \"Patel3\","
+      + " \"birthDate\": \"07/31/2009\"," + "\"gender\": \"FEMALE\"" + "},"
+      + "{" + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 4," + " \"firstName\": \"Tanay4\","
+      + " \"middleName\": \"kiran4\"," + " \"lastName\": \"Patel4\","
+      + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 5," + " \"firstName\": \"Nishka5\","
+      + " \"middleName\": \"Nilkanth5\"," + " \"lastName\": \"Patel5\","
+      + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "},"
+      + "{" + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 6," + " \"firstName\": \"Tanay6\","
+      + " \"middleName\": \"Kiran6\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 7," + " \"firstName\": \"Nishka7\","
+      + " \"middleName\": \"Nilkanth7\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "},"
+      + "{" + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 8," + " \"firstName\": \"Tanay8\","
+      + " \"middleName\": \"kiran8\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 9," + " \"firstName\": \"Nishka9\","
+      + " \"middleName\": \"Nilkanth9\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "},"
+      + "{" + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 10," + " \"firstName\": \"Tanay10\","
+      + " \"middleName\": \"kiran10\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{"
+      + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 11," + " \"firstName\": \"Nishka11\","
+      + " \"middleName\": \"Nilkanth11\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "},"
+      + "{" + "\"@type\": \"com.gemstone.gemfire.rest.internal.web.controllers.Person\","
+      + "\"id\": 12," + " \"firstName\": \"Tanay12\","
+      + " \"middleName\": \"kiran12\"," + " \"lastName\": \"Patel\","
+      + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}" + "]";
+
+  public RestAPIsAndInterOpsDUnitTest(String name) {
+    super(name);
+    this.helper = new ManagementTestBase(name);
+
+  }
+
+  public void setUp() throws Exception {
+    disconnectAllFromDS();
+    super.setUp();
+  }
+
+  @Override
+  protected final void postTearDownLocatorTestBase() throws Exception {
+    disconnectAllFromDS();
+  }
+  
+  public static String startBridgeServerWithRestServiceOnInVM(VM vm, final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe) {
+    
+    final String hostName = vm.getHost().getHostName(); 
+    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    
+    //create Cache of given VM and start HTTP service with REST APIs service
+    new RestAPIsAndInterOpsDUnitTest("temp").startBridgeServer(hostName, serverPort, groups, locators, regions, probe);
+   
+    String restEndPoint =  "http://" + hostName + ":" + serverPort + "/gemfire-api/v1";
+    return restEndPoint;
+  }
+  
+  @SuppressWarnings("deprecation")
+  protected int startBridgeServer(String hostName, int restServicerPort, final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe) {
+            
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.MCAST_PORT_NAME, String.valueOf(0));
+    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+    props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
+    props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, hostName);
+    props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(restServicerPort));
+    
+    DistributedSystem ds = getSystem(props);
+    Cache cache = CacheFactory.create(ds);
+    ((GemFireCacheImpl)cache).setReadSerialized(true);
+    AttributesFactory factory = new AttributesFactory();
+    
+    factory.setEnableBridgeConflation(true);
+    factory.setDataPolicy(DataPolicy.REPLICATE);
+    RegionAttributes attrs = factory.create();
+    for(int i = 0; i < regions.length; i++) {
+      cache.createRegion(regions[i], attrs);
+    }
+    
+    CacheServer server = cache.addCacheServer();
+    final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    server.setPort(serverPort);
+    server.setGroups(groups);
+    server.setLoadProbe(probe);
+    try {
+      server.start();
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    remoteObjects.put(CACHE_KEY, cache);
+    return new Integer(serverPort);
+  }
+  
+  public static void doPutsInClientCache() {
+    ClientCache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);
+   
+    //put person object
+    final Person person1 = new Person(101L, "Mithali", "Dorai", "Raj", DateTimeUtils.createDate(1982, Calendar.DECEMBER, 4), Gender.FEMALE);
+    final Person person2 = new Person(102L, "Sachin", "Ramesh", "Tendulkar", DateTimeUtils.createDate(1975, Calendar.DECEMBER, 14), Gender.MALE);
+    final Person person3 = new Person(103L, "Saurabh", "Baburav", "Ganguly", DateTimeUtils.createDate(1972, Calendar.AUGUST, 29), Gender.MALE);
+    final Person person4 = new Person(104L, "Rahul", "subrymanyam", "Dravid", DateTimeUtils.createDate(1979, Calendar.MARCH, 17), Gender.MALE);
+    final Person person5 = new Person(105L, "Jhulan", "Chidambaram", "Goswami", DateTimeUtils.createDate(1983, Calendar.NOVEMBER, 25), Gender.FEMALE);
+   
+    region.put("1", person1);
+    region.put("2", person2);
+    region.put("3", person3);
+    region.put("4", person4);
+    region.put("5", person5);
+    
+    final Person person6 = new Person(101L, "Rahul", "Rajiv", "Gndhi", DateTimeUtils.createDate(1970, Calendar.MAY, 14), Gender.MALE);
+    final Person person7 = new Person(102L, "Narendra", "Damodar", "Modi", DateTimeUtils.createDate(1945, Calendar.DECEMBER, 24), Gender.MALE);
+    final Person person8 = new Person(103L, "Atal", "Bihari", "Vajpayee", DateTimeUtils.createDate(1920, Calendar.AUGUST, 9), Gender.MALE);
+    final Person person9 = new Person(104L, "Soniya", "Rajiv", "Gandhi", DateTimeUtils.createDate(1929, Calendar.MARCH, 27), Gender.FEMALE);
+    final Person person10 = new Person(104L, "Priyanka", "Robert", "Gandhi", DateTimeUtils.createDate(1973, Calendar.APRIL, 15), Gender.FEMALE);
+    
+    final Person person11 = new Person(104L, "Murali", "Manohar", "Joshi", DateTimeUtils.createDate(1923, Calendar.APRIL, 25), Gender.MALE);
+    final Person person12 = new Person(104L, "Lalkrishna", "Parmhansh", "Advani", DateTimeUtils.createDate(1910, Calendar.JANUARY, 01), Gender.MALE);
+    final Person person13 = new Person(104L, "Shushma", "kumari", "Swaraj", DateTimeUtils.createDate(1943, Calendar.AUGUST, 10), Gender.FEMALE);
+    final Person person14 = new Person(104L, "Arun", "raman", "jetly", DateTimeUtils.createDate(1942, Calendar.OCTOBER, 27), Gender.MALE);
+    final Person person15 = new Person(104L, "Amit", "kumar", "shah", DateTimeUtils.createDate(1958, Calendar.DECEMBER, 21), Gender.MALE);
+    final Person person16 = new Person(104L, "Shila", "kumari", "Dixit", DateTimeUtils.createDate(1927, Calendar.FEBRUARY, 15), Gender.FEMALE);
+    
+    Map<String, Object> userMap = new HashMap<String, Object>();
+    userMap.put("6", person6);
+    userMap.put("7", person7);
+    userMap.put("8", person8);
+    userMap.put("9", person9);
+    userMap.put("10", person10);
+    userMap.put("11", person11);
+    userMap.put("12", person12);
+    userMap.put("13", person13);
+    userMap.put("14", person14);
+    userMap.put("15", person15);
+    userMap.put("16", person16);
+    
+    region.putAll(userMap);
+    
+    if (cache != null)
+      cache.getLogger().info("Gemfire Cache Client: Puts successfully done");
+    
+  }
+
+  public static void doQueryOpsUsingRestApis(String restEndpoint) {
+    String currentQueryOp = null;
+    try {
+      // Query TestCase-1 :: Prepare parameterized Queries
+      {
+        currentQueryOp = "findAllPeopleQuery";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost post = new HttpPost(restEndpoint + findAllPeopleQuery);
+        post.addHeader("Content-Type", "application/json");
+        post.addHeader("Accept", "application/json");
+        CloseableHttpResponse createNamedQueryResponse = httpclient.execute(post);
+        assertEquals(createNamedQueryResponse.getStatusLine().getStatusCode(), 201);
+        assertNotNull(createNamedQueryResponse.getEntity());
+        createNamedQueryResponse.close();        
+        
+
+        post = new HttpPost(restEndpoint + findPeopleByGenderQuery);
+        post.addHeader("Content-Type", "application/json");
+        post.addHeader("Accept", "application/json");
+        createNamedQueryResponse = httpclient.execute(post);
+        assertEquals(createNamedQueryResponse.getStatusLine().getStatusCode(), 201);
+        assertNotNull(createNamedQueryResponse.getEntity());
+        createNamedQueryResponse.close();
+        
+
+        post = new HttpPost(restEndpoint + findPeopleByLastNameQuery);
+        post.addHeader("Content-Type", "application/json");
+        post.addHeader("Accept", "application/json");
+        createNamedQueryResponse = httpclient.execute(post);
+        assertEquals(createNamedQueryResponse.getStatusLine().getStatusCode(), 201);
+        assertNotNull(createNamedQueryResponse.getEntity());
+        createNamedQueryResponse.close();
+      }
+      
+      // Query TestCase-2 :: List all parameterized queries
+      {
+        currentQueryOp = "listAllQueries";
+        HttpGet get = new HttpGet(restEndpoint + "/queries");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse listAllQueriesResponse = httpclient.execute(get);
+        assertEquals(listAllQueriesResponse.getStatusLine().getStatusCode(), 200);
+        assertNotNull(listAllQueriesResponse.getEntity());
+        
+        HttpEntity entity = listAllQueriesResponse.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer sb = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          sb.append(line);
+        }
+        listAllQueriesResponse.close();
+      
+        // Check whether received response contains expected query IDs.
+
+        JSONObject jsonObject = new JSONObject(sb.toString());
+        JSONArray jsonArray = jsonObject.getJSONArray("queries");
+        for (int i = 0; i < jsonArray.length(); i++) {
+          assertTrue(
+            "PREPARE_PARAMETERIZED_QUERY: function IDs are not matched",
+            Arrays.asList(PARAM_QUERY_IDS_ARRAY).contains(
+                jsonArray.getJSONObject(i).getString("id")));
+        }
+      }  
+      
+      // Query TestCase-3 :: Run the specified named query passing in scalar values for query parameters.
+      {
+        currentQueryOp = "filterByLastName";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost post = new HttpPost(restEndpoint + "/queries/filterByLastName");
+        post.addHeader("Content-Type", "application/json");
+        post.addHeader("Accept", "application/json");
+        StringEntity entity = new StringEntity(QUERY_ARGS);       
+        post.setEntity(entity);
+        CloseableHttpResponse runNamedQueryResponse = httpclient.execute(post);
+
+        assertEquals(200, runNamedQueryResponse.getStatusLine().getStatusCode());
+        assertNotNull(runNamedQueryResponse.getEntity());
+      }
+    } catch ( Exception e ) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+  }
+  
+  public static void verifyUpdatesInClientCache() {
+    ClientCache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);
+    
+    {
+      Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3", DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE );
+      Object value = region.get("3");
+      if (value instanceof PdxInstance) {
+        PdxInstance pi3  = (PdxInstance) value;
+        Person actualPerson = (Person) pi3.getObject();
+        assertEquals(actualPerson.getId(), expectedPerson.getId());
+        assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName());
+        assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName());
+        assertEquals(actualPerson.getLastName(), expectedPerson.getLastName());
+        assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate());
+        assertEquals(actualPerson.getGender(), expectedPerson.getGender());
+      } else if (value instanceof Person) {
+        fail("VerifyUpdatesInClientCache, Get on key 3, Expected to get value of type PdxInstance ");
+      }
+    }
+     
+    
+    //TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the issue
+    // CAS functionality is not working in following test case
+    // step-1: Java client, Region.put("K", A);
+    //Step-2: Rest CAS request for key "K" with data "@old" = A. CAS is failing as existing PdxInstance in cache and
+    //        PdxInstance generated from JSON (CAS request) does not match as their value's type are getting changed 
+    /*
+    //verify update on key "1"
+    {
+      Object obj = region.get("1");
+      if (obj instanceof PdxInstance) {
+        PdxInstance pi = (PdxInstance)obj;
+        Person p1 = (Person)pi.getObject();
+        System.out.println("Nilkanth1 : verifyUpdatesInClientCache() : GET ON KEY=1" + p1.toString());
+      }else {
+        System.out.println("Nilkanth1 : verifyUpdatesInClientCache() GET ON KEY=1  returned OBJECT: " + obj.toString());
+      }
+    }
+    */
+    
+    //verify update on key "2"
+    {
+      Person expectedPerson = new Person(501L, "Barack", "Hussein", "Obama", DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE );
+      Object value = region.get("2");
+      if (value instanceof PdxInstance) {
+        PdxInstance pi3  = (PdxInstance) value;
+        Person actualPerson = (Person) pi3.getObject();
+        assertEquals(actualPerson.getId(), expectedPerson.getId());
+        assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName());
+        assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName());
+        assertEquals(actualPerson.getLastName(), expectedPerson.getLastName());
+        assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate());
+        assertEquals(actualPerson.getGender(), expectedPerson.getGender());
+      }else {
+        fail("VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance ");
+      }
+    }
+    
+    //verify Deleted key "13"
+    {
+      Object obj = region.get("13");
+      assertEquals(obj, null);
+      
+      obj = region.get("14");
+      assertEquals(obj, null);
+      
+      obj = region.get("15");
+      assertEquals(obj, null);
+      
+      obj = region.get("16");
+      assertEquals(obj, null);
+    }
+    
+  }
+  
+  public static void doUpdatesUsingRestApis(String restEndpoint) {
+    //UPdate keys using REST calls
+    {
+
+      try {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPut put = new HttpPut(restEndpoint
+            + "/People/3,4,5,6,7,8,9,10,11,12");
+        put.addHeader("Content-Type", "application/json");
+        put.addHeader("Accept", "application/json");
+        StringEntity entity = new StringEntity(PERSON_LIST_AS_JSON);
+        put.setEntity(entity);
+        CloseableHttpResponse result = httpclient.execute(put);
+      } catch (Exception e) {
+        throw new RuntimeException("unexpected exception", e);
+      }
+    }
+    
+    //Delete Single keys
+    {
+      try {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpDelete delete = new HttpDelete(restEndpoint + "/People/13");
+        delete.addHeader("Content-Type", "application/json");
+        delete.addHeader("Accept", "application/json");
+        CloseableHttpResponse result = httpclient.execute(delete);
+      } catch (Exception e) {
+        throw new RuntimeException("unexpected exception", e);
+      }
+    }
+    
+    //Delete set of keys
+    {
+      try {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpDelete delete = new HttpDelete(restEndpoint + "/People/14,15,16");
+        delete.addHeader("Content-Type", "application/json");
+        delete.addHeader("Accept", "application/json");
+        CloseableHttpResponse result = httpclient.execute(delete);
+      } catch (Exception e) {
+        throw new RuntimeException("unexpected exception", e);
+      }
+    }
+    
+    //REST put?op=CAS for key 1
+    /*
+    try {   
+    {  
+      HttpEntity<Object> entity = new HttpEntity<Object>(PERSON_AS_JSON_CAS, headers);
+      ResponseEntity<String> result = RestTestUtils.getRestTemplate().exchange(
+        restEndpoint + "/People/1?op=cas",
+        HttpMethod.PUT, entity, String.class);
+    }
+    } catch (HttpClientErrorException e) {
+      
+      fail("Caught HttpClientErrorException while doing put with op=cas");
+    }catch (HttpServerErrorException se) {
+      fail("Caught HttpServerErrorException while doing put with op=cas");
+    }
+    */ 
+    
+    //REST put?op=REPLACE for key 2
+    {
+      /*HttpEntity<Object> entity = new HttpEntity<Object>(PERSON_AS_JSON_REPLACE, headers);
+      ResponseEntity<String> result = RestTestUtils.getRestTemplate().exchange(
+        restEndpoint + "/People/2?op=replace",
+      HttpMethod.PUT, entity, String.class);*/
+      
+      try {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPut put = new HttpPut(restEndpoint
+            + "/People/2?op=replace");
+        put.addHeader("Content-Type", "application/json");
+        put.addHeader("Accept", "application/json");
+        StringEntity entity = new StringEntity(PERSON_AS_JSON_REPLACE);
+        put.setEntity(entity);
+        CloseableHttpResponse result = httpclient.execute(put);
+      } catch (Exception e) {
+        throw new RuntimeException("unexpected exception", e);
+      }
+    }
+  }
+  
+  public static void fetchRestServerEndpoints(String restEndpoint) {
+    HttpGet get = new HttpGet(restEndpoint + "/servers");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    CloseableHttpClient httpclient = HttpClients.createDefault();
+    CloseableHttpResponse response;
+    
+    try {
+      response = httpclient.execute(get);
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(
+          content));
+      String line;
+      StringBuffer str = new StringBuffer();
+      while ((line = reader.readLine()) != null) {
+        str.append(line);
+      }
+      
+      //validate the satus code
+      assertEquals(response.getStatusLine().getStatusCode(), 200);
+      
+      if(response.getStatusLine().getStatusCode() == 200) {
+        JSONArray jsonArray = new JSONArray(str.toString());
+        
+        //verify total number of REST service endpoints in DS
+        assertEquals(jsonArray.length(), 2);
+      }
+      
+    } catch (ClientProtocolException e) { 
+      e.printStackTrace();
+      fail(" Rest Request should not have thrown ClientProtocolException!");
+    } catch (IOException e) {
+      e.printStackTrace();
+      fail(" Rest Request should not have thrown IOException!");
+    } catch (JSONException e) {
+      e.printStackTrace();
+      fail(" Rest Request should not have thrown  JSONException!");
+    }
+    
+  }
+  
+  public static void doGetsUsingRestApis(String restEndpoint) {
+    
+    //HttpHeaders headers = setAcceptAndContentTypeHeaders(); 
+    String currentOperation = null;
+    JSONObject jObject;
+    JSONArray jArray;
+    try {    
+      //1. Get on key="1" and validate result.
+      {
+        currentOperation = "GET on key 1";
+        
+        HttpGet get = new HttpGet(restEndpoint + "/People/1");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse response = httpclient.execute(get);
+        
+        HttpEntity entity = response.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer str = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          str.append(line);
+        }
+        
+        jObject = new JSONObject(str.toString());
+      
+        assertEquals(jObject.get("id"), 101);
+        assertEquals(jObject.get("firstName"), "Mithali");
+        assertEquals(jObject.get("middleName"), "Dorai");
+        assertEquals(jObject.get("lastName"), "Raj");
+        assertEquals(jObject.get("gender"), Gender.FEMALE.name());
+      }
+      
+      //2. Get on key="16" and validate result.
+      {
+        currentOperation = "GET on key 16";
+
+        
+        HttpGet get = new HttpGet(restEndpoint + "/People/16");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse response = httpclient.execute(get);
+        
+        HttpEntity entity = response.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer str = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          str.append(line);
+        }
+        
+        jObject = new JSONObject(str.toString());
+        
+      
+        assertEquals(jObject.get("id"), 104);
+        assertEquals(jObject.get("firstName"), "Shila");
+        assertEquals(jObject.get("middleName"), "kumari");
+        assertEquals(jObject.get("lastName"), "Dixit");
+        assertEquals(jObject.get("gender"), Gender.FEMALE.name());
+      }
+      
+      //3. Get all (getAll) entries in Region
+      {
+
+        HttpGet get = new HttpGet(restEndpoint + "/People");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse result = httpclient.execute(get);
+        assertEquals(result.getStatusLine().getStatusCode(), 200);
+        assertNotNull(result.getEntity());
+      
+        HttpEntity entity = result.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer sb = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          sb.append(line);
+        }
+        result.close();
+        
+        try {
+          jObject = new JSONObject(sb.toString());
+          jArray = jObject.getJSONArray("People");
+          assertEquals(jArray.length(), 16);
+        } catch (JSONException e) {
+          fail(" Rest Request ::" + currentOperation +  " :: should not have thrown JSONException ");
+        }
+      }
+      
+      //4. GetAll?limit=10 (10 entries) and verify results
+      {
+        HttpGet get = new HttpGet(restEndpoint + "/People?limit=10");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(response.getStatusLine().getStatusCode(), 200);
+        assertNotNull(response.getEntity());
+        
+        HttpEntity entity = response.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer str = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          str.append(line);
+        }
+        
+        try {
+          jObject = new JSONObject(str.toString());
+          jArray = jObject.getJSONArray("People");
+          assertEquals(jArray.length(), 10);
+        } catch (JSONException e) {
+          fail(" Rest Request ::" + currentOperation +  " :: should not have thrown JSONException ");
+        }
+      }
+      
+      //5. Get keys - List all keys in region
+      {  
+        
+        HttpGet get = new HttpGet(restEndpoint + "/People/keys");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(response.getStatusLine().getStatusCode(), 200);
+        assertNotNull(response.getEntity());
+        
+        HttpEntity entity = response.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer str = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          str.append(line);
+        }
+        
+        try {
+          jObject = new JSONObject(str.toString());
+          jArray = jObject.getJSONArray("keys"); 
+          assertEquals(jArray.length(), 16);
+        } catch (JSONException e) {
+          fail(" Rest Request ::" + currentOperation +  " :: should not have thrown JSONException ");
+        }
+      } 
+      
+      //6. Get data for specific keys
+      {  
+       
+        HttpGet get = new HttpGet(restEndpoint + "/People/1,3,5,7,9,11");
+        get.addHeader("Content-Type", "application/json");
+        get.addHeader("Accept", "application/json");
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(response.getStatusLine().getStatusCode(), 200);
+        assertNotNull(response.getEntity());
+        
+        HttpEntity entity = response.getEntity();
+        InputStream content = entity.getContent();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+            content));
+        String line;
+        StringBuffer str = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+          str.append(line);
+        }
+        
+        try {
+          jObject = new JSONObject(str.toString());
+          jArray = jObject.getJSONArray("People");
+          assertEquals(jArray.length(), 6);
+          
+        } catch (JSONException e) {
+          fail(" Rest Request ::" + currentOperation +  " :: should not have thrown JSONException ");
+        }
+      } 
+    }catch ( Exception e ) {
+      throw new RuntimeException("unexpected exception", e); 
+    }
+  }
+
+  public static void createRegionInClientCache() {
+    ClientCache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+    ClientRegionFactory<String, Object> crf = cache
+        .createClientRegionFactory(ClientRegionShortcut.PROXY);
+    Region<String, Object> region = crf.create(PEOPLE_REGION_NAME);
+
+  }
+
+  public static void createRegionInManager() {
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+
+    RegionFactory<String, Object> rf = cache
+        .createRegionFactory(RegionShortcut.REPLICATE);
+    Region<String, Object> region = rf.create(PEOPLE_REGION_NAME);
+  }
+
+  public static void createRegionInPeerServer() {
+    Cache cache = GemFireCacheImpl.getInstance();
+    assertNotNull(cache);
+
+    RegionFactory<String, Object> rf = cache
+        .createRegionFactory(RegionShortcut.REPLICATE);
+    Region<String, Object> region = rf.create(PEOPLE_REGION_NAME);
+  }
+
+  /**
+   * InterOps Test between REST-client, Peer Cache Client and Client Cache 
+   * @throws Exception
+   */
+ 
+  public void testInterOpsWithReplicatedRegion() throws Exception {
+
+    final Host host = Host.getHost(0);
+    VM locator = host.getVM(0);
+    VM manager = host.getVM(1);
+    VM server = host.getVM(2);
+    VM client = host.getVM(3);
+
+    // start locator
+    int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    
+    startLocatorInVM(locator, locatorPort, "");
+    
+    // find locators
+    String locators = NetworkUtils.getServerHostName(locator.getHost()) + "[" + locatorPort
+        + "]";
+
+    // start manager (peer cache)
+    int managerPort = startManagerInVM(manager,/* groups */null, locators,
+        new String[] {REGION_NAME}, CacheServer.DEFAULT_LOAD_PROBE);
+    
+    //start startCacheServer With RestService enabled
+    String restEndpoint = (String)server.invoke(RestAPIsAndInterOpsDUnitTest.class,
+        "startBridgeServerWithRestServiceOnInVM", new Object[] { server ,  null, locators, new String[] {REGION_NAME}, CacheServer.DEFAULT_LOAD_PROBE });
+    
+    // create a client cache
+    createClientCacheInVM(client, NetworkUtils.getServerHostName(locator.getHost()),
+        locatorPort);
+    
+    // create region in Manager, peer cache and Client cache nodes
+    manager.invoke(() -> RestAPIsAndInterOpsDUnitTest.createRegionInManager());
+    server.invoke(() -> RestAPIsAndInterOpsDUnitTest.createRegionInPeerServer());
+    client.invoke(() -> RestAPIsAndInterOpsDUnitTest.createRegionInClientCache());
+    
+    // do some person puts from clientcache
+    client.invoke(() -> RestAPIsAndInterOpsDUnitTest.doPutsInClientCache());
+
+    //TEST: fetch all available REST endpoints
+    RestAPIsAndInterOpsDUnitTest.fetchRestServerEndpoints(restEndpoint);
+   
+    // Controller VM - config REST Client and make HTTP calls
+    RestAPIsAndInterOpsDUnitTest.doGetsUsingRestApis(restEndpoint);
+    
+    //update Data using REST APIs
+    RestAPIsAndInterOpsDUnitTest.doUpdatesUsingRestApis(restEndpoint);
+    
+    client.invoke(() -> RestAPIsAndInterOpsDUnitTest.verifyUpdatesInClientCache());
+
+    //Querying
+    RestAPIsAndInterOpsDUnitTest.doQueryOpsUsingRestApis(restEndpoint);
+    
+    // stop the client and make sure the bridge server notifies
+    // stopBridgeMemberVM(client);
+    helper.closeCache(locator);
+    helper.closeCache(manager);
+    helper.closeCache(server);
+    helper.closeCache(client);
+
+  }
+
+  private void createClientCacheInVM(VM vm, final String host, final int port) throws Exception {
+    SerializableRunnable connect = new SerializableRunnable(
+        "Start Cache client") {
+      public void run() {
+        // Connect using the GemFire locator and create a Caching_Proxy cache
+        ClientCache c = new ClientCacheFactory().setPdxReadSerialized(true).addPoolLocator(host, port)
+            .create();
+       
+        Region r = c.createClientRegionFactory(
+            ClientRegionShortcut.PROXY).create(REGION_NAME);
+      }
+    };
+
+    if (vm == null) {
+      connect.run();
+    } else {
+      vm.invoke(connect);
+    }
+  }
+
+  private int startManagerInVM(VM vm, final String[] groups,
+      final String locators, final String[] regions, final ServerLoadProbe probe) {
+    SerializableCallable connect = new SerializableCallable("Start Manager ") {
+      public Object call() throws IOException {
+        Properties props = new Properties();
+        props
+            .setProperty(DistributionConfig.MCAST_PORT_NAME, String.valueOf(0));
+        props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+
+        props.setProperty("jmx-manager", "true");
+        props.setProperty("jmx-manager-start", "true");
+        props.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, "0");
+        
+        final int httpPort = AvailablePortHelper.getRandomAvailableTCPPort();
+        //Set REST service related configuration
+        props.setProperty(DistributionConfig.START_DEV_REST_API_NAME, "true");
+        props.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME, "localhost");
+        props.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
+
+        DistributedSystem ds = getSystem(props);
+        Cache cache = CacheFactory.create(ds);
+        AttributesFactory factory = new AttributesFactory();
+        
+        factory.setEnableBridgeConflation(true);
+        factory.setDataPolicy(DataPolicy.REPLICATE);
+        RegionAttributes attrs = factory.create();
+        for (int i = 0; i < regions.length; i++) {
+          cache.createRegion(regions[i], attrs);
+        }
+        CacheServer server = cache.addCacheServer();
+        final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
+        server.setPort(serverPort);
+        server.setGroups(groups);
+        server.setLoadProbe(probe);
+        server.start();
+        
+        return new Integer(serverPort);
+      }
+    };
+    Integer port = (Integer) vm.invoke(connect);
+    return port.intValue();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b55879e/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
new file mode 100644
index 0000000..1ae3810
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java
@@ -0,0 +1,306 @@
+/*
+ * 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 com.gemstone.gemfire.rest.internal.web.controllers;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionContext;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
+import com.gemstone.gemfire.test.dunit.VM;
+
+public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase {
+
+  public RestAPIsOnGroupsFunctionExecutionDUnitTest(String name) {
+    super(name);
+  }
+  
+  public void setUp() throws Exception {
+    super.setUp();
+    final Host host = Host.getHost(0);
+  }
+  
+  private void registerFunction(VM vm) {
+    vm.invoke(new SerializableCallable() {
+      private static final long serialVersionUID = 1L;
+      
+      @Override
+      public Object call() throws Exception {
+        FunctionService.registerFunction(new OnGroupsFunction());
+        return null;
+      }
+    });
+  }
+  
+  static class OnGroupsFunction implements Function {
+    private static final long serialVersionUID = -1032915440862585532L;
+    public static final String Id = "OnGroupsFunction";
+    public static int invocationCount;
+
+    @Override
+    public void execute(FunctionContext context) {
+      LogWriterUtils.getLogWriter().fine("SWAP:1:executing OnGroupsFunction:"+invocationCount);
+      InternalDistributedSystem ds = InternalDistributedSystem.getConnectedInstance();
+      invocationCount++;
+      ArrayList<String> l = (ArrayList<String>) context.getArguments();
+      if (l != null) {
+        assertFalse(Collections.disjoint(l, ds.getDistributedMember().getGroups()));
+      }
+      context.getResultSender().lastResult(Boolean.TRUE);
+    }
+
+    @Override
+    public String getId() {
+      return Id;
+    }
+
+    @Override
+    public boolean hasResult() {
+      return true;
+    }
+
+    @Override
+    public boolean optimizeForWrite() {
+      return false;
+    }
+
+    @Override
+    public boolean isHA() {
+      return false;
+    }
+  }
+  
+  
+  public static void executeFunctionThroughRestCall(List<String> restURLs) {
+    Random randomGenerator = new Random();
+    int index = randomGenerator.nextInt(restURLs.size());
+    
+    try {
+      
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnGroupsFunction?onGroups=g0,g1");
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      LogWriterUtils.getLogWriter().info("Request POST : " + post.toString());
+      response = httpclient.execute(post);
+      
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(
+          content));
+      String line;
+      StringBuffer sb = new StringBuffer();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }      
+      LogWriterUtils.getLogWriter().info("Response : " + sb.toString());
+    
+      //verify response status code. expected status code is 200 OK.
+      assertEquals(response.getStatusLine().getStatusCode(), 200);
+      
+      
+      //verify response hasbody flag, expected is true.
+      assertNotNull(response.getEntity());
+      
+      
+      response.close();
+      
+      //verify function execution result
+      JSONArray resultArray = new JSONArray(sb.toString());
+      assertEquals(resultArray.length(), 3);
+      
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }
+    
+  }
+  
+  public static void executeFunctionOnMemberThroughRestCall(List<String> restURLs) {
+    Random randomGenerator = new Random();
+    int index = randomGenerator.nextInt(restURLs.size());
+    
+    //Testcase-1: Executing function on non-existing group. 
+    final IgnoredException ex = IgnoredException.addIgnoredException("com.gemstone.gemfire.cache.execute.FunctionException");
+    try {
+      
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnGroupsFunction?onGroups=no%20such%20group");
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      response = httpclient.execute(post);
+      
+      if ( response.getStatusLine().getStatusCode() == 200 ) {
+        fail("FunctionException expected : no member(s) are found belonging to the provided group(s)");
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+      
+    } finally {
+      ex.remove();
+    }
+    
+    //Testcase-2: Executing function on group with args.
+    
+    final String FUNCTION_ARGS1 =  "{"
+        +        "\"@type\": \"string\","
+        +        "\"@value\": \"gm\""
+        +    "}";
+    
+    try {
+     
+      CloseableHttpClient httpclient = HttpClients.createDefault();
+      CloseableHttpResponse response = null;
+      HttpPost post = new HttpPost(restURLs.get(index) + "/functions/OnGroupsFunction?onGroups=gm");
+      post.addHeader("Content-Type", "application/json");
+      post.addHeader("Accept", "application/json");
+      response = httpclient.execute(post);
+      
+      //verify response status code
+      assertEquals(response.getStatusLine().getStatusCode(), 200);
+      
+      //verify response hasbody flag
+      assertNotNull(response.getEntity());
+      
+      HttpEntity entity = response.getEntity();
+      InputStream content = entity.getContent();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(
+          content));
+      String line;
+      StringBuffer sb = new StringBuffer();
+      while ((line = reader.readLine()) != null) {
+        sb.append(line);
+      }
+      response.close();
+      
+      //verify function execution result
+      JSONArray resultArray = new JSONArray(sb.toString());
+      assertEquals(resultArray.length(), 1);
+      
+    } catch (Exception e) {
+      throw new RuntimeException("unexpected exception", e);
+    }   
+  }
+  
+  private void verifyAndResetInvocationCount(VM vm, final int count) {
+    vm.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        OnGroupsFunction f = (OnGroupsFunction) FunctionService.getFunction(OnGroupsFunction.Id);
+        assertEquals(count, f.invocationCount);
+        // assert succeeded, reset count
+        f.invocationCount = 0;
+        return null;
+      }
+    });
+  }
+  
+  private void resetInvocationCount(VM vm) {
+    vm.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        OnGroupsFunction f = (OnGroupsFunction) FunctionService.getFunction(OnGroupsFunction.Id);
+        f.invocationCount = 0;
+        return null;
+      }
+    });
+  }
+  
+  public void testonGroupsExecutionOnAllMembers() {
+  
+    List<String> restURLs = new ArrayList<String>(); 
+    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
+    //         Create and configure Region on all VMs. Add Rest end-point into the restURLs list.
+    
+    String url1 = (String)vm0.invoke(() -> RestAPITestBase.createCacheWithGroups(vm0, "g0,gm", "TEST_REGION"));
+    restURLs.add(url1);
+    
+    String url2 = (String)vm1.invoke(() -> RestAPITestBase.createCacheWithGroups(vm1, "g1", "TEST_REGION" ));
+    restURLs.add(url2);
+    
+    String url3 = (String)vm2.invoke(() -> RestAPITestBase.createCacheWithGroups(vm2, "g0,g1", "TEST_REGION"));
+    restURLs.add(url3);
+    
+    //Step-2: Register function in all VMs
+    registerFunction(vm0);
+    registerFunction(vm1);
+    registerFunction(vm2);
+    
+    //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+    for (int i=0; i< 10; i++)
+      executeFunctionThroughRestCall(restURLs);
+    
+    //Verify that each node belonging to specified group has run the function
+    verifyAndResetInvocationCount(vm0, 10);
+    verifyAndResetInvocationCount(vm1, 10);
+    verifyAndResetInvocationCount(vm2, 10);
+   
+    restURLs.clear();
+  }
+  
+  
+  public void testBasicP2PFunctionSelectedGroup() {
+  
+    List<String> restURLs = new ArrayList<String>(); 
+    
+    //Step-1 : create cache on each VM, this will start HTTP service in embedded mode and deploy REST APIs web app on it.
+    //         Create and configure Region on all VMs. Add Rest end-point into the restURLs list.
+    String url1 = (String)vm0.invoke(() -> RestAPITestBase.createCacheWithGroups(vm0, "g0,gm", "null" ));
+    restURLs.add(url1);
+    
+    String url2 = (String)vm1.invoke(() -> RestAPITestBase.createCacheWithGroups(vm1, "g1", "null"  ));
+    restURLs.add(url2);
+    
+    String url3 = (String)vm2.invoke(() -> RestAPITestBase.createCacheWithGroups(vm2, "g0,g1", "null" ));
+    restURLs.add(url3);
+    
+    //Step-2: Register function in all VMs
+    registerFunction(vm0);
+    registerFunction(vm1);
+    registerFunction(vm2);
+    
+    //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result
+    for (int i=0; i< 5; i++)
+      executeFunctionOnMemberThroughRestCall(restURLs);
+    
+    resetInvocationCount(vm0);
+    resetInvocationCount(vm1);
+    resetInvocationCount(vm2);
+    
+    restURLs.clear();
+  }
+}
+