| org.apache.harmony.testframework.serialization.SerializationTest
All known Subclasses: org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLExceptionTest, org.apache.harmony.security.tests.java.security.serialization.TimestampTest, org.apache.harmony.security.tests.java.security.serialization.InvalidParameterExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.CredentialExpiredExceptionTest, org.apache.harmony.security.tests.java.security.serialization.KeyExceptionTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertificateNotYetValidExceptionTest, org.apache.harmony.security.tests.java.security.serialization.NoSuchProviderExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.PasswordCallbackTest, org.apache.harmony.security.tests.java.security.cert.serialization.CRLExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.serialization.DestroyFailedExceptionTest, org.apache.harmony.crypto.tests.javax.crypto.serialization.IllegalBlockSizeExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.DelegationPermissionTest, org.apache.harmony.auth.tests.javax.security.sasl.serialization.RealmChoiceCallbackTest, org.apache.harmony.security.tests.java.security.serialization.SignatureExceptionTest, org.apache.harmony.security.tests.java.security.serialization.PrivilegedActionExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountExceptionTest, org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateEncodingExceptionTest, org.apache.harmony.security.tests.java.security.serialization.KeyManagementExceptionTest, org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateExceptionTest, org.apache.harmony.security.tests.java.security.serialization.BasicPermissionCollectionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountExpiredExceptionTest, org.apache.harmony.security.tests.java.security.serialization.AllPermissionTest, org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLSessionBindingEventTest, org.apache.harmony.security.tests.java.security.serialization.GuardedObjectTest, org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbDelegationPermissionCollectionTest, org.apache.harmony.security.tests.java.security.serialization.UnrecoverableEntryExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.LoginExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.ChoiceCallbackTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.TextInputCallbackTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertificateExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.ConfirmationCallbackTest, org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateExpiredExceptionTest, org.apache.harmony.security.tests.java.security.serialization.PermissionsTest, org.apache.harmony.security.tests.java.security.serialization.GeneralSecurityExceptionTest, org.apache.harmony.security.tests.java.security.serialization.CodeSignerTest, org.apache.harmony.auth.tests.javax.security.auth.serialization.SubjectTest, org.apache.harmony.security.tests.java.security.serialization.AccessControlExceptionTest, org.apache.harmony.xnet.tests.javax.net.ssl.serialization.HandshakeCompletedEventTest, org.apache.harmony.security.tests.java.security.serialization.SecurityPermissionTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertificateEncodingExceptionTest, org.apache.harmony.crypto.tests.javax.crypto.serialization.BadPaddingExceptionTest, org.apache.harmony.security.tests.java.security.serialization.KeyStoreExceptionTest, org.apache.harmony.security.tests.java.security.serialization.PermissionCollectionTest, org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateParsingExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.serialization.AuthPermissionTest, org.apache.harmony.auth.tests.javax.security.sasl.serialization.RealmCallbackTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertificateExpiredExceptionTest, org.apache.harmony.security.tests.java.security.serialization.BasicPermissionTest, org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbServicePermissionCollectionTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertPathBuilderExceptionTest, org.apache.harmony.auth.tests.javax.security.sasl.serialization.SaslExceptionTest, org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLPeerUnverifiedExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.FailedLoginExceptionTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertPathValidatorExceptionTest, org.apache.harmony.security.tests.java.security.serialization.DigestExceptionTest, org.apache.harmony.security.tests.java.security.spec.serialization.InvalidKeySpecExceptionTest, org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateNotYetValidExceptionTest, org.apache.harmony.security.tests.java.security.serialization.UnresolvedPermissionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.CredentialExceptionTest, org.apache.harmony.crypto.tests.javax.crypto.serialization.ExemptionMechanismExceptionTest, org.apache.harmony.security.tests.java.security.serialization.UnrecoverableKeyExceptionTest, org.apache.harmony.security.tests.java.security.serialization.UnresolvedPermissionCollectionTest, org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLProtocolExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.NameCallbackTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertificateParsingExceptionTest, org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLHandshakeExceptionTest, org.apache.harmony.security.tests.java.security.serialization.SignedObjectTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountLockedExceptionTest, org.apache.harmony.security.tests.java.security.cert.serialization.CertStoreExceptionTest, org.apache.harmony.security.tests.java.security.spec.serialization.InvalidParameterSpecExceptionTest, org.apache.harmony.crypto.tests.javax.crypto.serialization.ShortBufferExceptionTest, org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLKeyExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.ServicePermissionTest, org.apache.harmony.security.tests.java.security.serialization.AllPermissionCollectionTest, org.apache.harmony.auth.tests.javax.security.auth.serialization.PrivateCredentialPermissionTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.CredentialNotFoundExceptionTest, org.apache.harmony.security.tests.java.security.serialization.NoSuchAlgorithmExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.LanguageCallbackTest, org.apache.harmony.security.tests.java.security.serialization.InvalidAlgorithmParameterExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.TextOutputCallbackTest, org.apache.harmony.security.tests.java.security.serialization.PermissionTest, org.apache.harmony.auth.tests.javax.security.sasl.serialization.AuthorizeCallbackTest, org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountNotFoundExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.UnsupportedCallbackExceptionTest, org.apache.harmony.crypto.tests.javax.crypto.serialization.NoSuchPaddingExceptionTest, org.apache.harmony.security.tests.java.security.serialization.ProviderExceptionTest, org.apache.harmony.security.tests.java.security.serialization.CodeSourceTest, org.apache.harmony.auth.tests.javax.security.auth.x500.serialization.X500PrincipalTest, org.apache.harmony.auth.tests.javax.security.sasl.serialization.AuthenticationExceptionTest, org.apache.harmony.security.tests.java.security.serialization.InvalidKeyExceptionTest, org.apache.harmony.auth.tests.javax.security.auth.serialization.RefreshFailedExceptionTest,
SerializationTest | abstract public class SerializationTest extends TestCase (Code) | | Framework for serialization testing. Subclasses only need to override
getData() method and, optionally, assertDeserialized() method. The first one
returns array of objects to be de/serialized in tests, and the second
compares reference and deserialized objects (needed only if tested objects do
not provide specific method equals()).
There are two modes of test run: reference generation mode and
testing mode . The actual mode is selected via
"test.mode" system property. The testing mode is
the default mode.
To turn on the reference generation mode , the test.mode property
should be set to value "serial.reference". In this mode, no testing
is performed but golden files are produced, which contain reference
serialized objects. This mode should be run on a pure
Implementation classes, which are targeted for compartibility.
The location of golden files (in both modes) is controlled via
"RESOURCE_DIR" system property.
|
Inner Class :public interface SerializableAssert | |
Method Summary | |
public static Serializable | copySerializable(Serializable initial) Copies an object by serializing/deserializing it. | public static void | createGoldenFile(String root, TestCase test, Object object) Creates golden file. | public static SerializableAssert | defineComparator(TestCase test, Object object) Returns comparator for provided serializable
object . | abstract protected Object[] | getData() This is the main working method of this framework. | protected File | getDataFile(int index) Returns golden file for an object being tested. | public static Serializable | getObjectFromStream(InputStream is) Deserializes single object from an input stream. | protected void | produceGoldenFiles() Working method for files generation mode. | public static void | putObjectToStream(Object obj, OutputStream os) Serializes specified object to an output stream. | public void | runBare() Depending on testing mode, produces golden files or performs testing. | public void | testGolden() Tests that data objects can be deserialized from golden files, to verify
compartibility with Reference Implementation. | public void | testSelf() Tests that data objects can be serialized and deserialized without
exceptions, and that deserialization really produces deeply cloned
objects. | public static void | verifyGolden(TestCase test, Object object) Verifies that object deserialized from golden file correctly. | public static void | verifyGolden(TestCase test, Object object, SerializableAssert comparator) Verifies that object deserialized from golden file correctly. | public static void | verifyGolden(TestCase test, Object[] objects) Verifies that objects from array deserialized from golden files
correctly. | public static void | verifyGolden(TestCase test, Object[] objects, SerializableAssert comparator) Verifies that objects from array deserialized from golden files
correctly.
The method loads "testName .golden.N .ser"
resource files from "/src/test/resources/serialization/testPackage "
folder, from each loaded file it reads an object from and compares it
with corresponding object in provided array (i.e. | public static void | verifySelf(Object object) Verifies that object can be smoothly serialized/deserialized. | public static void | verifySelf(Object object, SerializableAssert comparator) Verifies that object can be smoothly serialized/deserialized. | public static void | verifySelf(Object[] objects) Verifies that that objects from array can be smoothly
serialized/deserialized. | public static void | verifySelf(Object[] objects, SerializableAssert comparator) Verifies that that objects from array can be smoothly
serialized/deserialized. |
GOLDEN_PATH | final public static String GOLDEN_PATH(Code) | | Key to a system property defining root location of golden files.
|
MODE_KEY | final public static String MODE_KEY(Code) | | Property name for the testing mode.
|
PERMISSION_COLLECTION_COMPARATOR | final public static SerializableAssert PERMISSION_COLLECTION_COMPARATOR(Code) | | Comparator for java.security.PermissionCollection objects
|
SAME_COMPARATOR | final public static SerializableAssert SAME_COMPARATOR(Code) | | Comparator for verifying that deserialized object is the same as initial.
|
SERIAL_REFERENCE_MODE | final public static String SERIAL_REFERENCE_MODE(Code) | | Reference files generation mode switch.
|
THROWABLE_COMPARATOR | final public static SerializableAssert THROWABLE_COMPARATOR(Code) | | Comparator for java.lang.Throwable objects
|
SerializationTest | public SerializationTest(String name)(Code) | | Parameterized c-tor inherited from superclass.
|
SerializationTest | public SerializationTest()(Code) | | Default c-tor inherited from superclass.
|
createGoldenFile | public static void createGoldenFile(String root, TestCase test, Object object) throws IOException(Code) | | Creates golden file.
The folder for created file is: root + test's package name .
The file name is: test's name + "golden.ser"
Parameters: root - -root directory for serialization resource files Parameters: test - -test case Parameters: object - -object to be serialized throws: IOException - -if I/O error |
defineComparator | public static SerializableAssert defineComparator(TestCase test, Object object) throws Exception(Code) | | Returns comparator for provided serializable
object .
The comparator is searched in the following order: -
if test implements SerializableAssert interface then it is
selected as comparator. - if passed object
has class in its classes hierarchy that overrides equals(Object)
method then DEFAULT_COMPARATOR is selected. - the
method tries to select one of known comparators basing on object's
class,for example, if passed object is instance of
java.lang.Throwable then THROWABLE_COMPARATOR is used. -
otherwise RuntimeException is thrown
Parameters: test - -test case Parameters: object - -object to be compared object's comparator |
getData | abstract protected Object[] getData()(Code) | | This is the main working method of this framework. Subclasses must
override it to provide actual objects for testing.
array of objects to be de/serialized in tests. |
getDataFile | protected File getDataFile(int index)(Code) | | Returns golden file for an object being tested.
Parameters: index - array index of tested data (as returned bySerializationTest.getData() getData()) corresponding golden file |
runBare | public void runBare() throws Throwable(Code) | | Depending on testing mode, produces golden files or performs testing.
|
testGolden | public void testGolden() throws Throwable(Code) | | Tests that data objects can be deserialized from golden files, to verify
compartibility with Reference Implementation.
|
testSelf | public void testSelf() throws Throwable(Code) | | Tests that data objects can be serialized and deserialized without
exceptions, and that deserialization really produces deeply cloned
objects.
|
verifyGolden | public static void verifyGolden(TestCase test, Object object) throws Exception(Code) | | Verifies that object deserialized from golden file correctly.
The method invokes
verifyGolden(test, object, defineComparator(test, object));
Parameters: test - -test case Parameters: object - -to be compared |
verifyGolden | public static void verifyGolden(TestCase test, Object object, SerializableAssert comparator) throws Exception(Code) | | Verifies that object deserialized from golden file correctly.
The method loads "testName .golden.ser" resource file
from "/src/test/resources/serialization/testPackage "
folder, reads an object from the loaded file and compares it with
object using specified comparator .
test-test case object-to be compared Parameters: comparator - -for comparing (de)serialized objects |
verifyGolden | public static void verifyGolden(TestCase test, Object[] objects) throws Exception(Code) | | Verifies that objects from array deserialized from golden files
correctly.
The method invokes
verifyGolden(test, objects, defineComparator(test, object[0]));
Parameters: test - -test case Parameters: objects - -array of objects to be compared |
verifyGolden | public static void verifyGolden(TestCase test, Object[] objects, SerializableAssert comparator) throws Exception(Code) | | Verifies that objects from array deserialized from golden files
correctly.
The method loads "testName .golden.N .ser"
resource files from "/src/test/resources/serialization/testPackage "
folder, from each loaded file it reads an object from and compares it
with corresponding object in provided array (i.e. objects[N] )
using specified comparator . (N is index
in object's array.)
test-test case Parameters: objects - -array of objects to be compared Parameters: comparator - -for comparing (de)serialized objects |
verifySelf | public static void verifySelf(Object object) throws Exception(Code) | | Verifies that object can be smoothly serialized/deserialized.
The method invokes
verifySelf(object, defineComparator(null, object));
Parameters: object - -to be serialized/deserialized |
verifySelf | public static void verifySelf(Object object, SerializableAssert comparator) throws Exception(Code) | | Verifies that object can be smoothly serialized/deserialized.
The method serialize/deserialize object and compare it
with initial object .
Parameters: object - -object to be serialized/deserialized Parameters: comparator - -for comparing serialized/deserialized object with initialobject |
verifySelf | public static void verifySelf(Object[] objects) throws Exception(Code) | | Verifies that that objects from array can be smoothly
serialized/deserialized.
The method invokes
verifySelf(objects, defineComparator(null, object[0]));
Parameters: objects - -array of objects to be serialized/deserialized |
verifySelf | public static void verifySelf(Object[] objects, SerializableAssert comparator) throws Exception(Code) | | Verifies that that objects from array can be smoothly
serialized/deserialized.
The method serialize/deserialize each object in objects
array and compare it with initial object.
Parameters: objects - -array of objects to be serialized/deserialized Parameters: comparator - -for comparing serialized/deserialized object with initialobject |
|
|