JUnit-addons
version 1.4

junitx.extensions
Class SerializabilityTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--junitx.extensions.SerializabilityTestCase
All Implemented Interfaces:
junit.framework.Test

public abstract class SerializabilityTestCase
extends junit.framework.TestCase

Extend me in order to test the serializability of a class. Override my createInstance methods to provide me with an object to test against. The object's class must implement Serializable.

Version:
$Revision: 1.2 $ $Date: 2003/02/06 20:43:52 $
Author:
Paul Holser
See Also:
Serializable

Constructor Summary
SerializabilityTestCase(java.lang.String name)
          Creates a new test.
 
Method Summary
protected  void checkThawedObject(java.io.Serializable expected, java.io.Serializable actual)
          Template method--override this to perform checks on the deserialized form of the object serialized in testSerializability().
protected abstract  java.io.Serializable createInstance()
          Creates and returns an instance of the class under test.
protected  void setUp()
          Sets up the test fixture.
 void testSerializability()
          Verifies that an instance of the class under test can be serialized and deserialized without error.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SerializabilityTestCase

public SerializabilityTestCase(java.lang.String name)
Creates a new test.

Parameters:
name - name of the test
Method Detail

createInstance

protected abstract java.io.Serializable createInstance()
                                                throws java.lang.Exception
Creates and returns an instance of the class under test.

Returns:
a new instance of the class under test
Throws:
java.lang.Exception

setUp

protected void setUp()
              throws java.lang.Exception
Sets up the test fixture.

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testSerializability

public final void testSerializability()
                               throws java.lang.Exception
Verifies that an instance of the class under test can be serialized and deserialized without error.

java.lang.Exception

checkThawedObject

protected void checkThawedObject(java.io.Serializable expected,
                                 java.io.Serializable actual)
                          throws java.lang.Exception
Template method--override this to perform checks on the deserialized form of the object serialized in testSerializability(). If not overridden, this asserts that the pre-serialization and deserialized forms of the object compare equal via equals.

Parameters:
expected - the pre-serialization form of the object
actual - the deserialized form of the object
java.lang.Exception

JUnit-addons
version 1.4

Copyright © 2002-2003 Vladimir R. Bossicard. All Rights Reserved.