You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2017/08/25 17:08:06 UTC
[3/3] geode git commit: GEODE-3503: Removal of Codec classes left
behind. This closes #737 Added tests to test the remaining JSONCodec.
GEODE-3503: Removal of Codec classes left behind. This closes #737
Added tests to test the remaining JSONCodec.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d775dfb3
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d775dfb3
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d775dfb3
Branch: refs/heads/develop
Commit: d775dfb3b68e1f800bcfe7f92af048b26a1fb1a5
Parents: cbe51bd
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Aug 25 09:58:46 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Aug 25 10:07:34 2017 -0700
----------------------------------------------------------------------
.../geode/serialization/SerializationType.java | 11 +------
.../RoundTripCacheConnectionJUnitTest.java | 11 ++-----
.../serialization/codec/JSONCodecJUnitTest.java | 31 +++++++++++---------
3 files changed, 21 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/d775dfb3/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
index 10a3e51..01ef048 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
@@ -22,16 +22,7 @@ import org.apache.geode.pdx.PdxInstance;
*/
@Experimental
public enum SerializationType {
- STRING(String.class),
- BINARY(byte[].class),
- INT(int.class),
- BYTE(byte.class),
- SHORT(short.class),
- LONG(long.class),
- JSON(PdxInstance.class),
- BOOLEAN(boolean.class),
- FLOAT(float.class),
- DOUBLE(double.class);
+ JSON(PdxInstance.class);
public final Class klass;
http://git-wip-us.apache.org/repos/asf/geode/blob/d775dfb3/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
index 91e839c..b80e90e 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
@@ -122,14 +122,9 @@ public class RoundTripCacheConnectionJUnitTest {
}
CacheFactory cacheFactory = new CacheFactory(properties);
- cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0"); // sometimes it isn't due to other
- // tests.
- cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false"); // sometimes it
- // isn't due to
- // other tests.
- cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false"); // sometimes it
- // isn't due to
- // other tests.
+ cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0");
+ cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
+ cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false");
cache = cacheFactory.create();
CacheServer cacheServer = cache.addCacheServer();
http://git-wip-us.apache.org/repos/asf/geode/blob/d775dfb3/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
index ffdd744..bb7169e 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
@@ -101,26 +101,29 @@ public class JSONCodecJUnitTest {
PdxInstance pdxInstanceForComplexJSONString = createPDXInstanceForComplexJSONString();
PdxInstance decodedJSONPdxInstance = new JSONCodec().decode(complexJSONString.getBytes());
- assertEquals(pdxInstanceForComplexJSONString.getFieldNames(),
- decodedJSONPdxInstance.getFieldNames());
+ pdxInstanceEquals(pdxInstanceForComplexJSONString, decodedJSONPdxInstance);
+ }
- List<String> fieldNames = asList("_id", "index", "guid", "isActive", "balance", "picture",
- "age", "eyeColor", "name", "gender", "company", "email", "phone", "address", "about",
- "registered", "latitude", "longitude", "tags", "friends", "greeting", "favoriteFruit");
- fieldNames.forEach(
- fieldName -> assertEquals(pdxInstanceForComplexJSONString.getField(fieldName).getClass(),
- decodedJSONPdxInstance.getField(fieldName).getClass()));
+ private void pdxInstanceEquals(PdxInstance expectedPdxInstance,
+ PdxInstance decodedJSONPdxInstance) {
+ List<String> expectedFieldNames = expectedPdxInstance.getFieldNames();
+
+ assertEquals(expectedFieldNames, decodedJSONPdxInstance.getFieldNames());
- fieldNames.forEach(
- fieldName -> assertEquals(pdxFieldValues(pdxInstanceForComplexJSONString, fieldName),
- pdxFieldValues(decodedJSONPdxInstance, fieldName)));
+ expectedFieldNames.forEach(
+ fieldName -> {
+ assertEquals(expectedPdxInstance.getField(fieldName).getClass(),
+ decodedJSONPdxInstance.getField(fieldName).getClass());
+ assertEquals(pdxFieldValues(expectedPdxInstance, fieldName),
+ pdxFieldValues(decodedJSONPdxInstance, fieldName));
+ });
}
/**
- * This method is very specific to this test. It will take an pdxInstance object and return you
+ * This method is very specific to this test. It will take a pdxInstance object and return you
* the value for the fieldName. In most cases it will return the value directly, but in the case
- * of collections LinkedList<String> it will return an ArrayList<String> or in the case of a
- * LinkedList<PdxInstance> it will return an ArrayList<ArrayList>.
+ * of collections LinkedList<String> it will return an ArrayList<String> or in the case of a
+ * LinkedList<PdxInstance> it will return an ArrayList<ArrayList<String>>.
*/
private Object pdxFieldValues(PdxInstance pdxInstance, String fieldName) {
Object fieldValue = pdxInstance.getField(fieldName);