T - type of the serializable classpublic static interface SerializabilityTester.SemanticCompatibilityVerifier<T extends Serializable>
| Modifier and Type | Method and Description |
|---|---|
void |
assertSemanticCompatibility(T original,
T replica)
Asserts semantic compatibility.
|
void assertSemanticCompatibility(T original, T replica)
Important points to consider:
original and replica are not necessarily equal.
original, the reference set in
replica won't be the same. Thus, unless the referenced object overrides
Object.equals(Object) and all the object's attributes are part of the
Object.equals(Object) method, the following instruction will be invalid:
Assert.assertEquals(original.getMyObject(), replica.getMyObject()); // InvalidCompare the reference's attributes instead:
Assert.assertEquals(original.getMyObject().getPrimitiveAttribute_1(), replica.getMyObject().getPrimitiveAttribute_1()); // Valid ... Assert.assertEquals(original.getMyObject().getPrimitiveAttribute_n(), replica.getMyObject().getPrimitiveAttribute_n()); // Valid Assert.assertEquals(original.getMyObject().getObjectAttribute_1().getPrimitiveAttribute_1, replica.getMyObject().getObjectAttribute_1().getPrimitiveAttribute_1()); // Valid ... Assert.assertEquals(original.getMyObject().getObjectAttribute_1().getPrimitiveAttribute_n, replica.getMyObject().getObjectAttribute_1().getPrimitiveAttribute_n()); // ValidObject value types usually override
Object.equals(Object) involving all attributes:
Assert.assertEquals(original.getMyObjectValueType(), replica.getMyObjectValueType()); // Valid
original - original objectreplica - original object's replica reconstructed using deserializationCopyright © 2015. All rights reserved.