Package org.djutils.serialization
Class Tests
java.lang.Object
org.djutils.serialization.Tests
public class Tests extends Object
Test message conversions.
Copyright (c) 2019-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Tests.Compound
Class used to test serialization of classes that implement SerializableObject. -
Constructor Summary
Constructors Constructor Description Tests()
-
Method Summary
Modifier and Type Method Description (package private) static boolean
deepEquals0(Object e1, Object e2)
Compare two arrays of any type (stolen from java.util.Arrays).(package private) static Object
makePrimitive(Object in)
Convert an array, or matrix of Byte, Short, Integer, etc.void
pointerTest()
Test the Pointer class.void
serializationExceptionTest()
Test all constructors for SerializationException.void
serializationRuntimeExceptionTest()
Test all constructors for SerializationRuntimeException.void
simpleTests()
Basic test encoding and decoding of the basic types.void
testArrayOfDjutilsVectors()
Test serialization and deserialization of arrays of Djutils vectors.void
testArrays()
Test encoding and decoding of arrays.void
testBasicSerializer()
Test the toString and dataClassName methods of the BasicSerializer.void
testCompoundArrays()
Test the compound array encoder and decoder.void
testDJunitDisplayTypes()
Test stored information about djunits display types.void
testDJunits()
Test encoding and decoding of strongly typed quantities (DJUNITS).void
testEndianUtil()
Test the remainder of the EndianUtil class.void
testJaggedMatrices()
Test that jagged matrices are detected and cause a SerializationException.void
testMatrices()
Test encoding and decoding of arrays.void
testSerializationUnits()
Test stored information about djunits SerializationUnits.void
testStrings()
Test encoding and decoding of Strings with more exotic characters for UTF-8 and UTF-16.void
testUnhandledObject()
Test that the encoder throws a SerializationException when given something that it does not know how to serialize.void
testUnitType()
Test the UnitType class.
-
Constructor Details
-
Tests
public Tests()
-
-
Method Details
-
simpleTests
public void simpleTests() throws org.djutils.serialization.SerializationExceptionBasic test encoding and decoding of the basic types.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught this test has failed
-
testStrings
public void testStrings() throws org.djutils.serialization.SerializationException, UnsupportedEncodingExceptionTest encoding and decoding of Strings with more exotic characters for UTF-8 and UTF-16.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught this test has failedUnsupportedEncodingException
- when UTF-8 en/decoding fails
-
testArrays
public void testArrays() throws org.djutils.serialization.SerializationExceptionTest encoding and decoding of arrays.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught this test has failed
-
testMatrices
public void testMatrices() throws org.djutils.serialization.SerializationExceptionTest encoding and decoding of arrays.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught this test has failed
-
testDJunits
public void testDJunits() throws org.djutils.serialization.SerializationException, ValueRuntimeExceptionTest encoding and decoding of strongly typed quantities (DJUNITS).- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught, this test has failedValueRuntimeException
- when that happens uncaught, this test has failed
-
testSerializationUnits
public void testSerializationUnits() throws org.djutils.serialization.SerializationException, ValueRuntimeExceptionTest stored information about djunits SerializationUnits.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught, this test has failedValueRuntimeException
- when that happens uncaught, this test has failed
-
testDJunitDisplayTypes
public void testDJunitDisplayTypes() throws org.djutils.serialization.SerializationException, ValueRuntimeExceptionTest stored information about djunits display types.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught, this test has failedValueRuntimeException
- when that happens uncaught, this test has failed
-
testCompoundArrays
public void testCompoundArrays() throws org.djutils.serialization.SerializationExceptionTest the compound array encoder and decoder.- Throws:
org.djutils.serialization.SerializationException
- when that happens uncaught, this test has failed
-
testArrayOfDjutilsVectors
public void testArrayOfDjutilsVectors() throws ValueRuntimeException, org.djutils.serialization.SerializationExceptionTest serialization and deserialization of arrays of Djutils vectors.- Throws:
ValueRuntimeException
- if that happens uncaught; this test has failedorg.djutils.serialization.SerializationException
- if that happens uncaught; this test has failed
-
testJaggedMatrices
public void testJaggedMatrices()Test that jagged matrices are detected and cause a SerializationException. -
testUnhandledObject
public void testUnhandledObject()Test that the encoder throws a SerializationException when given something that it does not know how to serialize. -
pointerTest
public void pointerTest()Test the Pointer class. -
makePrimitive
Convert an array, or matrix of Byte, Short, Integer, etc. to an array/matrix of byte, short, int, etc.- Parameters:
in
- Object; the array to convert- Returns:
- Object; the converted input (if conversion was possible), or the unconverted input.
-
deepEquals0
Compare two arrays of any type (stolen from java.util.Arrays).- Parameters:
e1
- Object (should be some kind of array)e2
- Object (should be some kind of array)- Returns:
- boolean; true of the arrays have the same type, size and all elements in the arrays are equal to their counterpart
-
testUnitType
public void testUnitType()Test the UnitType class. -
serializationExceptionTest
public final void serializationExceptionTest()Test all constructors for SerializationException. -
serializationRuntimeExceptionTest
public final void serializationRuntimeExceptionTest()Test all constructors for SerializationRuntimeException. -
testEndianUtil
public void testEndianUtil()Test the remainder of the EndianUtil class. -
testBasicSerializer
public void testBasicSerializer()Test the toString and dataClassName methods of the BasicSerializer.
-