http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java index 0299615..c90a7a4 100644 --- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.rest.internal.web.controllers; @@ -100,91 +98,75 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { 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\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 101," + " \"firstName\": \"Mithali\"," - + " \"middleName\": \"Dorai\"," + " \"lastName\": \"Raj\"," - + " \"birthDate\": \"12/04/1982\"," + "\"gender\": \"FEMALE\"" - + "}," - + "\"@new\" :" - + "{" - + "\"@type\": \"org.apache.geode.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\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 501," + " \"firstName\": \"Barack\"," - + " \"middleName\": \"Hussein\"," + " \"lastName\": \"Obama\"," - + " \"birthDate\": \"04/08/1961\"," + "\"gender\": \"MALE\"" - + "}"; + // 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\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + "\"id\": 101," + + " \"firstName\": \"Mithali\"," + " \"middleName\": \"Dorai\"," + " \"lastName\": \"Raj\"," + + " \"birthDate\": \"12/04/1982\"," + "\"gender\": \"FEMALE\"" + "}," + "\"@new\" :" + "{" + + "\"@type\": \"org.apache.geode.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\": \"org.apache.geode.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\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 3," + " \"firstName\": \"Nishka3\"," - + " \"middleName\": \"Nilkanth3\"," + " \"lastName\": \"Patel3\"," - + " \"birthDate\": \"07/31/2009\"," + "\"gender\": \"FEMALE\"" + "}," - + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 4," + " \"firstName\": \"Tanay4\"," - + " \"middleName\": \"kiran4\"," + " \"lastName\": \"Patel4\"," - + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{" - + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 5," + " \"firstName\": \"Nishka5\"," - + " \"middleName\": \"Nilkanth5\"," + " \"lastName\": \"Patel5\"," - + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "}," - + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 6," + " \"firstName\": \"Tanay6\"," - + " \"middleName\": \"Kiran6\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{" - + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 7," + " \"firstName\": \"Nishka7\"," - + " \"middleName\": \"Nilkanth7\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "}," - + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 8," + " \"firstName\": \"Tanay8\"," - + " \"middleName\": \"kiran8\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{" - + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 9," + " \"firstName\": \"Nishka9\"," - + " \"middleName\": \"Nilkanth9\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "}," - + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 10," + " \"firstName\": \"Tanay10\"," - + " \"middleName\": \"kiran10\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}," + "{" - + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 11," + " \"firstName\": \"Nishka11\"," - + " \"middleName\": \"Nilkanth11\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + "}," - + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," - + "\"id\": 12," + " \"firstName\": \"Tanay12\"," - + " \"middleName\": \"kiran12\"," + " \"lastName\": \"Patel\"," - + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + "}" + "]"; + + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + "\"id\": 3," + + " \"firstName\": \"Nishka3\"," + " \"middleName\": \"Nilkanth3\"," + + " \"lastName\": \"Patel3\"," + " \"birthDate\": \"07/31/2009\"," + "\"gender\": \"FEMALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 4," + " \"firstName\": \"Tanay4\"," + " \"middleName\": \"kiran4\"," + + " \"lastName\": \"Patel4\"," + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 5," + " \"firstName\": \"Nishka5\"," + " \"middleName\": \"Nilkanth5\"," + + " \"lastName\": \"Patel5\"," + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 6," + " \"firstName\": \"Tanay6\"," + " \"middleName\": \"Kiran6\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 7," + " \"firstName\": \"Nishka7\"," + " \"middleName\": \"Nilkanth7\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 8," + " \"firstName\": \"Tanay8\"," + " \"middleName\": \"kiran8\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 9," + " \"firstName\": \"Nishka9\"," + " \"middleName\": \"Nilkanth9\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 10," + " \"firstName\": \"Tanay10\"," + " \"middleName\": \"kiran10\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 11," + " \"firstName\": \"Nishka11\"," + " \"middleName\": \"Nilkanth11\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"31/09/2009\"," + "\"gender\": \"FEMALE\"" + + "}," + "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + + "\"id\": 12," + " \"firstName\": \"Tanay12\"," + " \"middleName\": \"kiran12\"," + + " \"lastName\": \"Patel\"," + " \"birthDate\": \"23/08/2012\"," + "\"gender\": \"MALE\"" + + "}" + "]"; public RestAPIsAndInterOpsDUnitTest() { super(); - this.helper = new ManagementTestBase() {{}}; + this.helper = new ManagementTestBase() { + { + } + }; } @@ -198,19 +180,19 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { disconnectAllFromDS(); } - public String startBridgeServerWithRestService(final String hostName, final String[] groups, final String locators, final String[] regions, - final ServerLoadProbe probe) { + public String startBridgeServerWithRestService(final String hostName, final String[] groups, + final String locators, final String[] regions, final ServerLoadProbe probe) { final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort(); - //create Cache of given VM and start HTTP service with REST APIs service + // create Cache of given VM and start HTTP service with REST APIs service startBridgeServer(hostName, serverPort, groups, locators, regions, probe); return "http://" + hostName + ":" + serverPort + urlContext + "/v1"; } @SuppressWarnings("deprecation") - protected int startBridgeServer(String hostName, int restServicerPort, final String[] groups, final String locators, final String[] regions, - final ServerLoadProbe probe) { + 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(MCAST_PORT, String.valueOf(0)); @@ -249,12 +231,17 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { 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); + // 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); @@ -262,18 +249,29 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { 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); + 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); @@ -338,8 +336,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = listAllQueriesResponse.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer sb = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -352,14 +349,13 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { 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"))); + 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. + // Query TestCase-3 :: Run the specified named query passing in scalar values for query + // parameters. { currentQueryOp = "filterByLastName"; CloseableHttpClient httpclient = HttpClients.createDefault(); @@ -384,7 +380,8 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { 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); + 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; @@ -396,32 +393,32 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { 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 "); + 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 + // 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 + // 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" + * //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" { - 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); + 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; @@ -433,11 +430,12 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else { - fail("VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance "); + fail( + "VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance "); } } - //verify Deleted key "13" + // verify Deleted key "13" { Object obj = region.get("13"); assertEquals(obj, null); @@ -455,13 +453,12 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } public void doUpdatesUsingRestApis(String restEndpoint) { - //UPdate keys using REST calls + // 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"); + 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); @@ -472,7 +469,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } } - //Delete Single keys + // Delete Single keys { try { CloseableHttpClient httpclient = HttpClients.createDefault(); @@ -485,7 +482,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } } - //Delete set of keys + // Delete set of keys { try { CloseableHttpClient httpclient = HttpClients.createDefault(); @@ -498,34 +495,29 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } } - //REST put?op=CAS for key 1 + // 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 + * 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);*/ + /* + * 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"); + 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); @@ -548,21 +540,20 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { response = httpclient.execute(get); HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + 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 + // 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 + // verify total number of REST service endpoints in DS assertEquals(jsonArray.length(), 2); } @@ -581,12 +572,12 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { public void doGetsUsingRestApis(String restEndpoint) { - //HttpHeaders headers = setAcceptAndContentTypeHeaders(); + // HttpHeaders headers = setAcceptAndContentTypeHeaders(); String currentOperation = null; JSONObject jObject; JSONArray jArray; try { - //1. Get on key="1" and validate result. + // 1. Get on key="1" and validate result. { currentOperation = "GET on key 1"; @@ -598,8 +589,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer str = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -615,7 +605,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { assertEquals(jObject.get("gender"), Gender.FEMALE.name()); } - //2. Get on key="16" and validate result. + // 2. Get on key="16" and validate result. { currentOperation = "GET on key 16"; @@ -627,8 +617,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer str = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -644,7 +633,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { assertEquals(jObject.get("gender"), Gender.FEMALE.name()); } - //3. Get all (getAll) entries in Region + // 3. Get all (getAll) entries in Region { HttpGet get = new HttpGet(restEndpoint + "/People"); @@ -657,8 +646,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = result.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer sb = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -675,7 +663,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } } - //4. GetAll?limit=10 (10 entries) and verify results + // 4. GetAll?limit=10 (10 entries) and verify results { HttpGet get = new HttpGet(restEndpoint + "/People?limit=10"); get.addHeader("Content-Type", "application/json"); @@ -687,8 +675,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer str = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -704,7 +691,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } } - //5. Get keys - List all keys in region + // 5. Get keys - List all keys in region { HttpGet get = new HttpGet(restEndpoint + "/People/keys"); @@ -717,8 +704,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer str = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -734,7 +720,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { } } - //6. Get data for specific keys + // 6. Get data for specific keys { HttpGet get = new HttpGet(restEndpoint + "/People/1,3,5,7,9,11"); @@ -747,8 +733,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader(new InputStreamReader( - content)); + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; StringBuffer str = new StringBuffer(); while ((line = reader.readLine()) != null) { @@ -772,8 +757,8 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { public void createRegionInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache); - ClientRegionFactory<String, Object> crf = cache - .createClientRegionFactory(ClientRegionShortcut.PROXY); + ClientRegionFactory<String, Object> crf = + cache.createClientRegionFactory(ClientRegionShortcut.PROXY); Region<String, Object> region = crf.create(PEOPLE_REGION_NAME); } @@ -782,8 +767,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { Cache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache); - RegionFactory<String, Object> rf = cache - .createRegionFactory(RegionShortcut.REPLICATE); + RegionFactory<String, Object> rf = cache.createRegionFactory(RegionShortcut.REPLICATE); Region<String, Object> region = rf.create(PEOPLE_REGION_NAME); } @@ -811,12 +795,14 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { String locators = locatorHostName + "[" + locatorPort + "]"; // start manager (peer cache) - manager.invoke(() -> startManager(/* groups */null, locators, new String[] { REGION_NAME }, CacheServer.DEFAULT_LOAD_PROBE)); + manager.invoke(() -> startManager(/* groups */null, locators, new String[] {REGION_NAME}, + CacheServer.DEFAULT_LOAD_PROBE)); - //start startCacheServer With RestService enabled + // start startCacheServer With RestService enabled final String serverHostName = server.getHost().getHostName(); - String restEndpoint = (String) server.invoke(() -> startBridgeServerWithRestService(serverHostName, null, locators - , new String[] { REGION_NAME }, CacheServer.DEFAULT_LOAD_PROBE)); + String restEndpoint = + (String) server.invoke(() -> startBridgeServerWithRestService(serverHostName, null, + locators, new String[] {REGION_NAME}, CacheServer.DEFAULT_LOAD_PROBE)); // create a client cache client.invoke(() -> createClientCache(locatorHostName, locatorPort)); @@ -829,18 +815,18 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { // do some person puts from clientcache client.invoke(() -> doPutsInClientCache()); - //TEST: fetch all available REST endpoints + // TEST: fetch all available REST endpoints fetchRestServerEndpoints(restEndpoint); // Controller VM - config REST Client and make HTTP calls doGetsUsingRestApis(restEndpoint); - //update Data using REST APIs + // update Data using REST APIs doUpdatesUsingRestApis(restEndpoint); client.invoke(() -> verifyUpdatesInClientCache()); - //Querying + // Querying doQueryOpsUsingRestApis(restEndpoint); // stop the client and make sure the bridge server notifies @@ -854,18 +840,16 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { private void createClientCache(final String host, final int port) throws Exception { // Connect using the GemFire locator and create a Caching_Proxy cache - ClientCache c = new ClientCacheFactory().setPdxReadSerialized(true).addPoolLocator(host, port) - .create(); + ClientCache c = + new ClientCacheFactory().setPdxReadSerialized(true).addPoolLocator(host, port).create(); - c.createClientRegionFactory( - ClientRegionShortcut.PROXY).create(REGION_NAME); + c.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME); } - private int startManager(final String[] groups, final String locators, final String[] regions - , final ServerLoadProbe probe) throws IOException { + private int startManager(final String[] groups, final String locators, final String[] regions, + final ServerLoadProbe probe) throws IOException { Properties props = new Properties(); - props - .setProperty(MCAST_PORT, String.valueOf(0)); + props.setProperty(MCAST_PORT, String.valueOf(0)); props.setProperty(LOCATORS, locators); props.setProperty(JMX_MANAGER, "true"); @@ -873,7 +857,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase { props.setProperty(JMX_MANAGER_PORT, "0"); final int httpPort = AvailablePortHelper.getRandomAvailableTCPPort(); - //Set REST service related configuration + // Set REST service related configuration props.setProperty(START_DEV_REST_API, "true"); props.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost"); props.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java index 75eedd5..eae528c 100644 --- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnGroupsFunctionExecutionDUnitTest.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.rest.internal.web.controllers; @@ -58,13 +56,19 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase } private void setupCacheWithGroupsAndFunction() { - restURLs.add(vm0.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm0.getHost().getHostName(), "g0,gm", urlContext))); - restURLs.add(vm1.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm1.getHost().getHostName(), "g1", urlContext))); - restURLs.add(vm2.invoke("createCacheWithGroups", () -> createCacheWithGroups(vm2.getHost().getHostName(), "g0,g1", urlContext))); - - vm0.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction())); - vm1.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction())); - vm2.invoke("registerFunction(new OnGroupsFunction())", () -> FunctionService.registerFunction(new OnGroupsFunction())); + restURLs.add(vm0.invoke("createCacheWithGroups", + () -> createCacheWithGroups(vm0.getHost().getHostName(), "g0,gm", urlContext))); + restURLs.add(vm1.invoke("createCacheWithGroups", + () -> createCacheWithGroups(vm1.getHost().getHostName(), "g1", urlContext))); + restURLs.add(vm2.invoke("createCacheWithGroups", + () -> createCacheWithGroups(vm2.getHost().getHostName(), "g0,g1", urlContext))); + + vm0.invoke("registerFunction(new OnGroupsFunction())", + () -> FunctionService.registerFunction(new OnGroupsFunction())); + vm1.invoke("registerFunction(new OnGroupsFunction())", + () -> FunctionService.registerFunction(new OnGroupsFunction())); + vm2.invoke("registerFunction(new OnGroupsFunction())", + () -> FunctionService.registerFunction(new OnGroupsFunction())); } @Test @@ -72,7 +76,8 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase setupCacheWithGroupsAndFunction(); for (int i = 0; i < 10; i++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "g0,g1", null); + CloseableHttpResponse response = + executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "g0,g1", null); assertHttpResponse(response, 200, 3); } @@ -86,9 +91,11 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase public void testonGroupsExecutionOnAllMembersWithFilter() { setupCacheWithGroupsAndFunction(); - //Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result + // Execute function randomly (in iteration) on all available (per VM) REST end-points and verify + // its result for (int i = 0; i < 10; i++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, "someKey", null, "g1", null); + CloseableHttpResponse response = + executeFunctionThroughRestCall("OnGroupsFunction", null, "someKey", null, "g1", null); assertHttpResponse(response, 500, 0); } @@ -100,22 +107,25 @@ public class RestAPIsOnGroupsFunctionExecutionDUnitTest extends RestAPITestBase public void testBasicP2PFunctionSelectedGroup() { setupCacheWithGroupsAndFunction(); - //Step-3 : Execute function randomly (in iteration) on all available (per VM) REST end-points and verify its result + // 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++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "no%20such%20group", null); + CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, + null, null, "no%20such%20group", null); assertHttpResponse(response, 500, 0); } assertCorrectInvocationCount(0, vm0, vm1, vm2); for (int i = 0; i < 5; i++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "gm", null); + CloseableHttpResponse response = + executeFunctionThroughRestCall("OnGroupsFunction", null, null, null, "gm", null); assertHttpResponse(response, 200, 1); } assertCorrectInvocationCount(5, vm0, vm1, vm2); - resetInvocationCounts(vm0,vm1,vm2); + resetInvocationCounts(vm0, vm1, vm2); restURLs.clear(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java index 64fbba6..3907bfc 100644 --- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java +++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsOnMembersFunctionExecutionDUnitTest.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.rest.internal.web.controllers; @@ -63,7 +61,8 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase Cache c = null; try { - c = CacheFactory.getInstance(new RestAPIsOnMembersFunctionExecutionDUnitTest().getSystem(props)); + c = CacheFactory + .getInstance(new RestAPIsOnMembersFunctionExecutionDUnitTest().getSystem(props)); c.close(); } catch (CacheClosedException ignore) { } @@ -86,7 +85,8 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase createCacheForVMs(); for (int i = 0; i < 10; i++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction", null, null, null, null, null); + CloseableHttpResponse response = + executeFunctionThroughRestCall("OnMembersFunction", null, null, null, null, null); assertHttpResponse(response, 200, 4); } @@ -96,14 +96,14 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase } private void createCacheForVMs() { - restURLs.add(vm0.invoke("createCacheAndRegisterFunction", () -> createCacheAndRegisterFunction(vm0.getHost() - .getHostName(), "m1"))); - restURLs.add(vm1.invoke("createCacheAndRegisterFunction", () -> createCacheAndRegisterFunction(vm1.getHost() - .getHostName(), "m2"))); - restURLs.add(vm2.invoke("createCacheAndRegisterFunction", () -> createCacheAndRegisterFunction(vm2.getHost() - .getHostName(), "m3"))); - restURLs.add(vm3.invoke("createCacheAndRegisterFunction", () -> createCacheAndRegisterFunction(vm3.getHost() - .getHostName(), "m4"))); + restURLs.add(vm0.invoke("createCacheAndRegisterFunction", + () -> createCacheAndRegisterFunction(vm0.getHost().getHostName(), "m1"))); + restURLs.add(vm1.invoke("createCacheAndRegisterFunction", + () -> createCacheAndRegisterFunction(vm1.getHost().getHostName(), "m2"))); + restURLs.add(vm2.invoke("createCacheAndRegisterFunction", + () -> createCacheAndRegisterFunction(vm2.getHost().getHostName(), "m3"))); + restURLs.add(vm3.invoke("createCacheAndRegisterFunction", + () -> createCacheAndRegisterFunction(vm3.getHost().getHostName(), "m4"))); } @Test @@ -111,7 +111,8 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase createCacheForVMs(); for (int i = 0; i < 10; i++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction", null, null, null, null, "m1,m2,m3"); + CloseableHttpResponse response = + executeFunctionThroughRestCall("OnMembersFunction", null, null, null, null, "m1,m2,m3"); assertHttpResponse(response, 200, 3); } @@ -125,7 +126,8 @@ public class RestAPIsOnMembersFunctionExecutionDUnitTest extends RestAPITestBase createCacheForVMs(); for (int i = 0; i < 10; i++) { - CloseableHttpResponse response = executeFunctionThroughRestCall("OnMembersFunction", null, "key2", null, null, "m1,m2,m3"); + CloseableHttpResponse response = + executeFunctionThroughRestCall("OnMembersFunction", null, "key2", null, null, "m1,m2,m3"); assertHttpResponse(response, 500, 0); }
