Class CustomStub

  • All Implemented Interfaces:
    SelfDescribing, Stub

    public abstract class CustomStub
    extends java.lang.Object
    implements Stub
    A partial implementation of the Stub interface that makes it convenient to implement application-specific stubs with inline anonymous classes:
     final String name = "NAME";
     final StringBuffer buffer = new StringBuffer();
     

    mock.expect("describeTo", C.args(C.same(buffer))), new CustomStub("appends name to buffer") { public Object invoke( Invocation invocation ) throws Throwable { return buffer.append(name); } } );

    • Constructor Summary

      Constructors 
      Constructor Description
      CustomStub​(java.lang.String description)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StringBuffer describeTo​(java.lang.StringBuffer buffer)
      Appends the description of this object to the buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.jmock.core.Stub

        invoke
    • Constructor Detail

      • CustomStub

        public CustomStub​(java.lang.String description)
    • Method Detail

      • describeTo

        public java.lang.StringBuffer describeTo​(java.lang.StringBuffer buffer)
        Description copied from interface: SelfDescribing
        Appends the description of this object to the buffer.
        Specified by:
        describeTo in interface SelfDescribing
        Parameters:
        buffer - The buffer that the description is appended to.
        Returns:
        The buffer passed to the invokedMethod.