KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > ExpectationValue


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