Apache Harmony is retired at the Apache Software Foundation since Nov 16, 2011.

The information on these pages may be out of date, or may refer to resources that have moved or have been made read-only.
For more information please refer to the Apache Attic

Framework for Testing Serialization

The framework for testing serialization is currently PROPOSED and being discussed on the development mailing list dev@harmony.apache.org. Please direct comments and questions there.

The framework for testing serialization is intended to simplify and formalize development of serialization tests. This document contains guidelines for creating tests and conventions for resource files.

Guidelines for Developing Serialization Tests

The testing framework provides the support class org.apache.harmony.testframework.serialization.SerializationTest for serialization testing.

Compatibility Testing

Verifies that an object serialized on certified implementation is correctly deserialized on Harmony implementation.
The support class provides four methods for compatibility testing:

The first parameter TestCase is used to locate resource file(s) that contains serialized object(s).
The second parameter is an object or an array of objects to be compared with object(s) deserialized from resource file(s).
The third parameter is optional.

To create a compatibility test for selected class, a developer should:

Example

public void testSerializationCompatibility()
throws Exception {
SerializationTest.verifyGolden(this, new SomeSerializableClass());
}

Self-Testing

Verifies that an object can be smoothly serialized and deserialized on Harmony implementation.
The support class provides four methods for self-testing:

The provided object(s) is(are) serialized/deserialized and compared with initial object(s).

To create a self test for a selected class, a developer should:

Example

public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new SomeSerializableClass(),
new MyComparator());
}

Negative Testing

TBD

Interface SerializableAssert

If a class of object(s) to be compared does not have equals(Object) method or the testing framework can not find appropriate comparator, a test has to implement the interface. The interface has only one method to be implemented:

void assertDeserialized(Serializable reference, Serializable test);

Placement and Naming Conventions for Resource Files

The resource files should follow the next conventions:

Back to top