GEODE-9486: Fix validate-serializable-objects (#6823)
Rename DistributedSystemService to SanctionedSerializablesService and
remove unused init(DistributedSystem).
Move SanctionedSerializablesService to geode-serialization.
Implement SanctionedSerializablesService in both geode-core and
geode-management to remove special case for each in
InternalDataSerializer.
Fix sanctioned serializables support in geode-management and
geode-apis-compatible-with-redis.
Add sanctioned serializables support to geode-serialization and
geode-pulse.
Add sanctioned serializables support to geode-junit and geode-dunit
to simplify writing tests for validate-serializable-objects and prevent
having to list out DUnit Rules and other test framework classes when
validate-serializable-objects is enabled.
Use ExecutorServiceRule and reformat json strings in
RestRegionAPIIntegrationTest.
Reorganize QueryCommandDUnitTestBase.
Use InvalidClassException instead of Exception in
ObjectInputStreamFilterWrapper fatal log message.
Improve assertion messages in ResourceUtils.
Move loadSanctionedSerializablesServices and loadClassNames to
new SanctionedSerializables in geode-serialization.
Exclude Pulse GemFireAuthentication from sanctioned serializables.
Add SerializationTest Category to all AnalyzeSerializables integration
tests.
Tidy up SANCTIONED_SERIALIZABLES_DEPENDENCIES_PATTERN.
Convert to AssertJ and use BeforeClass in
InternalDataSerializerSerializationAcceptlistTest.
Note: If Git or GitHub is showing invalid file renames in the diffs, you
may need to pull the branch locally and configure diff.renameLimit to
something lower than the default value of 50.
(cherry picked from commit acbd0ff3c37a5e1fe3018d3f7288df385159ac4c)
(cherry picked from commit ba81c3670d85dbb4451030e2c4acb11ca8aef9da)
(cherry picked from commit 5b067cae5257e871055acebc94b944d36afb59e9)
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/test/junit/rules/GeodeDevRestClient.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/test/junit/rules/GeodeDevRestClient.java
index 5bb9b24..3c6395e 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/test/junit/rules/GeodeDevRestClient.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/test/junit/rules/GeodeDevRestClient.java
@@ -156,7 +156,10 @@
return clientBuilder.build().execute(host, request, clientContext);
} catch (Exception e) {
- throw new RuntimeException(e.getMessage(), e);
+ throw new RuntimeException(
+ String.format("Request %s' with username '%s' password '%s' failed", request, username,
+ password),
+ e);
}
}
diff --git a/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestRegionAPIIntegrationTest.java b/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestRegionAPIIntegrationTest.java
new file mode 100644
index 0000000..a1b0578
--- /dev/null
+++ b/geode-assembly/src/integrationTest/java/org/apache/geode/rest/internal/web/RestRegionAPIIntegrationTest.java
@@ -0,0 +1,514 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.rest.internal.web;
+
+import static java.lang.System.lineSeparator;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeoutException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.springframework.http.MediaType;
+
+import org.apache.geode.cache.CacheWriterException;
+import org.apache.geode.cache.Region;
+import org.apache.geode.rest.internal.web.controllers.Customer;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+import org.apache.geode.test.junit.rules.GeodeDevRestClient;
+import org.apache.geode.test.junit.rules.RequiresGeodeHome;
+import org.apache.geode.test.junit.rules.ServerStarterRule;
+
+public class RestRegionAPIIntegrationTest {
+
+ @SuppressWarnings("deprecation")
+ private static final String APPLICATION_JSON_UTF8_VALUE = MediaType.APPLICATION_JSON_UTF8_VALUE;
+ private static final List<String> JSON_DOCUMENTS = new ArrayList<>();
+
+ private static GeodeDevRestClient restClient;
+
+ @ClassRule
+ public static RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome();
+
+ @ClassRule
+ public static ServerStarterRule server = new ServerStarterRule()
+ .withRestService()
+ .withPDXReadSerialized()
+ .withRegion(REPLICATE, "regionA");
+
+ @Rule
+ public ExecutorServiceRule pool = new ExecutorServiceRule();
+
+ @BeforeClass
+ public static void setUpClass() throws URISyntaxException, IOException {
+ restClient = new GeodeDevRestClient("localhost", server.getHttpPort(), false);
+ initJsonDocuments();
+ }
+
+ @Before
+ public void clearRegionA() {
+ getRegionA().clear();
+ }
+
+ @Test
+ public void getAllResources() {
+ restClient.doGetAndAssert("")
+ .hasStatusCode(HttpStatus.SC_OK)
+ .hasContentType(APPLICATION_JSON_UTF8_VALUE)
+ .hasResponseBody()
+ .isEqualToIgnoringWhitespace(
+ "{\"regions\":[{\"name\":\"regionA\",\"type\":\"REPLICATE\",\"key-constraint\":null,\"value-constraint\":null}]}");
+ }
+
+ @Test
+ public void getRegionWhenEmpty() {
+ restClient.doGetAndAssert("/regionA")
+ .statusIsOk()
+ .hasResponseBody()
+ .isEqualToIgnoringWhitespace("{\"regionA\":[]}");
+ }
+
+ @Test
+ public void getRegionAWhenHasData() throws CacheWriterException, IOException {
+ Region<String, Customer> region = getRegionA();
+ region.put("customer1", new Customer(1L, "jon", "doe", "123-456-789"));
+ region.put("customer2", new Customer(2L, "jane", "doe", "123-456-999"));
+
+ JsonNode jsonObject = restClient.doGetAndAssert("/regionA")
+ .statusIsOk()
+ .getJsonObject();
+
+ assertThat(jsonObject.get("regionA")).hasSize(2);
+ }
+
+ @Test
+ public void getSingleKey() throws CacheWriterException, IOException {
+ Region<String, Customer> region = getRegionA();
+ region.put("customer1", new Customer(1L, "jon", "doe", "123-456-789"));
+
+ JsonNode jsonObject = restClient.doGetAndAssert("/regionA/customer1")
+ .statusIsOk()
+ .getJsonObject();
+
+ System.out.println(jsonObject.toString());
+ assertThat(jsonObject.get("firstName").asText()).isEqualTo("jon");
+ }
+
+ @Test
+ public void putIntoRegionA() {
+ for (int key = 0; key < JSON_DOCUMENTS.size(); key++) {
+ restClient.doPutAndAssert("/regionA/" + key, JSON_DOCUMENTS.get(key)).statusIsOk();
+ }
+
+ assertThat(getRegionA()).hasSize(JSON_DOCUMENTS.size());
+ }
+
+ @Test
+ public void postIntoRegionA() {
+ for (int key = 0; key < JSON_DOCUMENTS.size(); key++) {
+ restClient.doPostAndAssert("/regionA?key=" + key, JSON_DOCUMENTS.get(key)).statusIsOk();
+ }
+
+ assertThat(getRegionA()).hasSize(JSON_DOCUMENTS.size());
+ }
+
+ @Test
+ public void putDuplicateWithoutReplace() {
+ Region<String, Customer> region = getRegionA();
+ region.put("customer1", new Customer(1L, "jon", "doe", "123-456-789"));
+
+ // put with the same key and same value
+ restClient.doPutAndAssert("/regionA/customer1",
+ "{\"customerId\":1,\"firstName\":\"jon\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"123-456-789\"}")
+ .statusIsOk();
+
+ assertThat(region).hasSize(1);
+
+ // put the same key with a different value
+ restClient.doPutAndAssert("/regionA/customer1",
+ "{\"customerId\":1,\"firstName\":\"jane\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"111-111-111\"}")
+ .statusIsOk();
+
+ assertThat(region).hasSize(1);
+
+ // put with a different key
+ restClient.doPutAndAssert("/regionA/customer2",
+ "{\"customerId\":2,\"firstName\":\"jane\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"111-111-111\"}")
+ .statusIsOk();
+
+ assertThat(region).hasSize(2);
+ }
+
+ @Test
+ public void putDuplicateWithReplace() {
+ Region<String, Customer> region = getRegionA();
+ region.put("customer1", new Customer(1L, "jon", "doe", "123-456-789"));
+
+ // replace with an existing key and different value
+ restClient.doPutAndAssert("/regionA/customer1?op=REPLACE",
+ "{\"customerId\":2,\"firstName\":\"jane\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"123-456-789\"}")
+ .statusIsOk();
+
+ assertThat(region).hasSize(1);
+
+ // trying to replace with a non-existent key
+ restClient.doPutAndAssert("/regionA/customer2?op=REPLACE",
+ "{\"customerId\":2,\"firstName\":\"jane\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"123-456-789\"}")
+ .hasStatusCode(HttpStatus.SC_NOT_FOUND);
+
+ assertThat(region).hasSize(1);
+ }
+
+ @Test
+ public void putWithCAS() {
+ Region<?, ?> region = getRegionA();
+
+ // do a regular put first
+ restClient.doPutAndAssert("/regionA/customer1",
+ "{\"customerId\":1,\"firstName\":\"jon\",\"lastName\":\"doe\"}")
+ .statusIsOk();
+
+ assertThat(region).hasSize(1);
+
+ // invalid json doc in the request
+ restClient.doPutAndAssert("/regionA/customer1?op=CAS",
+ "{\"customerId\":1,\"firstName\":\"jon\",\"lastName\":\"doe\"}")
+ .hasStatusCode(HttpStatus.SC_BAD_REQUEST);
+
+ // put with CAS with existing key, but with different old value
+ restClient.doPutAndAssert("/regionA/customer1?op=CAS",
+ "{\"@old\":{\"customerId\":1,\"firstName\":\"jane\",\"lastName\":\"doe\"},"
+ + "\"@new\":{\"customerId\":1,\"firstName\":\"mary\",\"lastName\":\"doe\"}}")
+ .hasStatusCode(HttpStatus.SC_CONFLICT)
+ .hasResponseBody()
+ .isEqualToIgnoringWhitespace(
+ "{\"customerId\":1,\"firstName\":\"jon\",\"lastName\":\"doe\"}");
+
+ // put with CAS with different key, status is ok, but did not put a second entry in
+ restClient.doPutAndAssert("/regionA/customer2?op=CAS",
+ "{\"@old\":{\"customerId\":1,\"firstName\":\"jon\",\"lastName\":\"doe\"},"
+ + "\"@new\":{\"customerId\":1,\"firstName\":\"mary\",\"lastName\":\"doe\"}}")
+ .hasStatusCode(HttpStatus.SC_OK);
+
+ assertThat(region).hasSize(1);
+
+ // put with CAS successfully (with existing key, with correct old value)
+ restClient.doPutAndAssert("/regionA/customer1?op=CAS",
+ "{\"@old\":{\"customerId\":1,\"firstName\":\"jon\",\"lastName\":\"doe\"},"
+ + "\"@new\":{\"customerId\":1,\"firstName\":\"jane\",\"lastName\":\"doe\"}}")
+ .hasStatusCode(HttpStatus.SC_OK);
+
+ assertThat(region).hasSize(1);
+ }
+
+ @Test
+ public void deleteAll() {
+ Region<String, Customer> region = getRegionA();
+ region.put("1", new Customer(1L, "jon", "doe", "123-456-789"));
+ region.put("2", new Customer(2L, "jane", "doe", "123-456-999"));
+ region.put("3", new Customer(3L, "mary", "doe", "123-456-899"));
+
+ restClient.doDeleteAndAssert("/regionA")
+ .statusIsOk();
+
+ assertThat(region).isEmpty();
+ }
+
+ @Test
+ public void deleteWithKeys() {
+ Region<String, Customer> region = getRegionA();
+ region.put("1", new Customer(1L, "jon", "doe", "123-456-789"));
+ region.put("2", new Customer(2L, "jane", "doe", "123-456-999"));
+ region.put("3", new Customer(3L, "mary", "doe", "123-456-899"));
+
+ restClient.doDeleteAndAssert("/regionA/1,2")
+ .statusIsOk();
+
+ assertThat(region).hasSize(1);
+ assertThat(region.get("3")).isNotNull();
+ }
+
+ @Test
+ public void deleteNonExistentKey() {
+ restClient.doDeleteAndAssert("/regionA/1234")
+ .hasStatusCode(HttpStatus.SC_NOT_FOUND);
+ }
+
+ @Test
+ public void listKeys() throws CacheWriterException, IOException {
+ Region<String, Customer> region = getRegionA();
+ region.put("customer1", new Customer(1L, "jon", "doe", "123-456-789"));
+ region.put("customer2", new Customer(2L, "jane", "doe", "123-456-999"));
+
+ JsonNode jsonObject = restClient.doGetAndAssert("/regionA/keys")
+ .statusIsOk()
+ .getJsonObject();
+
+ assertThat(jsonObject.get("keys").toString()).isEqualTo("[\"customer1\",\"customer2\"]");
+ }
+
+ @Test
+ public void adhocQuery() throws IOException {
+ restClient.doPutAndAssert("/regionA/1", DOCUMENT1).statusIsOk();
+ restClient.doPutAndAssert("/regionA/2", DOCUMENT2).statusIsOk();
+ restClient.doPutAndAssert("/regionA/3", DOCUMENT3).statusIsOk();
+
+ String urlPrefix =
+ "/queries/adhoc?q=" + URLEncoder.encode(
+ "SELECT book.displayprice FROM " + SEPARATOR +
+ "regionA e, e.store.book book WHERE book.displayprice > 5",
+ "UTF-8");
+
+ restClient.doGetAndAssert(urlPrefix)
+ .statusIsOk()
+ .hasJsonArrayOfDoubles()
+ .hasSize(12)
+ .containsExactlyInAnyOrder(18.95, 18.95, 8.99, 8.99, 8.99, 8.95, 22.99, 22.99, 22.99, 12.99,
+ 112.99, 112.99);
+ }
+
+ @Test
+ public void preparedQuery() throws IOException {
+ restClient.doPutAndAssert("/regionA/1", DOCUMENT1).statusIsOk();
+ restClient.doPutAndAssert("/regionA/2", DOCUMENT2).statusIsOk();
+ restClient.doPutAndAssert("/regionA/3", DOCUMENT3).statusIsOk();
+
+ // create 5 prepared statements
+ for (int i = 0; i < 5; i++) {
+ String urlPrefix = "/queries/?id=" + "Query" + i + "&q=" + URLEncoder.encode(
+ "SELECT book.displayprice FROM " + SEPARATOR
+ + "regionA e, e.store.book book WHERE book.displayprice > $1",
+ "UTF-8");
+ restClient.doPostAndAssert(urlPrefix, "").statusIsOk();
+ }
+
+ // get the list of defined queries and verify the size of them
+ JsonNode jsonObject = restClient.doGetAndAssert("/queries")
+ .statusIsOk()
+ .getJsonObject();
+
+ assertThat(jsonObject.get("queries")).hasSize(5);
+
+ // execute each defined queries
+ for (int i = 0; i < 5; i++) {
+ restClient.doPostAndAssert("/queries/Query" + i, "[{\"@type\":\"double\",\"@value\":8.99}]")
+ .statusIsOk()
+ .hasJsonArrayOfDoubles()
+ .hasSize(8)
+ .containsExactlyInAnyOrder(18.95, 18.95, 22.99, 22.99, 22.99, 12.99, 112.99, 112.99);
+ }
+ }
+
+ @Test
+ public void concurrentRequests()
+ throws ExecutionException, InterruptedException, TimeoutException {
+ int entryCount = 20;
+ Collection<Future<Void>> futures = new ArrayList<>();
+
+ futures.add(pool.submit(() -> {
+ for (int i = 0; i < entryCount; i++) {
+ restClient.doPostAndAssert("/regionA?key=customer" + i,
+ "{\"customerId\":" + i
+ + ",\"firstName\":\"jon\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"123-456-789\"}")
+ .hasStatusCode(HttpStatus.SC_CREATED, HttpStatus.SC_CONFLICT);
+ }
+ }));
+
+ futures.add(pool.submit(() -> {
+ for (int i = 0; i < entryCount; i++) {
+ restClient.doPutAndAssert("/regionA/customer" + i,
+ "{\"customerId\":" + i
+ + ",\"firstName\":\"jon\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"123-456-789\"}")
+ .hasStatusCode(HttpStatus.SC_OK)
+ .hasResponseBody()
+ .isEmpty();
+ }
+ }));
+
+ futures.add(pool.submit(() -> {
+ for (int i = 0; i < entryCount; i++) {
+ restClient.doPutAndAssert("/regionA/customer" + i + "?op=REPLACE",
+ "{\"customerId\":" + i
+ + ",\"firstName\":\"jon\",\"lastName\":\"doe\",\"socialSecurityNumber\":\"123-456-789\"}")
+ .hasStatusCode(HttpStatus.SC_OK, HttpStatus.SC_NOT_FOUND);
+ }
+ }));
+
+ futures.add(pool.submit(() -> {
+ for (int i = 0; i < entryCount; i++) {
+ restClient.doGetAndAssert("/regionA/customer" + i)
+ .hasStatusCode(HttpStatus.SC_OK, HttpStatus.SC_NOT_FOUND);
+ }
+ }));
+
+ futures.add(pool.submit(() -> {
+ for (int i = 0; i < entryCount; i++) {
+ restClient.doDeleteAndAssert("/regionA/customer" + i)
+ .hasStatusCode(HttpStatus.SC_OK, HttpStatus.SC_NOT_FOUND);
+ }
+ }));
+
+ for (Future<Void> future : futures) {
+ future.get(getTimeout().getValueInMS(), MILLISECONDS);
+ }
+ }
+
+ private static void initJsonDocuments() throws URISyntaxException, IOException {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ URI uri = classLoader.getResource("sampleJson.json").toURI();
+
+ String rawJson = IOUtils.toString(uri, Charset.defaultCharset());
+
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode json = mapper.readTree(rawJson);
+
+ for (int i = 0; i < json.size(); i++) {
+ JSON_DOCUMENTS.add(json.get(i).toString());
+ }
+ }
+
+ private static <K, V> Region<K, V> getRegionA() {
+ return server.getCache().getRegion(SEPARATOR + "regionA");
+ }
+
+ private static final String DOCUMENT1 =
+ "{ \"store\": {" + lineSeparator() +
+ " \"book\": [ " + lineSeparator() +
+ " { \"category\": \"reference\"," + lineSeparator() +
+ " \"author\": \"Nigel Rees\"," + lineSeparator() +
+ " \"title\": \"Sayings of the Century\"," + lineSeparator() +
+ " \"displayprice\": 8.95" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"Evelyn Waugh\"," + lineSeparator() +
+ " \"title\": \"Sword of Honour\"," + lineSeparator() +
+ " \"displayprice\": 12.99" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"Herman Melville\"," + lineSeparator() +
+ " \"title\": \"Moby Dick\"," + lineSeparator() +
+ " \"isbn\": \"0-553-21311-3\"," + lineSeparator() +
+ " \"displayprice\": 8.99" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"J. R. R. Tolkien\"," + lineSeparator() +
+ " \"title\": \"The Lord of the Rings\"," + lineSeparator() +
+ " \"isbn\": \"0-395-19395-8\"," + lineSeparator() +
+ " \"displayprice\": 22.99" + lineSeparator() +
+ " }" + lineSeparator() +
+ " ]," + lineSeparator() +
+ " \"bicycle\": {" + lineSeparator() +
+ " \"color\": \"red\"," + lineSeparator() +
+ " \"displayprice\": 19.95," + lineSeparator() +
+ " \"foo:bar\": \"fooBar\"," + lineSeparator() +
+ " \"dot.notation\": \"new\"," + lineSeparator() +
+ " \"dash-notation\": \"dashes\"" + lineSeparator() +
+ " }" + lineSeparator() +
+ " }" + lineSeparator() +
+ "}";
+
+ private static final String DOCUMENT2 =
+ "{ \"store\": {" + lineSeparator() +
+ " \"book\": [ " + lineSeparator() +
+ " { \"category\": \"reference\"," + lineSeparator() +
+ " \"author\": \"Nigel Rees\"," + lineSeparator() +
+ " \"title\": \"Sayings of the Century\"," + lineSeparator() +
+ " \"displayprice\": 18.95" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"Evelyn Waugh\"," + lineSeparator() +
+ " \"title\": \"Sword of Honour\"," + lineSeparator() +
+ " \"displayprice\": 112.99" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"Herman Melville\"," + lineSeparator() +
+ " \"title\": \"Moby Dick\"," + lineSeparator() +
+ " \"isbn\": \"0-553-21311-3\"," + lineSeparator() +
+ " \"displayprice\": 8.99" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"J. R. R. Tolkien\"," + lineSeparator() +
+ " \"title\": \"The Lord of the Rings\"," + lineSeparator() +
+ " \"isbn\": \"0-395-19395-8\"," + lineSeparator() +
+ " \"displayprice\": 22.99" + lineSeparator() +
+ " }" + lineSeparator() +
+ " ]," + lineSeparator() +
+ " \"bicycle\": {" + lineSeparator() +
+ " \"color\": \"red\"," + lineSeparator() +
+ " \"displayprice\": 19.95," + lineSeparator() +
+ " \"foo:bar\": \"fooBar\"," + lineSeparator() +
+ " \"dot.notation\": \"new\"," + lineSeparator() +
+ " \"dash-notation\": \"dashes\"" + lineSeparator() +
+ " }" + lineSeparator() +
+ " }" + lineSeparator() +
+ "}";
+
+ private static final String DOCUMENT3 =
+ "{ \"store\": {" + lineSeparator() +
+ " \"book\": [ " + lineSeparator() +
+ " { \"category\": \"reference\"," + lineSeparator() +
+ " \"author\": \"Nigel Rees\"," + lineSeparator() +
+ " \"title\": \"Sayings of the Century\"," + lineSeparator() +
+ " \"displayprice\": 18.95" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"Evelyn Waugh\"," + lineSeparator() +
+ " \"title\": \"Sword of Honour\"," + lineSeparator() +
+ " \"displayprice\": 112.99" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"Herman Melville\"," + lineSeparator() +
+ " \"title\": \"Moby Dick\"," + lineSeparator() +
+ " \"isbn\": \"0-553-21311-3\"," + lineSeparator() +
+ " \"displayprice\": 8.99" + lineSeparator() +
+ " }," + lineSeparator() +
+ " { \"category\": \"fiction\"," + lineSeparator() +
+ " \"author\": \"J. R. R. Tolkien\"," + lineSeparator() +
+ " \"title\": \"The Lord of the Rings\"," + lineSeparator() +
+ " \"isbn\": \"0-395-19395-8\"," + lineSeparator() +
+ " \"displayprice\": 22.99" + lineSeparator() +
+ " }" + lineSeparator() +
+ " ]," + lineSeparator() +
+ " \"bicycle\": {" + lineSeparator() +
+ " \"color\": \"red\"," + lineSeparator() +
+ " \"displayprice\": 129.95," + lineSeparator() +
+ " \"foo:bar\": \"fooBar\"," + lineSeparator() +
+ " \"dot.notation\": \"new\"," + lineSeparator() +
+ " \"dash-notation\": \"dashes\"" + lineSeparator() +
+ " }" + lineSeparator() +
+ " }" + lineSeparator() +
+ "}";
+}
diff --git a/geode-connectors/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeConnectorsSerializablesJUnitTest.java b/geode-connectors/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeConnectorsSerializablesIntegrationTest.java
similarity index 74%
rename from geode-connectors/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeConnectorsSerializablesJUnitTest.java
rename to geode-connectors/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeConnectorsSerializablesIntegrationTest.java
index 88d12c7..b53ac7d 100644
--- a/geode-connectors/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeConnectorsSerializablesJUnitTest.java
+++ b/geode-connectors/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeConnectorsSerializablesIntegrationTest.java
@@ -16,13 +16,20 @@
import org.junit.experimental.categories.Category;
+import org.apache.geode.connectors.jdbc.internal.ConnectorsSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeConnectorsSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeConnectorsSerializablesIntegrationTest
+ extends AnalyzeSerializablesJUnitTestBase {
@Override
protected String getModuleName() {
return "geode-connectors";
}
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return ConnectorsSanctionedSerializablesService.class;
+ }
}
diff --git a/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.java b/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..7a6d11a
--- /dev/null
+++ b/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.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 org.apache.geode.connectors.jdbc.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class ConnectorsSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service =
+ new ConnectorsSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java
similarity index 67%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java
index 66d3a15..76b5390 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.connectors.jdbc.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class ConnectorsSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-connectors-serializables.txt");
}
}
diff --git a/geode-connectors/src/main/java/org/apache/geode/internal/ConnectorsDistributedSystemService.java b/geode-connectors/src/main/java/org/apache/geode/internal/ConnectorsDistributedSystemService.java
deleted file mode 100644
index 56278cd..0000000
--- a/geode-connectors/src/main/java/org/apache/geode/internal/ConnectorsDistributedSystemService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-
-public class ConnectorsDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-connectors-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index 5fbba6d..0000000
--- a/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1,16 +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.
-org.apache.geode.internal.ConnectorsDistributedSystemService
-
diff --git a/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..707525b
--- /dev/null
+++ b/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.connectors.jdbc.internal.ConnectorsSanctionedSerializablesService
diff --git a/geode-connectors/src/main/resources/org/apache/geode/internal/sanctioned-geode-connectors-serializables.txt b/geode-connectors/src/main/resources/org/apache/geode/connectors/jdbc/internal/sanctioned-geode-connectors-serializables.txt
similarity index 100%
rename from geode-connectors/src/main/resources/org/apache/geode/internal/sanctioned-geode-connectors-serializables.txt
rename to geode-connectors/src/main/resources/org/apache/geode/connectors/jdbc/internal/sanctioned-geode-connectors-serializables.txt
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCoreSerializablesIntegrationTest.java
old mode 100644
new mode 100755
similarity index 78%
rename from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
rename to geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCoreSerializablesIntegrationTest.java
index 32ce5c3..54128fe
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCoreSerializablesIntegrationTest.java
@@ -12,23 +12,23 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.internal.CoreSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeCoreSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
- return "geode-management";
+ return "geode-core";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return CoreSanctionedSerializablesService.class;
}
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..feeb08d
--- /dev/null
+++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class CoreSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new CoreSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index e97bd02..ddf99fe 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -26,15 +26,12 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
import java.util.Properties;
-import java.util.ServiceLoader;
import java.util.Set;
import java.util.SortedSet;
import java.util.StringTokenizer;
@@ -191,11 +188,6 @@
private final GrantorRequestProcessor.GrantorRequestContext grc;
- /**
- * services provided by other modules
- */
- private Map<Class, DistributedSystemService> services = new HashMap<>();
-
private final AtomicReference<ClusterAlertMessaging> clusterAlertMessaging =
new AtomicReference<>();
@@ -657,20 +649,6 @@
}
/**
- * Initialize any services that provided as extensions to the cache using the service loader
- * mechanism.
- */
- private void initializeServices() {
- ServiceLoader<DistributedSystemService> loader =
- ServiceLoader.load(DistributedSystemService.class);
- for (DistributedSystemService service : loader) {
- service.init(this);
- services.put(service.getInterface(), service);
- }
- }
-
-
- /**
* Initializes this connection to a distributed system with the current configuration state.
*/
private void initialize(SecurityManager securityManager, PostProcessor postProcessor,
@@ -735,8 +713,7 @@
locatorDMTypeForced = true;
}
- initializeServices();
- InternalDataSerializer.initialize(config, services.values());
+ InternalDataSerializer.initializeSerializationFilter(config);
// Initialize the Diffie-Hellman and public/private keys
try {
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java
similarity index 69%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java
index 66d3a15..790520e 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class CoreSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-core-serializables.txt");
}
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
index 468a13a..df91d13 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java
@@ -14,14 +14,14 @@
*/
package org.apache.geode.internal;
-import java.io.BufferedReader;
+import static org.apache.geode.internal.serialization.SanctionedSerializables.loadSanctionedSerializablesServices;
+
import java.io.DataInput;
import java.io.DataOutput;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.NotSerializableException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
@@ -40,7 +40,6 @@
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.SocketException;
-import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
@@ -82,13 +81,13 @@
import org.apache.geode.SystemFailure;
import org.apache.geode.ToDataException;
import org.apache.geode.annotations.Immutable;
+import org.apache.geode.annotations.VisibleForTesting;
import org.apache.geode.annotations.internal.MakeNotStatic;
import org.apache.geode.annotations.internal.MutableForTesting;
import org.apache.geode.cache.CacheClosedException;
import org.apache.geode.cache.execute.Function;
import org.apache.geode.distributed.internal.ClusterDistributionManager;
import org.apache.geode.distributed.internal.DMStats;
-import org.apache.geode.distributed.internal.DistributedSystemService;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.distributed.internal.LonerDistributionManager;
@@ -115,6 +114,7 @@
import org.apache.geode.internal.serialization.DscodeHelper;
import org.apache.geode.internal.serialization.ObjectDeserializer;
import org.apache.geode.internal.serialization.ObjectSerializer;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
import org.apache.geode.internal.serialization.SerializationContext;
import org.apache.geode.internal.serialization.SerializationVersions;
import org.apache.geode.internal.serialization.StaticSerialization;
@@ -161,52 +161,71 @@
* used by our Object Query Language. It also contains certain classes that are DataSerializable
* but end up being serialized as part of other serializable objects. VersionedObjectList, for
* instance, is serialized as part of a partial putAll exception object.
+ *
* <p>
* Do not java-serialize objects that Geode does not have complete control over. This leaves us
* open to security attacks such as Gadget Chains and compromises the ability to do a rolling
* upgrade from one version of Geode to the next.
+ *
* <p>
- * In general you shouldn't use java serialization and you should implement
+ * In general, you shouldn't use java serialization, and you should implement
* DataSerializableFixedID for internal Geode objects. This gives you better control over
* backward-compatibility.
+ *
* <p>
- * Do not add to this list unless absolutely necessary. Instead put your classes either in the
+ * Do not add to this list unless absolutely necessary. Instead, put your classes either in the
* sanctionedSerializables file for your module or in its excludedClasses file. Run
* AnalyzeSerializables to generate the content for the file.
- * <p>
*/
private static final String SANCTIONED_SERIALIZABLES_DEPENDENCIES_PATTERN =
- "java.**;javax.management.**" + ";javax.print.attribute.EnumSyntax" // used for some old enums
- + ";antlr.**" // query AST objects
+ // Java
+ "java.**"
- // old Admin API
- + ";org.apache.commons.modeler.AttributeInfo" + ";org.apache.commons.modeler.FeatureInfo"
+ // JMX
+ + ";javax.management.**"
+
+ // used for some old enums
+ + ";javax.print.attribute.EnumSyntax"
+
+ // Query AST objects
+ + ";antlr.**"
+
+ // old Admin API and old JMX
+ + ";org.apache.commons.modeler.AttributeInfo"
+ + ";org.apache.commons.modeler.FeatureInfo"
+ ";org.apache.commons.modeler.ManagedBean"
+ ";org.apache.geode.distributed.internal.DistributionConfigSnapshot"
+ ";org.apache.geode.distributed.internal.RuntimeDistributionConfigImpl"
+ ";org.apache.geode.distributed.internal.DistributionConfigImpl"
- // WindowedExportFunction, RegionSnapshotService
+ // WindowedExportFunction and RegionSnapshotService
+ ";org.apache.geode.distributed.internal.membership.InternalDistributedMember"
+
// putAll
- + ";org.apache.geode.internal.cache.persistence.PersistentMemberID" // putAll
- + ";org.apache.geode.internal.cache.persistence.DiskStoreID" // putAll
- + ";org.apache.geode.internal.cache.tier.sockets.VersionedObjectList" // putAll
+ + ";org.apache.geode.internal.cache.persistence.PersistentMemberID"
+ + ";org.apache.geode.internal.cache.persistence.DiskStoreID"
+ + ";org.apache.geode.internal.cache.tier.sockets.VersionedObjectList"
// security services
- + ";org.apache.shiro.*;org.apache.shiro.authz.*;org.apache.shiro.authc.*"
+ + ";org.apache.shiro.*"
+ + ";org.apache.shiro.authz.*"
+ + ";org.apache.shiro.authc.*"
// export logs
- + ";org.apache.logging.log4j.Level" + ";org.apache.logging.log4j.spi.StandardLevel"
+ + ";org.apache.logging.log4j.Level"
+ + ";org.apache.logging.log4j.spi.StandardLevel"
// jar deployment
- + ";com.sun.proxy.$Proxy*" + ";com.healthmarketscience.rmiio.RemoteInputStream"
- + ";javax.rmi.ssl.SslRMIClientSocketFactory" + ";javax.net.ssl.SSLHandshakeException"
+ + ";com.sun.proxy.$Proxy*"
+ + ";com.healthmarketscience.rmiio.RemoteInputStream"
+ + ";javax.rmi.ssl.SslRMIClientSocketFactory"
+ + ";javax.net.ssl.SSLHandshakeException"
+ ";javax.net.ssl.SSLException;sun.security.validator.ValidatorException"
+ ";sun.security.provider.certpath.SunCertPathBuilderException"
// geode-modules
- + ";org.apache.geode.modules.util.SessionCustomExpiry" + ";";
+ + ";org.apache.geode.modules.util.SessionCustomExpiry"
+ + ";";
private static final String serializationVersionTxt =
System.getProperty(GeodeGlossary.GEMFIRE_PREFIX + "serializationVersion");
/**
@@ -373,10 +392,21 @@
* DistributionConfig
*
* @param distributionConfig the DistributedSystem configuration
- * @param services DistributedSystem services that might have classes to acceptlist
*/
- public static void initialize(DistributionConfig distributionConfig,
- Collection<DistributedSystemService> services) {
+ public static void initializeSerializationFilter(DistributionConfig distributionConfig) {
+ initializeSerializationFilter(distributionConfig, loadSanctionedSerializablesServices());
+ }
+
+ /**
+ * Initializes the optional serialization "accept list" if the user has requested it in the
+ * DistributionConfig
+ *
+ * @param distributionConfig the DistributedSystem configuration
+ * @param services SanctionedSerializablesService that might have classes to acceptlist
+ */
+ @VisibleForTesting
+ public static void initializeSerializationFilter(DistributionConfig distributionConfig,
+ Collection<SanctionedSerializablesService> services) {
logger.info("initializing InternalDataSerializer with {} services", services.size());
if (distributionConfig.getValidateSerializableObjects()) {
if (!ClassUtils.isClassAvailable("sun.misc.ObjectInputFilter")
@@ -396,33 +426,6 @@
serializationFilter = defaultSerializationFilter;
}
- /**
- * {@link DistributedSystemService}s that need to acceptlist Serializable objects can use this to
- * read them from a file and then return them via
- * {@link DistributedSystemService#getSerializationAcceptlist}
- */
- public static Collection<String> loadClassNames(URL sanctionedSerializables) throws IOException {
- ArrayList<String> result = new ArrayList<>(1000);
- InputStream inputStream = sanctionedSerializables.openStream();
- InputStreamReader reader = new InputStreamReader(inputStream);
- BufferedReader in = new BufferedReader(reader);
- try {
- String line;
- while ((line = in.readLine()) != null) {
- line = line.trim();
- if (!(line.startsWith("#") || line.startsWith("//"))) {
- line = line.replaceAll("/", ".");
- result.add(line.substring(0, line.indexOf(',')));
- }
- }
- } finally {
- inputStream.close();
- }
- // logger.info("loaded {} class names from {}", result.size(), sanctionedSerializables);
- return result;
-
- }
-
private static SERIALIZATION_VERSION calculateSerializationVersion() {
if (serializationVersionTxt == null || serializationVersionTxt.isEmpty()) {
return latestVersion;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java b/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java
index 34029a3..184eb9f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java
@@ -15,12 +15,12 @@
package org.apache.geode.internal;
import java.io.IOException;
+import java.io.InvalidClassException;
import java.io.ObjectInputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -30,7 +30,7 @@
import org.apache.geode.GemFireConfigException;
import org.apache.geode.InternalGemFireError;
import org.apache.geode.InternalGemFireException;
-import org.apache.geode.distributed.internal.DistributedSystemService;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
import org.apache.geode.logging.internal.log4j.api.LogService;
@@ -65,10 +65,10 @@
private Method serialClassMethod; // method on ObjectInputFilter$FilterInfo
public ObjectInputStreamFilterWrapper(String serializationFilterSpec,
- Collection<DistributedSystemService> services) {
+ Collection<SanctionedSerializablesService> services) {
Set<String> sanctionedClasses = new HashSet<>(500);
- for (DistributedSystemService service : services) {
+ for (SanctionedSerializablesService service : services) {
try {
Collection<String> classNames = service.getSerializationAcceptlist();
logger.info("loaded {} sanctioned serializables from {}", classNames.size(),
@@ -80,25 +80,6 @@
}
}
- try {
- URL sanctionedSerializables = ClassPathLoader.getLatest()
- .getResource(InternalDataSerializer.class, "sanctioned-geode-core-serializables.txt");
- Collection<String> coreClassNames =
- InternalDataSerializer.loadClassNames(sanctionedSerializables);
-
- URL sanctionedManagementSerializables = ClassPathLoader.getLatest()
- .getResource(InternalDataSerializer.class,
- "sanctioned-geode-management-serializables.txt");
- Collection<String> managmentClassNames =
- InternalDataSerializer.loadClassNames(sanctionedManagementSerializables);
-
- sanctionedClasses.addAll(coreClassNames);
- sanctionedClasses.addAll(managmentClassNames);
- } catch (IOException e) {
- throw new InternalGemFireException(
- "unable to read sanctionedSerializables.txt to form a serialization acceptlist", e);
- }
-
logger.info("setting a serialization filter containing {}", serializationFilterSpec);
// try java8 - this will not throw an exception if ObjectInputFilter can't be found
@@ -217,7 +198,7 @@
switch (method.getName()) {
case "checkInput":
Object filterInfo = args[0];
- Class serialClass = (Class) serialClassMethod.invoke(filterInfo);
+ Class<?> serialClass = (Class<?>) serialClassMethod.invoke(filterInfo);
if (serialClass == null) { // no class to check, so nothing to accept-list
return checkInputMethod.invoke(userFilter, filterInfo);
}
@@ -227,14 +208,15 @@
}
if (sanctionedClasses.contains(className)) {
return ALLOWED;
- } else {
- Object status = checkInputMethod.invoke(userFilter, filterInfo);
- if (status == REJECTED) {
- logger.fatal("Serialization filter is rejecting class {}", className,
- new Exception(""));
- }
- return status;
}
+ Object status = checkInputMethod.invoke(userFilter, filterInfo);
+ if (status == REJECTED) {
+ logger.fatal("Serialization filter is rejecting class {}", className,
+ new InvalidClassException(className));
+ }
+ return status;
+ case "toString":
+ return userFilter.toString();
default:
throw new UnsupportedOperationException(
"ObjectInputFilter." + method.getName() + " is not implemented");
diff --git a/geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..57dbe52
--- /dev/null
+++ b/geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.internal.CoreSanctionedSerializablesService
diff --git a/geode-core/src/test/java/org/apache/geode/internal/InternalDataSerializerSerializationAcceptlistTest.java b/geode-core/src/test/java/org/apache/geode/internal/InternalDataSerializerSerializationAcceptlistTest.java
index fc8e787..bb02284 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/InternalDataSerializerSerializationAcceptlistTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/InternalDataSerializerSerializationAcceptlistTest.java
@@ -1,28 +1,3 @@
-package org.apache.geode.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Properties;
-
-import org.junit.AfterClass;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.DataSerializer;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.internal.lang.ClassUtils;
-import org.apache.geode.internal.serialization.Version;
-import org.apache.geode.test.junit.categories.SerializationTest;
-
/*
* 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
@@ -37,38 +12,68 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-@Category({SerializationTest.class})
+package org.apache.geode.internal;
+
+import static java.util.Collections.emptySet;
+import static org.apache.geode.distributed.internal.DistributionConfig.SERIALIZABLE_OBJECT_FILTER_NAME;
+import static org.apache.geode.distributed.internal.DistributionConfig.VALIDATE_SERIALIZABLE_OBJECTS_NAME;
+import static org.apache.geode.internal.lang.ClassUtils.isClassAvailable;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InvalidClassException;
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.DataSerializer;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionConfigImpl;
+import org.apache.geode.internal.serialization.Version;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category(SerializationTest.class)
public class InternalDataSerializerSerializationAcceptlistTest {
+
private HeapDataOutputStream outputStream;
private Object testSerializable;
private Properties properties;
+ @BeforeClass
+ public static void hasObjectInputFilter() {
+ assumeTrue("ObjectInputFilter is present in this JVM (post- 8.111)",
+ isClassAvailable("sun.misc.ObjectInputFilter") ||
+ isClassAvailable("java.io.ObjectInputFilter"));
+ }
+
@Before
public void setUp() {
- Assume.assumeTrue("ObjectInputFilter is present in this JVM (post- 8.111)",
- hasObjectInputFilter());
outputStream = new HeapDataOutputStream(Version.CURRENT);
testSerializable = new TestSerializable();
properties = new Properties();
}
- private boolean hasObjectInputFilter() {
- return (ClassUtils.isClassAvailable("sun.misc.ObjectInputFilter")
- || ClassUtils.isClassAvailable("java.io.ObjectInputFilter"));
- }
-
@AfterClass
public static void clearDataSerializerFilter() {
- InternalDataSerializer.initialize(new DistributionConfigImpl(new Properties()),
- new ArrayList<>());
+ InternalDataSerializer
+ .initializeSerializationFilter(new DistributionConfigImpl(new Properties()), emptySet());
}
@Test
public void distributionConfigDefaults() {
- DistributionConfigImpl distributionConfig = new DistributionConfigImpl(new Properties());
+ DistributionConfig distributionConfig = new DistributionConfigImpl(new Properties());
- assertFalse(distributionConfig.getValidateSerializableObjects());
- assertEquals("!*", distributionConfig.getSerializableObjectFilter());
+ assertThat(distributionConfig.getValidateSerializableObjects()).isFalse();
+ assertThat(distributionConfig.getSerializableObjectFilter()).isEqualTo("!*");
}
@Test
@@ -76,46 +81,69 @@
trySerializingTestObject(new Properties());
}
- @Test(expected = java.io.InvalidClassException.class)
- public void notAcceptlistedWithFilterCannotSerialize() throws Exception {
- properties.setProperty(DistributionConfig.VALIDATE_SERIALIZABLE_OBJECTS_NAME, "true");
+ @Test
+ public void notAcceptlistedWithFilterCannotSerialize() {
+ properties.setProperty(VALIDATE_SERIALIZABLE_OBJECTS_NAME, "true");
+
+ Throwable thrown = catchThrowable(() -> {
+ trySerializingTestObject(properties);
+ });
+
+ assertThat(thrown).isInstanceOf(InvalidClassException.class);
+ }
+
+ @Test
+ public void acceptlistedWithFilterCanSerialize() throws Exception {
+ properties.setProperty(VALIDATE_SERIALIZABLE_OBJECTS_NAME, "true");
+ properties.setProperty(SERIALIZABLE_OBJECT_FILTER_NAME, TestSerializable.class.getName());
trySerializingTestObject(properties);
}
@Test
- public void acceptlistedWithFilterCanSerialize() throws Exception {
- properties.setProperty(DistributionConfig.VALIDATE_SERIALIZABLE_OBJECTS_NAME, "true");
- properties.setProperty(DistributionConfig.SERIALIZABLE_OBJECT_FILTER_NAME,
- TestSerializable.class.getName());
+ public void acceptlistedWithNonMatchingFilterCannotSerialize() {
+ Throwable thrown = catchThrowable(() -> {
+ trySerializingWithFilter("RabidMonkeyTurnip");
+ });
- trySerializingTestObject(properties);
+ assertThat(thrown).isInstanceOf(InvalidClassException.class);
}
- @Test(expected = java.io.InvalidClassException.class)
- public void acceptlistedWithNonMatchingFilterCannotSerialize() throws Exception {
- trySerializingWithFilter("RabidMonkeyTurnip");
+ @Test
+ public void acceptlistedWithPartialMatchingFilterCannotSerialize() {
+ Throwable thrown = catchThrowable(() -> {
+ trySerializingWithFilter("TestSerializable"); // Not fully qualified class name
+ });
+
+ assertThat(thrown).isInstanceOf(InvalidClassException.class);
}
- @Test(expected = java.io.InvalidClassException.class)
- public void acceptlistedWithPartialMatchingFilterCannotSerialize() throws Exception {
- trySerializingWithFilter("TestSerializable"); // Not fully qualified class name
+ @Test
+ public void acceptlistedWithEmptyFilterCannotSerialize() {
+ Throwable thrown = catchThrowable(() -> {
+ trySerializingWithFilter("");
+ });
+
+ assertThat(thrown).isInstanceOf(InvalidClassException.class);
}
- @Test(expected = java.io.InvalidClassException.class)
- public void acceptlistedWithEmptyFilterCannotSerialize() throws Exception {
- trySerializingWithFilter("");
+ @Test
+ public void acceptlistedWithIncorrectPathFilterCannotSerialize() {
+ Throwable thrown = catchThrowable(() -> {
+ trySerializingWithFilter(
+ "org.apache.commons.InternalDataSerializerSerializationAcceptlistTest$TestSerializable");
+ });
+
+ assertThat(thrown).isInstanceOf(InvalidClassException.class);
}
- @Test(expected = java.io.InvalidClassException.class)
- public void acceptlistedWithIncorrectPathFilterCannotSerialize() throws Exception {
- trySerializingWithFilter(
- "org.apache.commons.InternalDataSerializerSerializationAcceptlistTest$TestSerializable");
- }
+ @Test
+ public void acceptlistedWithWildcardPathFilterCannotSerialize() {
+ Throwable thrown = catchThrowable(() -> {
+ trySerializingWithFilter("org.apache.*");
+ });
- @Test(expected = java.io.InvalidClassException.class)
- public void acceptlistedWithWildcardPathFilterCannotSerialize() throws Exception {
- trySerializingWithFilter("org.apache.*");
+ assertThat(thrown).isInstanceOf(InvalidClassException.class);
}
@Test
@@ -124,8 +152,8 @@
}
private void trySerializingWithFilter(String filter) throws Exception {
- properties.setProperty(DistributionConfig.VALIDATE_SERIALIZABLE_OBJECTS_NAME, "true");
- properties.setProperty(DistributionConfig.SERIALIZABLE_OBJECT_FILTER_NAME, filter);
+ properties.setProperty(VALIDATE_SERIALIZABLE_OBJECTS_NAME, "true");
+ properties.setProperty(SERIALIZABLE_OBJECT_FILTER_NAME, filter);
trySerializingTestObject(properties);
}
@@ -133,7 +161,7 @@
private void trySerializingTestObject(Properties properties)
throws IOException, ClassNotFoundException {
DistributionConfig distributionConfig = new DistributionConfigImpl(properties);
- InternalDataSerializer.initialize(distributionConfig, new ArrayList<>());
+ InternalDataSerializer.initializeSerializationFilter(distributionConfig, emptySet());
DataSerializer.writeObject(testSerializable, outputStream);
@@ -142,8 +170,8 @@
.readObject(new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
}
+ @SuppressWarnings("serial")
private static class TestSerializable implements Serializable {
-
+ // nothing
}
-
}
diff --git a/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java b/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..b17a1cf
--- /dev/null
+++ b/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.cache.query.cq.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class CQSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new CQSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-cq/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java b/geode-cq/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesIntegrationTest.java
similarity index 72%
rename from geode-cq/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
rename to geode-cq/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesIntegrationTest.java
index 8f1f384..43cc2df 100755
--- a/geode-cq/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
+++ b/geode-cq/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesIntegrationTest.java
@@ -16,11 +16,12 @@
import org.junit.experimental.categories.Category;
-import org.apache.geode.cache.query.cq.internal.CQDistributedSystemService;
+import org.apache.geode.cache.query.cq.internal.CQSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({ClientSubscriptionTest.class})
-public class AnalyzeCQSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category({ClientSubscriptionTest.class, SerializationTest.class})
+public class AnalyzeCQSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
@Override
protected String getModuleName() {
@@ -28,7 +29,7 @@
}
@Override
- protected Class getModuleClass() {
- return CQDistributedSystemService.class;
+ protected Class<?> getModuleClass() {
+ return CQSanctionedSerializablesService.class;
}
}
diff --git a/geode-cq/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-cq/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
deleted file mode 100644
index 8ce0692..0000000
--- a/geode-cq/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# e.g.,
-#org/apache/geode/cache/query/CqAttributesFactory
diff --git a/geode-cq/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt b/geode-cq/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
deleted file mode 100644
index f41f6f0..0000000
--- a/geode-cq/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# This is a list of classes excluded due to open bugs about their having
-# incompatible changes. There should be no entries in this file at the
-# time of a product release.
-
-# Each entry should be a bug number followed by a comma and the
-# full class name. The package components can be delimited with a period
-# or a comma. Don't include ".class" or ".java" at the end of the name.
-
-# example: 50174,org/apache/geode/distributed/internal/StartupResponseWithVersionMessage
-# example: 50175,com.gemstone.org.jgroups.Message$Header
-
-
-# ~~~~~~~~~~~~~~~~~~~ DataSerializables ~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testDataSerializables
-
-
-# ~~~~~~~~~~~~~~~~~~~ Serializables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testSerializables
-
-
-
diff --git a/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQDistributedSystemService.java b/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQDistributedSystemService.java
deleted file mode 100644
index fbc3bc5..0000000
--- a/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQDistributedSystemService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.cache.query.cq.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.InternalDataSerializer;
-
-public class CQDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-cq-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java
index 66d3a15..59838f8 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.cache.query.cq.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class CQSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-cq-serializables.txt");
}
}
diff --git a/geode-cq/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-cq/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index 7b645e3..0000000
--- a/geode-cq/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1,16 +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.
-org.apache.geode.cache.query.cq.internal.CQDistributedSystemService
-
diff --git a/geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..ff9f5ff
--- /dev/null
+++ b/geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.cache.query.cq.internal.CQSanctionedSerializablesService
diff --git a/geode-dunit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeDUnitSerializablesIntegrationTest.java b/geode-dunit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeDUnitSerializablesIntegrationTest.java
new file mode 100644
index 0000000..4186351
--- /dev/null
+++ b/geode-dunit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeDUnitSerializablesIntegrationTest.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 org.apache.geode.codeAnalysis;
+
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+
+import org.apache.logging.log4j.Logger;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.logging.internal.log4j.api.LogService;
+import org.apache.geode.test.dunit.internal.DUnitSanctionedSerializablesService;
+import org.apache.geode.test.dunit.internal.Master;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category(SerializationTest.class)
+public class AnalyzeDUnitSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
+ private static final Logger logger = LogService.getLogger();
+
+ private static final Set<Class<?>> IGNORE_CLASSES = new HashSet<>();
+ static {
+ IGNORE_CLASSES.add(Master.class);
+ classForName("org.apache.geode.test.dunit.internal.RemoteDUnitVM")
+ .ifPresent(IGNORE_CLASSES::add);
+ }
+
+ @Override
+ protected String getModuleName() {
+ return "geode-dunit";
+ }
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return DUnitSanctionedSerializablesService.class;
+ }
+
+ @Override
+ protected boolean ignoreClass(Class<?> theClass) {
+ return IGNORE_CLASSES.contains(theClass);
+ }
+
+ private static Optional<Class<?>> classForName(String className) {
+ try {
+ return Optional.of(Class.forName(className));
+ } catch (ClassNotFoundException e) {
+ logger.error("Unable to add class {} to IGNORE_CLASSES", className, e);
+ }
+ return Optional.empty();
+ }
+}
diff --git a/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java b/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..f70d3c3
--- /dev/null
+++ b/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.test.dunit.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class DUnitSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new DUnitSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-dunit/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-dunit/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
new file mode 100644
index 0000000..0a118b9
--- /dev/null
+++ b/geode-dunit/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -0,0 +1,4 @@
+org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase$FailsSerializationFilter
+org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase$Value
+org/apache/geode/test/dunit/log4j/LogWriterLogger
+org/apache/geode/test/dunit/log4j/LogWriterLogger$LogWriterLevel
diff --git a/geode-dunit/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt b/geode-dunit/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
new file mode 100644
index 0000000..626eb10
--- /dev/null
+++ b/geode-dunit/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -0,0 +1,47 @@
+org/apache/geode/cache/query/dunit/TestObject,2
+fromData,29
+toData,29
+
+org/apache/geode/cache30/MultiVMRegionTestCase$DSIntWrapper,2
+fromData,11
+toData,11
+
+org/apache/geode/cache30/MultiVMRegionTestCase$DSLongWrapper,2
+fromData,11
+toData,11
+
+org/apache/geode/internal/cache/CommitFunction,2
+fromData,1
+toData,1
+
+org/apache/geode/internal/cache/NestedTransactionFunction,2
+fromData,1
+toData,1
+
+org/apache/geode/internal/cache/RollbackFunction,2
+fromData,1
+toData,1
+
+org/apache/geode/internal/cache/execute/data/Customer,2
+fromData,17
+toData,17
+
+org/apache/geode/internal/cache/execute/data/Order,2
+fromData,9
+toData,9
+
+org/apache/geode/internal/cache/execute/data/Shipment,2
+fromData,9
+toData,9
+
+org/apache/geode/internal/cache/functions/TestFunction,2
+fromData,71
+toData,9
+
+org/apache/geode/internal/cache/wan/GatewayEventSubstituteObject,2
+fromData,9
+toData,16
+
+org/apache/geode/security/SecurityTestUtils$Employee,2
+fromData,8
+toData,43
diff --git a/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
index 44b4e50..186cf90 100644
--- a/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
@@ -14,13 +14,21 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static java.lang.System.nanoTime;
+import static java.util.Objects.requireNonNull;
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.cache.RegionShortcut.PARTITION;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
+import static org.apache.geode.management.ManagementService.getExistingManagementService;
+import static org.apache.geode.management.internal.cli.domain.DataCommandResult.DATA_INFO_SECTION;
+import static org.apache.geode.management.internal.cli.domain.DataCommandResult.QUERY_SECTION;
import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
-import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
-import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.apache.geode.test.dunit.rules.ClusterStartupRule.getCache;
+import static org.assertj.core.api.Assertions.assertThat;
+import java.io.InvalidClassException;
+import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -39,274 +47,317 @@
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.query.QueryInvalidException;
import org.apache.geode.cache.query.data.Portfolio;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.AvailablePortHelper;
import org.apache.geode.internal.cache.EvictionAttributesImpl;
-import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.management.ManagementService;
import org.apache.geode.management.MemberMXBean;
-import org.apache.geode.management.internal.cli.domain.DataCommandResult;
-import org.apache.geode.management.internal.cli.dto.Value1;
import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.management.internal.cli.result.model.ResultModel;
-import org.apache.geode.test.dunit.IgnoredException;
import org.apache.geode.test.dunit.rules.ClusterStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-@SuppressWarnings("serial")
-public class QueryCommandDUnitTestBase {
- private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
- private static final String DATA_REGION_NAME_PATH = "/" + DATA_REGION_NAME;
- private static final String DATA_REGION_WITH_EVICTION_NAME =
- "GemfireDataCommandsTestRegionWithEviction";
- private static final String DATA_REGION_WITH_EVICTION_NAME_PATH =
- "/" + DATA_REGION_WITH_EVICTION_NAME;
- private static final String DATA_PAR_REGION_NAME = "GemfireDataCommandsTestParRegion";
- private static final String DATA_PAR_REGION_NAME_PATH = "/" + DATA_PAR_REGION_NAME;
+public abstract class QueryCommandDUnitTestBase {
- private static final String SERIALIZATION_FILTER =
- "org.apache.geode.management.internal.cli.dto.**";
+ private static final String SERIALIZATION_FILTER = Value.class.getName();
- static final int COUNT = 5;
+ private static final String REGION_NAME = "region";
+ private static final String REGION_NAME_PATH = SEPARATOR + REGION_NAME;
+
+ private static final String REGION_EVICTION_NAME = "regionWithEviction";
+ private static final String REGION_EVICTION_NAME_PATH = SEPARATOR + REGION_EVICTION_NAME;
+
+ private static final String PARTITIONED_REGION_NAME = "partitionedRegion";
+ private static final String PARTITIONED_REGION_NAME_PATH = SEPARATOR + PARTITIONED_REGION_NAME;
+
+ private static final int MAX_RANDOM_INTEGER = 5;
+
+ protected MemberVM locator;
+ protected MemberVM server1;
+ protected MemberVM server2;
@Rule
public GfshCommandRule gfsh = new GfshCommandRule();
-
@Rule
public ClusterStartupRule cluster = new ClusterStartupRule();
- protected MemberVM locator, server1, server2;
-
@Before
- public void before() throws Exception {
+ public void setUp() throws Exception {
Properties locatorProps = locatorProperties();
+
locator = cluster.startLocatorVM(0, l -> l.withHttpService().withProperties(locatorProps));
server1 = cluster.startServerVM(1, serverProperties(), locator.getPort());
server2 = cluster.startServerVM(2, serverProperties(), locator.getPort());
- server1.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME));
- server2.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME));
- server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
+ server1.invoke(() -> createReplicatedRegion(REGION_NAME));
+ server2.invoke(() -> createReplicatedRegion(REGION_NAME));
+ server1.invoke(() -> createPartitionedRegion(PARTITIONED_REGION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 1);
+ locator.waitUntilRegionIsReadyOnExactlyThisManyServers(REGION_NAME_PATH, 2);
+ locator.waitUntilRegionIsReadyOnExactlyThisManyServers(PARTITIONED_REGION_NAME_PATH, 1);
connectToLocator();
}
- public void connectToLocator() throws Exception {
- gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
+ /**
+ * Override to add additional locator config properties. {@code serializable-object-filter} has
+ * already been set in the config properties.
+ */
+ protected abstract Properties locatorProperties(Properties configProperties);
+
+ /**
+ * Override to specify the mechanism used to connect to the Locator.
+ */
+ protected abstract void connectToLocator() throws Exception;
+
+ private Properties locatorProperties() {
+ Properties configProperties = new Properties();
+ configProperties.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
+ return locatorProperties(configProperties);
+ }
+
+ private Properties serverProperties() {
+ Properties configProperties = new Properties();
+ configProperties.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
+ return configProperties;
}
@Test
public void testWithGfshEnvironmentVariables() {
- String query =
- "query --query=\"select ID , status , createTime , pk, floatMinValue from ${DATA_REGION} where ID <= ${PORTFOLIO_ID}"
- + " and status=${STATUS}" + "\" --interactive=false";
- gfsh.executeAndAssertThat("set variable --name=DATA_REGION --value=" + DATA_REGION_NAME_PATH)
+ gfsh.executeAndAssertThat("set variable --name=DATA_REGION --value=" + REGION_NAME_PATH)
.statusIsSuccess();
- gfsh.executeAndAssertThat("set variable --name=PORTFOLIO_ID --value=3").statusIsSuccess();
- gfsh.executeAndAssertThat("set variable --name=STATUS --value=inactive").statusIsSuccess();
- gfsh.executeAndAssertThat(query).statusIsSuccess();
+ gfsh.executeAndAssertThat("set variable --name=PORTFOLIO_ID --value=3")
+ .statusIsSuccess();
+ gfsh.executeAndAssertThat("set variable --name=STATUS --value=inactive")
+ .statusIsSuccess();
+
+ String query = "query --query=\"" +
+ "select ID , status , createTime , pk, floatMinValue " +
+ "from ${DATA_REGION} " +
+ "where ID <= ${PORTFOLIO_ID} and status=${STATUS}" + "\" --interactive=false";
+
+ gfsh.executeAndAssertThat(query)
+ .statusIsSuccess();
}
@Test
public void testWithUnsetGfshEnvironmentVariables() {
- IgnoredException ex =
- addIgnoredException(QueryInvalidException.class.getSimpleName(), locator.getVM());
- try {
- String query =
- "query --query=\"select ID , status , createTime , pk, floatMinValue from ${UNSET_REGION} where ID <= ${UNSET_PORTFOLIO_ID}"
- + " and status=${UNSET_STATUS}" + "\" --interactive=false";
- gfsh.executeAndAssertThat(query).statusIsError()
- .containsOutput(String.format("Syntax error in query: %s", ""));
- } finally {
- ex.remove();
- }
+ addIgnoredException(QueryInvalidException.class);
+
+ String query = "query --query=\"" +
+ "select ID , status , createTime , pk, floatMinValue " +
+ "from ${UNSET_REGION} " +
+ "where ID <= ${UNSET_PORTFOLIO_ID} and status=${UNSET_STATUS}" + "\" --interactive=false";
+
+ gfsh.executeAndAssertThat(query)
+ .statusIsError()
+ .containsOutput(String.format("Syntax error in query: %s", ""));
}
@Test
public void testSimpleQuery() {
- server1.invoke(() -> prepareDataForRegion(DATA_PAR_REGION_NAME_PATH));
- Random random = new Random(System.nanoTime());
- int randomInteger = random.nextInt(COUNT);
- String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from "
- + DATA_PAR_REGION_NAME_PATH + " where ID <= " + randomInteger + "\" --interactive=false";
+ server1.invoke(() -> setUpDataForRegion(PARTITIONED_REGION_NAME_PATH));
+
+ int randomInteger = new Random(nanoTime()).nextInt(MAX_RANDOM_INTEGER);
+
+ String query = "query --query=\"" +
+ "select ID , status , createTime , pk, floatMinValue " +
+ "from " + PARTITIONED_REGION_NAME_PATH + " " +
+ "where ID <= " + randomInteger + "\" --interactive=false";
+
CommandResult commandResult = gfsh.executeCommand(query);
- validateSelectResult(commandResult, true, (randomInteger + 1),
- new String[] {"ID", "status", "createTime", "pk", "floatMinValue"});
+
+ validateSelectResult(commandResult, true, randomInteger + 1,
+ "ID", "status", "createTime", "pk", "floatMinValue");
}
@Test
public void testSimpleQueryOnLocator() {
- server1.invoke(() -> prepareDataForRegion(DATA_PAR_REGION_NAME_PATH));
+ server1.invoke(() -> setUpDataForRegion(PARTITIONED_REGION_NAME_PATH));
locator.invoke(() -> {
- String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from "
- + DATA_PAR_REGION_NAME_PATH + " where ID <= 4"
- + "\" --interactive=false";
- ManagementService service =
- ManagementService.getExistingManagementService(ClusterStartupRule.getCache());
- MemberMXBean member = service.getMemberMXBean();
- String cmdResult = member.processCommand(query);
+ String query = "query --query=\"" +
+ "select ID , status , createTime , pk, floatMinValue " +
+ "from " + PARTITIONED_REGION_NAME_PATH + " " +
+ "where ID <= 4" + "\" --interactive=false";
- assertThat(cmdResult).contains("ID");
- assertThat(cmdResult).contains("status");
- assertThat(cmdResult).contains("createTime");
- assertThat(cmdResult).contains("pk");
- assertThat(cmdResult).contains("floatMinValue");
- assertThat(cmdResult).contains("\"Rows\":\"5\"");
+ String result = getMemberMXBean().processCommand(query);
+
+ assertThat(result).contains("ID");
+ assertThat(result).contains("status");
+ assertThat(result).contains("createTime");
+ assertThat(result).contains("pk");
+ assertThat(result).contains("floatMinValue");
+ assertThat(result).contains("\"Rows\":\"5\"");
});
}
@Test
public void testQueryEvictedDataDeserializable() {
- server1.invoke(() -> setupReplicatedRegionWithEviction(DATA_REGION_WITH_EVICTION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_WITH_EVICTION_NAME_PATH, 1);
- server1.invoke(() -> prepareDeserializableDataForRegion(DATA_REGION_WITH_EVICTION_NAME_PATH));
+ server1.invoke(() -> createReplicatedRegionWithEviction(REGION_EVICTION_NAME));
+ locator.waitUntilRegionIsReadyOnExactlyThisManyServers(REGION_EVICTION_NAME_PATH, 1);
+ server1.invoke(() -> setUpDeserializableDataForRegion(REGION_EVICTION_NAME_PATH));
- String query = "query --query=\"select Value from " + DATA_REGION_WITH_EVICTION_NAME_PATH
- + "\" --interactive=false";
+ String query = "query --query=\"" +
+ "select Value from " + REGION_EVICTION_NAME_PATH + "\" --interactive=false";
+
CommandResult commandResult = gfsh.executeCommand(query);
- validateSelectResult(commandResult, Boolean.TRUE, 10, new String[] {"Value"});
+
+ validateSelectResult(commandResult, true, 10, "Value");
}
@Test
public void testQueryEvictedDataNotDeserializable() {
- IgnoredException ex =
- addIgnoredException(Exception.class.getSimpleName(), locator.getVM());
+ addIgnoredException(InvalidClassException.class);
- server1.invoke(() -> setupReplicatedRegionWithEviction(DATA_REGION_WITH_EVICTION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_WITH_EVICTION_NAME_PATH, 1);
- server1
- .invoke(() -> prepareNotDeserializableDataForRegion(DATA_REGION_WITH_EVICTION_NAME_PATH));
+ server1.invoke(() -> createReplicatedRegionWithEviction(REGION_EVICTION_NAME));
+ locator.waitUntilRegionIsReadyOnExactlyThisManyServers(REGION_EVICTION_NAME_PATH, 1);
+ server1.invoke(() -> setUpNotDeserializableDataForRegion(REGION_EVICTION_NAME_PATH));
- String query = "query --query=\"select Value from " + DATA_REGION_WITH_EVICTION_NAME_PATH
- + "\" --interactive=false";
+ String query = "query --query=\"" +
+ "select Value from " + REGION_EVICTION_NAME_PATH + "\" --interactive=false";
+
CommandResult commandResult = gfsh.executeCommand(query);
- validateSelectResult(commandResult, Boolean.FALSE, -1, new String[] {"Value"});
- assertThat(commandResult.asString())
- .contains("An IOException was thrown while deserializing");
- ex.remove();
+ validateSelectResult(commandResult, false, -1, "Value");
+
+ assertThat(commandResult.asString()).contains("An IOException was thrown while deserializing");
}
- private static void prepareDataForRegion(String regionPath) {
- InternalCache cache = ClusterStartupRule.getCache();
- Region dataRegion = cache.getRegion(regionPath);
+ private static void createReplicatedRegion(String regionName) {
+ createRegionFactory(REPLICATE)
+ .create(regionName);
+ }
- for (int j = 0; j < 10; j++) {
- dataRegion.put(new Integer(j), new Portfolio(j));
+ private static void createReplicatedRegionWithEviction(String regionName) {
+ EvictionAttributesImpl evictionAttributes = new EvictionAttributesImpl()
+ .setAction(EvictionAction.OVERFLOW_TO_DISK)
+ .setAlgorithm(EvictionAlgorithm.LRU_ENTRY)
+ .setMaximum(1);
+
+ createRegionFactory(REPLICATE)
+ .setEvictionAttributes(evictionAttributes)
+ .create(regionName);
+ }
+
+ private static void createPartitionedRegion(String regionName) {
+ PartitionAttributes<?, ?> partitionAttributes = new PartitionAttributesFactory<>()
+ .setRedundantCopies(2)
+ .create();
+
+ createRegionFactory(PARTITION)
+ .setPartitionAttributes(partitionAttributes)
+ .create(regionName);
+ }
+
+ private static void setUpDataForRegion(String regionPath) {
+ Region<Integer, Portfolio> region = getRegion(regionPath);
+
+ for (int index = 0; index < 10; index++) {
+ region.put(index, new Portfolio(index));
}
}
- private static void prepareNotDeserializableDataForRegion(String regionPath) {
- InternalCache cache = ClusterStartupRule.getCache();
- Region dataRegion = cache.getRegion(regionPath);
+ private static void setUpNotDeserializableDataForRegion(String regionPath) {
+ Region<Integer, FailsSerializationFilter> region = getRegion(regionPath);
- for (int j = 0; j < 10; j++) {
- dataRegion.put(new Integer(j), new shouldFailSerializationFilter(j));
+ for (int index = 0; index < 10; index++) {
+ region.put(index, new FailsSerializationFilter(index));
}
}
- private static void prepareDeserializableDataForRegion(String regionPath) {
- InternalCache cache = ClusterStartupRule.getCache();
- Region dataRegion = cache.getRegion(regionPath);
+ private static void setUpDeserializableDataForRegion(String regionPath) {
+ Region<Integer, Value> region = getRegion(regionPath);
- for (int j = 0; j < 10; j++) {
- dataRegion.put(new Integer(j), new Value1(j));
+ for (int index = 0; index < 10; index++) {
+ region.put(index, new Value(index));
}
}
- private static void setupReplicatedRegionWithEviction(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- EvictionAttributesImpl evictionAttributes = new EvictionAttributesImpl();
- evictionAttributes.setMaximum(1).setAction(EvictionAction.OVERFLOW_TO_DISK)
- .setAlgorithm(EvictionAlgorithm.LRU_ENTRY);
- RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE)
- .setEvictionAttributes(evictionAttributes);
+ private static void validateSelectResult(CommandResult commandResult, boolean expectSuccess,
+ int expectedRows, String... columns) {
+ ResultModel resultData = commandResult.getResultData();
- Region dataRegion = regionFactory.create(regionName);
- assertThat(dataRegion).isNotNull();
- assertThat(dataRegion.getFullPath()).contains(regionName);
- }
-
- private static void setupPartitionedRegion(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- PartitionAttributes partitionAttrs =
- new PartitionAttributesFactory().setRedundantCopies(2).create();
- RegionFactory<Object, Object> partitionRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
-
- partitionRegionFactory.setPartitionAttributes(partitionAttrs);
- Region dataParRegion = partitionRegionFactory.create(regionName);
-
- assertThat(dataParRegion).isNotNull();
- assertThat(dataParRegion.getFullPath()).contains(regionName);
- }
-
- private static void setupReplicatedRegion(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
-
- Region dataRegion = regionFactory.create(regionName);
- assertThat(dataRegion).isNotNull();
- assertThat(dataRegion.getFullPath()).contains(regionName);
- }
-
- private void validateSelectResult(CommandResult cmdResult, Boolean expectSuccess,
- Integer expectedRows, String[] cols) {
- ResultModel rd = cmdResult.getResultData();
-
- Map<String, String> data =
- rd.getDataSection(DataCommandResult.DATA_INFO_SECTION).getContent();
- assertThat(data.get("Result")).isEqualTo(expectSuccess.toString());
+ Map<String, String> data = resultData.getDataSection(DATA_INFO_SECTION).getContent();
+ assertThat(data.get("Result")).isEqualTo(String.valueOf(expectSuccess));
if (expectSuccess && expectedRows != -1) {
- assertThat(data.get("Rows")).isEqualTo(expectedRows.toString());
+ assertThat(data.get("Rows")).isEqualTo(String.valueOf(expectedRows));
- if (expectedRows > 0 && cols != null) {
- Map<String, List<String>> table =
- rd.getTableSection(DataCommandResult.QUERY_SECTION).getContent();
- assertThat(table.keySet()).contains(cols);
+ if (expectedRows > 0 && columns != null) {
+ Map<String, List<String>> table = resultData.getTableSection(QUERY_SECTION).getContent();
+ assertThat(table.keySet()).contains(columns);
}
}
-
}
- private Properties locatorProperties() {
- int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
- Properties props = new Properties();
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(LOG_LEVEL, "fine");
- props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
- props.setProperty(ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS, "localhost");
- props.setProperty(ConfigurationProperties.JMX_MANAGER_PORT, "" + jmxPort);
-
- return props;
+ private static MemberMXBean getMemberMXBean() {
+ return getManagementService().getMemberMXBean();
}
- private Properties serverProperties() {
- Properties props = new Properties();
- props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
-
- return props;
+ private static ManagementService getManagementService() {
+ return getExistingManagementService(getCache());
}
- public static class shouldFailSerializationFilter extends Value1 {
- private Value1 value1 = null;
+ private static <K, V> RegionFactory<K, V> createRegionFactory(RegionShortcut shortcut) {
+ return requireNonNull(getCache()).createRegionFactory(shortcut);
+ }
- public shouldFailSerializationFilter(int i) {
- super(i);
+ private static <K, V> Region<K, V> getRegion(String regionPath) {
+ return requireNonNull(getCache()).getRegion(regionPath);
+ }
+
+ /**
+ * Sample class for Data DUnit tests with JSON keys and values
+ */
+ @SuppressWarnings("serial")
+ public static class Value implements Serializable {
+
+ private final String name;
+ private final String lastName;
+ private final String department;
+ private final int age;
+ private final int employeeId;
+
+ public Value(int suffix) {
+ employeeId = suffix;
+ name = "Name" + suffix;
+ lastName = "lastName" + suffix;
+ department = "department" + suffix;
+ age = suffix;
}
- public Value1 getValue1() {
- return value1;
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof Value) {
+ Value value = (Value) other;
+ return value.employeeId == employeeId;
+ }
+ return false;
}
- public void setValue1(Value1 value1) {
- this.value1 = value1;
+ @Override
+ public int hashCode() {
+ return employeeId % 7;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("Value [")
+ .append(" name : ").append(name)
+ .append(" lastName : ").append(lastName)
+ .append(" department : ").append(department)
+ .append(" age : ").append(age)
+ .append(" employeeId : ").append(employeeId)
+ .append(" ]")
+ .toString();
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class FailsSerializationFilter extends Value {
+
+ public FailsSerializationFilter(int suffix) {
+ super(suffix);
}
}
}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java
index 66d3a15..6ae34d7 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.test.dunit.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class DUnitSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-dunit-serializables.txt");
}
}
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/LocatorLauncherStartupRule.java b/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/LocatorLauncherStartupRule.java
index 8097393..40573d1 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/LocatorLauncherStartupRule.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/LocatorLauncherStartupRule.java
@@ -28,10 +28,11 @@
import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.distributed.LocatorLauncher;
import org.apache.geode.test.junit.rules.serializable.SerializableExternalResource;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
public class LocatorLauncherStartupRule extends SerializableExternalResource {
private LocatorLauncher launcher;
- private final TemporaryFolder temp = new TemporaryFolder();
+ private final TemporaryFolder temp = new SerializableTemporaryFolder();
private final Properties properties = new Properties();
private boolean autoStart;
private UnaryOperator<LocatorLauncher.Builder> builderOperator;
diff --git a/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/ServerLauncherStartupRule.java b/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/ServerLauncherStartupRule.java
index 17b66f0..07794c1 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/ServerLauncherStartupRule.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/junit/rules/ServerLauncherStartupRule.java
@@ -26,10 +26,11 @@
import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.distributed.ServerLauncher;
import org.apache.geode.test.junit.rules.serializable.SerializableExternalResource;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
public class ServerLauncherStartupRule extends SerializableExternalResource {
private ServerLauncher launcher;
- private final TemporaryFolder temp = new TemporaryFolder();
+ private final TemporaryFolder temp = new SerializableTemporaryFolder();
private final Properties properties = new Properties();
private boolean autoStart;
private UnaryOperator<ServerLauncher.Builder> builderOperator;
diff --git a/geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..1d12933
--- /dev/null
+++ b/geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.test.dunit.internal.DUnitSanctionedSerializablesService
diff --git a/geode-dunit/src/main/resources/org/apache/geode/test/dunit/internal/sanctioned-geode-dunit-serializables.txt b/geode-dunit/src/main/resources/org/apache/geode/test/dunit/internal/sanctioned-geode-dunit-serializables.txt
new file mode 100644
index 0000000..f837935
--- /dev/null
+++ b/geode-dunit/src/main/resources/org/apache/geode/test/dunit/internal/sanctioned-geode-dunit-serializables.txt
@@ -0,0 +1,182 @@
+org/apache/geode/cache/client/internal/LocatorTestBase,false
+org/apache/geode/cache/client/internal/LocatorTestBase$1,false,this$0:org/apache/geode/cache/client/internal/LocatorTestBase
+org/apache/geode/cache/client/internal/LocatorTestBase$2,false,this$0:org/apache/geode/cache/client/internal/LocatorTestBase,val$pool:org/apache/geode/cache/client/Pool,val$regions:java/lang/String[]
+org/apache/geode/cache/client/internal/LocatorTestBase$3,false,this$0:org/apache/geode/cache/client/internal/LocatorTestBase
+org/apache/geode/cache/query/QueryTestUtils,false,bindQueries:java/util/HashMap,queries:java/util/HashMap
+org/apache/geode/cache/query/QueryTestUtils$1,true,1,this$0:org/apache/geode/cache/query/QueryTestUtils,val$prop:java/util/Properties
+org/apache/geode/cache/query/QueryTestUtils$10,false,this$0:org/apache/geode/cache/query/QueryTestUtils,val$qarr:java/lang/String[]
+org/apache/geode/cache/query/QueryTestUtils$2,true,1,this$0:org/apache/geode/cache/query/QueryTestUtils,val$constraint:java/lang/Class,val$name:java/lang/String
+org/apache/geode/cache/query/QueryTestUtils$3,true,1,this$0:org/apache/geode/cache/query/QueryTestUtils,val$name:java/lang/String
+org/apache/geode/cache/query/QueryTestUtils$4,false,this$0:org/apache/geode/cache/query/QueryTestUtils,val$field:java/lang/String,val$name:java/lang/String,val$region:java/lang/String
+org/apache/geode/cache/query/QueryTestUtils$5,false,this$0:org/apache/geode/cache/query/QueryTestUtils,val$field:java/lang/String,val$name:java/lang/String,val$region:java/lang/String
+org/apache/geode/cache/query/QueryTestUtils$6,true,1,this$0:org/apache/geode/cache/query/QueryTestUtils,val$name:java/lang/String
+org/apache/geode/cache/query/QueryTestUtils$7,true,1,this$0:org/apache/geode/cache/query/QueryTestUtils,val$name:java/lang/String,val$regionAttributes:org/apache/geode/cache/RegionAttributes,val$rootName:java/lang/String
+org/apache/geode/cache/query/QueryTestUtils$8,true,1,this$0:org/apache/geode/cache/query/QueryTestUtils
+org/apache/geode/cache/query/QueryTestUtils$9,false,this$0:org/apache/geode/cache/query/QueryTestUtils,val$qarr:java/lang/String[]
+org/apache/geode/cache/query/dunit/HelperTestCase,false
+org/apache/geode/cache/query/dunit/HelperTestCase$1,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$regionName:java/lang/String,val$valueConstraint:java/lang/Class
+org/apache/geode/cache/query/dunit/HelperTestCase$10,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$cqName:java/lang/String
+org/apache/geode/cache/query/dunit/HelperTestCase$11,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase
+org/apache/geode/cache/query/dunit/HelperTestCase$12,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$port:int,val$properties:java/util/Properties
+org/apache/geode/cache/query/dunit/HelperTestCase$13,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase
+org/apache/geode/cache/query/dunit/HelperTestCase$14,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$ports:int[],val$properties:java/util/Properties,val$redundancyLevel:int,val$servers:org/apache/geode/test/dunit/VM[]
+org/apache/geode/cache/query/dunit/HelperTestCase$2,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$regionName:java/lang/String,val$valueConstraint:java/lang/Class
+org/apache/geode/cache/query/dunit/HelperTestCase$3,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$regionName:java/lang/String,val$valueConstraint:java/lang/Class
+org/apache/geode/cache/query/dunit/HelperTestCase$4,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$cqAttr:org/apache/geode/cache/query/CqAttributes,val$cqName:java/lang/String,val$query:java/lang/String
+org/apache/geode/cache/query/dunit/HelperTestCase$5,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$regionName:java/lang/String
+org/apache/geode/cache/query/dunit/HelperTestCase$6,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$indexName:java/lang/String,val$indexedExpression:java/lang/String,val$regionPath:java/lang/String
+org/apache/geode/cache/query/dunit/HelperTestCase$7,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$indexName:java/lang/String,val$regionName:java/lang/String
+org/apache/geode/cache/query/dunit/HelperTestCase$8,false,this$0:org/apache/geode/cache/query/dunit/HelperTestCase,val$key:java/lang/Object,val$regionName:java/lang/String,val$value:java/lang/Object
+org/apache/geode/cache30/CacheSerializableRunnable,false
+org/apache/geode/cache30/CacheSerializableRunnable$CacheSerializableRunnableException,false
+org/apache/geode/cache30/CacheTestCase,false
+org/apache/geode/cache30/CacheXmlTestCase,false,restoreSystemProperties:org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties,temporaryFolder:org/apache/geode/test/junit/rules/serializable/SerializableTemporaryFolder,testName:org/apache/geode/test/junit/rules/serializable/SerializableTestName,xmlFile:java/io/File
+org/apache/geode/cache30/ClientServerTestCase,false
+org/apache/geode/cache30/ClientServerTestCase$1,false,this$0:org/apache/geode/cache30/ClientServerTestCase,val$port:int,val$rName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase,false,vm0:org/apache/geode/test/dunit/VM,vm1:org/apache/geode/test/dunit/VM,vm2:org/apache/geode/test/dunit/VM,vm3:org/apache/geode/test/dunit/VM
+org/apache/geode/cache30/MultiVMRegionTestCase$2,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$22,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String,val$value:java/lang/Object
+org/apache/geode/cache30/MultiVMRegionTestCase$23,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key2:java/lang/Object,val$name:java/lang/String,val$value2:java/lang/Object
+org/apache/geode/cache30/MultiVMRegionTestCase$3,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String,val$value:java/lang/Object
+org/apache/geode/cache30/MultiVMRegionTestCase$36,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$37,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$38,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key1:java/lang/Object,val$key2:java/lang/Object,val$key3:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$39,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key1:java/lang/Object,val$key2:java/lang/Object,val$key3:java/lang/Object,val$name:java/lang/String,val$value1:java/lang/Object,val$value2:java/lang/Object,val$value3:java/lang/Object
+org/apache/geode/cache30/MultiVMRegionTestCase$4,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String,val$value:java/lang/Object
+org/apache/geode/cache30/MultiVMRegionTestCase$40,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$41,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$45,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$46,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$47,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$48,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String,val$values:byte[][]
+org/apache/geode/cache30/MultiVMRegionTestCase$49,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$5,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$50,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$51,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$52,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$53,false,entriesDumped:boolean,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$54,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$iiComplete:long,val$name:java/lang/String,val$values:byte[][]
+org/apache/geode/cache30/MultiVMRegionTestCase$55,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$56,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key2:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$57,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$58,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key2:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$59,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$6,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String,val$value:java/lang/Object
+org/apache/geode/cache30/MultiVMRegionTestCase$60,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$61,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String,val$txId:org/apache/geode/cache/TransactionId
+org/apache/geode/cache30/MultiVMRegionTestCase$62,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$63,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String,val$txId:org/apache/geode/cache/TransactionId
+org/apache/geode/cache30/MultiVMRegionTestCase$64,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$65,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String,val$txId:org/apache/geode/cache/TransactionId
+org/apache/geode/cache30/MultiVMRegionTestCase$66,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$67,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String,val$txId:org/apache/geode/cache/TransactionId
+org/apache/geode/cache30/MultiVMRegionTestCase$68,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$7,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$key:java/lang/Object,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$70,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName1:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$71,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName1:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$72,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName2:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$73,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName2:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$74,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName3:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$75,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName3:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$76,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName1:java/lang/String,val$rgnName3:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$77,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName2:java/lang/String,val$rgnName3:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$78,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName1:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$79,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName2:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$80,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName3:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$81,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$82,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$rgnName:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$83,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String,val$serverPort:int
+org/apache/geode/cache30/MultiVMRegionTestCase$84,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$85,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$86,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$87,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$88,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$89,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$92,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$oldClientTimeout:long,val$oldExpiredTombstoneLimit:int,val$oldIdleExpiration:boolean,val$oldLimit:double,val$oldMaxSleepTime:long,val$oldServerTimeout:long
+org/apache/geode/cache30/MultiVMRegionTestCase$93,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$94,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase
+org/apache/geode/cache30/MultiVMRegionTestCase$95,false,this$0:org/apache/geode/cache30/MultiVMRegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/MultiVMRegionTestCase$DeltaValue,false,value:java/lang/String
+org/apache/geode/cache30/RegionTestCase,false,eventCount:java/util/concurrent/atomic/AtomicInteger
+org/apache/geode/cache30/RegionTestCase$3,false,this$0:org/apache/geode/cache30/RegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/RegionTestCase$5,false,this$0:org/apache/geode/cache30/RegionTestCase,val$key:java/lang/Object,val$name:java/lang/String,val$subname:java/lang/String,val$value:java/lang/Object
+org/apache/geode/cache30/RegionTestCase$6,false,this$0:org/apache/geode/cache30/RegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/RegionTestCase$7,false,this$0:org/apache/geode/cache30/RegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/RegionTestCase$8,false,this$0:org/apache/geode/cache30/RegionTestCase,val$name:java/lang/String
+org/apache/geode/cache30/RegionTestCase$9,false,this$0:org/apache/geode/cache30/RegionTestCase,val$name:java/lang/String
+org/apache/geode/internal/cache/InternalCacheForClientAccessDUnitTest,true,1,clientVM:org/apache/geode/test/dunit/VM,dunitRule:org/apache/geode/test/dunit/rules/DistributedRule,serverVM:org/apache/geode/test/dunit/VM
+org/apache/geode/internal/cache/tier/sockets/CacheServerTestUtil,false
+org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase,false,props:java/util/Properties,putRange_1End:int,putRange_1Start:int,putRange_2End:int,putRange_2Start:int,testVersion:java/lang/String
+org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase$1,false,this$0:org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase,val$rName:java/lang/String
+org/apache/geode/internal/cache/wan/AsyncEventQueueTestBase,false
+org/apache/geode/management/ManagementTestBase,false,restoreSystemProperties:org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties
+org/apache/geode/management/ManagementTestBase$3,false,this$0:org/apache/geode/management/ManagementTestBase
+org/apache/geode/management/internal/cli/commands/ExportLogsDistributedTestBase$LogLine,false,level:java/lang/String,message:java/lang/String,shouldBeIgnoredDueToTimestamp:boolean
+org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTestBase$Value1WithValue2,false,value2:org/apache/geode/management/internal/cli/dto/Value2
+org/apache/geode/management/internal/cli/commands/Product,false,contractSize:java/lang/String,productCodes:java/util/TreeMap,productID:java/lang/Long,status:java/lang/String
+org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTestBase$Address,false,city:java/lang/String,street:java/lang/String
+org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTestBase$Customer,false,address:org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTestBase$Address,name:java/lang/String
+org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest,false,cluster:org/apache/geode/test/dunit/rules/ClusterStartupRule,locator:org/apache/geode/test/dunit/rules/MemberVM,server1:org/apache/geode/test/dunit/rules/MemberVM,server2:org/apache/geode/test/dunit/rules/MemberVM
+org/apache/geode/management/internal/cli/commands/ShowDeadlockDistributedTestBase$LockFunction,false
+org/apache/geode/management/internal/cli/commands/ShowLogCommandDistributedTestBase,false
+org/apache/geode/management/internal/configuration/ClusterConfig,false,groups:java/util/List
+org/apache/geode/security/ClientAuthorizationTestCase,false,clientVersion:java/lang/String
+org/apache/geode/security/SecurityTestUtils$1,false,this$0:org/apache/geode/security/SecurityTestUtils
+org/apache/geode/security/query/AbstractQuerySecurityDistributedTest,false,cluster:org/apache/geode/test/dunit/rules/ClusterStartupRule,keys:java/lang/Object[],regionName:java/lang/String,server:org/apache/geode/test/dunit/rules/MemberVM,specificUserClient:org/apache/geode/test/dunit/rules/ClientVM,superUserClient:org/apache/geode/test/dunit/rules/ClientVM,values:java/lang/Object[]
+org/apache/geode/security/templates/PKCSPrincipal,false,alias:java/lang/String
+org/apache/geode/security/templates/UsernamePrincipal,false,userName:java/lang/String
+org/apache/geode/test/dunit/DistributedTestCase,false
+org/apache/geode/test/dunit/Host,false,hostName:java/lang/String,vms:java/util/List
+org/apache/geode/test/dunit/IgnoredException,false,suspectString:java/lang/String
+org/apache/geode/test/dunit/IgnoredException$1,false,val$message:java/lang/String
+org/apache/geode/test/dunit/RMIException,false,cause:java/lang/Throwable,className:java/lang/String,methodName:java/lang/String,vm:org/apache/geode/test/dunit/VM
+org/apache/geode/test/dunit/RMIException$HokeyException,false,stackTrace:java/lang/String,toString:java/lang/String
+org/apache/geode/test/dunit/SerializableCallable,false,id:long,name:java/lang/String
+org/apache/geode/test/dunit/SerializableRunnable,false,id:long,name:java/lang/String
+org/apache/geode/test/dunit/VM,false,available:boolean,client:org/apache/geode/test/dunit/internal/RemoteDUnitVMIF,host:org/apache/geode/test/dunit/Host,id:int,version:java/lang/String
+org/apache/geode/test/dunit/cache/CacheTestCase,false
+org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase,false,RootRegionName:java/lang/String,cacheTestFixture:org/apache/geode/test/dunit/cache/internal/CacheTestFixture
+org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase$1,false,this$0:org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase,val$exceptionStringToIgnore:java/lang/String
+org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase$2,false,this$0:org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase,val$exceptionStringToIgnore:java/lang/String
+org/apache/geode/test/dunit/internal/DUnitHost,true,-8034165624503666383
+org/apache/geode/test/dunit/internal/DUnitLauncher$1,false,val$locatorLogFile:java/io/File
+org/apache/geode/test/dunit/internal/IdentifiableCallable,false,delegate:org/apache/geode/test/dunit/SerializableCallableIF,id:long,name:java/lang/String
+org/apache/geode/test/dunit/internal/IdentifiableRunnable,false,delegate:org/apache/geode/test/dunit/SerializableRunnableIF,id:long,name:java/lang/String
+org/apache/geode/test/dunit/internal/InternalBlackboardImpl,false,gates:java/util/Map,mailboxes:java/util/Map
+org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase,false,distributedTestFixture:org/apache/geode/test/dunit/internal/DistributedTestFixture,testNameForDistributedTestCase:org/apache/geode/test/junit/rules/serializable/SerializableTestName
+org/apache/geode/test/dunit/internal/Master,true,1178600200232603119,processManager:org/apache/geode/test/dunit/internal/ProcessManager,registry:java/rmi/registry/Registry
+org/apache/geode/test/dunit/internal/MethodInvokerResult,false,exception:java/lang/Throwable,result:java/lang/Object,stackTrace:java/lang/String
+org/apache/geode/test/dunit/internal/MethodInvokerResult$1,false
+org/apache/geode/test/dunit/internal/RemoteDUnitVM,true,251934856609958734
+org/apache/geode/test/dunit/internal/StackTrace,false
+org/apache/geode/test/dunit/internal/StackTraceInfo,false,message:java/lang/String,stackTraceElements:java/lang/StackTraceElement[]
+org/apache/geode/test/dunit/rules/AbstractDistributedRule,false,invoker:org/apache/geode/test/dunit/rules/RemoteInvoker,vmCount:int,vmEventListener:org/apache/geode/test/dunit/VMEventListener
+org/apache/geode/test/dunit/rules/AbstractDistributedRule$1,false,this$0:org/apache/geode/test/dunit/rules/AbstractDistributedRule,val$base:org/junit/runners/model/Statement,val$description:org/junit/runner/Description
+org/apache/geode/test/dunit/rules/AbstractDistributedRule$InternalVMEventListener,false,this$0:org/apache/geode/test/dunit/rules/AbstractDistributedRule
+org/apache/geode/test/dunit/rules/CacheRule,false,config:java/util/Properties,createCache:boolean,createCacheInAll:boolean,createCacheInVMs:java/util/List,destroyRegions:boolean,disconnectAfter:boolean,replaceConfig:boolean,systemProperties:java/util/Properties
+org/apache/geode/test/dunit/rules/CleanupDUnitVMsRule,false
+org/apache/geode/test/dunit/rules/ClientCacheRule,false,config:java/util/Properties,createClientCache:boolean,createClientCacheInVMs:java/util/List,disconnectAfter:boolean,systemProperties:java/util/Properties
+org/apache/geode/test/dunit/rules/ClientVM,false,vm:org/apache/geode/test/dunit/VM
+org/apache/geode/test/dunit/rules/ClusterStartupRule,false,logFile:boolean,occupiedVMs:java/util/Map,restoreSystemProperties:org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties,skipLocalDistributedSystemCleanup:boolean,vmCount:int
+org/apache/geode/test/dunit/rules/DistributedDiskDirRule,false,invoker:org/apache/geode/test/dunit/rules/RemoteInvoker,temporaryFolder:org/apache/geode/test/junit/rules/serializable/SerializableTemporaryFolder,testClassName:java/lang/String,testName:org/apache/geode/test/junit/rules/serializable/SerializableTestName,vmCount:int,vmEventListener:org/apache/geode/test/dunit/VMEventListener
+org/apache/geode/test/dunit/rules/DistributedDiskDirRule$InternalVMEventListener,false,this$0:org/apache/geode/test/dunit/rules/DistributedDiskDirRule
+org/apache/geode/test/dunit/rules/DistributedExecutorServiceRule,false
+org/apache/geode/test/dunit/rules/DistributedExternalResource,false,invoker:org/apache/geode/test/dunit/rules/RemoteInvoker
+org/apache/geode/test/dunit/rules/DistributedReference,false,autoClose:java/util/concurrent/atomic/AtomicBoolean
+org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties,false
+org/apache/geode/test/dunit/rules/DistributedRule,false
+org/apache/geode/test/dunit/rules/DistributedRule$TearDown,false
+org/apache/geode/test/dunit/rules/DistributedUseJacksonForJsonPathRule,false,invoker:org/apache/geode/test/dunit/rules/RemoteInvoker,vmCount:int,vmEventListener:org/apache/geode/test/dunit/VMEventListener
+org/apache/geode/test/dunit/rules/DistributedUseJacksonForJsonPathRule$InternalVMEventListener,false,this$0:org/apache/geode/test/dunit/rules/DistributedUseJacksonForJsonPathRule
+org/apache/geode/test/dunit/rules/MemberVM,false,member:org/apache/geode/test/junit/rules/Member,vm:org/apache/geode/test/dunit/VM
+org/apache/geode/test/dunit/rules/RemoteInvoker,true,-1759722991299584649
+org/apache/geode/test/dunit/rules/SharedCountersRule,false,beforeBounceCounters:java/util/Map,idsToInitInBefore:java/util/List
+org/apache/geode/test/dunit/rules/SharedErrorCollector,false,beforeBounceErrors:java/util/Map
+org/apache/geode/test/greplogs/Patterns,false,pattern:java/util/regex/Pattern
+org/apache/geode/test/junit/rules/ClientCacheRule,false,autoCreate:boolean,cache:org/apache/geode/cache/client/ClientCache,cacheFactory:org/apache/geode/cache/client/ClientCacheFactory,cacheSetups:java/util/List,properties:java/util/Properties
+org/apache/geode/test/junit/rules/GfshCommandRule$PortType,false
+org/apache/geode/test/junit/rules/LocatorLauncherStartupRule,false,autoStart:boolean,builderOperator:java/util/function/UnaryOperator,launcher:org/apache/geode/distributed/LocatorLauncher,properties:java/util/Properties,temp:org/junit/rules/TemporaryFolder
+org/apache/geode/test/junit/rules/LocatorStarterRule,false
+org/apache/geode/test/junit/rules/MemberStarterRule,false,autoStart:boolean,cleanWorkingDir:boolean,firstLevelChildrenFile:java/util/List,httpPort:int,jmxPort:int,logFile:boolean,memberPort:int,name:java/lang/String,properties:java/util/Properties,restore:org/apache/geode/test/junit/rules/accessible/AccessibleRestoreSystemProperties,systemProperties:java/util/Properties
+org/apache/geode/test/junit/rules/ServerLauncherStartupRule,false,autoStart:boolean,builderOperator:java/util/function/UnaryOperator,launcher:org/apache/geode/distributed/ServerLauncher,properties:java/util/Properties,temp:org/junit/rules/TemporaryFolder
+org/apache/geode/test/junit/rules/ServerStarterRule,false,embeddedLocatorPort:int,pdxPersistent:boolean,pdxPersistentUserSet:boolean,pdxReadSerialized:boolean,pdxReadSerializedUserSet:boolean,pdxSerializer:org/apache/geode/pdx/PdxSerializer,regions:java/util/Map,serverCount:int
diff --git a/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java b/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
index 1105b8e..80180f3 100644
--- a/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
+++ b/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
@@ -14,5 +14,28 @@
*/
package org.apache.geode.management.internal.cli.commands;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort;
+
+import java.util.Properties;
+
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+
public class QueryCommandDUnitTest extends QueryCommandDUnitTestBase {
+
+ @Override
+ protected Properties locatorProperties(Properties configProperties) {
+ int jmxPort = getRandomAvailableTCPPort();
+ configProperties.setProperty(HTTP_SERVICE_PORT, "0");
+ configProperties.setProperty(JMX_MANAGER, "true");
+ configProperties.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
+ return configProperties;
+ }
+
+ @Override
+ protected void connectToLocator() throws Exception {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshCommandRule.PortType.jmxManager);
+ }
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java
old mode 100644
new mode 100755
similarity index 77%
copy from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
copy to geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java
index 32ce5c3..1f68a7d
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java
@@ -12,23 +12,23 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.management.internal.GfshSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeGfshSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
- return "geode-management";
+ return "geode-gfsh";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return GfshSanctionedSerializablesService.class;
}
}
diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesJUnitTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesJUnitTest.java
deleted file mode 100755
index 6b95f6d..0000000
--- a/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesJUnitTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.codeAnalysis;
-
-
-import org.apache.geode.management.internal.GfshDistributedSystemService;
-
-public class AnalyzeGfshSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
-
- @Override
- protected String getModuleName() {
- return "geode-gfsh";
- }
-
- @Override
- protected Class getModuleClass() {
- return GfshDistributedSystemService.class;
- }
-}
diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/GfshSanctionedSerializablesServiceIntegrationTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/GfshSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..a2d7644
--- /dev/null
+++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/GfshSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.management.cli.CommandProcessingException;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class GfshSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new GfshSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+
+ @Test
+ public void acceptListContainsCommandProcessingException() throws IOException {
+ SanctionedSerializablesService service = getService();
+
+ Collection<String> serializables = service.getSerializationAcceptlist();
+
+ assertThat(serializables)
+ .contains(CommandProcessingException.class.getName());
+ }
+}
diff --git a/geode-gfsh/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-gfsh/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
deleted file mode 100644
index 8ce0692..0000000
--- a/geode-gfsh/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# e.g.,
-#org/apache/geode/cache/query/CqAttributesFactory
diff --git a/geode-gfsh/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt b/geode-gfsh/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
deleted file mode 100644
index bf62d60..0000000
--- a/geode-gfsh/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# This is a list of classes excluded due to open bugs about their having
-# incompatible changes. There should be no entries in this file at the
-# time of a product release.
-
-# Each entry should be a bug number followed by a comma and the
-# full class name. The package components can be delimited with a period
-# or a comma. Don't include ".class" or ".java" at the end of the name.
-
-# example: 50174,org/apache/geode/distributed/internal/StartupResponseWithVersionMessage
-# example: 50175,com.gemstone.org.jgroups.Message$Header
-
-
-# ~~~~~~~~~~~~~~~~~~~ DataSerializables ~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testDataSerializables
-
-
-# ~~~~~~~~~~~~~~~~~~~ Serializables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testSerializables
diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshDistributedSystemService.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshDistributedSystemService.java
deleted file mode 100644
index dbf7189..0000000
--- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshDistributedSystemService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.InternalDataSerializer;
-
-public class GfshDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-gfsh-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshSanctionedSerializablesService.java
index 66d3a15..66c9457 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.management.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class GfshSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-gfsh-serializables.txt");
}
}
diff --git a/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index 4a0427d..0000000
--- a/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1,16 +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.
-org.apache.geode.management.internal.GfshDistributedSystemService
-
diff --git a/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..e51ef5e
--- /dev/null
+++ b/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.management.internal.GfshSanctionedSerializablesService
diff --git a/geode-junit/build.gradle b/geode-junit/build.gradle
index 8eeacee..76db0ea 100755
--- a/geode-junit/build.gradle
+++ b/geode-junit/build.gradle
@@ -55,6 +55,9 @@
testCompile('pl.pragmatists:JUnitParams')
testRuntime(project(path: ':geode-old-versions', configuration: 'testOutput'))
+
+ integrationTestImplementation(project(':geode-core'))
+ integrationTestImplementation(project(':geode-serialization'))
}
test {
diff --git a/geode-junit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeJUnitSerializablesIntegrationTest.java b/geode-junit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeJUnitSerializablesIntegrationTest.java
new file mode 100644
index 0000000..fa1b8c6
--- /dev/null
+++ b/geode-junit/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeJUnitSerializablesIntegrationTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.codeAnalysis;
+
+import static java.util.Arrays.asList;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.query.data.PortfolioNoDS;
+import org.apache.geode.cache.query.data.PortfolioPdx;
+import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.test.junit.internal.JUnitSanctionedSerializablesService;
+
+@Category(SerializationTest.class)
+public class AnalyzeJUnitSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
+
+ private static final Set<Class<?>> IGNORE_CLASSES = new HashSet<>(asList(
+ PortfolioNoDS.class, PortfolioPdx.class));
+
+ @Override
+ protected String getModuleName() {
+ return "geode-junit";
+ }
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return JUnitSanctionedSerializablesService.class;
+ }
+
+ @Override
+ protected boolean ignoreClass(Class<?> theClass) {
+ return IGNORE_CLASSES.contains(theClass);
+ }
+}
diff --git a/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.java b/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..f317278
--- /dev/null
+++ b/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.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 org.apache.geode.test.junit.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.CoreSanctionedSerializablesService;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class JUnitSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new CoreSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-junit/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-junit/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
new file mode 100644
index 0000000..28b0f22
--- /dev/null
+++ b/geode-junit/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -0,0 +1,3 @@
+org/apache/geode/cache/query/data/PortfolioNoDS
+org/apache/geode/cache/query/data/PortfolioPdx
+org/apache/geode/cache/query/data/PortfolioPdx$Day
diff --git a/geode-junit/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt b/geode-junit/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
new file mode 100644
index 0000000..715be27
--- /dev/null
+++ b/geode-junit/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -0,0 +1,99 @@
+com/examples/ds/Employee,2
+fromData,40
+toData,37
+
+com/examples/ds/User,2
+fromData,21
+toData,21
+
+com/examples/snapshot/MyObjectDataSerializable,2
+fromData,21
+toData,21
+
+com/examples/snapshot/MyObjectPdxSerializable,2
+fromData,25
+toData,27
+
+org/apache/geode/DeltaTestImpl,2
+fromData,44
+toData,41
+
+org/apache/geode/cache/query/data/CollectionHolder,2
+fromData,9
+toData,9
+
+org/apache/geode/cache/query/data/Portfolio,2
+fromData,186
+toData,192
+
+org/apache/geode/cache/query/data/Position,2
+fromData,159
+toData,159
+
+org/apache/geode/cache/query/data/PositionPdx,2
+fromData,205
+toData,231
+
+org/apache/geode/cache/query/transaction/Person,2
+fromData,21
+toData,21
+
+org/apache/geode/internal/cache/TestObjectWithIdentifier,2
+fromData,27
+toData,27
+
+org/apache/geode/internal/cache/execute/data/CustId,2
+fromData,9
+toData,9
+
+org/apache/geode/internal/cache/execute/data/OrderId,2
+fromData,20
+toData,17
+
+org/apache/geode/internal/cache/execute/data/ShipmentId,2
+fromData,20
+toData,17
+
+org/apache/geode/internal/cache/ha/ConflatableObject,2
+fromData,48
+toData,45
+
+org/apache/geode/pdx/DSInsidePdx,2
+fromData,64
+toData,66
+
+org/apache/geode/pdx/Employee,2
+fromData,40
+toData,43
+
+org/apache/geode/pdx/NestedPdx,2
+fromData,64
+toData,66
+
+org/apache/geode/pdx/PdxInsideDS,2
+fromData,36
+toData,33
+
+org/apache/geode/pdx/SeparateClassloaderPdx,2
+fromData,1
+toData,55
+
+org/apache/geode/pdx/SimpleClass,2
+fromData,40
+toData,40
+
+org/apache/geode/pdx/SimpleClass1,2
+fromData,97
+toData,105
+
+org/apache/geode/pdx/TestObjectForJSONFormatter,2
+fromData,614
+toData,569
+
+org/apache/geode/security/query/data/PdxQueryTestObject,2
+fromData,25
+toData,27
+
+org/apache/geode/security/query/data/PdxTrade,2
+fromData,49
+toData,53
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeDataSerializablesJUnitTestBase.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeDataSerializablesJUnitTestBase.java
new file mode 100644
index 0000000..f26d1b5
--- /dev/null
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeDataSerializablesJUnitTestBase.java
@@ -0,0 +1,394 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.codeAnalysis;
+
+import static java.util.Collections.emptyList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InvalidClassException;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+import org.apache.geode.codeAnalysis.decode.CompiledClass;
+import org.apache.geode.codeAnalysis.decode.CompiledMethod;
+import org.apache.geode.internal.serialization.BufferDataOutputStream;
+import org.apache.geode.internal.serialization.Version;
+import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.test.junit.rules.ClassAnalysisRule;
+
+/**
+ * This abstract test class is the basis for all of our AnalyzeModuleNameSerializables tests.
+ * Subclasses must provide serialization/deserialization methods.
+ *
+ * <p>
+ * Most tests should subclass {@link AnalyzeSerializablesJUnitTestBase} instead of this
+ * class because it ties into geode-core serialization and saves a lot of work.
+ */
+@Category({SerializationTest.class})
+public abstract class AnalyzeDataSerializablesJUnitTestBase {
+
+ private static final Path MODULE_ROOT = Paths.get("..", "..", "..").toAbsolutePath().normalize();
+ private static final Path SOURCE_ROOT = MODULE_ROOT.resolve(Paths.get("src"));
+ private static final Path TEST_RESOURCES_SOURCE_ROOT =
+ SOURCE_ROOT.resolve(Paths.get("integrationTest", "resources"));
+ private static final Path BUILD_RESOURCES_ROOT =
+ MODULE_ROOT.resolve(Paths.get("build", "resources"));
+
+ private static final String NEW_LINE = System.getProperty("line.separator");
+
+ static final String FAIL_MESSAGE = NEW_LINE + NEW_LINE
+ + "If the class is not persisted or sent over the wire add it to the file " + NEW_LINE + "%s"
+ + NEW_LINE + "Otherwise if this doesn't break backward compatibility, copy the file "
+ + NEW_LINE + "%s to " + NEW_LINE + "%s.";
+
+ static final String EXCLUDED_CLASSES_TXT = "excludedClasses.txt";
+ private static final String ACTUAL_DATA_SERIALIZABLES_DAT = "actualDataSerializables.dat";
+ static final String OPEN_BUGS_TXT = "openBugs.txt";
+ private static final String SANCTIONED_DATA_SERIALIZABLES_FILE =
+ "sanctionedDataSerializables.txt";
+
+ /**
+ * all loaded classes
+ */
+ protected Map<String, CompiledClass> classes;
+
+ private File expectedDataSerializablesFile;
+
+ private List<ClassAndMethodDetails> expectedDataSerializables;
+ @Rule
+ public TestName testName = new TestName();
+
+ @Rule
+ public ClassAnalysisRule classProvider = new ClassAnalysisRule(getModuleName());
+
+ @AfterClass
+ public static void afterClass() {
+ ClassAnalysisRule.clearCache();
+ }
+
+ /**
+ * implement this to return your module's name, such as "geode-core"
+ */
+ protected abstract String getModuleName();
+
+ /**
+ * Implement this method to return a production class in your module that corresponds to where
+ * you have put your sanctioned-modulename-serializables.txt file in the production resources
+ * tree.
+ */
+ protected abstract Class<?> getModuleClass();
+
+ /**
+ * Implement this to deserialize an object that was serialized with serializeObject()
+ */
+ protected abstract void deserializeObject(BufferDataOutputStream outputStream)
+ throws IOException, ClassNotFoundException;
+
+ /**
+ * Implement this to serialize the given object to the given output stream
+ */
+ protected abstract void serializeObject(Object object, BufferDataOutputStream outputStream)
+ throws IOException;
+
+ /**
+ * Prepare your serialization service for use
+ */
+ protected abstract void initializeSerializationService();
+
+ private void loadExpectedDataSerializables() throws Exception {
+ expectedDataSerializablesFile = getResourceAsFile(SANCTIONED_DATA_SERIALIZABLES_FILE);
+ if (expectedDataSerializablesFile == null) {
+ expectedDataSerializables = emptyList();
+ } else {
+ expectedDataSerializables =
+ CompiledClassUtils.loadClassesAndMethods(expectedDataSerializablesFile);
+ }
+ }
+
+ public void findClasses() throws Exception {
+ classes = classProvider.getClasses();
+
+ List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
+ List<String> openBugs = loadOpenBugs(getResourceAsFile(OPEN_BUGS_TXT));
+
+ excludedClasses.addAll(openBugs);
+ removeExclusions(classes, excludedClasses);
+ }
+
+ @Test
+ public void testDataSerializables() throws Exception {
+ // assumeTrue("Ignoring this test when java version is 9 and above",
+ // !SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9));
+ System.out.println(testName.getMethodName() + " starting");
+ findClasses();
+ loadExpectedDataSerializables();
+
+ File actualDataSerializablesFile = createEmptyFile(ACTUAL_DATA_SERIALIZABLES_DAT);
+ System.out.println(testName.getMethodName() + " actualDataSerializablesFile="
+ + actualDataSerializablesFile.getAbsolutePath());
+
+ List<ClassAndMethods> actualDataSerializables = findToDatasAndFromDatas();
+ CompiledClassUtils.storeClassesAndMethods(actualDataSerializables, actualDataSerializablesFile);
+
+ String diff =
+ CompiledClassUtils
+ .diffSortedClassesAndMethods(expectedDataSerializables, actualDataSerializables);
+ if (!diff.isEmpty()) {
+ System.out.println(
+ "++++++++++++++++++++++++++++++testDataSerializables found discrepancies++++++++++++++++++++++++++++++++++++");
+ System.out.println(diff);
+ fail(diff + FAIL_MESSAGE, toBuildPathString(getResourceAsFile(EXCLUDED_CLASSES_TXT)),
+ actualDataSerializablesFile.getAbsolutePath(),
+ toTestResourcesSourcePathString(Paths.get("org", "apache", "geode", "codeAnalysis",
+ SANCTIONED_DATA_SERIALIZABLES_FILE)));
+ }
+ }
+
+ @Test
+ public void testExcludedClassesExistAndDoNotDeserialize() throws Exception {
+ List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
+
+ initializeSerializationService();
+
+ for (String filePath : excludedClasses) {
+ String className = filePath.replaceAll("/", ".");
+ System.out.println("testing class " + className);
+
+ Class<?> excludedClass = Class.forName(className);
+ if (ignoreClass(excludedClass)) {
+ continue;
+ }
+ assertTrue(
+ excludedClass.getName()
+ + " is not Serializable and should be removed from excludedClasses.txt",
+ Serializable.class.isAssignableFrom(excludedClass));
+
+ if (!excludedClass.isEnum()) {
+ final Object excludedInstance;
+ try {
+ excludedInstance = excludedClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ // okay - it's in the excludedClasses.txt file after all
+ // IllegalAccessException means that the constructor is private.
+ continue;
+ }
+ serializeAndDeserializeObject(excludedInstance);
+ }
+ }
+ }
+
+ /**
+ * Override in test class to ignore any class that is purposely broken for testing purposes.
+ */
+ protected boolean ignoreClass(Class<?> theClass) {
+ return false;
+ }
+
+ private void serializeAndDeserializeObject(Object object) throws Exception {
+ BufferDataOutputStream outputStream = new BufferDataOutputStream(Version.CURRENT);
+ try {
+ serializeObject(object, outputStream);
+ } catch (IOException e) {
+ // some classes, such as BackupLock, are Serializable because the extend something
+ // like ReentrantLock but we never serialize them & it doesn't work to try to do so
+ System.out.println("Not Serializable: " + object.getClass().getName());
+ }
+ try {
+ deserializeObject(outputStream);
+ fail("I was able to deserialize " + object.getClass().getName());
+ } catch (InvalidClassException e) {
+ // expected
+ }
+ }
+
+ String toBuildPathString(File file) {
+ if (file == null) {
+ return null;
+ }
+ return file.toPath().toAbsolutePath().normalize().toString();
+ }
+
+ private String toTestResourcesSourcePathString(Path relativeFilePath) {
+ return TEST_RESOURCES_SOURCE_ROOT.resolve(relativeFilePath).normalize().toString();
+ }
+
+ /**
+ * <pre>
+ * FROM:
+ * /Users/user/dev/geode/geode-junit/build/resources/main/org/apache/geode/test/junit/internal/sanctioned-geode-junit-serializables.txt
+ *
+ * TO:
+ * /Users/user/dev/geode/geode-junit/src/main/resources/org/apache/geode/test/junit/internal/sanctioned-geode-junit-serializables.txt
+ * </pre>
+ */
+ String mainResourceToSourcePath(URI buildResourceURI) {
+ Path mainBuildResources = BUILD_RESOURCES_ROOT.resolve(Paths.get("main"));
+ Path mainSourceResources = SOURCE_ROOT.resolve(Paths.get("main", "resources"));
+ Path relativeFilePath = mainBuildResources.relativize(Paths.get(buildResourceURI));
+ return mainSourceResources.resolve(relativeFilePath).toString();
+ }
+
+ List<String> loadExcludedClasses(File excludedClassesFile) throws IOException {
+ if (excludedClassesFile == null) {
+ return emptyList();
+ }
+
+ List<String> excludedClasses = new LinkedList<>();
+ FileReader fr = new FileReader(excludedClassesFile);
+ BufferedReader br = new BufferedReader(fr);
+ try {
+ String line;
+ while ((line = br.readLine()) != null) {
+ line = line.trim();
+ if (!line.isEmpty() && !line.startsWith("#")) {
+ excludedClasses.add(line);
+ }
+ }
+ } finally {
+ fr.close();
+ }
+ return excludedClasses;
+ }
+
+ List<String> loadOpenBugs(File openBugsFile) throws IOException {
+ if (openBugsFile == null) {
+ return emptyList();
+ }
+
+ List<String> excludedClasses = new LinkedList<>();
+ FileReader fr = new FileReader(openBugsFile);
+ BufferedReader br = new BufferedReader(fr);
+ try {
+ String line;
+ // each line should have bug#,full-class-name
+ while ((line = br.readLine()) != null) {
+ line = line.trim();
+ if (!line.isEmpty() && !line.startsWith("#")) {
+ String[] split = line.split(",");
+ if (split.length != 2) {
+ fail("unable to load classes due to malformed line in openBugs.txt: " + line);
+ }
+ excludedClasses.add(line.split(",")[1].trim());
+ }
+ }
+ } finally {
+ fr.close();
+ }
+ return excludedClasses;
+ }
+
+ private void removeExclusions(Map<String, CompiledClass> classes, List<String> exclusions) {
+ for (String exclusion : exclusions) {
+ exclusion = exclusion.replace('.', '/');
+ classes.remove(exclusion);
+ }
+ }
+
+ private List<ClassAndMethods> findToDatasAndFromDatas() {
+ List<ClassAndMethods> result = new ArrayList<>();
+ for (Map.Entry<String, CompiledClass> entry : classes.entrySet()) {
+ CompiledClass compiledClass = entry.getValue();
+ ClassAndMethods classAndMethods = null;
+
+ for (int i = 0; i < compiledClass.methods.length; i++) {
+ CompiledMethod method = compiledClass.methods[i];
+
+ if (!method.isAbstract() && method.descriptor().equals("void")) {
+ String name = method.name();
+ if (name.startsWith("toData") || name.startsWith("fromData")) {
+ if (classAndMethods == null) {
+ classAndMethods = new ClassAndMethods(compiledClass);
+ }
+ classAndMethods.methods.put(method.name(), method);
+ }
+ }
+ }
+ if (classAndMethods != null) {
+ result.add(classAndMethods);
+ }
+ }
+ Collections.sort(result);
+ return result;
+ }
+
+ File createEmptyFile(String fileName) throws IOException {
+ final String workingDir = System.getProperty("user.dir");
+ final String filePath;
+ if (isIntelliJDir(workingDir)) {
+ String buildDir = workingDir.replace(getModuleName(), "");
+ buildDir =
+ Paths.get(buildDir, "out", "production", "geode." + getModuleName() + ".integrationTest")
+ .toString();
+ filePath = buildDir + File.separator + fileName;
+ } else {
+ filePath = fileName;
+ }
+ File file = new File(filePath);
+ if (file.exists()) {
+ assertThat(file.delete()).isTrue();
+ }
+ assertThat(file.createNewFile()).isTrue();
+ assertThat(file).exists().canWrite();
+ return file;
+ }
+
+ private boolean isIntelliJDir(final String workingDir) {
+ return !workingDir.contains("build");
+ }
+
+ /**
+ * Use this method to get a resource stored in the test's resource directory
+ */
+ File getResourceAsFile(String resourceName) {
+ URL resource = getResource(getClass(), resourceName);
+ if (resource == null) {
+ return null;
+ }
+ return new File(resource.getFile());
+ }
+
+ /**
+ * Use this method to get a resource that might be in a JAR file
+ */
+ protected InputStream getResourceAsStream(Class<?> associatedClass, String resourceName)
+ throws IOException {
+ return getResource(associatedClass, resourceName).openStream();
+ }
+
+ static URL getResource(final Class<?> classInSamePackage, final String resourceName) {
+ return classInSamePackage.getResource(resourceName);
+ }
+}
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
index d30e1c5..e0f28cf 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
@@ -14,242 +14,93 @@
*/
package org.apache.geode.codeAnalysis;
-import static org.assertj.core.api.Assertions.assertThat;
+import static java.util.Collections.emptyList;
+import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
+import static org.apache.geode.distributed.ConfigurationProperties.VALIDATE_SERIALIZABLE_OBJECTS;
import static org.assertj.core.api.Assertions.fail;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.Externalizable;
import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidClassException;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
-import java.nio.file.Paths;
+import java.rmi.RemoteException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.ServiceLoader;
import java.util.Set;
-import java.util.stream.Collectors;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
import org.apache.geode.CancelException;
+import org.apache.geode.DataSerializable;
import org.apache.geode.DataSerializer;
import org.apache.geode.codeAnalysis.decode.CompiledClass;
import org.apache.geode.codeAnalysis.decode.CompiledField;
-import org.apache.geode.codeAnalysis.decode.CompiledMethod;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.internal.HeapDataOutputStream;
import org.apache.geode.internal.InternalDataSerializer;
+import org.apache.geode.internal.serialization.BufferDataOutputStream;
+import org.apache.geode.internal.serialization.DataSerializableFixedID;
import org.apache.geode.internal.serialization.Version;
import org.apache.geode.pdx.internal.TypeRegistry;
import org.apache.geode.test.junit.categories.SerializationTest;
import org.apache.geode.unsafe.internal.sun.reflect.ReflectionFactory;
-@Category({SerializationTest.class})
-public abstract class AnalyzeSerializablesJUnitTestBase {
+/**
+ * This subclass of AbstractAnalyzeSerializablesTestBase uses DataSerializer and
+ * InternalDataSerializer. It also performs initialization of the Geode TypeRegistry
+ */
+@Category(SerializationTest.class)
+public abstract class AnalyzeSerializablesJUnitTestBase
+ extends AnalyzeDataSerializablesJUnitTestBase {
- private static final String NEW_LINE = System.getProperty("line.separator");
-
- private static final String FAIL_MESSAGE = NEW_LINE + NEW_LINE
- + "If the class is not persisted or sent over the wire add it to the file " + NEW_LINE + "%s"
- + NEW_LINE + "Otherwise if this doesn't break backward compatibility, copy the file "
- + NEW_LINE + "%s to " + NEW_LINE + "%s.";
- private static final String EXCLUDED_CLASSES_TXT = "excludedClasses.txt";
- private static final String ACTUAL_DATA_SERIALIZABLES_DAT = "actualDataSerializables.dat";
private static final String ACTUAL_SERIALIZABLES_DAT = "actualSerializables.dat";
- private static final String OPEN_BUGS_TXT = "openBugs.txt";
- /**
- * all loaded classes
- */
- private Map<String, CompiledClass> classes;
-
- private File expectedDataSerializablesFile;
- private String expectedSerializablesFileName =
+ private final String expectedSerializablesFileName =
"sanctioned-" + getModuleName() + "-serializables.txt";
- private List<ClassAndMethodDetails> expectedDataSerializables;
- private List<ClassAndVariableDetails> expectedSerializables;
-
- @Rule
- public TestName testName = new TestName();
-
- private void loadExpectedDataSerializables() throws Exception {
- this.expectedDataSerializablesFile = getResourceAsFile("sanctionedDataSerializables.txt");
- assertThat(this.expectedDataSerializablesFile).exists().canRead();
-
- this.expectedDataSerializables =
- CompiledClassUtils.loadClassesAndMethods(this.expectedDataSerializablesFile);
- }
-
- public void loadExpectedSerializables() throws Exception {
- try (InputStream expectedSerializablesStream =
- getResourceAsStream(getModuleClass(), expectedSerializablesFileName)) {
- // the expectedSerializablesStream will be automatically closed when we exit this block
- this.expectedSerializables =
- CompiledClassUtils.loadClassesAndVariables(expectedSerializablesStream);
- }
- }
-
- public void findClasses() throws Exception {
- this.classes = new HashMap<>();
-
- loadClasses();
- }
+ protected List<ClassAndVariableDetails> expectedSerializables;
@Before
public void setUp() throws Exception {
- // assumeThat(
- // "AnalyzeSerializables requires Java 8 but tests are running with v"
- // + SystemUtils.JAVA_VERSION,
- // isJavaVersionAtLeast(JavaVersion.JAVA_1_8), is(true));
TypeRegistry.init();
}
- private List<DistributedSystemService> initializeServices() {
- ServiceLoader<DistributedSystemService> loader =
- ServiceLoader.load(DistributedSystemService.class);
- List<DistributedSystemService> services = new ArrayList<>();
- for (DistributedSystemService service : loader) {
- services.add(service);
- }
- return services;
- }
-
-
- /**
- * Override only this one method in sub-classes
- */
- protected abstract String getModuleName();
-
- protected Class getModuleClass() {
- return InternalDataSerializer.class;
- }
-
- @Test
- public void testDataSerializables() throws Exception {
- // assumeTrue("Ignoring this test when java version is 9 and above",
- // !SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9));
- System.out.println(this.testName.getMethodName() + " starting");
- findClasses();
- loadExpectedDataSerializables();
-
- File actualDataSerializablesFile = createEmptyFile(ACTUAL_DATA_SERIALIZABLES_DAT);
- System.out.println(this.testName.getMethodName() + " actualDataSerializablesFile="
- + actualDataSerializablesFile.getAbsolutePath());
-
- List<ClassAndMethods> actualDataSerializables = findToDatasAndFromDatas();
- CompiledClassUtils.storeClassesAndMethods(actualDataSerializables, actualDataSerializablesFile);
-
- String diff =
- CompiledClassUtils
- .diffSortedClassesAndMethods(this.expectedDataSerializables, actualDataSerializables);
- if (!diff.isEmpty()) {
- System.out.println(
- "++++++++++++++++++++++++++++++testDataSerializables found discrepancies++++++++++++++++++++++++++++++++++++");
- System.out.println(diff);
- fail(diff + FAIL_MESSAGE, getSrcPathFor(getResourceAsFile(EXCLUDED_CLASSES_TXT)),
- actualDataSerializablesFile.getAbsolutePath(),
- getSrcPathFor(this.expectedDataSerializablesFile));
- }
- }
-
@Test
public void testSerializables() throws Exception {
- System.out.println(this.testName.getMethodName() + " starting");
+ System.out.println(testName.getMethodName() + " starting");
findClasses();
loadExpectedSerializables();
File actualSerializablesFile = createEmptyFile(ACTUAL_SERIALIZABLES_DAT);
- System.out.println(this.testName.getMethodName() + " actualSerializablesFile="
+ System.out.println(testName.getMethodName() + " actualSerializablesFile="
+ actualSerializablesFile.getAbsolutePath());
List<ClassAndVariables> actualSerializables = findSerializables();
CompiledClassUtils.storeClassesAndVariables(actualSerializables, actualSerializablesFile);
String diff = CompiledClassUtils
- .diffSortedClassesAndVariables(this.expectedSerializables, actualSerializables);
+ .diffSortedClassesAndVariables(expectedSerializables, actualSerializables);
if (!diff.isEmpty()) {
System.out.println(
"++++++++++++++++++++++++++++++testSerializables found discrepancies++++++++++++++++++++++++++++++++++++");
System.out.println(diff);
- fail(diff + FAIL_MESSAGE, getSrcPathFor(getResourceAsFile(EXCLUDED_CLASSES_TXT)),
+ fail(diff + FAIL_MESSAGE, toBuildPathString(getResourceAsFile(EXCLUDED_CLASSES_TXT)),
actualSerializablesFile.getAbsolutePath(),
- this.expectedSerializablesFileName);
- }
- }
-
- @Test
- public void testExcludedClassesExistAndDoNotDeserialize() throws Exception {
- List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
- Properties properties = new Properties();
- properties.put(ConfigurationProperties.VALIDATE_SERIALIZABLE_OBJECTS, "true");
- properties.put(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "!*");
- DistributionConfig distributionConfig = new DistributionConfigImpl(properties);
- InternalDataSerializer.initialize(distributionConfig, initializeServices());
-
- for (String filePath : excludedClasses) {
- String className = filePath.replaceAll("/", ".");
- System.out.println("testing class " + className);
-
- Class excludedClass = Class.forName(className);
- assertTrue(
- excludedClass.getName()
- + " is not Serializable and should be removed from excludedClasses.txt",
- Serializable.class.isAssignableFrom(excludedClass));
-
- if (!excludedClass.isEnum()) {
- final Object excludedInstance;
- try {
- excludedInstance = excludedClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- // okay - it's in the excludedClasses.txt file after all
- // IllegalAccessException means that the constructor is private.
- continue;
- }
- serializeAndDeserializeObject(excludedInstance);
- }
- }
- }
-
-
- private void serializeAndDeserializeObject(Object object) throws Exception {
- HeapDataOutputStream outputStream = new HeapDataOutputStream(Version.CURRENT);
- try {
- DataSerializer.writeObject(object, outputStream);
- } catch (IOException e) {
- // some classes, such as BackupLock, are Serializable because the extend something
- // like ReentrantLock but we never serialize them & it doesn't work to try to do so
- System.out.println("Not Serializable: " + object.getClass().getName());
- }
- try {
- DataSerializer
- .readObject(new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
- fail("I was able to deserialize " + object.getClass().getName());
- } catch (InvalidClassException e) {
- // expected
+ mainResourceToSourcePath(
+ getResource(getModuleClass(), expectedSerializablesFileName).toURI()));
}
}
@@ -258,10 +109,7 @@
loadExpectedSerializables();
Set<String> openBugs = new HashSet<>(loadOpenBugs(getResourceAsFile(OPEN_BUGS_TXT)));
- DistributionConfig distributionConfig = new DistributionConfigImpl(new Properties());
- distributionConfig.setValidateSerializableObjects(true);
- distributionConfig.setSerializableObjectFilter("!*");
- InternalDataSerializer.initialize(distributionConfig, initializeServices());
+ initializeSerializationService();
for (ClassAndVariableDetails details : expectedSerializables) {
if (openBugs.contains(details.className)) {
@@ -271,7 +119,7 @@
String className = details.className.replaceAll("/", ".");
System.out.println("testing class " + details.className);
- Class sanctionedClass = null;
+ Class<?> sanctionedClass = null;
try {
sanctionedClass = Class.forName(className);
} catch (ClassNotFoundException cnf) {
@@ -279,6 +127,10 @@
+ expectedSerializablesFileName);
}
+ if (ignoreClass(sanctionedClass)) {
+ continue;
+ }
+
assertTrue(
sanctionedClass.getName() + " is not Serializable and should be removed from "
+ expectedSerializablesFileName,
@@ -311,8 +163,9 @@
try {
boolean isThrowable = Throwable.class.isAssignableFrom(sanctionedClass);
- Constructor constructor = isThrowable ? sanctionedClass.getDeclaredConstructor(String.class)
- : sanctionedClass.getDeclaredConstructor((Class<?>[]) null);
+ Constructor<?> constructor =
+ isThrowable ? sanctionedClass.getDeclaredConstructor(String.class)
+ : sanctionedClass.getDeclaredConstructor((Class<?>[]) null);
constructor.setAccessible(true);
sanctionedInstance =
isThrowable ? constructor.newInstance("test throwable") : constructor.newInstance();
@@ -323,7 +176,7 @@
}
try {
Class<?> superClass = sanctionedClass;
- Constructor constructor = null;
+ Constructor<?> constructor = null;
if (Externalizable.class.isAssignableFrom(sanctionedClass)) {
Constructor<?> cons = sanctionedClass.getDeclaredConstructor((Class<?>[]) null);
cons.setAccessible(true);
@@ -341,9 +194,9 @@
.newConstructorForSerialization(sanctionedClass, constructor);
}
sanctionedInstance = constructor.newInstance();
- } catch (Exception e2) {
+ } catch (Exception e) {
throw new AssertionError("Unable to instantiate " + className + " - please move it from "
- + expectedSerializablesFileName + " to excludedClasses.txt", e2);
+ + expectedSerializablesFileName + " to excludedClasses.txt", e);
}
serializeAndDeserializeSanctionedObject(sanctionedInstance);
}
@@ -384,159 +237,17 @@
}
}
- private void serializeAndDeserializeSanctionedObject(Object object) throws Exception {
- HeapDataOutputStream outputStream = new HeapDataOutputStream(Version.CURRENT);
- try {
- DataSerializer.writeObject(object, outputStream);
- } catch (IOException e) {
- // some classes, such as BackupLock, are Serializable because the extend something
- // like ReentrantLock but we never serialize them & it doesn't work to try to do so
- throw new AssertionError("Not Serializable: " + object.getClass().getName(), e);
- }
- try {
- Object instance = DataSerializer
- .readObject(new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
- } catch (CancelException e) {
- // PDX classes fish for a PDXRegistry and find that there is no cache
- } catch (InvalidClassException e) {
- fail("I was unable to deserialize " + object.getClass().getName(), e);
- }
- }
-
- private String getSrcPathFor(File file) {
- return getSrcPathFor(file, "test");
- }
-
- private String getSrcPathFor(File file, String testOrMain) {
- return file.getAbsolutePath().replace(
- "build" + File.separator + "resources" + File.separator + "test",
- "src" + File.separator + testOrMain + File.separator + "resources");
- }
-
- private void loadClasses() throws IOException {
- System.out.println("loadClasses starting");
-
- List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
- List<String> openBugs = loadOpenBugs(getResourceAsFile(OPEN_BUGS_TXT));
-
- excludedClasses.addAll(openBugs);
-
- String classpath = System.getProperty("java.class.path");
- System.out.println("java classpath is " + classpath);
-
- List<File> entries =
- Arrays.stream(classpath.split(File.pathSeparator)).map(x -> new File(x)).collect(
- Collectors.toList());
- String gradleBuildDirName =
- Paths.get(getModuleName(), "build", "classes", "java", "main").toString();
- System.out.println("gradleBuildDirName is " + gradleBuildDirName);
- String ideaBuildDirName = Paths.get(getModuleName(), "out", "production", "classes").toString();
- System.out.println("ideaBuildDirName is " + ideaBuildDirName);
- String ideaFQCNBuildDirName = Paths.get("out", "production",
- "geode." + getModuleName() + ".main").toString();
- System.out.println("idea build path with full package names is " + ideaFQCNBuildDirName);
- String buildDir = null;
-
- for (File entry : entries) {
- System.out.println("examining '" + entry + "'");
- if (entry.toString().endsWith(gradleBuildDirName)
- || entry.toString().endsWith(ideaBuildDirName)
- || entry.toString().endsWith(ideaFQCNBuildDirName)) {
- buildDir = entry.toString();
- break;
+ public void loadExpectedSerializables() throws Exception {
+ if (expectedSerializablesFileName == null) {
+ expectedSerializables = emptyList();
+ } else {
+ try (InputStream expectedSerializablesStream =
+ getResourceAsStream(getModuleClass(), expectedSerializablesFileName)) {
+ // the expectedSerializablesStream will be automatically closed when we exit this block
+ expectedSerializables =
+ CompiledClassUtils.loadClassesAndVariables(expectedSerializablesStream);
}
}
-
- assertThat(buildDir).isNotNull();
- System.out.println("loading class files from " + buildDir);
-
- long start = System.currentTimeMillis();
- loadClassesFromBuild(new File(buildDir), excludedClasses);
- long finish = System.currentTimeMillis();
-
- System.out.println("done loading " + this.classes.size() + " classes. elapsed time = "
- + (finish - start) / 1000 + " seconds");
- }
-
- private List<String> loadExcludedClasses(File exclusionsFile) throws IOException {
- List<String> excludedClasses = new LinkedList<>();
- FileReader fr = new FileReader(exclusionsFile);
- BufferedReader br = new BufferedReader(fr);
- try {
- String line;
- while ((line = br.readLine()) != null) {
- line = line.trim();
- if (!line.isEmpty() && !line.startsWith("#")) {
- excludedClasses.add(line);
- }
- }
- } finally {
- fr.close();
- }
- return excludedClasses;
- }
-
- private List<String> loadOpenBugs(File exclusionsFile) throws IOException {
- List<String> excludedClasses = new LinkedList<>();
- FileReader fr = new FileReader(exclusionsFile);
- BufferedReader br = new BufferedReader(fr);
- try {
- String line;
- // each line should have bug#,full-class-name
- while ((line = br.readLine()) != null) {
- line = line.trim();
- if (!line.isEmpty() && !line.startsWith("#")) {
- String[] split = line.split(",");
- if (split.length != 2) {
- fail("unable to load classes due to malformed line in openBugs.txt: " + line);
- }
- excludedClasses.add(line.split(",")[1].trim());
- }
- }
- } finally {
- fr.close();
- }
- return excludedClasses;
- }
-
- private void removeExclusions(Map<String, CompiledClass> classes, List<String> exclusions) {
- for (String exclusion : exclusions) {
- exclusion = exclusion.replace('.', '/');
- classes.remove(exclusion);
- }
- }
-
- private void loadClassesFromBuild(File buildDir, List<String> excludedClasses) {
- Map<String, CompiledClass> newClasses = CompiledClassUtils.parseClassFilesInDir(buildDir);
- removeExclusions(newClasses, excludedClasses);
- this.classes.putAll(newClasses);
- }
-
- private List<ClassAndMethods> findToDatasAndFromDatas() {
- List<ClassAndMethods> result = new ArrayList<>();
- for (Map.Entry<String, CompiledClass> entry : this.classes.entrySet()) {
- CompiledClass compiledClass = entry.getValue();
- ClassAndMethods classAndMethods = null;
-
- for (int i = 0; i < compiledClass.methods.length; i++) {
- CompiledMethod method = compiledClass.methods[i];
-
- if (!method.isAbstract() && method.descriptor().equals("void")) {
- String name = method.name();
- if (name.startsWith("toData") || name.startsWith("fromData")) {
- if (classAndMethods == null) {
- classAndMethods = new ClassAndMethods(compiledClass);
- }
- classAndMethods.methods.put(method.name(), method);
- }
- }
- }
- if (classAndMethods != null) {
- result.add(classAndMethods);
- }
- }
- Collections.sort(result);
- return result;
}
private List<ClassAndVariables> findSerializables() throws IOException {
@@ -544,7 +255,7 @@
List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
System.out.println("excluded classes are " + excludedClasses);
Set<String> setOfExclusions = new HashSet<>(excludedClasses);
- for (Map.Entry<String, CompiledClass> entry : this.classes.entrySet()) {
+ for (Map.Entry<String, CompiledClass> entry : classes.entrySet()) {
CompiledClass compiledClass = entry.getValue();
if (setOfExclusions.contains(compiledClass.fullyQualifiedName())) {
System.out.println("excluding class " + compiledClass.fullyQualifiedName());
@@ -552,7 +263,7 @@
}
// System.out.println("processing class " + compiledClass.fullyQualifiedName());
- if (!compiledClass.isInterface() && compiledClass.isSerializableAndNotDataSerializable()) {
+ if (!compiledClass.isInterface() && isSerializableAndNotDataSerializable(compiledClass)) {
ClassAndVariables classAndVariables = new ClassAndVariables(compiledClass);
for (int i = 0; i < compiledClass.fields_count; i++) {
CompiledField compiledField = compiledClass.fields[i];
@@ -567,28 +278,69 @@
return result;
}
- private File createEmptyFile(String fileName) throws IOException {
- File file = new File(fileName);
- if (file.exists()) {
- assertThat(file.delete()).isTrue();
- }
- assertThat(file.createNewFile()).isTrue();
- assertThat(file).exists().canWrite();
- return file;
+ @Override
+ protected void initializeSerializationService() {
+ Properties properties = new Properties();
+ properties.setProperty(VALIDATE_SERIALIZABLE_OBJECTS, "true");
+ properties.setProperty(SERIALIZABLE_OBJECT_FILTER, "!*");
+
+ InternalDataSerializer.initializeSerializationFilter(new DistributionConfigImpl(properties));
}
- /**
- * Use this method to get a resource stored in the test's resource directory
- */
- private File getResourceAsFile(String resourceName) {
- return new File(getClass().getResource(resourceName).getFile());
+ @Override
+ protected void deserializeObject(BufferDataOutputStream outputStream)
+ throws IOException, ClassNotFoundException {
+ DataSerializer
+ .readObject(new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
}
- /**
- * Use this method to get a resource that might be in a JAR file
- */
- private InputStream getResourceAsStream(Class associatedClass, String resourceName)
+ @Override
+ protected void serializeObject(Object object, BufferDataOutputStream outputStream)
throws IOException {
- return associatedClass.getResource(resourceName).openStream();
+ DataSerializer.writeObject(object, outputStream);
+ }
+
+ private void serializeAndDeserializeSanctionedObject(Object object) throws Exception {
+ BufferDataOutputStream outputStream = new BufferDataOutputStream(Version.CURRENT);
+ try {
+ serializeObject(object, outputStream);
+ } catch (RemoteException e) {
+ fail(object.getClass().getName() +
+ " is a java.rmi.server.RemoteObject which is not supported by AnalyzeSerializables", e);
+ } catch (IOException e) {
+ // some classes, such as BackupLock, are Serializable because the extend something
+ // like ReentrantLock but we never serialize them & it doesn't work to try to do so
+ throw new AssertionError("Not Serializable: " + object.getClass().getName(), e);
+ }
+ try {
+ deserializeObject(outputStream);
+ } catch (CancelException e) {
+ // PDX classes fish for a PDXRegistry and find that there is no cache
+ } catch (InvalidClassException e) {
+ fail("I was unable to deserialize " + object.getClass().getName(), e);
+ }
+ }
+
+ private boolean isSerializableAndNotDataSerializable(CompiledClass compiledClass) {
+ // these classes throw exceptions or log ugly messages when you try to load them
+ // in junit
+ String name = compiledClass.fullyQualifiedName().replace('/', '.');
+ if (name.startsWith("org.apache.geode.internal.shared.NativeCallsJNAImpl")
+ || name.startsWith("org.apache.geode.internal.statistics.HostStatHelper")) {
+ return false;
+ }
+ try {
+ Class<?> realClass = Class.forName(name);
+ return Serializable.class.isAssignableFrom(realClass)
+ && !DataSerializable.class.isAssignableFrom(realClass)
+ && !DataSerializableFixedID.class.isAssignableFrom(realClass);
+ } catch (UnsatisfiedLinkError e) {
+ System.out.println("Unable to load actual class " + name + " external JNI dependencies");
+ } catch (NoClassDefFoundError e) {
+ System.out.println("Unable to load actual class " + name + " not in JUnit classpath");
+ } catch (Throwable e) {
+ System.out.println("Unable to load actual class " + name + ": " + e);
+ }
+ return false;
}
}
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/CompiledClassUtils.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/CompiledClassUtils.java
index c7e2d27..25dda45 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/CompiledClassUtils.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/CompiledClassUtils.java
@@ -124,6 +124,8 @@
}
} catch (IOException e) {
System.err.println("Exception while parsing " + entry.getName() + ": " + e.getMessage());
+ } catch (NoClassDefFoundError e) {
+ throw new RuntimeException("NoClassDefFoundError while parsing " + entry.getName(), e);
}
}
}
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java
new file mode 100644
index 0000000..4a02107
--- /dev/null
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.codeAnalysis;
+
+import static org.apache.geode.internal.serialization.SanctionedSerializables.loadSanctionedSerializablesServices;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+
+import org.junit.Test;
+
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+
+public abstract class SanctionedSerializablesServiceIntegrationTestBase {
+
+ protected abstract SanctionedSerializablesService getService();
+
+ protected abstract ServiceResourceExpectation getServiceResourceExpectation();
+
+ protected enum ServiceResourceExpectation {
+ NULL,
+ EMPTY,
+ NON_EMPTY
+ }
+
+ @Test
+ public final void serviceIsLoaded() {
+ Collection<SanctionedSerializablesService> services = loadSanctionedSerializablesServices();
+ SanctionedSerializablesService service = getService();
+
+ boolean found = false;
+ for (SanctionedSerializablesService aService : services) {
+ if (service.getClass().equals(aService.getClass())) {
+ found = true;
+ break;
+ }
+ }
+
+ assertThat(found)
+ .as("Services " + services + " contains " + getService().getClass().getSimpleName())
+ .isTrue();
+ }
+
+ @Test
+ public final void serviceResourceExists() {
+ SanctionedSerializablesService service = getService();
+
+ URL url = service.getSanctionedSerializablesURL();
+
+ switch (getServiceResourceExpectation()) {
+ case NULL:
+ assertThat(url).isNull();
+ break;
+ case EMPTY:
+ case NON_EMPTY:
+ assertThat(url).isNotNull();
+ }
+ }
+
+ @Test
+ public final void serviceResourceIsLoaded() throws IOException {
+ SanctionedSerializablesService service = getService();
+
+ Collection<String> serializables = service.getSerializationAcceptlist();
+
+ switch (getServiceResourceExpectation()) {
+ case NULL:
+ case EMPTY:
+ assertThat(serializables).isEmpty();
+ break;
+ case NON_EMPTY:
+ assertThat(serializables).isNotEmpty();
+ }
+ }
+}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributedSystemService.java b/geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java
similarity index 71%
rename from geode-core/src/main/java/org/apache/geode/distributed/internal/DistributedSystemService.java
rename to geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java
index 8f78e65..3401da1 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributedSystemService.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java
@@ -12,15 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.distributed.internal;
+package org.apache.geode.test.junit.categories;
-import java.io.IOException;
-import java.util.Collection;
-
-public interface DistributedSystemService {
- void init(InternalDistributedSystem internalDistributedSystem);
-
- Class getInterface();
-
- Collection<String> getSerializationAcceptlist() throws IOException;
+public interface SanctionedSerializablesTest {
}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java
index 66d3a15..0c3030e 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.test.junit.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class JUnitSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-junit-serializables.txt");
}
}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ClassAnalysisRule.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ClassAnalysisRule.java
new file mode 100644
index 0000000..599edf1
--- /dev/null
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ClassAnalysisRule.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.test.junit.rules;
+
+import static java.util.Arrays.stream;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import org.apache.geode.codeAnalysis.CompiledClassUtils;
+import org.apache.geode.codeAnalysis.decode.CompiledClass;
+
+/**
+ * ClassAnalysisRule will load all classes from the main src set of your module and
+ * make them available to your test as CompiledClass instances via the getClasses()
+ * method. The constructor for ClassAnalysisRule takes the name of your gradle
+ * subproject, such as geode-core or geode-wan, and the rule uses this to locate
+ * the build directory in order to load the classes.
+ * <p>
+ * This Rule is used by our AnalyzeSerializables unit tests.
+ * <p>
+ * NOTE: this rule is not thread-safe
+ */
+public class ClassAnalysisRule implements TestRule {
+
+ private static final AtomicReference<Map<String, CompiledClass>> cachedClasses =
+ new AtomicReference<>(new HashMap<>());
+
+ private final String moduleName;
+ private final Map<String, CompiledClass> classes = new HashMap<>();
+
+ /**
+ * @param moduleName The name of the gradle module in which your test resides
+ */
+ public ClassAnalysisRule(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ public Map<String, CompiledClass> getClasses() {
+ return new HashMap<>(classes);
+ }
+
+ public static void clearCache() {
+ cachedClasses.get().clear();
+ }
+
+ @Override
+ public Statement apply(final Statement statement, final Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ before();
+ statement.evaluate();
+ }
+ };
+ }
+
+ private void before() {
+ if (cachedClasses.get().isEmpty()) {
+ loadClasses();
+ cachedClasses.get().putAll(classes);
+ } else {
+ classes.putAll(cachedClasses.get());
+ }
+ }
+
+ private void loadClasses() {
+ String classpath = System.getProperty("java.class.path");
+ // System.out.println("java classpath is " + classpath);
+
+ List<File> entries =
+ stream(classpath.split(File.pathSeparator))
+ .map(x -> new File(x))
+ .collect(Collectors.toList());
+
+ String gradleBuildDirName =
+ Paths.get(getModuleName(), "build", "classes", "java", "main").toString();
+ // System.out.println("gradleBuildDirName is " + gradleBuildDirName);
+ String ideaBuildDirName =
+ Paths.get(getModuleName(), "out", "production", "classes").toString();
+ // System.out.println("ideaBuildDirName is " + ideaBuildDirName);
+ String ideaFQCNBuildDirName =
+ Paths.get("out", "production", "geode." + getModuleName() + ".main").toString();
+ // System.out.println("idea build path with full package names is " + ideaFQCNBuildDirName);
+
+ String buildDir = null;
+ for (File entry : entries) {
+ if (entry.toString().endsWith(gradleBuildDirName)
+ || entry.toString().endsWith(ideaBuildDirName)
+ || entry.toString().endsWith(ideaFQCNBuildDirName)) {
+ buildDir = entry.toString();
+ break;
+ }
+ }
+ assertThat(buildDir).isNotNull();
+ System.out.println("ClassAnalysisRule is loading class files from " + buildDir);
+
+ long start = System.currentTimeMillis();
+ loadClassesFromBuild(new File(buildDir));
+ long finish = System.currentTimeMillis();
+
+ System.out.println("done loading " + classes.size() + " classes. elapsed time = "
+ + (finish - start) / 1000 + " seconds");
+ }
+
+ private String getModuleName() {
+ return moduleName;
+ }
+
+ private void loadClassesFromBuild(File buildDir) {
+ Map<String, CompiledClass> newClasses = CompiledClassUtils.parseClassFilesInDir(buildDir);
+ classes.putAll(newClasses);
+ }
+}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java
index db972f0..3e614cf 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java
@@ -32,8 +32,8 @@
import com.google.common.base.Stopwatch;
import org.junit.rules.ErrorCollector;
+import org.junit.rules.ExternalResource;
-import org.apache.geode.test.junit.rules.serializable.SerializableExternalResource;
/**
* A rule for testing using multiple threads. This rule should not be used as a class rule. This
@@ -73,7 +73,7 @@
* </code>
* </pre>
*/
-public class ConcurrencyRule extends SerializableExternalResource {
+public class ConcurrencyRule extends ExternalResource {
private final ExecutorService threadPool = Executors.newCachedThreadPool();
private final Collection<ConcurrentOperation> toInvoke;
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/GsRandom.java
similarity index 60%
rename from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
rename to geode-junit/src/main/java/org/apache/geode/test/junit/rules/GsRandom.java
index 6d8fec7..66aa4a6 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/GsRandom.java
@@ -12,17 +12,32 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.test.junit.rules;
-import org.junit.experimental.categories.Category;
+interface GsRandom {
-import org.apache.geode.test.junit.categories.SerializationTest;
+ boolean nextBoolean();
-@Category({SerializationTest.class})
-public class AnalyzeSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+ char nextChar();
- @Override
- protected String getModuleName() {
- return "geode-core";
- }
+ byte nextByte();
+
+ double nextDouble(double max);
+
+ double nextDouble(double min, double max);
+
+ short nextShort();
+
+ long nextLong(long max);
+
+ long nextLong(long min, long max);
+
+ int nextInt(int max);
+
+ int nextInt(int min, int max);
+ // Date nextDate();
+ // Object randomElement(Vector vec);
+ // String randomString();
+ // String randomString(int max);
+ // String randomReadableString(int max);
}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RandomRule.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RandomRule.java
new file mode 100644
index 0000000..1670d89
--- /dev/null
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RandomRule.java
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.test.junit.rules;
+
+import static java.util.Arrays.asList;
+import static java.util.Objects.requireNonNull;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.StreamSupport.stream;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.security.SecureRandom;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import org.apache.geode.annotations.VisibleForTesting;
+import org.apache.geode.test.junit.rules.serializable.SerializableStatement;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestRule;
+
+@SuppressWarnings({"serial", "unused", "WeakerAccess", "NumericCastThatLosesPrecision"})
+public class RandomRule extends SecureRandom implements GsRandom, SerializableTestRule {
+
+ private final transient AtomicReference<SecureRandom> random = new AtomicReference<>();
+ private final byte[] seed;
+
+ public RandomRule() {
+ this(null, null);
+ }
+
+ public RandomRule(byte[] seed) {
+ this(null, seed);
+ }
+
+ public RandomRule(SecureRandom random) {
+ this(random, null);
+ }
+
+ private RandomRule(SecureRandom random, byte[] seed) {
+ this.random.set(random);
+ this.seed = seed;
+ }
+
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return statement(base);
+ }
+
+ private Statement statement(Statement base) {
+ return new SerializableStatement() {
+ @Override
+ public void evaluate() throws Throwable {
+ before();
+ base.evaluate();
+ }
+ };
+ }
+
+ private void before() {
+ random.compareAndSet(null, newRandom());
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code boolean} value from this random
+ * number generator's sequence.
+ *
+ * @return the next pseudorandom, uniformly distributed {@code boolean} value from this random
+ * number generator's sequence.
+ */
+ @Override
+ public boolean nextBoolean() {
+ return next(1) == 0;
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code char} value from this random number
+ * generator's sequence There is a hack here to prevent '}' so as to eliminate the possibility of
+ * generating a sequence which would falsely get marked as a suspect string while we are matching
+ * the pattern {@code {[0-9]+}}.
+ *
+ * @return the next pseudorandom, uniformly distributed {@code char} value from this random number
+ * generator's sequence.
+ */
+ @Override
+ public char nextChar() {
+ char c = (char) next(16);
+ if (c == '}') {
+ c = nextChar(); // prevent right bracket, try again
+ }
+ return c;
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code byte} value from this random number
+ * generator's sequence.
+ *
+ * @return the next pseudorandom, uniformly distributed {@code byte} value from this random
+ * number generator's sequence.
+ */
+ @Override
+ public byte nextByte() {
+ return (byte) next(8);
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code double} value from this random
+ * number generator's sequence within a range from 0 to max.
+ *
+ * @param max the maximum range (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed {@code double} value from this random
+ * number generator's sequence.
+ */
+ @Override
+ public double nextDouble(double max) {
+ return nextDouble(0.0, max);
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code double} value from this random
+ * number generator's sequence within a range from min to max.
+ *
+ * @param min the minimum range (inclusive) for the pseudorandom.
+ * @param max the maximum range (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed {@code double} value from this random
+ * number generator's sequence.
+ */
+ @Override
+ public double nextDouble(double min, double max) {
+ return nextDouble() * (max - min) + min;
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code short} value from this random
+ * number generator's sequence.
+ *
+ * @return the next pseudorandom, uniformly distributed {@code short} value from this random
+ * number generator's sequence.
+ */
+ @Override
+ public short nextShort() {
+ return (short) nextChar();
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code long} value from this random number
+ * generator's sequence within a range from 0 to max.
+ *
+ * @param max the maximum range (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed {@code long} value from this random number
+ * generator's sequence.
+ */
+ @Override
+ public long nextLong(long max) {
+ if (max == Long.MAX_VALUE) {
+ max--;
+ }
+ return Math.abs(nextLong()) % (max + 1);
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code long} value from this random number
+ * generator's sequence within a range from min to max.
+ *
+ * @param min the minimum range (inclusive) for the pseudorandom.
+ * @param max the maximum range (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed {@code long} value from this random number
+ * generator's sequence.
+ */
+ @Override
+ public long nextLong(long min, long max) {
+ return nextLong(max - min) + min;
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code int} value from this random number
+ * generator's sequence within a range from 0 to max (inclusive -- which is different from
+ * {@link Random#nextInt}).
+ *
+ * @param max the maximum range (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed {@code int} value from this random number
+ * generator's sequence.
+ */
+ @Override
+ public int nextInt(int max) {
+ if (max == Integer.MAX_VALUE) {
+ max--;
+ }
+
+ int theNext = nextInt();
+ // Math.abs behaves badly when given min int, so avoid
+ if (theNext == Integer.MIN_VALUE) {
+ theNext = Integer.MIN_VALUE + 1;
+ }
+ return Math.abs(theNext) % (max + 1);
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed {@code int} value from this random number
+ * generator's sequence within a range from min to max. If max < min, returns 0.
+ *
+ * @param min the minimum range (inclusive) for the pseudorandom.
+ * @param max the maximum range (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed {@code int} value from this random number
+ * generator's sequence.
+ */
+ @Override
+ public int nextInt(int min, int max) {
+ if (max < min) {
+ return 0; // handle max == 0 and avoid divide-by-zero exceptions
+ }
+
+ return nextInt(max - min) + min;
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed element from the specified iterable as
+ * indexed by this random number generator's sequence.
+ *
+ * @param iterable the range of values (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed element from the specified iterable as
+ * indexed by this random number generator's sequence.
+ * @throws NullPointerException if iterable is null.
+ * @throws IllegalArgumentException if iterable is empty.
+ */
+ public <T> T next(Iterable<T> iterable) {
+ List<T> list = requireNonNulls(requireNonEmpty(stream(iterable.spliterator(), false)
+ .collect(toList())));
+ return list.get(nextInt(0, list.size() - 1));
+ }
+
+ /**
+ * Returns the next pseudorandom, uniformly distributed element from the specified values as
+ * indexed by this random number generator's sequence.
+ *
+ * @param values the range of values (inclusive) for the pseudorandom.
+ * @return the next pseudorandom, uniformly distributed element from the specified values as
+ * indexed by this random number generator's sequence.
+ * @throws NullPointerException if values is null.
+ * @throws IllegalArgumentException if values is empty.
+ */
+ public <T> T next(T... values) {
+ List<T> list = requireNonNulls(requireNonEmpty(asList(values)));
+ return requireNonEmpty(list).get(nextInt(0, list.size() - 1));
+ }
+
+ @VisibleForTesting
+ byte[] getSeed() {
+ return seed == null ? null : seed.clone();
+ }
+
+ private SecureRandom newRandom() {
+ if (seed == null) {
+ return new SecureRandom();
+ }
+ return new SecureRandom(seed);
+ }
+
+ private <T> List<T> requireNonEmpty(List<T> list) {
+ if (list.isEmpty()) {
+ throw new IllegalArgumentException("At least one element is required");
+ }
+ return list;
+ }
+
+ private <T> List<T> requireNonNulls(List<T> list) {
+ list.forEach(t -> requireNonNull(t));
+ return list;
+ }
+
+ private void readObject(ObjectInputStream stream) throws InvalidObjectException {
+ throw new InvalidObjectException("SerializationProxy required");
+ }
+
+ protected Object writeReplace() {
+ return new SerializationProxy(this);
+ }
+
+ /**
+ * Serialization proxy for {@code RandomRule}.
+ */
+ @SuppressWarnings("serial")
+ private static class SerializationProxy implements Serializable {
+
+ private final byte[] seed;
+
+ private SerializationProxy(RandomRule instance) {
+ seed = instance.getSeed();
+ }
+
+ protected Object readResolve() {
+ RandomRule randomRule = seed == null ? new RandomRule() : new RandomRule(seed.clone());
+ randomRule.before();
+ return randomRule;
+ }
+ }
+}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RuleList.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RuleList.java
index e6eca48..e48e0f7 100755
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RuleList.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/RuleList.java
@@ -43,7 +43,9 @@
/**
* Creates an empty {@code RuleList}.
*/
- public RuleList() {}
+ public RuleList() {
+ // nothing
+ }
/**
* Creates a {@code RuleList} containing a single {@link TestRule}.
@@ -51,7 +53,7 @@
* @param rule the first rule of the {@code RuleList}
*/
public RuleList(final TestRule rule) {
- this.rules.add(rule);
+ rules.add(rule);
}
/**
@@ -60,7 +62,9 @@
* @param rules the list of {@code TestRule}s to add
*/
protected RuleList(final List<TestRule> rules) {
- this.rules.addAll(rules);
+ if (rules != null) {
+ this.rules.addAll(rules);
+ }
}
/**
@@ -70,13 +74,13 @@
* @return the {@code RuleList} with a new TestRule added
*/
public RuleList add(final TestRule rule) {
- this.rules.add(rule);
+ rules.add(rule);
return this;
}
@Override
public Statement apply(Statement base, final Description description) {
- for (TestRule each : this.rules) {
+ for (TestRule each : rules) {
base = each.apply(base, description);
}
return base;
@@ -86,6 +90,6 @@
* Returns a reference to the actual list of {@code TestRule}s. For use by subclasses and tests.
*/
protected List<TestRule> rules() {
- return this.rules;
+ return rules;
}
}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeout.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeout.java
index 8689e16..8095163 100755
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeout.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeout.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.test.junit.rules.serializable;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.geode.test.junit.rules.serializable.FieldSerializationUtils.readField;
import static org.apache.geode.test.junit.rules.serializable.FieldsOfTimeout.FIELD_LOOK_FOR_STUCK_THREAD;
import static org.apache.geode.test.junit.rules.serializable.FieldsOfTimeout.FIELD_TIMEOUT;
@@ -26,9 +27,12 @@
import org.junit.rules.Timeout;
+import org.apache.geode.annotations.VisibleForTesting;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+
/**
- * Serializable subclass of {@link org.junit.rules.Timeout Timeout}. All instance variables of
- * {@code Timeout} are serialized by reflection.
+ * Serializable subclass of {@link Timeout Timeout}. All instance variables of {@code Timeout} are
+ * serialized by reflection.
*/
public class SerializableTimeout extends Timeout implements SerializableTestRule {
@@ -36,6 +40,10 @@
return new Builder();
}
+ public SerializableTimeout() {
+ this(GeodeAwaitility.getTimeout().getValueInMS(), MILLISECONDS);
+ }
+
public SerializableTimeout(final long timeout, final TimeUnit timeUnit) {
super(timeout, timeUnit);
}
@@ -44,11 +52,16 @@
super(builder);
}
+ @VisibleForTesting
+ long timeout(TimeUnit unit) {
+ return getTimeout(unit);
+ }
+
private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("SerializationProxy required");
}
- private Object writeReplace() {
+ protected Object writeReplace() {
return new SerializationProxy(this);
}
@@ -57,10 +70,6 @@
*/
public static class Builder extends Timeout.Builder {
- protected Builder() {
- super();
- }
-
@Override
public Builder withTimeout(final long timeout, final TimeUnit unit) {
super.withTimeout(timeout, unit);
@@ -82,6 +91,7 @@
/**
* Serialization proxy for {@code SerializableTimeout}.
*/
+ @SuppressWarnings("serial")
private static class SerializationProxy implements Serializable {
private final long timeout;
@@ -89,15 +99,17 @@
private final boolean lookForStuckThread;
SerializationProxy(final SerializableTimeout instance) {
- this.timeout = (long) readField(Timeout.class, instance, FIELD_TIMEOUT);
- this.timeUnit = (TimeUnit) readField(Timeout.class, instance, FIELD_TIME_UNIT);
- this.lookForStuckThread =
+ timeout = (long) readField(Timeout.class, instance, FIELD_TIMEOUT);
+ timeUnit = (TimeUnit) readField(Timeout.class, instance, FIELD_TIME_UNIT);
+ lookForStuckThread =
(boolean) readField(Timeout.class, instance, FIELD_LOOK_FOR_STUCK_THREAD);
}
- private Object readResolve() {
- return new SerializableTimeout.Builder().withTimeout(this.timeout, this.timeUnit)
- .withLookingForStuckThread(this.lookForStuckThread).build();
+ protected Object readResolve() {
+ return new SerializableTimeout.Builder()
+ .withTimeout(timeout, timeUnit)
+ .withLookingForStuckThread(lookForStuckThread)
+ .build();
}
}
}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java b/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java
index cdd6f9d..7673c45 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/util/ResourceUtils.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
*
- * 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.test.util;
@@ -69,7 +67,9 @@
*/
public static URL getResource(final String resourceName) {
URL resource = getCallerClass(2).getResource(resourceName);
- assertThat(resource).as(resourceName).isNotNull();
+ assertThat(resource)
+ .as("Resource '" + resourceName + "'")
+ .isNotNull();
return resource;
}
@@ -82,7 +82,10 @@
*/
public static URL getResource(final Class<?> classInSamePackage, final String resourceName) {
URL resource = classInSamePackage.getResource(resourceName);
- assertThat(resource).as(resourceName).isNotNull();
+ assertThat(resource)
+ .as("Resource '" + resourceName + "' associated with Class '" + classInSamePackage.getName()
+ + "'")
+ .isNotNull();
return resource;
}
@@ -95,7 +98,9 @@
*/
public static URL getResource(final ClassLoader classLoader, final String resourceName) {
URL resource = classLoader.getResource(resourceName);
- assertThat(resource).as(resourceName).isNotNull();
+ assertThat(resource)
+ .as("Resource '" + resourceName + "' associated with ClassLoader '" + classLoader + "'")
+ .isNotNull();
return resource;
}
@@ -251,7 +256,9 @@
public static void copyDirectoryResource(final URL resource, final File targetFolder) {
try {
File source = new File(resource.getPath());
- assertThat(source.exists()).as("Source does not exist: " + resource.getPath());
+ assertThat(source)
+ .as("Resource path '" + resource.getPath() + "'")
+ .exists();
FileUtils.copyDirectory(source, targetFolder);
} catch (IOException e) {
throw new UncheckedIOException(e);
diff --git a/geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..9ae0589
--- /dev/null
+++ b/geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.test.junit.internal.JUnitSanctionedSerializablesService
diff --git a/geode-junit/src/main/resources/org/apache/geode/test/junit/internal/sanctioned-geode-junit-serializables.txt b/geode-junit/src/main/resources/org/apache/geode/test/junit/internal/sanctioned-geode-junit-serializables.txt
new file mode 100644
index 0000000..4925104
--- /dev/null
+++ b/geode-junit/src/main/resources/org/apache/geode/test/junit/internal/sanctioned-geode-junit-serializables.txt
@@ -0,0 +1,111 @@
+com/examples/ds/Address,false
+com/examples/snapshot/MyDataSerializer$MyObjectDataSerializable2,false
+com/examples/snapshot/MyObject,false,f1:long,f2:java/lang/String
+com/examples/snapshot/MyObjectPdx,false,enumVal:com/examples/snapshot/MyObjectPdx$MyEnumPdx
+com/examples/snapshot/MyObjectPdx$MyEnumPdx,false
+com/examples/snapshot/MyObjectPdxSerializable,false
+com/examples/snapshot/MyPdxSerializer$MyObjectPdx2,false
+org/apache/geode/cache/query/data/Address,false,city:java/lang/String,phoneNo:java/util/Set,street:java/util/Set,zipCode:java/lang/String
+org/apache/geode/cache/query/data/City,false,name:java/lang/String,zip:int
+org/apache/geode/cache/query/data/ComparableWrapper,false,val:int
+org/apache/geode/cache/query/data/Country,false,continent:java/lang/String,name:java/lang/String,states:java/util/Set
+org/apache/geode/cache/query/data/Data,false
+org/apache/geode/cache/query/data/District,false,cities:java/util/Set,name:java/lang/String,villages:java/util/Set
+org/apache/geode/cache/query/data/Employee,false,addresses:java/util/Set,age:int,empId:int,name:java/lang/String,phoneNo:org/apache/geode/cache/query/data/PhoneNo,salary:int,title:java/lang/String
+org/apache/geode/cache/query/data/Instrument,false,id:java/lang/String,tradingLines:java/util/List
+org/apache/geode/cache/query/data/Inventory,false,cusip:java/lang/String,dealer_code:java/lang/String,i:int,inc_order_qty:int,is_benchmark_flag:java/lang/String,lower_qty:int,max_order_qty:int,min_order_qty:int,price_type:java/lang/String,quote_price:double,quote_timestamp:java/sql/Timestamp,retail_price:int,tempArr:java/lang/String[],tempDouble:double,tempInt:int,tempStr:java/lang/String,treasury_cusip:java/lang/String,upper_qty:int,yield_spread:double
+org/apache/geode/cache/query/data/Keywords,false,and:boolean,distinct:boolean,element:boolean,from:boolean,not:boolean,or:boolean,select:boolean,type:boolean,undefined:boolean,where:boolean
+org/apache/geode/cache/query/data/Manager,false,manager_id:int
+org/apache/geode/cache/query/data/Numbers,false,avg1:float,id:int,id1:int,id2:int,l:long,max1:float,range:double
+org/apache/geode/cache/query/data/PhoneNo,false,mobile:int,phoneNo1:int,phoneNo2:int,phoneNo3:int
+org/apache/geode/cache/query/data/PortfolioData,false,ID:int,collectionHolderMap:java/util/HashMap,names:java/lang/String[],pkid:java/lang/String,status:java/lang/String,type:java/lang/String
+org/apache/geode/cache/query/data/PositionNoDS,false,avg20DaysVol:long,bondRating:java/lang/String,convRatio:double,country:java/lang/String,delta:double,industry:long,issuer:long,mktValue:double,pid:int,portfolioId:int,qty:double,secId:java/lang/String,secIdIndexed:java/lang/String,secLinks:java/lang/String,secType:java/lang/String,sharesOutstanding:double,underlyer:java/lang/String,volatility:long
+org/apache/geode/cache/query/data/PositionPdx,false,avg20DaysVol:long,bondRating:java/lang/String,convRatio:double,country:java/lang/String,delta:double,industry:long,issuer:long,mktValue:double,pid:int,portfolioId:int,qty:double,secId:java/lang/String,secIdIndexed:java/lang/String,secLinks:java/lang/String,secType:java/lang/String,sharesOutstanding:double,underlyer:java/lang/String,volatility:long
+org/apache/geode/cache/query/data/ProhibitedSecurityQuote,false,block_reason:java/lang/String,cusip:java/lang/String,dealer_code:java/lang/String,distribution_channel:java/lang/String,i:int,lower_qty:int,price_type:java/lang/String,prohibited_security_quote_id:int,sbs_timestamp:java/sql/Timestamp,status:java/lang/String,tempArr:java/lang/String[],upper_qty:int,user_id:java/lang/String,user_role:java/lang/String,ycf_filter_name:java/lang/String
+org/apache/geode/cache/query/data/Quote,false,channelName:java/lang/String,cusip:int,dealerCode:int,dealerPortfolio:java/lang/String,lowerQty:int,price:double,priceType:java/lang/String,quoteId:int,quoteIdStr:java/lang/String,quoteType:java/lang/String,restrict:java/util/Set,uniqueQuoteType:java/lang/String,upperQty:int,ytm:int
+org/apache/geode/cache/query/data/Restricted,false,cusip:int,incQty:int,maxQty:int,minQty:int,price:double,quoteType:java/lang/String,uniqueQuoteType:java/lang/String
+org/apache/geode/cache/query/data/SecurityMaster,false,accrual_daycount_code:java/lang/String,additional_sec_desc:java/lang/String,advalorem_tax_status:java/lang/String,alternative_minimum_tax_status:java/lang/String,amortization_term:int,article_counter:double,bank_qualified_status:java/lang/String,call_type:java/lang/String,country_code:java/lang/String,coupon_class:java/lang/String,coupon_date:java/sql/Timestamp,coupon_frequency:java/lang/String,coupon_rate:double,coupon_type:java/lang/String,cusip:java/lang/String,cusip_prohibited:java/lang/String,dated_date:java/sql/Timestamp,escrow_type:java/lang/String,exchange:java/lang/String,first_coupon_date:java/sql/Timestamp,first_settlement_date:java/sql/Timestamp,hand_figure_ind:java/lang/String,i:int,insurance_type:java/lang/String,insurer_name:java/lang/String,investment_grade:java/lang/String,is_bank_qualified:java/lang/String,is_callable:java/lang/String,is_endof_monthpayment:java/lang/String,is_escrow:java/lang/String,is_exmt_amt:java/lang/String,is_general_oblig:java/lang/String,is_insured:java/lang/String,is_perpetual:java/lang/String,is_prerefunded:java/lang/String,is_revenue:java/lang/String,is_subj_amt:java/lang/String,is_taxable:java/lang/String,issue_date:java/sql/Timestamp,issuer_price:double,last_coupon_date:java/sql/Timestamp,legal_defeasance_status:java/lang/String,maturity_date:java/sql/Timestamp,mbs_class_code:java/lang/String,mbscc_eligibility_flag:java/lang/String,monetary_default_ind:java/lang/String,moody_rating:java/lang/String,moody_watch:java/lang/String,next_last_coupon_date:java/sql/Timestamp,next_settlement_date:java/sql/Timestamp,pre_refund_type:java/lang/String,pre_refunded_date:java/sql/Timestamp,pre_refunded_price:double,put_type:java/lang/String,sbs_product_code:java/lang/String,sbs_product_group:java/lang/String,security_description:java/lang/String,security_number:java/lang/String,security_type:java/lang/String,short_description:java/lang/String,sinking_fund_type:java/lang/String,snp_rating:java/lang/String,snp_watch:java/lang/String,source:java/lang/String,state_code:java/lang/String,symbol:java/lang/String,tax_indicator:java/lang/String,taxable_status:java/lang/String,tba_cusip:java/lang/String,tempArr:java/lang/String[],tempDouble:double,tempInt:int,tempStr:java/lang/String,trading_flat_ind:java/lang/String,update_date:java/sql/Timestamp
+org/apache/geode/cache/query/data/State,false,districts:java/util/Set,name:java/lang/String,zone:java/lang/String
+org/apache/geode/cache/query/data/Street,false,lane:java/lang/String,street:java/lang/String
+org/apache/geode/cache/query/data/TestData$MyValue,false,value:int
+org/apache/geode/cache/query/data/TradingLine,false,alternateReferences:java/util/Map
+org/apache/geode/cache/query/data/Village,false,name:java/lang/String,zip:int
+org/apache/geode/cache/query/functional/StructSetOrResultsSet$ValidationLevel,false
+org/apache/geode/cache/snapshot/RegionGenerator$RegionType,false
+org/apache/geode/cache/snapshot/RegionGenerator$SerializationType,false
+org/apache/geode/cache30/MyGatewayTransportFilter1,false
+org/apache/geode/cache30/MyGatewayTransportFilter2,false
+org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase$ServiceResourceExpectation,false
+org/apache/geode/internal/cache/SerializableObject,false,i:int,str:java/lang/String
+org/apache/geode/internal/cache/UnitTestValueHolder,false,value:java/lang/Object
+org/apache/geode/internal/cache/execute/MyFunctionExecutionException,false
+org/apache/geode/internal/cache/ha/TestBlockingHARegionQueue$1,false,this$0:org/apache/geode/internal/cache/ha/TestBlockingHARegionQueue
+org/apache/geode/internal/cache/wan/Filter70,false,Id:java/lang/String,eventEnqued:int,eventTransmitted:int
+org/apache/geode/internal/cache/wan/MyGatewaySenderEventListener,false,eventsMap:java/util/Map,id:java/lang/String
+org/apache/geode/internal/cache/wan/MyGatewaySenderEventListener2,false,eventsMap:java/util/Map,id:java/lang/String
+org/apache/geode/internal/cache/wan/MyGatewayTransportFilter1,false,Id:java/lang/String
+org/apache/geode/internal/cache/wan/MyGatewayTransportFilter2,false,Id:java/lang/String
+org/apache/geode/internal/cache/wan/MyGatewayTransportFilter3,false,Id:java/lang/String
+org/apache/geode/internal/cache/wan/MyGatewayTransportFilter4,false,Id:java/lang/String
+org/apache/geode/management/internal/cli/domain/Stock,false,key:java/lang/String,value:double
+org/apache/geode/management/internal/cli/dto/Car,false,attributeArray:java/lang/String[],attributeSet:java/util/Set,attributes:java/util/Map,colors:java/util/List,make:java/lang/String,model:java/lang/String
+org/apache/geode/management/internal/cli/dto/Key,false,key:int
+org/apache/geode/management/internal/cli/dto/Key1,false,id:java/lang/String,name:java/lang/String
+org/apache/geode/management/internal/cli/dto/Key2,false,id:java/lang/String,name:java/lang/String
+org/apache/geode/management/internal/cli/dto/ObjectWithCharAttr,false,c:char,name:java/lang/String,t:int
+org/apache/geode/management/internal/cli/dto/Value,false,value:java/lang/String
+org/apache/geode/management/internal/cli/dto/Value1,false,age:int,department:java/lang/String,employeeId:int,lastName:java/lang/String,name:java/lang/String
+org/apache/geode/management/internal/cli/dto/Value2,false,areaInSqKm:double,capitalCity:java/lang/String,population:int,stateName:java/lang/String
+org/apache/geode/management/internal/configuration/ConfigGroup,false,configFiles:java/util/Set,jars:java/util/Set,maxLogFileSize:java/lang/String,name:java/lang/String,regions:java/util/Set
+org/apache/geode/management/internal/security/TestFunctions,false
+org/apache/geode/management/internal/security/TestFunctions$ReadFunction,false
+org/apache/geode/management/internal/security/TestFunctions$WriteFunction,false
+org/apache/geode/management/model/EmptyObject,false
+org/apache/geode/management/model/Item,true,-1174387683312780907,itemDescription:java/lang/String,itemId:java/lang/String,order:org/apache/geode/management/model/Order
+org/apache/geode/management/model/Order,true,2049641616996906290,id:java/lang/String,items:java/util/Collection
+org/apache/geode/management/model/SubOrder,true,2049641616996906291
+org/apache/geode/pdx/Day,false
+org/apache/geode/pdx/DomainObjectPdxAuto$Day,false
+org/apache/geode/pdx/DomainObjectPdxAutoNoDefaultConstructor$Day,false
+org/apache/geode/pdx/SimpleClass$SimpleEnum,false
+org/apache/geode/security/query/data/PdxQueryTestObject,false,age:int,id:int,name:java/lang/String,shouldThrowException:boolean
+org/apache/geode/security/query/data/PdxTrade,false,cusip:java/lang/String,id:java/lang/String,price:int,shares:int
+org/apache/geode/security/query/data/QueryTestObject,false,dateField:java/util/Date,id:int,mapField:java/util/Map,name:java/lang/String
+org/apache/geode/test/compiler/ClassBuilder,false,classPath:java/lang/String
+org/apache/geode/test/concurrent/FileBasedCountDownLatch,false,dataFile:java/io/File,lockFile:java/io/File
+org/apache/geode/test/junit/rules/CloseableReference,false,autoClose:java/util/concurrent/atomic/AtomicBoolean
+org/apache/geode/test/junit/rules/ConditionalIgnoreRule,false
+org/apache/geode/test/junit/rules/ExecutorServiceRule,false,awaitTerminationBeforeShutdown:boolean,awaitTerminationTimeUnit:java/util/concurrent/TimeUnit,awaitTerminationTimeout:long,enableAwaitTermination:boolean,useShutdown:boolean,useShutdownNow:boolean
+org/apache/geode/test/junit/rules/IgnoreOnWindowsRule,false
+org/apache/geode/test/junit/rules/IgnoreUntilRule,false
+org/apache/geode/test/junit/rules/JarFileRule,false,className:java/lang/String,jarFile:java/io/File,jarName:java/lang/String,makeJarLarge:boolean
+org/apache/geode/test/junit/rules/RandomRule,false,seed:byte[]
+org/apache/geode/test/junit/rules/RandomRule$1,false,this$0:org/apache/geode/test/junit/rules/RandomRule,val$base:org/junit/runners/model/Statement
+org/apache/geode/test/junit/rules/RandomRule$SerializationProxy,false,seed:byte[]
+org/apache/geode/test/junit/rules/RepeatRule,false
+org/apache/geode/test/junit/rules/RequiresGeodeHome,false
+org/apache/geode/test/junit/rules/RetryRule,false,implementation:org/apache/geode/test/junit/rules/RetryRule$AbstractRetryRule
+org/apache/geode/test/junit/rules/RetryRule$AbstractRetryRule,false,this$0:org/apache/geode/test/junit/rules/RetryRule
+org/apache/geode/test/junit/rules/RetryRule$GlobalRetryRule,false,retryCount:int,this$0:org/apache/geode/test/junit/rules/RetryRule
+org/apache/geode/test/junit/rules/RetryRule$LocalRetryRule,false,this$0:org/apache/geode/test/junit/rules/RetryRule
+org/apache/geode/test/junit/rules/UseJacksonForJsonPathRule,false,jsonProvider:com/jayway/jsonpath/spi/json/JsonProvider,mappingProvider:com/jayway/jsonpath/spi/mapper/MappingProvider,options:java/util/Set,restoreDefaults:boolean
+org/apache/geode/test/junit/rules/accessible/AccessibleRestoreSystemProperties,false
+org/apache/geode/test/junit/rules/gfsh/internal/OutputLine$OutputSource,false
+org/apache/geode/test/junit/rules/serializable/SerializableErrorCollector,false
+org/apache/geode/test/junit/rules/serializable/SerializableExternalResource,false
+org/apache/geode/test/junit/rules/serializable/SerializableExternalResource$1,false,this$0:org/apache/geode/test/junit/rules/serializable/SerializableExternalResource,val$base:org/junit/runners/model/Statement
+org/apache/geode/test/junit/rules/serializable/SerializableRuleList,false
+org/apache/geode/test/junit/rules/serializable/SerializableRuleList$SerializationProxy,false,rules:java/util/List
+org/apache/geode/test/junit/rules/serializable/SerializableStatement,false
+org/apache/geode/test/junit/rules/serializable/SerializableTemporaryFolder,false
+org/apache/geode/test/junit/rules/serializable/SerializableTemporaryFolder$SerializationProxy,false,folder:java/io/File,parentFolder:java/io/File
+org/apache/geode/test/junit/rules/serializable/SerializableTestName,false
+org/apache/geode/test/junit/rules/serializable/SerializableTestName$SerializationProxy,false,name:java/lang/String
+org/apache/geode/test/junit/rules/serializable/SerializableTestWatcher,false
+org/apache/geode/test/junit/rules/serializable/SerializableTimeout,false
+org/apache/geode/test/junit/rules/serializable/SerializableTimeout$SerializationProxy,false,lookForStuckThread:boolean,timeUnit:java/util/concurrent/TimeUnit,timeout:long
+org/apache/geode/test/junit/support/IgnoreConditionEvaluationException,false
+org/apache/geode/test/version/TestVersion,false,major:int,minor:int,patch:int
+parReg/query/unittest/NewPortfolio,false,MAX_NUM_OF_POSITIONS:int,MAX_PRICE:int,MAX_QTY:int,NUM_OF_SECURITIES:int,NUM_OF_TYPES:int,id:int,myVersion:java/lang/String,name:java/lang/String,positions:java/util/Map,status:java/lang/String,type:java/lang/String,undefinedTestField:java/lang/String
+parReg/query/unittest/Position,false,MAX_PRICE:int,NUM_OF_SECURITIES:int,mktValue:double,qty:double,secId:java/lang/String
+util/TestException,false
diff --git a/geode-junit/src/test/java/org/apache/geode/test/junit/rules/RandomRuleTest.java b/geode-junit/src/test/java/org/apache/geode/test/junit/rules/RandomRuleTest.java
new file mode 100644
index 0000000..39cfe13
--- /dev/null
+++ b/geode-junit/src/test/java/org/apache/geode/test/junit/rules/RandomRuleTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.test.junit.rules;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singleton;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.SerializationUtils;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class RandomRuleTest {
+
+ @Rule
+ public RandomRule randomRule = new RandomRule();
+
+ @Test
+ public void isSerializable() {
+ assertThat(randomRule).isInstanceOf(Serializable.class);
+ }
+
+ @Test
+ public void serializes() {
+ RandomRule clone = SerializationUtils.clone(randomRule);
+
+ assertThat(clone.getSeed()).isEqualTo(randomRule.getSeed());
+ }
+
+ @Test
+ public void iterableWithOneElementReturnsThatElement() {
+ String value = randomRule.next(singleton("item"));
+
+ assertThat(value).isEqualTo("item");
+ }
+
+ @Test
+ public void nullNullIterableThrowsNullPointerException() {
+ Iterable<String> input = null;
+
+ Throwable thrown = catchThrowable(() -> randomRule.next(input));
+
+ assertThat(thrown).isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ public void emptyIterableThrowsIllegalArgumentException() {
+ Throwable thrown = catchThrowable(() -> randomRule.next(emptyList()));
+
+ assertThat(thrown).isInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ public void iterableWithTwoElementsReturnsRandomElement() {
+ String value = randomRule.next(asList("one", "two"));
+
+ assertThat(value).isIn("one", "two");
+ }
+
+ @Test
+ public void iterableWithManyElementsReturnsRandomElement() {
+ String value = randomRule.next(asList("one", "two", "three"));
+
+ assertThat(value).isIn("one", "two", "three");
+ }
+
+ @Test
+ public void varArgsWithOneElementReturnsThatElement() {
+ String value = randomRule.next("item");
+
+ assertThat(value).isEqualTo("item");
+ }
+
+ @Test
+ public void varArgsWithTwoElementsReturnsRandomElement() {
+ String value = randomRule.next("one", "two");
+
+ assertThat(value).isIn("one", "two");
+ }
+
+ @Test
+ public void varArgsWithManyElementsReturnsRandomElement() {
+ String value = randomRule.next("one", "two", "three");
+
+ assertThat(value).isIn("one", "two", "three");
+ }
+
+ @Test
+ public void nullVarArgThrowsNullPointerException() {
+ String input = null;
+
+ Throwable thrown = catchThrowable(() -> randomRule.next(input));
+
+ assertThat(thrown).isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ public void zeroVarArgsThrowsIllegalArgumentException() {
+ String[] input = new String[0];
+
+ Throwable thrown = catchThrowable(() -> randomRule.next(input));
+
+ assertThat(thrown)
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("At least one element is required");
+ }
+}
diff --git a/geode-junit/src/test/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeoutTest.java b/geode-junit/src/test/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeoutTest.java
index 72c3665..a598aa6 100755
--- a/geode-junit/src/test/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeoutTest.java
+++ b/geode-junit/src/test/java/org/apache/geode/test/junit/rules/serializable/SerializableTimeoutTest.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.test.junit.rules.serializable;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.geode.test.junit.rules.serializable.FieldSerializationUtils.readField;
import static org.apache.geode.test.junit.rules.serializable.FieldsOfTimeout.FIELD_LOOK_FOR_STUCK_THREAD;
import static org.apache.geode.test.junit.rules.serializable.FieldsOfTimeout.FIELD_TIMEOUT;
@@ -36,7 +37,7 @@
public class SerializableTimeoutTest {
@Test
- public void hasThreeFields() throws Exception {
+ public void hasThreeFields() {
Field[] fields = Timeout.class.getDeclaredFields();
assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).isEqualTo(3);
}
@@ -60,7 +61,7 @@
}
@Test
- public void fieldsCanBeRead() throws Exception {
+ public void fieldsCanBeRead() {
long timeout = 1000;
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
boolean lookingForStuckThread = false;
@@ -75,14 +76,27 @@
}
@Test
- public void isSerializable() throws Exception {
- assertThat(SerializableTimeout.class).isInstanceOf(Serializable.class);
+ public void isSerializable() {
+ SerializableTimeout serializableTimeout =
+ new SerializableTimeout(SerializableTimeout.builder());
+
+ assertThat(serializableTimeout).isInstanceOf(Serializable.class);
}
@Test
- public void canBeSerialized() throws Exception {
+ public void serializes() {
+ SerializableTimeout serializableTimeout =
+ new SerializableTimeout(SerializableTimeout.builder());
+
+ SerializableTimeout clone = SerializationUtils.clone(serializableTimeout);
+
+ assertThat(clone.timeout(SECONDS)).isEqualTo(serializableTimeout.timeout(SECONDS));
+ }
+
+ @Test
+ public void canBeSerialized() {
long timeout = 2;
- TimeUnit timeUnit = TimeUnit.SECONDS;
+ TimeUnit timeUnit = SECONDS;
boolean lookingForStuckThread = true;
SerializableTimeout instance = SerializableTimeout.builder().withTimeout(timeout, timeUnit)
diff --git a/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java b/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..2c6ba29
--- /dev/null
+++ b/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.cache.lucene.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class LuceneSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new LuceneSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-lucene/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeLuceneSerializablesJUnitTest.java b/geode-lucene/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeLuceneSerializablesIntegrationTest.java
similarity index 71%
rename from geode-lucene/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeLuceneSerializablesJUnitTest.java
rename to geode-lucene/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeLuceneSerializablesIntegrationTest.java
index 9a5fd6c..1e0af7c 100644
--- a/geode-lucene/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeLuceneSerializablesJUnitTest.java
+++ b/geode-lucene/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeLuceneSerializablesIntegrationTest.java
@@ -16,14 +16,20 @@
import org.junit.experimental.categories.Category;
+import org.apache.geode.cache.lucene.internal.LuceneSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.LuceneTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
-
-@Category({LuceneTest.class})
-public class AnalyzeLuceneSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category({LuceneTest.class, SerializationTest.class})
+public class AnalyzeLuceneSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
@Override
protected String getModuleName() {
return "geode-lucene";
}
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return LuceneSanctionedSerializablesService.class;
+ }
}
diff --git a/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
deleted file mode 100644
index 8ce0692..0000000
--- a/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# e.g.,
-#org/apache/geode/cache/query/CqAttributesFactory
diff --git a/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt b/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
deleted file mode 100644
index f41f6f0..0000000
--- a/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# This is a list of classes excluded due to open bugs about their having
-# incompatible changes. There should be no entries in this file at the
-# time of a product release.
-
-# Each entry should be a bug number followed by a comma and the
-# full class name. The package components can be delimited with a period
-# or a comma. Don't include ".class" or ".java" at the end of the name.
-
-# example: 50174,org/apache/geode/distributed/internal/StartupResponseWithVersionMessage
-# example: 50175,com.gemstone.org.jgroups.Message$Header
-
-
-# ~~~~~~~~~~~~~~~~~~~ DataSerializables ~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testDataSerializables
-
-
-# ~~~~~~~~~~~~~~~~~~~ Serializables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testSerializables
-
-
-
diff --git a/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt b/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
index 7c3348d..7d80d08 100644
--- a/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
+++ b/geode-lucene/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -55,4 +55,3 @@
org/apache/geode/cache/lucene/internal/results/PageResults,2
fromData,45
toData,45
-
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java
index 66d3a15..918c05d 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.cache.lucene.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class LuceneSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-lucene-serializables.txt");
}
}
diff --git a/geode-lucene/src/main/java/org/apache/geode/internal/LuceneDistributedSystemService.java b/geode-lucene/src/main/java/org/apache/geode/internal/LuceneDistributedSystemService.java
deleted file mode 100644
index 1fbdf7f..0000000
--- a/geode-lucene/src/main/java/org/apache/geode/internal/LuceneDistributedSystemService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-
-public class LuceneDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-lucene-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index b6b88e3..0000000
--- a/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1,16 +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.
-org.apache.geode.internal.LuceneDistributedSystemService
-
diff --git a/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..93608d5
--- /dev/null
+++ b/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.cache.lucene.internal.LuceneSanctionedSerializablesService
diff --git a/geode-lucene/src/main/resources/org/apache/geode/internal/sanctioned-geode-lucene-serializables.txt b/geode-lucene/src/main/resources/org/apache/geode/cache/lucene/internal/sanctioned-geode-lucene-serializables.txt
similarity index 100%
rename from geode-lucene/src/main/resources/org/apache/geode/internal/sanctioned-geode-lucene-serializables.txt
rename to geode-lucene/src/main/resources/org/apache/geode/cache/lucene/internal/sanctioned-geode-lucene-serializables.txt
diff --git a/geode-management/build.gradle b/geode-management/build.gradle
index 1853790..be99f04 100755
--- a/geode-management/build.gradle
+++ b/geode-management/build.gradle
@@ -21,6 +21,9 @@
dependencies {
compile(platform(project(':boms:geode-all-bom')))
+
+ compile(project(':geode-serialization'))
+
compile('org.apache.commons:commons-lang3')
compile('com.fasterxml.jackson.core:jackson-databind')
compile('com.fasterxml.jackson.core:jackson-core')
@@ -40,4 +43,9 @@
testCompile(project(':geode-junit')) {
exclude module: 'geode-core'
}
+
+ integrationTestImplementation(project(':geode-dunit'))
+ integrationTestImplementation(project(':geode-junit'))
+ integrationTestImplementation('junit:junit')
+ integrationTestImplementation('org.awaitility:awaitility')
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-management/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesIntegrationTest.java
similarity index 75%
copy from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
copy to geode-management/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesIntegrationTest.java
index 32ce5c3..9cb2f81 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-management/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesIntegrationTest.java
@@ -12,23 +12,24 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.management.internal.ManagementSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeManagementSerializablesIntegrationTest
+ extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
return "geode-management";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return ManagementSanctionedSerializablesService.class;
}
}
diff --git a/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.java b/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..e2f1c10
--- /dev/null
+++ b/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.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 org.apache.geode.management.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class ManagementSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service =
+ new ManagementSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java
similarity index 67%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java
index 66d3a15..6e232a5 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.management.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class ManagementSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-management-serializables.txt");
}
}
diff --git a/geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..7e8cfc3
--- /dev/null
+++ b/geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.management.internal.ManagementSanctionedSerializablesService
diff --git a/geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-management-serializables.txt b/geode-management/src/main/resources/org/apache/geode/management/internal/sanctioned-geode-management-serializables.txt
similarity index 93%
rename from geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-management-serializables.txt
rename to geode-management/src/main/resources/org/apache/geode/management/internal/sanctioned-geode-management-serializables.txt
index 9d35238..41f50ba 100644
--- a/geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-management-serializables.txt
+++ b/geode-management/src/main/resources/org/apache/geode/management/internal/sanctioned-geode-management-serializables.txt
@@ -1,3 +1,5 @@
+org/apache/geode/management/api/ClusterManagementException,false,result:org/apache/geode/management/api/ClusterManagementResult
+org/apache/geode/management/api/ClusterManagementRealizationException,false,result:org/apache/geode/management/api/ClusterManagementRealizationResult
org/apache/geode/management/api/ClusterManagementResult$StatusCode,false
org/apache/geode/management/api/CommandType,false
org/apache/geode/management/api/RealizationResult,false,memberName:java/lang/String,message:java/lang/String,success:boolean
@@ -26,4 +28,4 @@
org/apache/geode/management/runtime/MemberInformation,true,1,cacheServerList:java/util/List,cacheXmlFilePath:java/lang/String,clientCount:int,cpuUsage:double,groups:java/lang/String,heapUsage:long,host:java/lang/String,hostedRegions:java/util/Set,httpServiceBindAddress:java/lang/String,httpServicePort:int,id:java/lang/String,initHeapSize:long,isCoordinator:boolean,isSecured:boolean,isServer:boolean,locatorPort:int,locators:java/lang/String,logFilePath:java/lang/String,maxHeapSize:long,offHeapMemorySize:java/lang/String,processId:int,serverBindAddress:java/lang/String,statArchiveFilePath:java/lang/String,status:java/lang/String,webSSL:boolean,workingDirPath:java/lang/String
org/apache/geode/management/runtime/PdxInfo,false,diskStoreName:java/lang/String,ignoreUnreadFields:boolean,pdxSerializer:java/lang/String,readSerialized:boolean
org/apache/geode/management/runtime/RuntimeInfo,false,memberName:java/lang/String
-org/apache/geode/management/runtime/RuntimeRegionInfo,false,entryCount:long
\ No newline at end of file
+org/apache/geode/management/runtime/RuntimeRegionInfo,false,entryCount:long
diff --git a/geode-management/src/test/resources/expected-pom.xml b/geode-management/src/test/resources/expected-pom.xml
index 3935ffd..1a22d01 100644
--- a/geode-management/src/test/resources/expected-pom.xml
+++ b/geode-management/src/test/resources/expected-pom.xml
@@ -47,6 +47,11 @@
</dependencyManagement>
<dependencies>
<dependency>
+ <groupId>org.apache.geode</groupId>
+ <artifactId>geode-serialization</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>compile</scope>
diff --git a/geode-membership/build.gradle b/geode-membership/build.gradle
index 9d549c5..0b1140a 100644
--- a/geode-membership/build.gradle
+++ b/geode-membership/build.gradle
@@ -49,6 +49,7 @@
testRuntime(project(path: ':geode-old-versions', configuration: 'testOutput'))
+ integrationTestCompile(project(':geode-core'))
integrationTestCompile(project(':geode-junit')) {
exclude module: 'geode-logging'
}
diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMembershipSerializablesIntegrationTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMembershipSerializablesIntegrationTest.java
new file mode 100644
index 0000000..0fb6f85
--- /dev/null
+++ b/geode-membership/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMembershipSerializablesIntegrationTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.codeAnalysis;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.distributed.internal.membership.gms.Services;
+import org.apache.geode.internal.serialization.BufferDataOutputStream;
+import org.apache.geode.internal.serialization.DSFIDSerializer;
+import org.apache.geode.internal.serialization.DSFIDSerializerFactory;
+import org.apache.geode.test.junit.categories.MembershipTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+/**
+ * AnalyzeMembershipSerializablesIntegrationTest analyzes the DataSerializableFixedID and
+ * BasicSerializable implementations in the membership package. It does not test
+ * java Serializable objects because the DSFIDSerializer that is used by default in the
+ * membership module does not support java Serializables.
+ */
+@Category({MembershipTest.class, SerializationTest.class})
+public class AnalyzeMembershipSerializablesIntegrationTest
+ extends AnalyzeDataSerializablesJUnitTestBase {
+
+ private final DSFIDSerializer dsfidSerializer = new DSFIDSerializerFactory().create();
+
+ @Override
+ protected String getModuleName() {
+ return "geode-membership";
+ }
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return Services.class;
+ }
+
+ @Override
+ protected void deserializeObject(BufferDataOutputStream outputStream)
+ throws IOException, ClassNotFoundException {
+ dsfidSerializer.getObjectDeserializer()
+ .readObject(new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
+ }
+
+ @Override
+ protected void serializeObject(Object object, BufferDataOutputStream outputStream)
+ throws IOException {
+ dsfidSerializer.getObjectSerializer().writeObject(object, outputStream);
+ }
+
+ @Override
+ protected void initializeSerializationService() {
+ Services.registerSerializables(dsfidSerializer);
+ }
+}
diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java
index a1b1260..08211f8 100644
--- a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java
+++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java
@@ -57,6 +57,7 @@
.or(resideInAPackage("org.apache.geode.distributed.internal.tcpserver.."))
.or(resideInAPackage("org.apache.geode.internal.inet.."))
.or(resideInAPackage("org.apache.geode.internal.lang.."))
+ .or(resideInAPackage("org.apache.geode.codeAnalysis.."))
.or(not(resideInAPackage("org.apache.geode..")))
.or(type(AvailablePortHelper.class))
diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..cc1e6e9
--- /dev/null
+++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.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 org.apache.geode.distributed.internal.membership.gms;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class MembershipSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service =
+ new MembershipSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NULL;
+ }
+}
diff --git a/geode-membership/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt b/geode-membership/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
new file mode 100644
index 0000000..c9c9799
--- /dev/null
+++ b/geode-membership/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -0,0 +1,72 @@
+org/apache/geode/distributed/internal/membership/gms/GMSMembershipView,2
+fromData,121
+toData,72
+
+org/apache/geode/distributed/internal/membership/gms/MemberIdentifierImpl,6
+fromData,39
+fromDataPre_GFE_7_1_0_0,308
+fromDataPre_GFE_9_0_0_0,308
+toData,35
+toDataPre_GFE_7_1_0_0,290
+toDataPre_GFE_9_0_0_0,280
+
+org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorRequest,2
+fromData,112
+toData,132
+
+org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse,2
+fromData,130
+toData,114
+
+org/apache/geode/distributed/internal/membership/gms/locator/GetViewRequest,2
+fromData,1
+toData,1
+
+org/apache/geode/distributed/internal/membership/gms/locator/GetViewResponse,2
+fromData,20
+toData,17
+
+org/apache/geode/distributed/internal/membership/gms/messages/FinalCheckPassedMessage,2
+fromData,20
+toData,17
+
+org/apache/geode/distributed/internal/membership/gms/messages/HeartbeatMessage,2
+fromData,11
+toData,11
+
+org/apache/geode/distributed/internal/membership/gms/messages/HeartbeatRequestMessage,2
+fromData,30
+toData,27
+
+org/apache/geode/distributed/internal/membership/gms/messages/InstallViewMessage,2
+fromData,60
+toData,56
+
+org/apache/geode/distributed/internal/membership/gms/messages/JoinRequestMessage,2
+fromData,63
+toData,60
+
+org/apache/geode/distributed/internal/membership/gms/messages/JoinResponseMessage,2
+fromData,63
+toData,57
+
+org/apache/geode/distributed/internal/membership/gms/messages/LeaveRequestMessage,2
+fromData,28
+toData,25
+
+org/apache/geode/distributed/internal/membership/gms/messages/NetworkPartitionMessage,2
+fromData,1
+toData,1
+
+org/apache/geode/distributed/internal/membership/gms/messages/RemoveMemberMessage,2
+fromData,28
+toData,25
+
+org/apache/geode/distributed/internal/membership/gms/messages/SuspectMembersMessage,2
+fromData,63
+toData,92
+
+org/apache/geode/distributed/internal/membership/gms/messages/ViewAckMessage,2
+fromData,40
+toData,37
+
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java
similarity index 66%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java
index 66d3a15..b611b75 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.distributed.internal.membership.gms;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class MembershipSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-membership-serializables.txt");
}
}
diff --git a/geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..3cdd57e
--- /dev/null
+++ b/geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.distributed.internal.membership.gms.MembershipSanctionedSerializablesService
diff --git a/geode-memcached/build.gradle b/geode-memcached/build.gradle
index 5a813b2..4c2b1b0 100644
--- a/geode-memcached/build.gradle
+++ b/geode-memcached/build.gradle
@@ -26,6 +26,8 @@
implementation(platform(project(':boms:geode-all-bom')))
implementation(project(':geode-core'))
implementation(project(':geode-logging'))
+ implementation(project(':geode-serialization'))
+
implementation('org.apache.logging.log4j:log4j-api')
testImplementation('org.mockito:mockito-core')
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-memcached/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMemcachedSerializablesIntegrationTest.java
similarity index 73%
copy from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
copy to geode-memcached/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMemcachedSerializablesIntegrationTest.java
index 32ce5c3..f2ac741 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-memcached/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMemcachedSerializablesIntegrationTest.java
@@ -12,23 +12,24 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.internal.memcached.MemcachedSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeMemcachedSerializablesIntegrationTest
+ extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
- return "geode-management";
+ return "geode-memcached";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return MemcachedSanctionedSerializablesService.class;
}
}
diff --git a/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java b/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..536b61b
--- /dev/null
+++ b/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.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 org.apache.geode.internal.memcached;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class MemcachedSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service =
+ new MemcachedSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt b/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
deleted file mode 100644
index af8c45a..0000000
--- a/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# This is a list of classes excluded due to open bugs about their having
-# incompatible changes. There should be no entries in this file at the
-# time of a product release.
-
-# Each entry should be a bug number followed by a comma and the
-# full class name. The package components can be delimited with a period
-# or a comma. Don't include ".class" or ".java" at the end of the name.
-
-# example: 50174,org/apache/geode/distributed/internal/StartupResponseWithVersionMessage
-# example: 50175,com.gemstone.org.jgroups.Message$Header
-
-
-# ~~~~~~~~~~~~~~~~~~~ DataSerializables ~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testDataSerializables
-
-# ~~~~~~~~~~~~~~~~~~~ Serializables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testSerializables
-
-
-# ~~~~~~~~~~~~~~~~~~~ Whitelist Testing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
diff --git a/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt b/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
index 862679f..0058c1a 100644
--- a/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
+++ b/geode-memcached/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -5,4 +5,3 @@
org/apache/geode/internal/memcached/ValueWrapper,2
fromData,29
toData,29
-
diff --git a/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedDistributedSystemService.java b/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedDistributedSystemService.java
deleted file mode 100644
index 36837bb..0000000
--- a/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedDistributedSystemService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.memcached;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.InternalDataSerializer;
-
-public class MemcachedDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-memcached-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-memcached/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMemcachedSerializablesJUnitTest.java b/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java
old mode 100755
new mode 100644
similarity index 68%
rename from geode-memcached/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMemcachedSerializablesJUnitTest.java
rename to geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java
index de6ba3c..ab04e2d
--- a/geode-memcached/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeMemcachedSerializablesJUnitTest.java
+++ b/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java
@@ -12,20 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.internal.memcached;
+import java.net.URL;
-import org.apache.geode.internal.memcached.GeodeMemcachedService;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-public class AnalyzeMemcachedSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class MemcachedSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-memcached";
- }
-
- @Override
- protected Class getModuleClass() {
- return GeodeMemcachedService.class;
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-memcached-serializables.txt");
}
}
diff --git a/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index 252b58b..0000000
--- a/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.geode.internal.memcached.MemcachedDistributedSystemService
\ No newline at end of file
diff --git a/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..93a17eb
--- /dev/null
+++ b/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.internal.memcached.MemcachedSanctionedSerializablesService
diff --git a/geode-memcached/src/test/resources/expected-pom.xml b/geode-memcached/src/test/resources/expected-pom.xml
index 391dbd6..c1067c1 100644
--- a/geode-memcached/src/test/resources/expected-pom.xml
+++ b/geode-memcached/src/test/resources/expected-pom.xml
@@ -57,6 +57,11 @@
<scope>runtime</scope>
</dependency>
<dependency>
+ <groupId>org.apache.geode</groupId>
+ <artifactId>geode-serialization</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>runtime</scope>
diff --git a/geode-old-client-support/src/distributedTest/java/org/apache/geode/OldClientSupportDUnitTest.java b/geode-old-client-support/src/distributedTest/java/org/apache/geode/OldClientSupportDUnitTest.java
index 319a483..ad90575 100644
--- a/geode-old-client-support/src/distributedTest/java/org/apache/geode/OldClientSupportDUnitTest.java
+++ b/geode-old-client-support/src/distributedTest/java/org/apache/geode/OldClientSupportDUnitTest.java
@@ -14,13 +14,15 @@
*/
package org.apache.geode;
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptySet;
+import static java.util.Collections.singletonList;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
@@ -31,7 +33,6 @@
import org.apache.geode.cache.Cache;
import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.internal.DistributedSystemService;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.DistributionConfigImpl;
import org.apache.geode.internal.HeapDataOutputStream;
@@ -52,17 +53,17 @@
public class OldClientSupportDUnitTest extends JUnit4CacheTestCase {
private static final List<String> allGeodeThrowableClasses =
- Arrays.asList(new String[] {"org.apache.geode.cache.execute.EmptyRegionFunctionException",});
+ singletonList("org.apache.geode.cache.execute.EmptyRegionFunctionException");
- private static final List<String> newArrayClassNames = Arrays.asList(new String[] {
- "[Lorg.apache.geode.class1", "[[Lorg.apache.geode.class1", "[[[Lorg.apache.geode.class1"});
+ private static final List<String> newArrayClassNames = asList("[Lorg.apache.geode.class1",
+ "[[Lorg.apache.geode.class1", "[[[Lorg.apache.geode.class1");
private static final List<String> oldArrayClassNames =
- Arrays.asList(new String[] {"[Lcom.gemstone.gemfire.class1", "[[Lcom.gemstone.gemfire.class1",
- "[[[Lcom.gemstone.gemfire.class1"});
+ asList("[Lcom.gemstone.gemfire.class1", "[[Lcom.gemstone.gemfire.class1",
+ "[[[Lcom.gemstone.gemfire.class1");
- private static final List<String> allNonconformingArrayClassNames = Arrays.asList(
- new String[] {"[Lmypackage.org.apache.geode.class2", "[[Lmypackage.org.apache.geode.class2"});
+ private static final List<String> allNonconformingArrayClassNames = asList(
+ "[Lmypackage.org.apache.geode.class2", "[[Lmypackage.org.apache.geode.class2");
private Cache myCache;
@@ -183,7 +184,7 @@
properties.put(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER,
"org.apache.geode.ClientSerializableObjec");
DistributionConfig config = new DistributionConfigImpl(properties);
- InternalDataSerializer.initialize(config, new ArrayList<DistributedSystemService>());
+ InternalDataSerializer.initializeSerializationFilter(config, emptySet());
com.gemstone.gemfire.ClientSerializableObject gemfireObject =
new com.gemstone.gemfire.ClientSerializableObject();
diff --git a/geode-pulse/build.gradle b/geode-pulse/build.gradle
index 9d60078..3d7398d 100644
--- a/geode-pulse/build.gradle
+++ b/geode-pulse/build.gradle
@@ -29,6 +29,8 @@
compileOnly(platform(project(':boms:geode-all-bom')))
providedCompile(platform(project(':boms:geode-all-bom')))
+ compile(project(':geode-serialization'))
+
compile('org.springframework.security:spring-security-core')
compile('javax.servlet:javax.servlet-api')
compile('mx4j:mx4j') {
@@ -122,6 +124,11 @@
integrationTestCompile('org.springframework:spring-test')
+ integrationTestCompile('junit:junit')
+ integrationTestCompile('org.hamcrest:hamcrest-core')
+ integrationTestCompile('org.hamcrest:hamcrest-library')
+ integrationTestCompile('org.hamcrest:hamcrest-all')
+
uiTestRuntime(project(':geode-core'))
uiTestCompile(project(':geode-junit')) {
exclude module: 'geode-core'
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-pulse/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzePulseSerializablesIntegrationTest.java
similarity index 74%
copy from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
copy to geode-pulse/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzePulseSerializablesIntegrationTest.java
index 32ce5c3..13fed94 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-pulse/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzePulseSerializablesIntegrationTest.java
@@ -12,23 +12,23 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.tools.pulse.internal.PulseSanctionedSerializablesService;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzePulseSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
- return "geode-management";
+ return "geode-pulse";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return PulseSanctionedSerializablesService.class;
}
}
diff --git a/geode-pulse/src/integrationTest/java/org/apache/geode/tools/pulse/internal/PulseSanctionedSerializablesServiceIntegrationTest.java b/geode-pulse/src/integrationTest/java/org/apache/geode/tools/pulse/internal/PulseSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..3019f09
--- /dev/null
+++ b/geode-pulse/src/integrationTest/java/org/apache/geode/tools/pulse/internal/PulseSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.tools.pulse.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class PulseSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new PulseSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.EMPTY;
+ }
+}
diff --git a/geode-pulse/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-pulse/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
new file mode 100644
index 0000000..a22c2fe
--- /dev/null
+++ b/geode-pulse/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -0,0 +1 @@
+org/apache/geode/tools/pulse/internal/security/GemFireAuthentication
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseSanctionedSerializablesService.java
index 66d3a15..29981bf 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.tools.pulse.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class PulseSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-pulse-serializables.txt");
}
}
diff --git a/geode-pulse/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-pulse/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..52d2158
--- /dev/null
+++ b/geode-pulse/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.tools.pulse.internal.PulseSanctionedSerializablesService
diff --git a/geode-wan/src/main/resources/org/apache/geode/internal/sanctioned-geode-wan-serializables.txt b/geode-pulse/src/main/resources/org/apache/geode/tools/pulse/internal/sanctioned-geode-pulse-serializables.txt
old mode 100755
new mode 100644
similarity index 100%
copy from geode-wan/src/main/resources/org/apache/geode/internal/sanctioned-geode-wan-serializables.txt
copy to geode-pulse/src/main/resources/org/apache/geode/tools/pulse/internal/sanctioned-geode-pulse-serializables.txt
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesIntegrationTest.java
old mode 100644
new mode 100755
similarity index 75%
copy from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
copy to geode-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesIntegrationTest.java
index 32ce5c3..1c28908
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesIntegrationTest.java
@@ -12,23 +12,23 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.redis.internal.RedisSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeRedisSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
- return "geode-management";
+ return "geode-redis";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return RedisSanctionedSerializablesService.class;
}
}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesJUnitTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesJUnitTest.java
deleted file mode 100755
index b388dde..0000000
--- a/geode-redis/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeRedisSerializablesJUnitTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.codeAnalysis;
-
-
-import org.apache.geode.redis.internal.GeodeRedisService;
-
-public class AnalyzeRedisSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
-
- @Override
- protected String getModuleName() {
- return "geode-redis";
- }
-
- @Override
- protected Class getModuleClass() {
- return GeodeRedisService.class;
- }
-}
diff --git a/geode-redis/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt b/geode-redis/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
deleted file mode 100644
index f41f6f0..0000000
--- a/geode-redis/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# This is a list of classes excluded due to open bugs about their having
-# incompatible changes. There should be no entries in this file at the
-# time of a product release.
-
-# Each entry should be a bug number followed by a comma and the
-# full class name. The package components can be delimited with a period
-# or a comma. Don't include ".class" or ".java" at the end of the name.
-
-# example: 50174,org/apache/geode/distributed/internal/StartupResponseWithVersionMessage
-# example: 50175,com.gemstone.org.jgroups.Message$Header
-
-
-# ~~~~~~~~~~~~~~~~~~~ DataSerializables ~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testDataSerializables
-
-
-# ~~~~~~~~~~~~~~~~~~~ Serializables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testSerializables
-
-
-
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisDistributedSystemService.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisDistributedSystemService.java
deleted file mode 100644
index 3458048..0000000
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisDistributedSystemService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.redis.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.InternalDataSerializer;
-
-public class RedisDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-redis-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java
index 66d3a15..d9853ef 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.redis.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class RedisSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-redis-serializables.txt");
}
}
diff --git a/geode-redis/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-redis/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index d123569..0000000
--- a/geode-redis/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.geode.redis.internal.RedisDistributedSystemService
\ No newline at end of file
diff --git a/geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..c11ffee
--- /dev/null
+++ b/geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.redis.internal.RedisSanctionedSerializablesService
diff --git a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..420db71
--- /dev/null
+++ b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class RedisSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new RedisSanctionedSerializablesService();
+
+ @Override
+ public SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-redis/src/test/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-redis/src/test/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..c11ffee
--- /dev/null
+++ b/geode-redis/src/test/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.redis.internal.RedisSanctionedSerializablesService
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java b/geode-serialization/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeSerializationSerializablesIntegrationTest.java
similarity index 72%
copy from geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
copy to geode-serialization/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeSerializationSerializablesIntegrationTest.java
index 32ce5c3..dcfc7a2 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeManagementSerializablesJUnitTest.java
+++ b/geode-serialization/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeSerializationSerializablesIntegrationTest.java
@@ -12,23 +12,24 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.codeAnalysis;
import org.junit.experimental.categories.Category;
+import org.apache.geode.internal.serialization.SerializationSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({SerializationTest.class})
-public class AnalyzeManagementSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category(SerializationTest.class)
+public class AnalyzeSerializationSerializablesIntegrationTest
+ extends AnalyzeSerializablesJUnitTestBase {
+
@Override
protected String getModuleName() {
- return "geode-management";
+ return "geode-serialization";
}
@Override
- // Override this method because geode-management module has no data serializable classes
- public void testDataSerializables() throws Exception {
-
+ protected Class<?> getModuleClass() {
+ return SerializationSanctionedSerializablesService.class;
}
}
diff --git a/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java b/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..f733ee7
--- /dev/null
+++ b/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.serialization;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class SerializationSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service =
+ new SerializationSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.NON_EMPTY;
+ }
+}
diff --git a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializables.java b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializables.java
new file mode 100644
index 0000000..7b9a77f
--- /dev/null
+++ b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializables.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.serialization;
+
+import static java.util.Collections.emptyList;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.ServiceLoader;
+
+public class SanctionedSerializables {
+
+ /**
+ * Loads all SanctionedSerializablesServices on the classpath.
+ */
+ public static Collection<SanctionedSerializablesService> loadSanctionedSerializablesServices() {
+ ServiceLoader<SanctionedSerializablesService> loader =
+ ServiceLoader.load(SanctionedSerializablesService.class);
+ Collection<SanctionedSerializablesService> services = new ArrayList<>();
+ for (SanctionedSerializablesService service : loader) {
+ services.add(service);
+ }
+ return services;
+ }
+
+ /**
+ * Loads class names of sanctioned serializables from a resource. Caller will add these to the
+ * serialization filter acceptlist.
+ */
+ public static Collection<String> loadClassNames(URL sanctionedSerializables) throws IOException {
+ if (sanctionedSerializables == null) {
+ return emptyList();
+ }
+ Collection<String> result = new ArrayList<>(1000);
+ try (InputStream inputStream = sanctionedSerializables.openStream();
+ BufferedReader in = new BufferedReader(new InputStreamReader(inputStream))) {
+ String line;
+ while ((line = in.readLine()) != null) {
+ line = line.trim();
+ if (!(line.startsWith("#") || line.startsWith("//"))) {
+ line = line.replaceAll("/", ".");
+ result.add(line.substring(0, line.indexOf(',')));
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributedSystemService.java b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializablesService.java
similarity index 66%
copy from geode-core/src/main/java/org/apache/geode/distributed/internal/DistributedSystemService.java
copy to geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializablesService.java
index 8f78e65..ad40721 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributedSystemService.java
+++ b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializablesService.java
@@ -12,15 +12,22 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.distributed.internal;
+package org.apache.geode.internal.serialization;
import java.io.IOException;
+import java.net.URL;
import java.util.Collection;
-public interface DistributedSystemService {
- void init(InternalDistributedSystem internalDistributedSystem);
+@FunctionalInterface
+public interface SanctionedSerializablesService {
- Class getInterface();
+ URL getSanctionedSerializablesURL();
- Collection<String> getSerializationAcceptlist() throws IOException;
+ default Class<?> getInterface() {
+ return getClass();
+ }
+
+ default Collection<String> getSerializationAcceptlist() throws IOException {
+ return SanctionedSerializables.loadClassNames(getSanctionedSerializablesURL());
+ }
}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java
similarity index 70%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java
index 66d3a15..52827f2 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java
@@ -12,18 +12,14 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.internal.serialization;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
-
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class SerializationSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-serialization-serializables.txt");
}
}
diff --git a/geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..dae9b2b
--- /dev/null
+++ b/geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.internal.serialization.SerializationSanctionedSerializablesService
diff --git a/geode-serialization/src/main/resources/org/apache/geode/internal/serialization/sanctioned-geode-serialization-serializables.txt b/geode-serialization/src/main/resources/org/apache/geode/internal/serialization/sanctioned-geode-serialization-serializables.txt
new file mode 100644
index 0000000..4e9c598
--- /dev/null
+++ b/geode-serialization/src/main/resources/org/apache/geode/internal/serialization/sanctioned-geode-serialization-serializables.txt
@@ -0,0 +1,3 @@
+org/apache/geode/internal/serialization/DSCODE,false,value:byte
+org/apache/geode/internal/serialization/DSFIDNotFoundException,true,130596009484324655,dsfid:int,versionOrdinal:short
+org/apache/geode/internal/serialization/UnsupportedSerializationVersionException,true,3572445857994216007
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java
similarity index 71%
rename from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
rename to geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java
index 66d3a15..8fe1a80 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java
@@ -16,14 +16,20 @@
import org.junit.experimental.categories.Category;
+import org.apache.geode.internal.cache.wan.WANSanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SerializationTest;
import org.apache.geode.test.junit.categories.WanTest;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category({WanTest.class, SerializationTest.class})
+public class AnalyzeWANSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
@Override
protected String getModuleName() {
return "geode-wan";
}
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return WANSanctionedSerializablesService.class;
+ }
}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesServiceIntegrationTest.java b/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..49749d4
--- /dev/null
+++ b/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.wan;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class WANSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new WANSanctionedSerializablesService();
+
+ @Override
+ protected SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.EMPTY;
+ }
+}
diff --git a/geode-wan/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-wan/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
deleted file mode 100644
index 8ce0692..0000000
--- a/geode-wan/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# e.g.,
-#org/apache/geode/cache/query/CqAttributesFactory
diff --git a/geode-wan/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt b/geode-wan/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
deleted file mode 100644
index f41f6f0..0000000
--- a/geode-wan/src/integrationTest/resources/org/apache/geode/codeAnalysis/openBugs.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# This is a list of classes excluded due to open bugs about their having
-# incompatible changes. There should be no entries in this file at the
-# time of a product release.
-
-# Each entry should be a bug number followed by a comma and the
-# full class name. The package components can be delimited with a period
-# or a comma. Don't include ".class" or ".java" at the end of the name.
-
-# example: 50174,org/apache/geode/distributed/internal/StartupResponseWithVersionMessage
-# example: 50175,com.gemstone.org.jgroups.Message$Header
-
-
-# ~~~~~~~~~~~~~~~~~~~ DataSerializables ~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testDataSerializables
-
-
-# ~~~~~~~~~~~~~~~~~~~ Serializables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# these are failures from testSerializables
-
-
-
diff --git a/geode-wan/src/main/java/org/apache/geode/internal/WANDistributedSystemService.java b/geode-wan/src/main/java/org/apache/geode/internal/WANDistributedSystemService.java
deleted file mode 100644
index 8e79a3f..0000000
--- a/geode-wan/src/main/java/org/apache/geode/internal/WANDistributedSystemService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.geode.distributed.internal.DistributedSystemService;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-
-public class WANDistributedSystemService implements DistributedSystemService {
- @Override
- public void init(InternalDistributedSystem internalDistributedSystem) {
-
- }
-
- @Override
- public Class getInterface() {
- return getClass();
- }
-
- @Override
- public Collection<String> getSerializationAcceptlist() throws IOException {
- URL sanctionedSerializables = ClassPathLoader.getLatest().getResource(getClass(),
- "sanctioned-geode-wan-serializables.txt");
- return InternalDataSerializer.loadClassNames(sanctionedSerializables);
- }
-}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-wan/src/main/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesService.java
index 66d3a15..0c92c02 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.internal.cache.wan;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class WANSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-wan-serializables.txt");
}
}
diff --git a/geode-wan/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService b/geode-wan/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
deleted file mode 100644
index f62960b..0000000
--- a/geode-wan/src/main/resources/META-INF/services/org.apache.geode.distributed.internal.DistributedSystemService
+++ /dev/null
@@ -1,15 +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.
-org.apache.geode.internal.WANDistributedSystemService
diff --git a/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..c6090ca
--- /dev/null
+++ b/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.internal.cache.wan.WANSanctionedSerializablesService
diff --git a/geode-wan/src/main/resources/org/apache/geode/internal/sanctioned-geode-wan-serializables.txt b/geode-wan/src/main/resources/org/apache/geode/internal/cache/wan/sanctioned-geode-wan-serializables.txt
similarity index 100%
rename from geode-wan/src/main/resources/org/apache/geode/internal/sanctioned-geode-wan-serializables.txt
rename to geode-wan/src/main/resources/org/apache/geode/internal/cache/wan/sanctioned-geode-wan-serializables.txt
diff --git a/geode-web-api/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWebApiSerializablesJUnitTest.java b/geode-web-api/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWebApiSerializablesIntegrationTest.java
similarity index 71%
rename from geode-web-api/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWebApiSerializablesJUnitTest.java
rename to geode-web-api/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWebApiSerializablesIntegrationTest.java
index be4220b..828dba6 100644
--- a/geode-web-api/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWebApiSerializablesJUnitTest.java
+++ b/geode-web-api/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWebApiSerializablesIntegrationTest.java
@@ -16,13 +16,20 @@
import org.junit.experimental.categories.Category;
+import org.apache.geode.rest.internal.WebApiSanctionedSerializablesService;
import org.apache.geode.test.junit.categories.RestAPITest;
+import org.apache.geode.test.junit.categories.SerializationTest;
-@Category({RestAPITest.class})
-public class AnalyzeWebApiSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+@Category({RestAPITest.class, SerializationTest.class})
+public class AnalyzeWebApiSerializablesIntegrationTest extends AnalyzeSerializablesJUnitTestBase {
@Override
protected String getModuleName() {
return "geode-web-api";
}
+
+ @Override
+ protected Class<?> getModuleClass() {
+ return WebApiSanctionedSerializablesService.class;
+ }
}
diff --git a/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java b/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java
new file mode 100644
index 0000000..8408c24
--- /dev/null
+++ b/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.rest.internal;
+
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
+import org.apache.geode.test.junit.categories.SanctionedSerializablesTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+
+@Category({SerializationTest.class, SanctionedSerializablesTest.class})
+public class WebApiSanctionedSerializablesServiceIntegrationTest
+ extends SanctionedSerializablesServiceIntegrationTestBase {
+
+ private final SanctionedSerializablesService service = new WebApiSanctionedSerializablesService();
+
+ @Override
+ public SanctionedSerializablesService getService() {
+ return service;
+ }
+
+ @Override
+ protected ServiceResourceExpectation getServiceResourceExpectation() {
+ return ServiceResourceExpectation.EMPTY;
+ }
+}
diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java
similarity index 68%
copy from geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
copy to geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java
index 66d3a15..846a02e 100644
--- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java
@@ -12,18 +12,16 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.codeAnalysis;
+package org.apache.geode.rest.internal;
-import org.junit.experimental.categories.Category;
+import java.net.URL;
-import org.apache.geode.test.junit.categories.WanTest;
+import org.apache.geode.internal.serialization.SanctionedSerializablesService;
-
-@Category({WanTest.class})
-public class AnalyzeWANSerializablesJUnitTest extends AnalyzeSerializablesJUnitTestBase {
+public class WebApiSanctionedSerializablesService implements SanctionedSerializablesService {
@Override
- protected String getModuleName() {
- return "geode-wan";
+ public URL getSanctionedSerializablesURL() {
+ return getClass().getResource("sanctioned-geode-web-api-serializables.txt");
}
}
diff --git a/geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
new file mode 100644
index 0000000..024fc27
--- /dev/null
+++ b/geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService
@@ -0,0 +1,15 @@
+#
+# 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.
+#
+org.apache.geode.rest.internal.WebApiSanctionedSerializablesService
diff --git a/geode-wan/src/main/resources/org/apache/geode/internal/sanctioned-geode-wan-serializables.txt b/geode-web-api/src/main/resources/org/apache/geode/rest/internal/sanctioned-geode-web-api-serializables.txt
old mode 100755
new mode 100644
similarity index 100%
copy from geode-wan/src/main/resources/org/apache/geode/internal/sanctioned-geode-wan-serializables.txt
copy to geode-web-api/src/main/resources/org/apache/geode/rest/internal/sanctioned-geode-web-api-serializables.txt
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java
index 2c48983..81171d3 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java
@@ -12,14 +12,31 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.management.internal.cli.commands;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
+
+import java.util.Properties;
+
import org.apache.geode.test.junit.rules.GfshCommandRule;
public class QueryCommandOverHttpDUnitTest extends QueryCommandDUnitTestBase {
+
@Override
- public void connectToLocator() throws Exception {
+ protected Properties locatorProperties(Properties configProperties) {
+ int[] ports = getRandomAvailableTCPPorts(2);
+ int httpPort = ports[0];
+ int jmxPort = ports[1];
+
+ configProperties.setProperty(HTTP_SERVICE_PORT, String.valueOf(httpPort));
+ configProperties.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort));
+ return configProperties;
+ }
+
+ @Override
+ protected void connectToLocator() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), GfshCommandRule.PortType.http);
}
}