KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > jmock > core > stub > VoidStubTest


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

3 package test.jmock.core.stub;
4
5 import junit.framework.TestCase;
6 import org.jmock.core.Invocation;
7 import org.jmock.core.stub.VoidStub;
8 import test.jmock.core.testsupport.MethodFactory;
9
10
11 public class VoidStubTest
12         extends TestCase
13 {
14     Invocation invocation;
15     VoidStub voidStub;
16
17     public void setUp() {
18         MethodFactory methodFactory = new MethodFactory();
19         invocation = new Invocation("INVOKED-OBJECT", methodFactory.newMethodReturning(void.class), new Object JavaDoc[0]);
20         voidStub = new VoidStub();
21     }
22
23     public void testReturnsNullWhenInvoked() throws Throwable JavaDoc {
24         assertNull("Should return null",
25                    new VoidStub().invoke(invocation));
26     }
27
28     public void testIncludesVoidInDescription() {
29         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
30
31         voidStub.describeTo(buffer);
32
33         String JavaDoc description = buffer.toString();
34
35         assertTrue("contains 'void' in description",
36                    description.indexOf("void") >= 0);
37     }
38 }
39
Popular Tags