Class MockFutureListener

  • All Implemented Interfaces:
    java.lang.Runnable

    @Beta
    @GwtIncompatible
    public class MockFutureListener
    extends java.lang.Object
    implements java.lang.Runnable
    A simple mock implementation of Runnable that can be used for testing ListenableFutures.
    Since:
    10.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assertException​(java.lang.Throwable expectedCause)
      Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws an ExecutableException and that the cause of the ExecutableException is expectedCause.
      void assertSuccess​(java.lang.Object expectedData)
      Verify that the listener completes in a reasonable amount of time, and Asserts that the future returns the expected data.
      void assertTimeout()  
      void run()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • assertSuccess

        public void assertSuccess​(java.lang.Object expectedData)
                           throws java.lang.Throwable
        Verify that the listener completes in a reasonable amount of time, and Asserts that the future returns the expected data.
        Throws:
        java.lang.Throwable - if the listener isn't called or if it resulted in a throwable or if the result doesn't match the expected value.
      • assertException

        public void assertException​(java.lang.Throwable expectedCause)
                             throws java.lang.Exception
        Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws an ExecutableException and that the cause of the ExecutableException is expectedCause.
        Throws:
        java.lang.Exception
      • assertTimeout

        public void assertTimeout()
                           throws java.lang.Exception
        Throws:
        java.lang.Exception