@Override public boolean toData(Object o, PdxWriter out) { if (o instanceof MyObjectPdx2) { MyObjectPdx2 obj = (MyObjectPdx2) o; out.writeLong("f1", obj.f1); out.writeString("f2", obj.f2); return true; } return auto.toData(o, out); }
public void testAllWithNullsWF() throws IOException, ClassNotFoundException { AllFieldTypesWF v1 = new AllFieldTypesWF(0x102030405060708L, true); AllFieldTypesWF v2 = (AllFieldTypesWF) serializeAndDeserialize(v1); assertEquals(v1, v2); }
public void toData(PdxWriter out) { out.writeBoolean("field1", false); out.writeInt("field2", 53); out.writeObject("field3", new TestPdx() { public void toData(PdxWriter writer) { writer.writeString("afield", "hello"); } }); } });
public void testHashCodeAndEqualsSameType() throws IOException, ClassNotFoundException { PdxInstance instance = getAllFields(0); assertEquals(instance, getAllFields(0)); assertEquals(instance.hashCode(), getAllFields(0).hashCode()); for(int i =1; i < allFieldCount + 1; i++) { PdxInstance other = getAllFields(i); assertFalse("One field " + i + " hashcode have been unequal but were equal" + instance.getField("field" + (i-1)) +", " + other.getField("field" + (i-1)) + ", " + instance + ", " + other, instance.equals(other)); //Technically, this could be true. If this asserts fails I guess we can just change the test. assertFalse("One field " + i + " hashcode have been unequal but were equal" + instance +", " + other, instance.hashCode() == other.hashCode()); } }
private PdxInstance checkPdxInstance(PdxInstance pi) throws IOException, ClassNotFoundException { // serialize the pi and make sure it can be deserialized PdxInstance pi2 = (PdxInstance) serializeAndDeserialize(pi); assertEquals(pi, pi2); assertEquals(pi.hashCode(), pi2.hashCode()); assertEquals(pi.getFieldNames(), pi2.getFieldNames()); return pi2; }
private void setupSerializer(boolean checkPortability, String... classPatterns) { setupSerializer(new ReflectionBasedAutoSerializer(checkPortability, classPatterns), true); } private void setupSerializer(boolean checkPortability, boolean readSerialized, String... classPatterns) {
public void testLong() throws IOException, ClassNotFoundException { LongHolder v = (LongHolder) serializeAndDeserialize(new LongHolder(0x69)); assertEquals(0x69, v.getLong()); } // this method adds coverage for bug 43236
public void testLongField() throws IOException, ClassNotFoundException { LongFieldHolder v = (LongFieldHolder) serializeAndDeserialize(new LongFieldHolder( 0x1020304050607080L)); assertEquals(0x1020304050607080L, v.getLong()); }
public void testHashCodeEqualsOutOfOrderFields() throws IOException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { PdxSerializable serializable1 = getSeparateClassLoadedPdx(true); PdxInstance instance1 = getPdx(serializable1); PdxSerializable serializable2 = getSeparateClassLoadedPdx(false); PdxInstance instance2 = getPdx(serializable2); assertEquals(instance1, instance2); assertEquals(instance1.hashCode(), instance2.hashCode()); }
public void testPdxSerializerFalse() throws IOException, ClassNotFoundException { this.c.setPdxSerializer(new BasicAllFieldTypesPdxSerializer()); try { POS v1 = new POS(3); POS v2 = (POS) serializeAndDeserialize(v1); assertEquals(v1, v2); } finally { this.c.setPdxSerializer(null); } }
public Object call() throws Exception { Region r = getRootRegion("testSimplePdx"); r.put(1, new SimpleClass(57, (byte) 3)); r.put(2, new SimpleClass2(57, (byte) 3)); return null; } });
public void testAll() throws IOException, ClassNotFoundException { AllFieldTypes v1 = new AllFieldTypes(0x1020304050607080L, false); AllFieldTypes v2 = (AllFieldTypes) serializeAndDeserialize(v1); assertEquals(v1, v2); }
public void testExtensibility() throws Exception { setupSerializer(new BigIntegerAutoSerializer(true, "com.gemstone.gemfire.pdx.AutoSerializableJUnitTest.BigHolder"), false); doExtensible("with autoSerializer handling Big*"); } public void testNoExtensibility() throws Exception {
public void testAllRF() throws IOException, ClassNotFoundException { AllFieldTypesRF v1 = new AllFieldTypesRF(0x1020304050607080L, false); AllFieldTypesRF v2 = (AllFieldTypesRF) serializeAndDeserialize(v1); assertEquals(v1, v2); }
public void testCHM() throws Exception { setupSerializer(new ConcurrentHashMapAutoSerializer(false, "com.gemstone.gemfire.pdx.AutoSerializableJUnitTest.*Holder"), false); doCHM("with autoSerializer handling ConcurrentHashMap"); } public void testNoCHM() throws Exception {
public void toData(PdxWriter writer) { if (getVersion() == 3) { writer.writeInt("f2", this.f2); } writer.writeInt("f1", this.f1); if (getVersion() == 2) { writer.writeInt("f2", this.f2); } }
public void fromData(PdxReader reader) { if (getVersion() == 3) { this.f2 = reader.readInt("f2"); } this.f1 = reader.readInt("f1"); if (getVersion() == 2) { this.f2 = reader.readInt("f2"); } } }
private void setupSerializer(String... classPatterns) { setupSerializer(new ReflectionBasedAutoSerializer(classPatterns), true); } private void setupSerializer(boolean checkPortability, String... classPatterns) {
public void testAllWF() throws IOException, ClassNotFoundException { AllFieldTypesWF v1 = new AllFieldTypesWF(0x1020304050607080L, false); AllFieldTypesWF v2 = (AllFieldTypesWF) serializeAndDeserialize(v1); assertEquals(v1, v2); }
public void testAllWithNulls() throws IOException, ClassNotFoundException { AllFieldTypes v1 = new AllFieldTypes(0x102030405060708L, true); AllFieldTypes v2 = (AllFieldTypes) serializeAndDeserialize(v1); assertEquals(v1, v2); }