@Singleton public class TestUtils extends Object
| Modifier and Type | Field | Description |
|---|---|---|
static String |
SYS_PROPERTY_OUTPUT_DIR |
Name of the system property to override the default output directory
|
static String |
SYS_PROPERTY_PROFILE |
Name of the system property to pass the desired profile
|
static String |
SYS_PROPERTY_REPORT_FILE |
Name of the system property to override the default report file
|
static String |
SYS_PROPERTY_VERBOSE |
Name of the system property to set the
verbose flag |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
assertValue(String section,
Object value,
String methodName,
Object instance) |
Checks the returned value, when calling a given method.
|
static void |
testComparable(String section,
Class<?> type) |
Tests if the given type is comparable.
|
static void |
testHasNotPublicMethod(String section,
Class type,
Class returnType,
String name,
Class... paramTypes) |
Tests if the given type has not a public method with the given signature.
|
static void |
testHasPublicMethod(String section,
Class<?> type,
boolean trySuperclassFirst,
Class<?> returnType,
String name,
Class<?>... paramTypes) |
|
static void |
testHasPublicMethod(String section,
Class<?> type,
Class<?> returnType,
String name,
Class<?>... paramTypes) |
Deprecated.
use the simplified version on top of Reflections.org where possible
|
static void |
testHasPublicMethod(String section,
Class<?> type,
String name) |
|
static void |
testHasPublicMethod(String section,
Class<?> type,
String name,
boolean hasParameters) |
Tests if the given type has a public method with the given signature.
|
static void |
testImmutable(String section,
Class<?> type) |
Tests the given class being serializable.
|
static boolean |
testImmutableOpt(String section,
Class type) |
Test for immutability (optional recommendation), writes a warning if not given.
|
static void |
testImplementsInterface(String section,
Class<?> type,
Class<?> iface) |
Tests the given class implements a given interface.
|
static void |
testSerializable(String section,
Class<?> type) |
Tests the given object being (effectively) serializable by serializing it.
|
static void |
testSerializable(String section,
Object o) |
Tests the given object being (effectively) serializable by serializing it.
|
static boolean |
testSerializableOpt(String section,
Class type) |
Test for serializable (optional recommendation), writes a warning if not given.
|
static boolean |
testSerializableOpt(String section,
Object instance) |
Test for serializable (optional recommendation), writes a warning if not given.
|
public static final String SYS_PROPERTY_PROFILE
public static final String SYS_PROPERTY_OUTPUT_DIR
public static final String SYS_PROPERTY_REPORT_FILE
public static final String SYS_PROPERTY_VERBOSE
verbose flagpublic static void testSerializable(String section, Class<?> type)
section - the section of the spec under testtype - the type to be checked.TCKValidationException - if the test fails.public static void testImmutable(String section, Class<?> type)
section - the section of the spec under testtype - the type to be checked.TCKValidationException - if test fails.public static void testSerializable(String section, Object o)
section - the section of the spec under testo - the object to be checked.TCKValidationException - if test fails.public static void testImplementsInterface(String section, Class<?> type, Class<?> iface)
section - the section of the spec under testtype - the type to be checked.iface - the interface to be checked for.
Triggers Assert#fail
if test fails.public static void testComparable(String section, Class<?> type)
section - the section of the spec under testtype - the type to be checked.public static void testHasPublicMethod(String section, Class<?> type, Class<?> returnType, String name, Class<?>... paramTypes)
section - the section of the specificationtype - the type to be checked.returnType - the expected return typename - the name of the methodparamTypes - the types of parameters if availablepublic static void testHasPublicMethod(String section, Class<?> type, boolean trySuperclassFirst, Class<?> returnType, String name, Class<?>... paramTypes)
section - the section of the specificationtype - the data typetrySuperclassFirst - if tht super class if available should be tested firstreturnType - the expected return typename - the name of the methodparamTypes - types of parameterspublic static void testHasPublicMethod(String section, Class<?> type, String name, boolean hasParameters)
section - the section of the spec under testtype - the type to be checked.name - the method namehasParameters - the method has parameters.TCKValidationException - if test fails.public static void testHasPublicMethod(String section, Class<?> type, String name)
section - the section of the specificationtype - the data typename - the name of the methodpublic static void testHasNotPublicMethod(String section, Class type, Class returnType, String name, Class... paramTypes)
section - the section of the spec under testtype - the type to be checked.returnType - the method return type.name - the method nameparamTypes - the parameter types.TCKValidationException - if test fails.public static void assertValue(String section, Object value, String methodName, Object instance) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
section - the section of the spec under testvalue - the expected valuemethodName - the target method nameinstance - the instance to callNoSuchMethodException - if no method with the given name exists.SecurityException - if a security problem occurs.IllegalAccessException - if the method may not be called, e.g. due to security constraints.IllegalArgumentException - if a wrong or inappropriate argument was provided.InvocationTargetException - if an exception thrown by an invoked method or constructor.TCKValidationException - if test fails.public static boolean testImmutableOpt(String section, Class type)
section - the section of the spec under testtype - the type to be checked.public static boolean testSerializableOpt(String section, Class type)
section - the section of the spec under testtype - the type to be checked.public static boolean testSerializableOpt(String section, Object instance)
section - the section of the spec under testinstance - the object to be checked.Copyright © 2005–2019 Units of Measurement project. All rights reserved.