01: package net.sf.mockcreator;
02:
03: import net.sf.mockcreator.expectable.Ignore;
04:
05: public class VoidVoidClassTest extends TestCase {
06: MockVoidVoidClass mock;
07:
08: public VoidVoidClassTest(String name) {
09: super (name);
10: }
11:
12: public void setUp() throws Exception {
13: super .setUp();
14: mock = new MockVoidVoidClass();
15: }
16:
17: public RuntimeException th() {
18: return new IllegalArgumentException("oops");
19: }
20:
21: public void testExpect() throws Exception {
22: mock.expectVoidMethod();
23: mock.voidMethod();
24:
25: MockCore.verify();
26: }
27:
28: public void testExpectThrow() throws Exception {
29: mock.expectVoidMethod().throwable(th());
30:
31: try {
32: mock.voidMethod();
33: fail();
34: } catch (IllegalArgumentException ex) {
35: }
36:
37: MockCore.verify();
38: }
39:
40: public void testAccept() throws Exception {
41: mock.acceptAnotherMethod_int(new Integer(5));
42: mock.anotherMethod(5);
43:
44: MockCore.verify();
45: }
46:
47: public void testAcceptThrow() throws Exception {
48: mock.acceptAnotherMethod_int(new Ignore()).throwable(th());
49:
50: try {
51: mock.anotherMethod(5);
52: fail();
53: } catch (IllegalArgumentException ex) {
54: }
55:
56: MockCore.verify();
57: }
58:
59: public void testDummy() throws Exception {
60: mock.expectZeroOrMoreVoidMethod().throwable(th());
61:
62: try {
63: mock.voidMethod();
64: fail();
65: } catch (IllegalArgumentException ex) {
66: }
67:
68: try {
69: mock.voidMethod();
70: fail();
71: } catch (IllegalArgumentException ex) {
72: }
73:
74: MockCore.verify();
75: }
76: }
|