1 3 package test.jmock.core.testsupport; 4 5 import org.jmock.core.Invocation; 6 import org.jmock.core.Stub; 7 import org.jmock.core.Verifiable; 8 import org.jmock.expectation.ExpectationValue; 9 import org.jmock.util.Verifier; 10 11 12 public class MockStub 13 implements Stub, Verifiable 14 { 15 private String name; 16 17 public MockStub() { 18 this("mockStub"); 19 } 20 21 public MockStub( String name ) { 22 this.name = name; 23 } 24 25 public String toString() { 26 return name; 27 } 28 29 public ExpectationValue invokeInvocation = 30 new ExpectationValue("invoke invocation"); 31 public Object invokeResult; 32 33 public Object invoke( Invocation invocation ) throws Throwable { 34 invokeInvocation.setActual(invocation); 35 return invokeResult; 36 } 37 38 39 public ExpectationValue describeToBuffer = new ExpectationValue("describeTo buffer"); 40 public String describeToOutput = ""; 41 42 public StringBuffer describeTo( StringBuffer buffer ) { 43 describeToBuffer.setActual(buffer); 44 buffer.append(describeToOutput); 45 return buffer; 46 } 47 48 public void verify() { 49 Verifier.verifyObject(this); 50 } 51 } 52 | Popular Tags |