Class ForwardingWrapperTester

java.lang.Object
com.google.common.testing.ForwardingWrapperTester

public final class ForwardingWrapperTester extends Object
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
  • Field Details

    • testsEquals

      private boolean testsEquals
  • Constructor Details

    • ForwardingWrapperTester

      public ForwardingWrapperTester()
  • Method Details

    • includingEquals

      public ForwardingWrapperTester includingEquals()
      Asks for Object.equals(java.lang.Object) and Object.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 by wrapperFunction properly forwards method calls with parameters passed as is, return value returned as is, and exceptions propagated as is.
    • getMostConcreteMethods

      private static Method[] getMostConcreteMethods(Class<?> type)
      Returns the most concrete public methods from type.
    • testSuccessfulForwarding

      private static <T> void testSuccessfulForwarding(Class<T> interfaceType, Method method, Function<? super T,? extends T> wrapperFunction)
    • testExceptionPropagation

      private static <T> void testExceptionPropagation(Class<T> interfaceType, Method method, Function<? super T,? extends T> wrapperFunction)
    • testEquals

      private static <T> void testEquals(Class<T> interfaceType, Function<? super T,? extends T> wrapperFunction)
    • testToString

      private static <T> void testToString(Class<T> interfaceType, Function<? super T,? extends T> wrapperFunction)
    • getParameterValues

      private static Object[] getParameterValues(Method method)