Package com.google.common.testing
Class ForwardingWrapperTester
java.lang.Object
com.google.common.testing.ForwardingWrapperTester
Tester to ensure forwarding wrapper works by delegating calls to the corresponding method with
the same parameters forwarded and return value forwarded back or exception propagated as is.
For example:
new ForwardingWrapperTester().testForwarding(Foo.class, new Function<Foo, Foo>() {
public Foo apply(Foo foo) {
return new ForwardingFoo(foo);
}
});
- Since:
- 14.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classTests a single interaction against a method. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Method[]getMostConcreteMethods(Class<?> type) Returns the most concrete public methods fromtype.private static Object[]getParameterValues(Method method) Asks forObject.equals(java.lang.Object)andObject.hashCode()to be tested.private static <T> voidtestEquals(Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) private static <T> voidtestExceptionPropagation(Class<T> interfaceType, Method method, Function<? super T, ? extends T> wrapperFunction) <T> voidtestForwarding(Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) Tests that the forwarding wrapper returned bywrapperFunctionproperly forwards method calls with parameters passed as is, return value returned as is, and exceptions propagated as is.private static <T> voidtestSuccessfulForwarding(Class<T> interfaceType, Method method, Function<? super T, ? extends T> wrapperFunction) private static <T> voidtestToString(Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction)
-
Field Details
-
testsEquals
private boolean testsEquals
-
-
Constructor Details
-
ForwardingWrapperTester
public ForwardingWrapperTester()
-
-
Method Details
-
includingEquals
Asks forObject.equals(java.lang.Object)andObject.hashCode()to be tested. That is, forwarding wrappers of equal instances should be equal. -
testForwarding
public <T> void testForwarding(Class<T> interfaceType, Function<? super T, ? extends T> wrapperFunction) Tests that the forwarding wrapper returned bywrapperFunctionproperly forwards method calls with parameters passed as is, return value returned as is, and exceptions propagated as is. -
getMostConcreteMethods
Returns the most concrete public methods fromtype. -
testSuccessfulForwarding
-
testExceptionPropagation
-
testEquals
-
testToString
-
getParameterValues
-