KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > typed > TypedSupplierAdminImplTest


1 package org.jacorb.test.notification.typed;
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.Test;
24
25 import org.easymock.MockControl;
26 import org.jacorb.notification.OfferManager;
27 import org.jacorb.notification.SubscriptionManager;
28 import org.jacorb.notification.container.RepositoryComponentAdapter;
29 import org.jacorb.notification.servant.IEventChannel;
30 import org.jacorb.notification.servant.TypedSupplierAdminImpl;
31 import org.jacorb.test.notification.NotificationTestCase;
32 import org.jacorb.test.notification.NotificationTestCaseSetup;
33 import org.omg.CORBA.IntHolder JavaDoc;
34 import org.omg.CosTypedNotifyChannelAdmin.TypedProxyPullConsumer;
35 import org.omg.CosTypedNotifyChannelAdmin.TypedProxyPushConsumer;
36 import org.omg.CosTypedNotifyChannelAdmin.TypedSupplierAdmin;
37 import org.omg.CosTypedNotifyChannelAdmin.TypedSupplierAdminHelper;
38 import org.picocontainer.MutablePicoContainer;
39
40 /**
41  * @author Alphonse Bendt
42  * @version $Id: TypedSupplierAdminImplTest.java,v 1.7 2005/05/04 17:32:29 alphonse.bendt Exp $
43  */

44 public class TypedSupplierAdminImplTest extends NotificationTestCase
45 {
46     private TypedSupplierAdminImpl objectUnderTest_;
47
48     private TypedSupplierAdmin supplierAdmin_;
49
50     private MutablePicoContainer container_;
51
52     public TypedSupplierAdminImplTest(String JavaDoc name, NotificationTestCaseSetup setup)
53     {
54         super(name, setup);
55     }
56
57     public void setUpTest() throws Exception JavaDoc
58     {
59         container_ = getPicoContainer();
60
61         container_.registerComponentInstance(new OfferManager());
62
63         container_.registerComponentInstance(new SubscriptionManager());
64
65         container_.registerComponent(new RepositoryComponentAdapter());
66         
67         MockControl controlChannel = MockControl.createControl(IEventChannel.class);
68         IEventChannel mockChannel = (IEventChannel) controlChannel.getMock();
69
70         mockChannel.getEventChannel();
71         controlChannel.setReturnValue(getDefaultChannel());
72
73         mockChannel.getContainer();
74         controlChannel.setReturnValue(container_);
75
76         mockChannel.getAdminID();
77         controlChannel.setReturnValue(10);
78
79         mockChannel.getChannelID();
80         controlChannel.setReturnValue(20);
81
82         controlChannel.replay();
83
84         objectUnderTest_ = new TypedSupplierAdminImpl(mockChannel, getORB(), getPOA(),
85                 getConfiguration(), getMessageFactory(), (OfferManager) container_
86                         .getComponentInstance(OfferManager.class), (SubscriptionManager) container_
87                         .getComponentInstance(SubscriptionManager.class));
88
89         supplierAdmin_ = TypedSupplierAdminHelper.narrow(objectUnderTest_.activate());
90     }
91
92     public void testMyChannel() throws Exception JavaDoc
93     {
94         assertEquals(getDefaultChannel(), supplierAdmin_.MyChannel());
95     }
96
97     public void testCreatePushConsumer() throws Exception JavaDoc
98     {
99         IntHolder JavaDoc id = new IntHolder JavaDoc();
100
101         TypedProxyPushConsumer consumer = supplierAdmin_.obtain_typed_notification_push_consumer(
102                 CoffeeHelper.id(), id);
103
104         assertEquals(consumer, supplierAdmin_.get_proxy_consumer(id.value));
105     }
106
107     public void testCreatePullConsumer() throws Exception JavaDoc
108     {
109         IntHolder JavaDoc id = new IntHolder JavaDoc();
110
111         TypedProxyPullConsumer consumer = supplierAdmin_.obtain_typed_notification_pull_consumer(
112                 PullCoffeeHelper.id(), id);
113
114         assertEquals(consumer, supplierAdmin_.get_proxy_consumer(id.value));
115     }
116
117     public static Test suite() throws Exception JavaDoc
118     {
119         return NotificationTestCase.suite("TypedSupplierAdminImpl Tests",
120                 TypedSupplierAdminImplTest.class);
121     }
122 }
Popular Tags