public final class ForwardingWrapperTester
extends java.lang.Object
For example:
new ForwardingWrapperTester().testForwarding(Foo.class, new Function<Foo, Foo>() {
public Foo apply(Foo foo) {
return new ForwardingFoo(foo);
}
});
Modifier and Type | Class and Description |
---|---|
private static class |
ForwardingWrapperTester.InteractionTester<T>
Tests a single interaction against a method.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
testsEquals |
Constructor and Description |
---|
ForwardingWrapperTester() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.reflect.Method[] |
getMostConcreteMethods(java.lang.Class<?> type)
Returns the most concrete public methods from
type . |
private static java.lang.Object[] |
getParameterValues(java.lang.reflect.Method method) |
ForwardingWrapperTester |
includingEquals()
Asks for
Object.equals(java.lang.Object) and Object.hashCode() to be tested. |
private static <T> void |
testEquals(java.lang.Class<T> interfaceType,
Function<? super T,? extends T> wrapperFunction) |
private static <T> void |
testExceptionPropagation(java.lang.Class<T> interfaceType,
java.lang.reflect.Method method,
Function<? super T,? extends T> wrapperFunction) |
<T> void |
testForwarding(java.lang.Class<T> interfaceType,
Function<? super T,? extends T> wrapperFunction)
Tests that the forwarding wrapper returned by
wrapperFunction properly forwards method
calls with parameters passed as is, return value returned as is, and exceptions propagated as
is. |
private static <T> void |
testSuccessfulForwarding(java.lang.Class<T> interfaceType,
java.lang.reflect.Method method,
Function<? super T,? extends T> wrapperFunction) |
private static <T> void |
testToString(java.lang.Class<T> interfaceType,
Function<? super T,? extends T> wrapperFunction) |
public ForwardingWrapperTester includingEquals()
Object.equals(java.lang.Object)
and Object.hashCode()
to be tested. That is, forwarding
wrappers of equal instances should be equal.public <T> void testForwarding(java.lang.Class<T> interfaceType, Function<? super T,? extends T> wrapperFunction)
wrapperFunction
properly forwards method
calls with parameters passed as is, return value returned as is, and exceptions propagated as
is.private static java.lang.reflect.Method[] getMostConcreteMethods(java.lang.Class<?> type)
type
.private static <T> void testSuccessfulForwarding(java.lang.Class<T> interfaceType, java.lang.reflect.Method method, Function<? super T,? extends T> wrapperFunction)
private static <T> void testExceptionPropagation(java.lang.Class<T> interfaceType, java.lang.reflect.Method method, Function<? super T,? extends T> wrapperFunction)
private static <T> void testEquals(java.lang.Class<T> interfaceType, Function<? super T,? extends T> wrapperFunction)
private static <T> void testToString(java.lang.Class<T> interfaceType, Function<? super T,? extends T> wrapperFunction)
private static java.lang.Object[] getParameterValues(java.lang.reflect.Method method)