org.apache.commons.id.test
Class AssertSerialization

java.lang.Object
  extended by org.apache.commons.id.test.AssertSerialization

public class AssertSerialization
extends java.lang.Object

Assert class for serialization operations.

Note: This class is intented to be moved to a commons-test component later.

Since:
1.0
Author:
Jörg Schaible

Nested Class Summary
static interface AssertSerialization.Context
          Interface for the serialization test context.
protected static class AssertSerialization.SerializationTest
          A test case used to test the serialization capability and the compatibility with previous versions of the type.
 
Constructor Summary
AssertSerialization()
           
 
Method Summary
static java.io.Serializable assertSerializable(java.io.Serializable serializable)
          Assert an object to be Serializable.
static java.io.Serializable assertSerializable(java.io.Serializable serializable, java.lang.Class expectedType)
          Assert an object to be Serializable.
static java.io.Serializable assertSerializable(java.lang.String message, java.io.Serializable serializable)
          Assert an object to be Serializable.
static java.io.Serializable assertSerializable(java.lang.String message, java.io.Serializable serializable, java.lang.Class expectedType)
          Assert an object to be Serializable.
static junit.framework.TestSuite createSerializationTestSuite(AssertSerialization.Context context)
          Create a TestSuite for the serializability of a type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssertSerialization

public AssertSerialization()
Method Detail

assertSerializable

public static java.io.Serializable assertSerializable(java.io.Serializable serializable)
Assert an object to be Serializable.

Parameters:
serializable - object to serialize
Returns:
the serialized object
Since:
1.0

assertSerializable

public static java.io.Serializable assertSerializable(java.lang.String message,
                                                      java.io.Serializable serializable)
Assert an object to be Serializable.

Parameters:
message - the error message
serializable - object to serialize
Returns:
the serialized object
Since:
1.0

assertSerializable

public static java.io.Serializable assertSerializable(java.io.Serializable serializable,
                                                      java.lang.Class expectedType)
Assert an object to be Serializable.

Parameters:
serializable - object to serialize
expectedType - the expected type of the result
Returns:
the serialized object
Since:
1.0

assertSerializable

public static java.io.Serializable assertSerializable(java.lang.String message,
                                                      java.io.Serializable serializable,
                                                      java.lang.Class expectedType)
Assert an object to be Serializable.

Parameters:
message - the error message
serializable - object to serialize
expectedType - the expected type of the result
Returns:
the serialized object
Since:
1.0

createSerializationTestSuite

public static junit.framework.TestSuite createSerializationTestSuite(AssertSerialization.Context context)
Create a TestSuite for the serializability of a type. A caller must provide a proper AssertSerialization.Context, that enables the suite to test the serializability of the provided type and ensures backward compatibility for older versions of the type. For each type version a file is provided with the serialVersionUID as filename in a directory named like the type to test. If no reference file is stored in the reference DB, the test fails, but the file is created automatically, so the next run will succeed.

Parameters:
context - the test Context
Returns:
the TestSuite with the tests
Since:
1.0


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.