|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.reflectionassert.ReflectionAssert
public class ReflectionAssert
A class for asserting that 2 objects/collections are equal by comparing properties and fields of the objects/collections using reflection.
The (combination of) comparator modes specify how strict the comparison must be:
ReflectionComparator,
ReflectionComparatorMode| Nested Class Summary | |
|---|---|
protected static class |
ReflectionAssert.OgnlTransformer
A commons collections transformer that takes an object and returns the value of the property that is specified by the given ognl expression. |
| Constructor Summary | |
|---|---|
ReflectionAssert()
|
|
| Method Summary | |
|---|---|
static void |
assertLenEquals(java.lang.Object expected,
java.lang.Object actual)
Deprecated. As of version 2.0, replaced by assertLenientEquals(Object, Object). |
static void |
assertLenEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
Deprecated. As of version 2.0, replaced by assertLenientEquals(String, Object, Object). |
static void |
assertLenientEquals(java.lang.Object expected,
java.lang.Object actual)
Asserts that two objects are equal. |
static void |
assertLenientEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
Asserts that two objects are equal. |
static void |
assertPropertyLenEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
Deprecated. As of version 2.0, replaced by assertPropertyLenientEquals(String, Collection, Collection). |
static void |
assertPropertyLenEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
Deprecated. As of version 2.0, replaced by assertPropertyLenientEquals(String, Object, Object). |
static void |
assertPropertyLenEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
Deprecated. As of version 2.0, replaced by assertPropertyLenientEquals(String, String, Collection, Collection). |
static void |
assertPropertyLenEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
Deprecated. As of version 2.0, replaced by assertPropertyLenientEquals(String, String, Object, Object). |
static void |
assertPropertyLenientEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
Asserts that a property of all objects in the collection are equal to the given values. |
static void |
assertPropertyLenientEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
Asserts that the value of a property of an object is equal to the given value. |
static void |
assertPropertyLenientEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
Asserts that a property of all objects in the collection are equal to the given values. |
static void |
assertPropertyLenientEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
Asserts that the value of a property of an object is equal to the given value. |
static void |
assertPropertyRefEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
Deprecated. As of version 2.0, replaced by assertPropertyReflectionEquals(String, Collection, Collection). |
static void |
assertPropertyRefEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
Deprecated. As of version 2.0, replaced by assertPropertyReflectionEquals(String, Object, Object, ReflectionComparatorMode[]). |
static void |
assertPropertyRefEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
Deprecated. As of version 2.0, replaced by assertPropertyReflectionEquals(String, String, Collection, Collection, ReflectionComparatorMode[]). |
static void |
assertPropertyRefEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
Deprecated. As of version 2.0, replaced by assertPropertyReflectionEquals(String, String, Object, Object, ReflectionComparatorMode[]). |
static void |
assertPropertyReflectionEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
Asserts that a property of all objects in the collection are equal to the given values. |
static void |
assertPropertyReflectionEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
Asserts that the value of a property of an object is equal to the given value. |
static void |
assertPropertyReflectionEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
Asserts that a property of all objects in the collection are equal to the given values. |
static void |
assertPropertyReflectionEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
Asserts that the value of a property of an object is equal to the given value. |
static void |
assertRefEquals(java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
Deprecated. As of version 2.0, replaced by assertReflectionEquals(Object, Object, ReflectionComparatorMode[]). |
static void |
assertRefEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
Deprecated. As of version 2.0, replaced by assertReflectionEquals(String, Object, Object, ReflectionComparatorMode[]). |
static void |
assertReflectionEquals(java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
Asserts that two objects are equal. |
static void |
assertReflectionEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
Asserts that two objects are equal. |
protected static java.lang.String |
formatMessage(java.lang.String suppliedMessage,
java.lang.String specificMessage)
Formats the exception message. |
protected static java.lang.String |
getFailureMessage(java.lang.String message,
Difference difference)
|
protected static java.lang.Object |
getProperty(java.lang.Object object,
java.lang.String ognlExpression)
Evaluates the given OGNL expression, and returns the corresponding property value from the given object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectionAssert()
| Method Detail |
|---|
public static void assertLenEquals(java.lang.Object expected,
java.lang.Object actual)
throws junit.framework.AssertionFailedError
assertLenientEquals(Object, Object).
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
expected - the expected objectactual - the given object
junit.framework.AssertionFailedError - when both objects are not equalsassertLenientEquals(Object, Object)
public static void assertLenientEquals(java.lang.Object expected,
java.lang.Object actual)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
expected - the expected objectactual - the given object
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertRefEquals(java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object, Object, ReflectionComparatorMode[]).
expected - the expected objectactual - the given objectmodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equalsassertReflectionEquals(Object, Object, ReflectionComparatorMode[])
public static void assertReflectionEquals(java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
expected - the expected objectactual - the given objectmodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertLenEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
throws junit.framework.AssertionFailedError
assertLenientEquals(String, Object, Object).
assertReflectionEquals(String,Object,Object,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
message - a message for when the assertion failsexpected - the expected objectactual - the given object
junit.framework.AssertionFailedError - when both objects are not equalsassertLenientEquals(String, Object, Object)
public static void assertLenientEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
throws junit.framework.AssertionFailedError
assertReflectionEquals(String,Object,Object,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
message - a message for when the assertion failsexpected - the expected objectactual - the given object
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertRefEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertReflectionEquals(String, Object, Object, ReflectionComparatorMode[]).
message - a message for when the assertion failsexpected - the expected objectactual - the given objectmodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equalsassertReflectionEquals(String, Object, Object, ReflectionComparatorMode[])
public static void assertReflectionEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
message - a message for when the assertion failsexpected - the expected objectactual - the given objectmodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
protected static java.lang.String getFailureMessage(java.lang.String message,
Difference difference)
message - a custom user-provided message, null if the user didn't provide a messagedifference - the difference, not null
public static void assertPropertyLenEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
throws junit.framework.AssertionFailedError
assertPropertyLenientEquals(String, Object, Object).
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,Object,Object,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
propertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the property
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyLenientEquals(String, Object, Object)
public static void assertPropertyLenientEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,Object,Object,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
propertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the property
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyRefEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertPropertyReflectionEquals(String, Object, Object, ReflectionComparatorMode[]).
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
propertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyReflectionEquals(String, Object, Object, ReflectionComparatorMode[])
public static void assertPropertyReflectionEquals(java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
propertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyLenEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
throws junit.framework.AssertionFailedError
assertPropertyLenientEquals(String, String, Object, Object).
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,String,Object,Object,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the property
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyLenientEquals(String, String, Object, Object)
public static void assertPropertyLenientEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,String,Object,Object,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the property
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyRefEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertPropertyReflectionEquals(String, String, Object, Object, ReflectionComparatorMode[]).
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyReflectionEquals(String, String, Object, Object, ReflectionComparatorMode[])
public static void assertPropertyReflectionEquals(java.lang.String message,
java.lang.String propertyName,
java.lang.Object expectedPropertyValue,
java.lang.Object actualObject,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyLenEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
throws junit.framework.AssertionFailedError
assertPropertyLenientEquals(String, Collection, Collection).
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,Collection,Collection,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
propertyName - the property, not nullexpectedPropertyValues - the expected valuesactualObjects - the objects that contain the property
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyLenientEquals(String, Collection, Collection)
public static void assertPropertyLenientEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,Collection,Collection,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
propertyName - the property, not nullexpectedPropertyValues - the expected valuesactualObjects - the objects that contain the property
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyRefEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertPropertyReflectionEquals(String, Collection, Collection).
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
propertyName - the property, not nullexpectedPropertyValues - the expected valuesactualObjects - the objects that contain the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyReflectionEquals(String, Collection, Collection, ReflectionComparatorMode[])
public static void assertPropertyReflectionEquals(java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
propertyName - the property, not nullexpectedPropertyValues - the expected valuesactualObjects - the objects that contain the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyLenEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
throws junit.framework.AssertionFailedError
assertPropertyLenientEquals(String, String, Collection, Collection).
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,String,Collection,Collection,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValues - the expected values, not nullactualObjects - the objects that contain the property
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyLenientEquals(String, String, Collection, Collection)
public static void assertPropertyLenientEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object,ReflectionComparatorMode[]) is used to check whether both values are equal.
This is identical to assertPropertyReflectionEquals(String,String,Collection,Collection,ReflectionComparatorMode[]) with
lenient order and ignore defaults set as comparator modes.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValues - the expected values, not nullactualObjects - the objects that contain the property
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertPropertyRefEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertPropertyReflectionEquals(String, String, Collection, Collection, ReflectionComparatorMode[]).
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValues - the expected values, not nullactualObjects - the objects that contain the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equalsassertPropertyReflectionEquals(String, String, Collection, Collection, ReflectionComparatorMode[])
public static void assertPropertyReflectionEquals(java.lang.String message,
java.lang.String propertyName,
java.util.Collection<?> expectedPropertyValues,
java.util.Collection<?> actualObjects,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
assertReflectionEquals(Object,Object, ReflectionComparatorMode[]) is used to check whether both values are equal.
The comparator modes determine how strict to compare the values.
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValues - the expected values, not nullactualObjects - the objects that contain the propertymodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
protected static java.lang.String formatMessage(java.lang.String suppliedMessage,
java.lang.String specificMessage)
suppliedMessage - the user supplied messagespecificMessage - the reason
protected static java.lang.Object getProperty(java.lang.Object object,
java.lang.String ognlExpression)
object - The object on which the expression is evaluatedognlExpression - The OGNL expression that is evaluated
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||