KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > core > DynamicMockError


1 /* Copyright (c) 2000-2004 jMock.org
2  */

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 JavaDoc message ) {
18         super(message);
19         this.dynamicMock = dynamicMock;
20         this.invocation = invocation;
21         this.dispatcher = dispatcher;
22     }
23
24     public StringBuffer JavaDoc writeTo( StringBuffer JavaDoc 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 JavaDoc getMessage() {
36         return writeTo(new StringBuffer JavaDoc()).toString();
37     }
38 }
39
Popular Tags