|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.hd.d.pg2k.test.dev.SerializationTest
public final class SerializationTest
Test that critical classes can be correctly serialised and deserialised. This is useful for items that will be:
| Field Summary | |
|---|---|
private static int |
evv_TOTAL_EVENT_COUNT
Total event count in map. |
private static java.lang.String |
evvTestString1
First test string value for EVV; has a count of 1. |
private static java.lang.String |
evvTestString2
Second test string value for EVV; has a count of 2. |
private static java.lang.String |
hillsAreAlive
Raw value of String variable value for "hills are alive" value. |
private static int |
MAX_BYTES_PER_LINE
Maximum bytes to print on each line of serialised form. |
private static boolean |
PRINT_SER_BYTES
If true, print out serialised value in form that can be cut-n-paste back into test code. |
private static java.util.Random |
rnd
Private source of OK pseudo-random numbers. |
private static java.lang.String |
ROBA_compS1
Value to check compression is working and can be correctly undone even on non-ASCII/non-8-bit text. |
private static byte[] |
serData_AllExhibitPropertiesDelta_empty
Empty AEP delta instance. |
private static byte[] |
serData_C7BS_20060803
Forced serialised form to check deserialisation is not broken. |
private static byte[] |
serData_C7BS_20060804
Forced serialised form after allowing for partial token (prefix) matching. |
private static byte[] |
serData_CS8Bit
Serialised CS8 form. |
private static byte[] |
serData_efn1_20090711
Serialisation of ExhibitFullName("a/a-A.a"). |
private static byte[] |
serData_efnpair_20090711
Frozen pair of long values with common prefix and suffix. |
private static byte[] |
serData_esa1a_20090711
Original String field format serialisation of ExhibitStaticAttr("a/a-A.a", 1, CoreConsts.GALLERY_EPOC_START). |
private static byte[] |
serData_esa1b_20090711
CharSequence field format serialisation of ExhibitStaticAttr("a/a-A.a", 1, CoreConsts.GALLERY_EPOC_START) with run-time String field type. |
private static byte[] |
serData_esa1c_20090711
CharSequence field format serialisation of ExhibitStaticAttr("a/a-A.a", 1, CoreConsts.GALLERY_EPOC_START) with run-time Name.ExhibitFull field type. |
private static byte[] |
serData_evv1_20050130_1748
Old serialised format of a single EVV with embedded Map<Object, ValueInfo>. |
private static byte[] |
serData_evv1_20050131_1512
New (more compact) serialised format of a single EVV with counts[]/values[]. |
private static byte[] |
serData_evv1_20090806
Newer serialised format (with Name in place of String on the wire) of a single EVV with counts[]/values[]. |
private static byte[] |
serData_hillsAreAlive_20050130
Serialised String variable value for "hills are alive" value. |
private static byte[] |
serData_pdS16_20090714
Old-style String keys and values PropertiesDiff value. |
private static byte[] |
serData_pdvar_20090714
New-style String keys and values PropertiesDiff value. |
private static byte[] |
serData_ROBA_compS1_20050522
On-the-wire format on ROBA_compS1. |
private static byte[] |
serData_ROByteArray_EMPTY_20050522
Empty ROByteArray (ie wrapping a byte[0]). |
private static byte[] |
serData_Thumbnail_20060704
On-the-wire format of Thumbnail. |
private static java.lang.String[] |
TEST_C7BS_DATA
Sample input String values for Compact7BitString tests. |
private static java.lang.String |
THE_HILLS_ARE_ALIVE
Test text for CS8 (de)serialisation. |
| Constructor Summary | |
|---|---|
SerializationTest(java.lang.String name)
|
|
| Method Summary | |
|---|---|
static void |
checkEmptyInstancesAreZeroAndEqualAndSerializable(java.lang.Class<? extends java.io.Serializable> c)
Basic tests for those objects whose empty instances should have zero hash and compare equal. |
static java.lang.Object |
checkObjectCanBeSerialisedAndDeserialised(java.lang.Object obj)
Check that the object passed can be serialised and deserialised. |
static java.lang.Object |
checkSerialisationPreservesEquality(java.lang.Object obj)
Check that the passed (non-null) object compares equals after being serialised/deserialised. |
(package private) static java.lang.Object |
deserialiseFromByteArray(byte[] data)
Deserialise an Object from the supplied serialised form. |
private static void |
dumpAsciiComment(java.lang.StringBuilder sbTmp,
int count,
byte[] values)
Dump to System.out "count" characters from values, substituting non-printable-ASCII. |
private static void |
dumpSerData(java.lang.Object obj,
byte[] data)
Dump serialised data in a form suitable to copy-and-paste into code. |
static byte[] |
serialiseToByteArray(java.lang.Object obj)
Serialise given object to byte array; never null. |
static void |
testAccessionDataSer()
Tests of accessions of serialisation of AccessionData. |
static void |
testAEPSerialisationSize()
Check that the current AEP serialisation is not less compact (when compressed) than the last one persisted. |
static void |
testAllExhibitImmutableData()
Test AllExhibitImmutableData for (de)serialisability. |
static void |
testAllExhibitProperties()
Test AllExhibitProperties for (de)serialisability. |
static void |
testCompact7BitString()
Test of serialisation and other behaviour of Compact7BitString. |
static void |
testCompressors()
Test correctness of some of our (de)compressors often used with serialisation. |
static void |
testCS8Bit()
Test behaviour of PropertiesBundleDiff object. |
static void |
testDecompDeserRobustness()
Test the robustness of our decompression routines in conjunction with deserialization. |
static void |
testEPGIBasic()
Basic serialisation tests of EPGI and its diff. |
static void |
testESABasic()
Basic serialisation tests of ExhibitStaticAttrs. |
static void |
testEventVariableValues()
Test that we can succesfully create and (de)serialise event container objects... |
static void |
testExhibitFullNameBasic()
Basic serialisation tests of ExhibitFullName. |
static void |
testExhibitPropsLoadable()
Basic tests on ExhibitPropsLoadable. |
static void |
testExhibitThumbnails()
Test ExhibitThumbnails. |
static void |
testGenProps()
Test GenProps for (de)serialisability. |
static void |
testLocation()
Test Location data (esp Estd) can be (de)serialised. |
static void |
testLocationMap()
Test (de)serialisation of LocationMap. |
static void |
testPropertiesBundleDiff()
Test behaviour of PropertiesBundleDiff object. |
static void |
testPropertiesDiff()
Test behaviour of PropertiesDiff object. |
static void |
testROByteArray()
Test handling of ROByteArray. |
static void |
testSerAllExhibitPropertiesDelta()
Simple AllExhibitPropertiesDelta (de)serialisation tests. |
static void |
testSimpleVariables()
Test that variables can be correctly serialised/deserialised. |
static void |
testThumbnailSer()
Test that we can (de)serialise Thumbnail data OK. |
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString |
| Methods inherited from class junit.framework.Assert |
|---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, 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 |
| Field Detail |
|---|
private static final boolean PRINT_SER_BYTES
private static final int MAX_BYTES_PER_LINE
private static final java.lang.String hillsAreAlive
private static final byte[] serData_hillsAreAlive_20050130
private static final java.lang.String evvTestString1
private static final java.lang.String evvTestString2
private static final int evv_TOTAL_EVENT_COUNT
private static final byte[] serData_evv1_20050130_1748
private static final byte[] serData_evv1_20050131_1512
private static final byte[] serData_evv1_20090806
private static final byte[] serData_ROByteArray_EMPTY_20050522
private static final java.lang.String ROBA_compS1
private static final byte[] serData_ROBA_compS1_20050522
private static final byte[] serData_Thumbnail_20060704
private static final byte[] serData_AllExhibitPropertiesDelta_empty
private static final java.lang.String[] TEST_C7BS_DATA
These are tested individually and all together in one stream.
private static final byte[] serData_C7BS_20060803
private static final byte[] serData_C7BS_20060804
private static final byte[] serData_pdS16_20090714
private static final byte[] serData_pdvar_20090714
private static final byte[] serData_esa1a_20090711
private static final byte[] serData_esa1b_20090711
private static final byte[] serData_esa1c_20090711
private static final byte[] serData_efn1_20090711
private static final byte[] serData_efnpair_20090711
private static final java.lang.String THE_HILLS_ARE_ALIVE
private static final byte[] serData_CS8Bit
private static final java.util.Random rnd
| Constructor Detail |
|---|
public SerializationTest(java.lang.String name)
| Method Detail |
|---|
public static java.lang.Object checkObjectCanBeSerialisedAndDeserialised(java.lang.Object obj)
throws java.io.IOException,
java.lang.ClassNotFoundException
obj - must implement java.io.Serializable; never null
java.io.IOException
java.lang.ClassNotFoundException
public static byte[] serialiseToByteArray(java.lang.Object obj)
throws java.io.IOException
java.io.IOException
private static void dumpSerData(java.lang.Object obj,
byte[] data)
private static void dumpAsciiComment(java.lang.StringBuilder sbTmp,
int count,
byte[] values)
static java.lang.Object deserialiseFromByteArray(byte[] data)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public static java.lang.Object checkSerialisationPreservesEquality(java.lang.Object obj)
throws java.lang.Exception
Tests in passing that the object can be (de)serialised.
java.lang.Exception - in case of difficulty.
public static void checkEmptyInstancesAreZeroAndEqualAndSerializable(java.lang.Class<? extends java.io.Serializable> c)
throws java.lang.Exception
Most of our persistable and transmittable-across-the-wire objects should show this property so that we can easily tell empty objects from ones containing useful data for example.
These objects should also be Serializable ((de)serializable) and still compare equal.
java.lang.Exception - in case of difficulty.
public static void testAllExhibitImmutableData()
throws java.lang.Exception
java.lang.Exception
public static void testAllExhibitProperties()
throws java.lang.Exception
java.lang.Exception
public static void testExhibitPropsLoadable()
throws java.lang.Exception
java.lang.Exception
public static void testGenProps()
throws java.lang.Exception
java.lang.Exception
public static void testExhibitThumbnails()
throws java.lang.Exception
java.lang.Exception
public static void testLocation()
throws java.lang.Exception
java.lang.Exception
public static void testSimpleVariables()
throws java.lang.Exception
java.lang.Exception
public static void testEventVariableValues()
throws java.lang.Exception
java.lang.Exception
public static void testROByteArray()
throws java.lang.Exception
java.lang.Exception
public static void testAccessionDataSer()
throws java.lang.Exception
java.lang.Exception
public static void testThumbnailSer()
throws java.lang.Exception
java.lang.Exceptionpublic static void testDecompDeserRobustness()
public static void testSerAllExhibitPropertiesDelta()
throws java.lang.Exception
java.lang.Exception
public static void testCompact7BitString()
throws java.lang.Exception
We take the (maximally) compressed serialised stream to be our target usage.
java.lang.Exception
public static void testLocationMap()
throws java.lang.Exception
java.lang.Exception
public static void testCompressors()
throws java.lang.Exception
java.lang.Exception
public static void testPropertiesDiff()
throws java.lang.Exception
java.lang.Exception
public static void testPropertiesBundleDiff()
throws java.lang.Exception
java.lang.Exception
public static void testEPGIBasic()
throws java.lang.Exception
java.lang.Exception
public static void testESABasic()
throws java.lang.Exception
java.lang.Exception
public static void testExhibitFullNameBasic()
throws java.lang.Exception
java.lang.Exception
public static void testAEPSerialisationSize()
throws java.lang.Exception
This is quiet-ish unless the AEP changes in size significantly when re-serialised and GZIPped. A big enough bloat is an error.
Often serialisation formats will compress slightly better when less compact at the micro level (ie if we avoid internally (over-)compressing each component first).
We only test with the last captured AEP, assumed to be the nearest to current.
This also measures code performance in the (de)serialisation path.
java.lang.Exception
public static void testCS8Bit()
throws java.lang.Exception
java.lang.Exception
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||