net.sf.jsefa.test.common
Class JSefaTestUtil

java.lang.Object
  extended by net.sf.jsefa.test.common.JSefaTestUtil

public final class JSefaTestUtil
extends Object

Utility class for the JSefa tests.

Author:
Norman Lahme-Huetig

Nested Class Summary
static class JSefaTestUtil.FormatType
          Enum constants for the different format types.
 
Method Summary
static void assertRepeatedRoundTripSucceeds(JSefaTestUtil.FormatType formatType, Configuration config, Object... dtos)
          Does a repeated round trip check, i. e. serializes the given dtos, deserializes them back again and tests if the result equals the input.
static void assertRepeatedRoundTripSucceeds(JSefaTestUtil.FormatType formatType, Object... dtos)
          Does a repeated round trip check, i. e. serializes the given dtos, deserializes them back again and tests if the result equals the input.
static Configuration createConfiguration(JSefaTestUtil.FormatType formatType)
          Creates a default configuration for the given format type.
static IOFactory createIOFactory(JSefaTestUtil.FormatType formatType, Class<?>... objectTypes)
          Creates a IOFactory.
static IOFactory createIOFactory(JSefaTestUtil.FormatType formatType, Configuration config, Class<?>... objectTypes)
          Creates a IOFactory.
static
<T> T
deserialize(JSefaTestUtil.FormatType formatType, Configuration config, String inputString, Class<T>... objectTypes)
          Deserializes an object of the given DTO from the given String.
static
<T> T
deserialize(JSefaTestUtil.FormatType formatType, String inputString, Class<T>... objectTypes)
          Deserializes an object of the given DTO from the given String.
static String serialize(JSefaTestUtil.FormatType formatType, Class objectType, Object object)
          Serializes the given object using an IOFactory constructed for the given object type.
static String serialize(JSefaTestUtil.FormatType formatType, Configuration config, Object... objects)
          Serializes the given object.
static String serialize(JSefaTestUtil.FormatType formatType, Object... objects)
          Serializes the given objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertRepeatedRoundTripSucceeds

public static void assertRepeatedRoundTripSucceeds(JSefaTestUtil.FormatType formatType,
                                                   Object... dtos)
Does a repeated round trip check, i. e. serializes the given dtos, deserializes them back again and tests if the result equals the input. This check is repeated several times.

Parameters:
formatType - the format type
dtos - the DTOs

assertRepeatedRoundTripSucceeds

public static void assertRepeatedRoundTripSucceeds(JSefaTestUtil.FormatType formatType,
                                                   Configuration config,
                                                   Object... dtos)
Does a repeated round trip check, i. e. serializes the given dtos, deserializes them back again and tests if the result equals the input. This check is repeated several times.

Parameters:
formatType - the format type
config - the configuration
dtos - the DTOs

serialize

public static String serialize(JSefaTestUtil.FormatType formatType,
                               Object... objects)
Serializes the given objects.

Parameters:
formatType - the format type
objects - the objects to serialize
Returns:
the serialization result

serialize

public static String serialize(JSefaTestUtil.FormatType formatType,
                               Configuration config,
                               Object... objects)
Serializes the given object.

Parameters:
formatType - the format type
config - the configuration
objects - the objects to serialize
Returns:
the serialization result

serialize

public static String serialize(JSefaTestUtil.FormatType formatType,
                               Class objectType,
                               Object object)
Serializes the given object using an IOFactory constructed for the given object type.

Parameters:
formatType - the format type
objectType - the object type
object - the object to serialize
Returns:
the serialization result

deserialize

public static <T> T deserialize(JSefaTestUtil.FormatType formatType,
                                String inputString,
                                Class<T>... objectTypes)
Deserializes an object of the given DTO from the given String.

Type Parameters:
T - the type of the object
Parameters:
formatType - the format type
inputString - the String to deserialize the DTO from
objectTypes - the object types
Returns:
the deserialized object

deserialize

public static <T> T deserialize(JSefaTestUtil.FormatType formatType,
                                Configuration config,
                                String inputString,
                                Class<T>... objectTypes)
Deserializes an object of the given DTO from the given String.

Type Parameters:
T - the type of the object
Parameters:
formatType - the format type
config - the configuration
inputString - the String to deserialize the DTO from
objectTypes - the object types
Returns:
the deserialized object

createConfiguration

public static Configuration createConfiguration(JSefaTestUtil.FormatType formatType)
Creates a default configuration for the given format type.

Parameters:
formatType - the format type
Returns:
a configuration

createIOFactory

public static IOFactory createIOFactory(JSefaTestUtil.FormatType formatType,
                                        Class<?>... objectTypes)
Creates a IOFactory.

Parameters:
formatType - the format type
objectTypes - the object types
Returns:
an IOFactory

createIOFactory

public static IOFactory createIOFactory(JSefaTestUtil.FormatType formatType,
                                        Configuration config,
                                        Class<?>... objectTypes)
Creates a IOFactory.

Parameters:
formatType - the format type
config - the configuration
objectTypes - the object types
Returns:
an IOFactory


Copyright © 2014. All rights reserved.