KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mockobjects > TestReturnValue


1 package test.mockobjects;
2
3 import com.mockobjects.util.TestCaseMo;
4 import com.mockobjects.ReturnValue;
5 import junit.framework.AssertionFailedError;
6
7
8 public class TestReturnValue extends TestCaseMo {
9     private final ReturnValue value = new ReturnValue(getName());
10
11     public void testGetNull(){
12         value.setValue(null);
13         assertTrue(value.getValue()==null);
14     }
15
16     public void testGetValue(){
17         value.setValue(this);
18         assertEquals(this, value.getValue());
19     }
20
21     public void testGetBooleanValue(){
22         value.setValue(true);
23         assertTrue(value.getBooleanValue());
24     }
25
26     public void testIntValue(){
27         value.setValue(13);
28         assertEquals(13, value.getIntValue());
29     }
30
31     public void testLongValue(){
32         long now = System.currentTimeMillis();
33         value.setValue(now);
34         assertEquals(now, value.getLongValue());
35         value.getIntValue();
36     }
37
38     public void testValueNotSet() {
39         try {
40             value.getValue();
41             fail("Error not thrown");
42         } catch (AssertionFailedError e) {
43             assertEquals("The return value \"" + getName() + "\" has not been set.", e.getMessage());
44         }
45     }
46
47     public TestReturnValue(String JavaDoc name) {
48         super(name);
49     }
50
51     public static void main(String JavaDoc[] args) {
52         start(new String JavaDoc[] { TestReturnValue.class.getName()});
53     }
54
55 }
56
Popular Tags