1 3 package org.jmock.core; 4 5 import junit.framework.AssertionFailedError; 6 7 8 public class DynamicMockError 9 extends AssertionFailedError 10 { 11 public final DynamicMock dynamicMock; 12 public final Invocation invocation; 13 public final InvocationDispatcher dispatcher; 14 15 public DynamicMockError( DynamicMock dynamicMock, 16 Invocation invocation, 17 InvocationDispatcher dispatcher, String message ) { 18 super(message); 19 this.dynamicMock = dynamicMock; 20 this.invocation = invocation; 21 this.dispatcher = dispatcher; 22 } 23 24 public StringBuffer writeTo( StringBuffer buffer ) { 25 buffer.append(dynamicMock.toString()).append(": ") 26 .append(super.getMessage()).append("\n"); 27 buffer.append("Invoked: "); 28 invocation.describeTo(buffer); 29 buffer.append("\n"); 30 buffer.append("Allowed:\n"); 31 dispatcher.describeTo(buffer); 32 return buffer; 33 } 34 35 public String getMessage() { 36 return writeTo(new StringBuffer ()).toString(); 37 } 38 } 39 | Popular Tags |