1 package org.jacorb.test.notification.typed; 2 3 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 ; 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 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 name, NotificationTestCaseSetup setup) 58 { 59 super(name, setup); 60 } 61 62 public void setUpTest() throws Exception 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 105 { 106 assertEquals(getDefaultChannel(), consumerAdmin_.MyChannel()); 107 } 108 109 public void testCreateTypedPullSupplier() throws Exception 110 { 111 IntHolder id = new IntHolder (); 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 122 { 123 IntHolder id = new IntHolder (); 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 134 { 135 return NotificationTestCase.suite("TypedConsumerAdminImpl Tests", 136 TypedConsumerAdminImplTest.class); 137 } 138 } | Popular Tags |