org.apache.log4j.util

## Class SerializationTestHelper

- java.lang.Object
- - org.apache.log4j.util.SerializationTestHelper

-     public class SerializationTestHelper
      extends Object

  Utiities for serialization tests.
  Author:
    Curt Arnold

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `assertSerializationEquals(String witness, Object obj, int[] skip, int endCompare)` Checks the serialization of an object against an file containing the expected serialization.
    `static void` | `assertStreamEquals(String witness, byte[] actual, int[] skip, int endCompare)` Asserts the serialized form of an object.
    `static Object` | `deserializeStream(String witness)` Deserializes a specified file.
    `static Object` | `serializeClone(Object obj)` Creates a clone by serializing object and deserializing byte stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### serializeClone

          public static Object serializeClone(Object obj)
                                       throws IOException,
                                              ClassNotFoundException

      Creates a clone by serializing object and deserializing byte stream.
      Parameters:
        `obj` - object to serialize and deserialize.
      Returns:
        clone
      Throws:
        `IOException` - on IO error.
        `ClassNotFoundException` - if class not found.

    - #### deserializeStream

          public static Object deserializeStream(String witness)
                                          throws Exception

      Deserializes a specified file.
      Parameters:
        `witness` - serialization file, may not be null.
      Returns:
        deserialized object.
      Throws:
        `Exception` - thrown on IO or deserialization exception.

    - #### assertSerializationEquals

          public static void assertSerializationEquals(String witness,
                                       Object obj,
                                       int[] skip,
                                       int endCompare)
                                                throws Exception

      Checks the serialization of an object against an file containing the expected serialization.
      Parameters:
        `witness` - name of file containing expected serialization.
        `obj` - object to be serialized.
        `skip` - positions in serialized stream that should not be compared.
        `endCompare` - position to stop comparison.
      Throws:
        `Exception` - thrown on IO or serialization exception.

    - #### assertStreamEquals

          public static void assertStreamEquals(String witness,
                                byte[] actual,
                                int[] skip,
                                int endCompare)
                                         throws IOException

      Asserts the serialized form of an object.
      Parameters:
        `witness` - file name of expected serialization.
        `actual` - byte array of actual serialization.
        `skip` - positions to skip comparison.
        `endCompare` - position to stop comparison.
      Throws:
        `IOException` - thrown on IO or serialization exception.

Copyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0

Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.