KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > expectation > ExpectationValue


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

3 package org.jmock.expectation;
4
5
6 public class ExpectationValue extends AbstractExpectation
7 {
8     private Object JavaDoc myExpectedValue;
9     private Object JavaDoc myActualValue;
10
11     public ExpectationValue( String JavaDoc name ) {
12         super(name);
13         clearActual();
14     }
15
16     public void clearActual() {
17         myActualValue = new Null("Nothing");
18     }
19
20     public void setActual( int aValue ) {
21         setActual(new Integer JavaDoc(aValue));
22     }
23
24     public void setActual( long aValue ) {
25         setActual(new Long JavaDoc(aValue));
26     }
27
28     public void setActual( double aValue ) {
29         setActual(new Double JavaDoc(aValue));
30     }
31
32     public void setActual( Object JavaDoc aValue ) {
33         myActualValue = aValue;
34         if (shouldCheckImmediately()) {
35             verify();
36         }
37     }
38
39     public void setActual( boolean aValue ) {
40         setActual(new Boolean JavaDoc(aValue));
41     }
42
43     public void setExpected( int aValue ) {
44         setExpected(new Integer JavaDoc(aValue));
45     }
46
47     public void setExpected( long aValue ) {
48         setExpected(new Long JavaDoc(aValue));
49     }
50
51     public void setExpected( double aValue ) {
52         setExpected(new Double JavaDoc(aValue));
53     }
54
55     public void setExpected( Object JavaDoc aValue ) {
56         myExpectedValue = aValue;
57         setHasExpectations();
58     }
59
60     public void setExpected( boolean aValue ) {
61         setExpected(new Boolean JavaDoc(aValue));
62     }
63
64     public void setExpectNothing() {
65         setExpected(new Null("Nothing"));
66         myActualValue = myExpectedValue;
67     }
68
69     public void verify() {
70         assertEquals("did not receive the expected Value.",
71                      myExpectedValue,
72                      myActualValue);
73     }
74 }
75
Popular Tags