KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > jmock > builder > testsupport > MockMatchBuilder


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

3 package test.jmock.builder.testsupport;
4
5 import org.jmock.builder.BuilderNamespace;
6 import org.jmock.builder.IdentityBuilder;
7 import org.jmock.builder.MatchBuilder;
8 import org.jmock.core.InvocationMatcher;
9 import org.jmock.core.Stub;
10 import org.jmock.core.Verifiable;
11 import org.jmock.expectation.ExpectationCounter;
12 import org.jmock.expectation.ExpectationValue;
13 import org.jmock.util.Verifier;
14
15
16 public class MockMatchBuilder
17         implements MatchBuilder, Verifiable
18 {
19     ExpectationValue addedExpectationType = new ExpectationValue("added expectation type");
20
21     public IdentityBuilder isVoid() {
22         throw new NoSuchMethodError JavaDoc("isVoid not implemented");
23     }
24
25     public MatchBuilder match( InvocationMatcher customMatcher ) {
26         throw new NoSuchMethodError JavaDoc("match not implemented");
27     }
28
29     public IdentityBuilder stub( Stub customStub ) {
30         throw new NoSuchMethodError JavaDoc("stub not implemented");
31     }
32
33     public IdentityBuilder will( Stub stubAction ) {
34         throw new NoSuchMethodError JavaDoc("will not implemented");
35     }
36
37     public IdentityBuilder willReturn( boolean result ) {
38         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
39     }
40
41     public IdentityBuilder willReturn( byte result ) {
42         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
43     }
44
45     public IdentityBuilder willReturn( char result ) {
46         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
47     }
48
49     public IdentityBuilder willReturn( double result ) {
50         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
51     }
52
53     public IdentityBuilder willReturn( float result ) {
54         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
55     }
56
57     public IdentityBuilder willReturn( int result ) {
58         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
59     }
60
61     public IdentityBuilder willReturn( long result ) {
62         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
63     }
64
65     public IdentityBuilder willReturn( Object JavaDoc result ) {
66         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
67     }
68
69     public IdentityBuilder willReturn( short result ) {
70         throw new NoSuchMethodError JavaDoc("willReturn not implemented");
71     }
72
73     public IdentityBuilder willThrow( Throwable JavaDoc throwable ) {
74         throw new NoSuchMethodError JavaDoc("willThrow not implemented");
75     }
76
77     public IdentityBuilder expect( InvocationMatcher expectation ) {
78         addedExpectationType.setActual(expectation.getClass());
79         return this;
80     }
81
82     public IdentityBuilder addExpectation( InvocationMatcher expectation ) {
83         addedExpectationType.setActual(expectation.getClass());
84         return this;
85     }
86
87
88     ExpectationCounter expectOnceCalls = new ExpectationCounter("expectOnce #calls");
89
90     public IdentityBuilder expectOnce() {
91         expectOnceCalls.inc();
92         return this;
93     }
94
95     ExpectationCounter expectAtLeastOnceCalls = new ExpectationCounter("expectAtLeastOnce #calls");
96
97     public IdentityBuilder expectAtLeastOnce() {
98         expectAtLeastOnceCalls.inc();
99         return this;
100     }
101
102     ExpectationValue expectAfterPreviousCall = new ExpectationValue("expectAfter previousCall");
103
104     public IdentityBuilder expectAfter( IdentityBuilder previousCall ) {
105         expectAfterPreviousCall.setExpected(previousCall);
106         return this;
107     }
108
109
110     public ExpectationValue afterMock = new ExpectationValue("after mock");
111     public ExpectationValue afterPreviousCallID = new ExpectationValue("after previousCallID");
112
113     public MatchBuilder after( String JavaDoc previousCallID ) {
114         afterPreviousCallID.setActual(previousCallID);
115         return this;
116     }
117
118     public MatchBuilder after( BuilderNamespace otherMock, String JavaDoc previousCallID ) {
119         afterMock.setActual(otherMock);
120         return after(previousCallID);
121     }
122
123     public ExpectationValue id = new ExpectationValue("id");
124
125     public void id( String JavaDoc newID ) {
126         id.setActual(newID);
127     }
128
129     public ExpectationCounter expectNotCalledCalls =
130             new ExpectationCounter("expectNotCalled #calls");
131
132     public IdentityBuilder expectNotCalled() {
133         expectNotCalledCalls.inc();
134         return this;
135     }
136
137     public void verify() {
138         Verifier.verifyObject(this);
139     }
140
141
142 }
143
Popular Tags