KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > engine > PushOperationTest


1 package org.jacorb.test.notification.engine;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2003 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25
26 import org.easymock.MockControl;
27 import org.jacorb.notification.engine.MessagePushOperation;
28 import org.jacorb.notification.interfaces.Message;
29
30 /**
31  * @author Alphonse Bendt
32  * @version $Id: PushOperationTest.java,v 1.6 2005/04/17 17:18:30 alphonse.bendt Exp $
33  */

34 public class PushOperationTest extends TestCase
35 {
36     static class MockPushOperation extends MessagePushOperation
37     {
38         int pushInvoked = 0;
39
40         public MockPushOperation(Message message)
41         {
42             super(message);
43         }
44
45         public void invokePush()
46         {
47             ++pushInvoked;
48         }
49     }
50
51     public PushOperationTest(String JavaDoc name)
52     {
53         super(name);
54     }
55
56     public void testCreateDispose()
57     {
58         MockControl controlMessage = MockControl.createControl(Message.class);
59         Message mockMessage = (Message) controlMessage.getMock();
60
61         MockControl controlMessage2 = MockControl.createControl(Message.class);
62         Message mockMessage2 = (Message) controlMessage.getMock();
63
64         mockMessage.clone();
65         controlMessage.setReturnValue(mockMessage2);
66
67         mockMessage2.dispose();
68
69         controlMessage2.replay();
70         controlMessage.replay();
71
72         MockPushOperation operation = new MockPushOperation(mockMessage);
73         operation.dispose();
74
75         controlMessage2.verify();
76         controlMessage.verify();
77     }
78
79     public static TestSuite suite()
80     {
81         TestSuite suite = new TestSuite(PushOperationTest.class);
82
83         return suite;
84     }
85
86     public static void main(String JavaDoc[] args)
87     {
88         junit.textui.TestRunner.run(suite());
89     }
90 }
Popular Tags