public class Assert
extends java.lang.Object
Assert.assertEquals(...)
, however, readability can be improved if they
are referenced through static import:import static com.jalios.jcms.test.Assert.*; ... assertEquals(...);
Modifier | Constructor and Description |
---|---|
protected |
Assert()
Protect constructor since it is a static only class
|
Modifier and Type | Method and Description |
---|---|
static void |
assertAlert(Alert expectedAlert,
Alert actualAlert) |
static void |
assertCanBeReadBy(Publication pub,
Group grp) |
static void |
assertCanBeReadBy(Publication pub,
Member mbr) |
static void |
assertCanBeReadBy(Publication pub,
Member mbr,
boolean searchInGroup) |
static void |
assertCanDeleteOther(Member mbr,
Data data) |
static void |
assertCannotBeReadBy(Publication pub,
Group grp,
RightInfo.Explanation restriction) |
static void |
assertCannotBeReadBy(Publication pub,
Member mbr,
boolean searchInGroup,
RightInfo.Explanation explanation) |
static void |
assertCannotBeReadBy(Publication pub,
Member mbr,
RightInfo.Explanation explanation) |
static void |
assertCannotDeleteOther(Member mbr,
Data data,
RightInfo.Explanation explanation) |
static void |
assertCannotUpdateOther(Member mbr,
Data data,
RightInfo.Explanation explanation) |
static void |
assertCannotWorkOn(Member mbr,
Publication pub,
RightInfo.Explanation explanation) |
static void |
assertCanUpdateOther(Member mbr,
Data data) |
static void |
assertCanWorkOn(Member mbr,
Publication pub) |
static <T> void |
assertCmpEquals(java.util.Comparator<T> comparator,
T o1,
T o2) |
static <T> void |
assertCmpGreater(java.util.Comparator<T> comparator,
T o1,
T o2) |
static <T> void |
assertCmpLower(java.util.Comparator<T> comparator,
T o1,
T o2) |
static <T> void |
assertCmpOpposite(java.util.Comparator<T> comparator,
T o1,
T o2) |
static <T> void |
assertCmpSame(java.util.Comparator<T> c1,
java.util.Comparator<T> c2,
T o1,
T o2) |
static void |
assertContains(boolean isExpectedContained,
java.util.Collection<?> collection,
java.lang.Object object) |
static void |
assertContains(java.lang.String message,
boolean isExpectedContained,
java.util.Collection<?> collection,
java.lang.Object object) |
static void |
assertContainsAll(java.util.Collection<?> expectedElements,
java.util.Collection<?> actualElements) |
static void |
assertContainsAll(java.lang.String message,
java.util.Collection<?> expectedElements,
java.util.Collection<?> actualElements)
Assert that all elements in
expectedElements are contained in actualElements , but actualElements can contain others elements not in expectedElements . |
static void |
assertDateRange(java.util.Date date,
java.util.Date lowerDate,
java.util.Date upperDate)
Assert the given date d1 is in range {d2, d3}
|
static void |
assertDateRangeStrict(java.util.Date date,
java.util.Date lowerDate,
java.util.Date upperDate)
Assert the given date date is in the range {lowerDate, upperDate}
|
static void |
assertIsEmpty(java.lang.Object obj) |
static void |
assertIsEmpty(java.lang.String message,
java.lang.Object obj) |
static void |
assertIsSameXml(java.lang.String expectedXml,
java.lang.String xmlString)
Assert given xml string are identicial ( except normalized spaces).
|
static void |
assertIsSimilarXml(java.lang.String expectedXml,
java.lang.String xmlString)
Assert given xml string are similar (normalized spaces and child present by in different order)
|
static void |
assertNoStaticChannelField(java.lang.Class<?> clazz)
Checks given class does not declare a static Channel field.
|
static void |
assertNotEmpty(java.lang.Object obj) |
static void |
assertNotEmpty(java.lang.String message,
java.lang.Object obj) |
static void |
assertNotSameContent(java.util.Date date1,
java.util.Date date2) |
static void |
assertNotSameContent(java.util.List<?> list1,
java.util.List<?> list2) |
static void |
assertNotSameContent(java.util.Map<?,?> map1,
java.util.Map<?,?> map2) |
static void |
assertNotSameContent(java.lang.Object[] array1,
java.lang.Object[] array2) |
static void |
assertNotSameContent(java.util.Set<?> set1,
java.util.Set<?> set2) |
static void |
assertNotSameContent(java.lang.String message,
java.util.Collection<?> col1,
java.util.Collection<?> col2) |
static void |
assertNotSameContent(java.lang.String message,
java.util.Date date1,
java.util.Date date2) |
static void |
assertNotSameContent(java.lang.String message,
java.util.List<?> list1,
java.util.List<?> list2) |
static void |
assertNotSameContent(java.lang.String message,
java.util.Map<?,?> map1,
java.util.Map<?,?> map2) |
static void |
assertNotSameContent(java.lang.String message,
java.lang.Object[] array1,
java.lang.Object[] array2) |
static void |
assertNotSameContent(java.lang.String message,
java.util.Set<?> set1,
java.util.Set<?> set2) |
static void |
assertObjectIsGarbageCollected(java.lang.ref.WeakReference<? extends java.lang.Object> wRef,
long timeout,
boolean heapDump)
Check that the specified Object (referenced through a WeakReference) is garbage collected
in the designated time.
|
static void |
assertRange(long value,
long minValue,
long maxValue,
boolean strict)
Assert the given value lesser than minValue and graeter than maxValue.
|
static void |
assertResult(CheckResult result)
Allows to throw assertions errors for multiple tests at a time.
|
static void |
assertResult(java.lang.String message,
CheckResult result)
Allows to throw assertions errors for multiple tests at a time.
|
static void |
assertSameContent(java.util.Collection<?> set1,
java.util.Collection<?> set2) |
static void |
assertSameContent(java.util.Date date1,
java.util.Date date2) |
static void |
assertSameContent(java.util.List<?> list1,
java.util.List<?> list2) |
static void |
assertSameContent(java.util.Map<?,?> map1,
java.util.Map<?,?> map2) |
static void |
assertSameContent(java.lang.Object[] array1,
java.lang.Object[] array2) |
static void |
assertSameContent(java.util.Set<?> set1,
java.util.Set<?> set2) |
static void |
assertSameContent(java.lang.String message,
java.util.Collection<?> expected,
java.util.Collection<?> actual) |
static void |
assertSameContent(java.lang.String message,
java.util.Date date1,
java.util.Date date2) |
static void |
assertSameContent(java.lang.String message,
java.util.List<?> list1,
java.util.List<?> list2) |
static void |
assertSameContent(java.lang.String message,
java.util.Map<?,?> map1,
java.util.Map<?,?> map2) |
static void |
assertSameContent(java.lang.String message,
java.lang.Object[] array1,
java.lang.Object[] array2) |
static void |
assertSameDateList(java.util.List<java.util.Date> expectedDateList,
java.util.List<java.util.Date> actualDateList)
Assert both Set of Date are exactly the same, disregarding any difference related to
java.sql.Timestamp vs java.util.Date
|
static void |
assertSameDateSet(java.util.Set<java.util.Date> expectedDateSet,
java.util.Set<java.util.Date> actualDateSet)
Assert both Set of Date are exactly the same, disregarding any difference related to
java.sql.Timestamp vs java.util.Date
|
static void |
assertSameHtml(java.lang.String htmlFragment1,
java.lang.String htmlFragment2)
Asserts that the two specified HTML fragment are the same.
|
static void |
assertSameHtml(java.lang.String message,
java.lang.String htmlFragment1,
java.lang.String htmlFragment2)
Asserts that the two specified HTML fragment are the same.
|
static void |
assertStatusForbidden(ControllerStatus status) |
static void |
assertStatusHasFailed(ControllerStatus status) |
static void |
assertStatusHasFailed(java.lang.String prop,
ControllerStatus status) |
static void |
assertStatusHasFailed(java.lang.String msg,
java.lang.String prop,
ControllerStatus status) |
static void |
assertStatusOK(ControllerStatus status) |
static void |
assertStatusOK(java.lang.String msg,
ControllerStatus status) |
static void |
assertTypesDisabled(Workspace ws,
java.lang.Class<?>... classes)
Assert given types are disabled in the given Workspace.
|
static void |
assertTypesEnabled(Workspace ws,
java.lang.Class<?>... classes)
Assert given types are enabled in the given Workspace.
|
protected static java.util.List<java.util.Date> |
getDateList(java.util.List<java.util.Date> dateList)
Return a new List containing only java.util.Date if the specified Date is a timestamp.
|
protected static java.util.Set<java.util.Date> |
getDateSet(java.util.Set<java.util.Date> dateSet)
Return a new Set containing only java.util.Date if the specified Date is a timestamp.
|
public static void assertStatusOK(ControllerStatus status)
public static void assertStatusOK(java.lang.String msg, ControllerStatus status)
public static void assertStatusForbidden(ControllerStatus status)
public static void assertStatusHasFailed(ControllerStatus status)
public static void assertStatusHasFailed(java.lang.String prop, ControllerStatus status)
public static void assertStatusHasFailed(java.lang.String msg, java.lang.String prop, ControllerStatus status)
public static void assertCanBeReadBy(Publication pub, Member mbr)
public static void assertCannotBeReadBy(Publication pub, Member mbr, RightInfo.Explanation explanation)
public static void assertCanBeReadBy(Publication pub, Member mbr, boolean searchInGroup)
public static void assertCannotBeReadBy(Publication pub, Member mbr, boolean searchInGroup, RightInfo.Explanation explanation)
public static void assertCanBeReadBy(Publication pub, Group grp)
public static void assertCannotBeReadBy(Publication pub, Group grp, RightInfo.Explanation restriction)
public static void assertCannotUpdateOther(Member mbr, Data data, RightInfo.Explanation explanation)
public static void assertCannotDeleteOther(Member mbr, Data data, RightInfo.Explanation explanation)
public static void assertCanWorkOn(Member mbr, Publication pub)
public static void assertCannotWorkOn(Member mbr, Publication pub, RightInfo.Explanation explanation)
public static <T> void assertCmpGreater(java.util.Comparator<T> comparator, T o1, T o2)
public static <T> void assertCmpLower(java.util.Comparator<T> comparator, T o1, T o2)
public static <T> void assertCmpEquals(java.util.Comparator<T> comparator, T o1, T o2)
public static <T> void assertCmpOpposite(java.util.Comparator<T> comparator, T o1, T o2)
public static <T> void assertCmpSame(java.util.Comparator<T> c1, java.util.Comparator<T> c2, T o1, T o2)
public static void assertSameContent(java.lang.Object[] array1, java.lang.Object[] array2)
public static void assertSameContent(java.lang.String message, java.lang.Object[] array1, java.lang.Object[] array2)
public static void assertNotSameContent(java.lang.Object[] array1, java.lang.Object[] array2)
public static void assertNotSameContent(java.lang.String message, java.lang.Object[] array1, java.lang.Object[] array2)
public static void assertSameHtml(java.lang.String htmlFragment1, java.lang.String htmlFragment2)
htmlFragment1
- the first HTML fragment to comparehtmlFragment2
- the second HTML fragment to comparepublic static void assertSameHtml(java.lang.String message, java.lang.String htmlFragment1, java.lang.String htmlFragment2)
message
- a message displayed when assertion failshtmlFragment1
- the first HTML fragment to comparehtmlFragment2
- the second HTML fragment to comparepublic static void assertIsSimilarXml(java.lang.String expectedXml, java.lang.String xmlString)
expectedXml
- the expected XML stringxmlString
- the XML string to checkpublic static void assertIsSameXml(java.lang.String expectedXml, java.lang.String xmlString)
expectedXml
- the expected XML stringxmlString
- the XML string to checkprotected static java.util.Set<java.util.Date> getDateSet(java.util.Set<java.util.Date> dateSet)
dateSet
- the Set of Date object to check/convertprotected static java.util.List<java.util.Date> getDateList(java.util.List<java.util.Date> dateList)
dateList
- the List of Date object to check/convertpublic static void assertSameDateSet(java.util.Set<java.util.Date> expectedDateSet, java.util.Set<java.util.Date> actualDateSet)
expectedDateSet
- expected valuesactualDateSet
- actual valuespublic static void assertSameDateList(java.util.List<java.util.Date> expectedDateList, java.util.List<java.util.Date> actualDateList)
expectedDateList
- expected valuesactualDateList
- actual valuespublic static void assertSameContent(java.util.Collection<?> set1, java.util.Collection<?> set2)
public static void assertSameContent(java.lang.String message, java.util.Collection<?> expected, java.util.Collection<?> actual)
public static void assertNotSameContent(java.lang.String message, java.util.Collection<?> col1, java.util.Collection<?> col2)
public static void assertSameContent(java.util.Set<?> set1, java.util.Set<?> set2)
public static void assertNotSameContent(java.util.Set<?> set1, java.util.Set<?> set2)
public static void assertNotSameContent(java.lang.String message, java.util.Set<?> set1, java.util.Set<?> set2)
public static void assertContainsAll(java.util.Collection<?> expectedElements, java.util.Collection<?> actualElements)
expectedElements
- all elements must be contained by actualElements
actualElements
- the collection to assert it contains all elements in expectedElements
assertContainsAll(String, Collection, Collection)
public static void assertContainsAll(java.lang.String message, java.util.Collection<?> expectedElements, java.util.Collection<?> actualElements)
expectedElements
are contained in actualElements
, but actualElements
can contain others elements not in expectedElements
.message
- optional messageexpectedElements
- all elements must be contained by actualElements
actualElements
- the collection to assert it contains all elements in expectedElements
public static void assertSameContent(java.util.List<?> list1, java.util.List<?> list2)
public static void assertSameContent(java.lang.String message, java.util.List<?> list1, java.util.List<?> list2)
public static void assertNotSameContent(java.util.List<?> list1, java.util.List<?> list2)
public static void assertNotSameContent(java.lang.String message, java.util.List<?> list1, java.util.List<?> list2)
public static void assertSameContent(java.util.Map<?,?> map1, java.util.Map<?,?> map2)
public static void assertSameContent(java.lang.String message, java.util.Map<?,?> map1, java.util.Map<?,?> map2)
public static void assertNotSameContent(java.util.Map<?,?> map1, java.util.Map<?,?> map2)
public static void assertNotSameContent(java.lang.String message, java.util.Map<?,?> map1, java.util.Map<?,?> map2)
public static void assertSameContent(java.util.Date date1, java.util.Date date2)
public static void assertSameContent(java.lang.String message, java.util.Date date1, java.util.Date date2)
public static void assertNotSameContent(java.util.Date date1, java.util.Date date2)
public static void assertNotSameContent(java.lang.String message, java.util.Date date1, java.util.Date date2)
public static void assertContains(boolean isExpectedContained, java.util.Collection<?> collection, java.lang.Object object)
public static void assertContains(java.lang.String message, boolean isExpectedContained, java.util.Collection<?> collection, java.lang.Object object)
public static void assertIsEmpty(java.lang.Object obj)
public static void assertIsEmpty(java.lang.String message, java.lang.Object obj)
public static void assertNotEmpty(java.lang.Object obj)
public static void assertNotEmpty(java.lang.String message, java.lang.Object obj)
public static void assertRange(long value, long minValue, long maxValue, boolean strict)
value
- the valueminValue
- the minValuemaxValue
- the maxValuestrict
- true if the comparison must be strictpublic static void assertDateRange(java.util.Date date, java.util.Date lowerDate, java.util.Date upperDate)
date
- the date to be testedlowerDate
- the lower date limit (may be null)upperDate
- the upper date limit (may be null)public static void assertDateRangeStrict(java.util.Date date, java.util.Date lowerDate, java.util.Date upperDate)
date
- the date to be testedlowerDate
- the lower date limit (may be null)upperDate
- the upper date limit (may be null)public static void assertObjectIsGarbageCollected(java.lang.ref.WeakReference<? extends java.lang.Object> wRef, long timeout, boolean heapDump)
IMPORTANT : in order for this method to work properly and success, you must get rid of all strong references of your object in the method callee. For example :
Publication pub1 = createSmallNews(admin, defaultWorkspace); pub1.performDelete(); // 1. Create WeakReference for the object WeakReference<Object> pub1WeakRef = new WeakReference<Object>(pub1); // 2. Remove strong reference for the object pub1 = null; // 3. Test object is garbage collected correctly, requesting a heap dump in case of failure assertObjectIsGarbageCollected(pub1WeakRef, 10*MILLIS_IN_ONE_SECOND, true);
Implementation note : this method will trigger a GC through System.gc()
every second until the timeout has been reached or the object is detected has garbage collected.
wRef
- the object WeakReference (required to prevent strong reference of object through callstack)timeout
- the timeout after which this method will consider (should be a multiple of 1000 ms with current implementation)heapDump
- perform HEAP dump on failure for easier debuggingpublic static void assertTypesEnabled(Workspace ws, java.lang.Class<?>... classes)
ws
- the workspace to testclasses
- classes to test they are enabled in wspublic static void assertTypesDisabled(Workspace ws, java.lang.Class<?>... classes)
ws
- the workspace to testclasses
- classes to test they are disabled in wspublic static void assertResult(CheckResult result)
result
- the assertions in error wrapper.public static void assertResult(java.lang.String message, CheckResult result)
message
- an optional contextual messageresult
- the assertions in error wrapper.public static void assertNoStaticChannelField(java.lang.Class<?> clazz)
This kind of declaration may break site / feature initialization.
clazz
- class to testCopyright © 2001-2020 Jalios SA. All Rights Reserved.