KickJava   Java API By Example, From Geeks To Geeks.

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


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.DynAnyFactoryComponentAdapter;
29 import org.jacorb.notification.container.RepositoryComponentAdapter;
30 import org.jacorb.notification.engine.DefaultTaskExecutor;
31 import org.jacorb.notification.engine.TaskExecutor;
32 import org.jacorb.notification.servant.IEventChannel;
33 import org.jacorb.notification.servant.TypedConsumerAdminImpl;
34 import org.jacorb.test.notification.NotificationTestCase;
35 import org.jacorb.test.notification.NotificationTestCaseSetup;
36 import org.omg.CORBA.IntHolder JavaDoc;
37 import org.omg.CosNotifyChannelAdmin.ConsumerAdmin;
38 import org.omg.CosTypedNotifyChannelAdmin.TypedConsumerAdmin;
39 import org.omg.CosTypedNotifyChannelAdmin.TypedConsumerAdminHelper;
40 import org.omg.CosTypedNotifyChannelAdmin.TypedProxyPullSupplier;
41 import org.omg.CosTypedNotifyChannelAdmin.TypedProxyPushSupplier;
42 import org.picocontainer.MutablePicoContainer;
43
44 /**
45  * @author Alphonse Bendt
46  * @version $Id: TypedConsumerAdminImplTest.java,v 1.7 2005/05/04 17:32:29 alphonse.bendt Exp $
47  */

48
49 public class TypedConsumerAdminImplTest extends NotificationTestCase
50 {
51     private TypedConsumerAdminImpl objectUnderTest_;
52
53     private TypedConsumerAdmin consumerAdmin_;
54
55     private MutablePicoContainer container_;
56     
57     public TypedConsumerAdminImplTest(String JavaDoc name, NotificationTestCaseSetup setup)
58     {
59         super(name, setup);
60     }
61
62     public void setUpTest() throws Exception JavaDoc
63     {
64         container_ = getPicoContainer();
65
66         container_.registerComponentInstance(new OfferManager());
67         container_.registerComponentInstance(new SubscriptionManager());
68         
69         MockControl controlChannel = MockControl.createControl(IEventChannel.class);
70         IEventChannel mockChannel = (IEventChannel) controlChannel.getMock();
71
72         mockChannel.getEventChannel();
73         controlChannel.setReturnValue(getDefaultChannel());
74
75         mockChannel.getContainer();
76         controlChannel.setReturnValue(container_);
77
78         mockChannel.getAdminID();
79         controlChannel.setReturnValue(10);
80
81         mockChannel.getChannelID();
82         controlChannel.setReturnValue(20);
83
84         controlChannel.replay();
85
86         objectUnderTest_ = new TypedConsumerAdminImpl(getORB(), getPOA(), getConfiguration(),
87                 getMessageFactory(), (OfferManager) container_
88                         .getComponentInstance(OfferManager.class), (SubscriptionManager) container_
89                         .getComponentInstance(SubscriptionManager.class), mockChannel);
90
91         consumerAdmin_ = TypedConsumerAdminHelper.narrow(objectUnderTest_.activate());
92     }
93
94     public void testContainer()
95     {
96         assertNotNull(container_.getComponentInstance(ConsumerAdmin.class));
97     }
98     
99     public void testIDs()
100     {
101         assertEquals(10, consumerAdmin_.MyID());
102     }
103
104     public void testMyChannel() throws Exception JavaDoc
105     {
106         assertEquals(getDefaultChannel(), consumerAdmin_.MyChannel());
107     }
108
109     public void testCreateTypedPullSupplier() throws Exception JavaDoc
110     {
111         IntHolder JavaDoc id = new IntHolder JavaDoc();
112
113         TypedProxyPullSupplier supplier = consumerAdmin_.obtain_typed_notification_pull_supplier(
114                 PullCoffeeHelper.id(), id);
115
116         assertEquals(supplier, consumerAdmin_.get_proxy_supplier(id.value));
117         
118         assertEquals(supplier, supplier.MyAdmin().get_proxy_supplier(id.value));
119     }
120
121     public void testCreateTypedPushSupplier() throws Exception JavaDoc
122     {
123         IntHolder JavaDoc id = new IntHolder JavaDoc();
124
125         TypedProxyPushSupplier supplier = consumerAdmin_.obtain_typed_notification_push_supplier(
126                 CoffeeHelper.id(), id);
127
128         assertEquals(supplier, consumerAdmin_.get_proxy_supplier(id.value));
129         
130         assertEquals(supplier, supplier.MyAdmin().get_proxy_supplier(id.value));
131     }
132
133     public static Test suite() throws Exception JavaDoc
134     {
135         return NotificationTestCase.suite("TypedConsumerAdminImpl Tests",
136                 TypedConsumerAdminImplTest.class);
137     }
138 }
Popular Tags