|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.testng.Assert org.apache.tapestry5.ioc.test.TestUtils
public class TestUtils
Extra assertions on top of the standard set, packaged as a base class for easy referencing in tests. Also, utilities for instantiation objects and setting and reading private fields of those objects.
This class was originally in the tapestry-ioc module as was moved to tapestry-test; the package name was not changed to ensure backwards compatibility.
Constructor Summary | |
---|---|
TestUtils()
|
Method Summary | ||
---|---|---|
static
|
assertArraysEqual(T[] actual,
T... expected)
Convenience for assertListsEquals(List, List) . |
|
static
|
assertListsEquals(List<T> actual,
List<T> expected)
Compares two lists for equality; first all the elements are individually compared for equality (if the lists are of unequal length, only elements up to the shorter length are compared). |
|
static
|
assertListsEquals(List<T> actual,
T... expected)
Convenience for assertListsEquals(List, List) . |
|
static void |
assertMessageContains(Throwable t,
String... substrings)
Asserts that the message property of the throwable contains each of the provided substrings. |
|
static
|
create(Class<T> objectType,
Object... fieldValues)
Creates a new instance of the object using its default constructor, and initializes it (via set(Object, Object[]) ). |
|
static Object |
get(Object object,
String fieldName)
Reads the content of a private field. |
|
static
|
set(T object,
Object... fieldValues)
Initializes private fields (via reflection). |
|
protected static
|
showLists(List<T> actual,
List<T> expected)
|
|
static void |
unreachable()
Invoked from code that should not be reachable. |
Methods inherited from class org.testng.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TestUtils()
Method Detail |
---|
public static void unreachable()
public static void assertMessageContains(Throwable t, String... substrings)
t
- throwable to checksubstrings
- some number of expected substringspublic static <T> void assertListsEquals(List<T> actual, List<T> expected)
T
- type of objects to compareactual
- actual values to checkexpected
- expected valuesprotected static <T> void showLists(List<T> actual, List<T> expected)
public static <T> void assertListsEquals(List<T> actual, T... expected)
assertListsEquals(List, List)
.
T
- type of objects to compareactual
- actual values to checkexpected
- expected valuespublic static <T> void assertArraysEqual(T[] actual, T... expected)
assertListsEquals(List, List)
.
T
- type of objects to compareactual
- actual values to checkexpected
- expected valuespublic static <T> T set(T object, Object... fieldValues)
object
- object to be updatedfieldValues
- string field names and corresponding field values
public static Object get(Object object, String fieldName)
object
- to read the private field fromfieldName
- name of field to read
public static <T> T create(Class<T> objectType, Object... fieldValues)
set(Object, Object[])
).
objectType
- typeof object to instantiatefieldValues
- string field names and corresponding field values
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |