1 21 22 package org.jacorb.test.notification.servant; 23 24 import junit.framework.Test; 25 26 import org.easymock.MockControl; 27 import org.jacorb.notification.OfferManager; 28 import org.jacorb.notification.SubscriptionManager; 29 import org.jacorb.notification.engine.DefaultPushTaskExecutorFactory; 30 import org.jacorb.notification.engine.TaskProcessor; 31 import org.jacorb.notification.interfaces.Message; 32 import org.jacorb.notification.servant.IAdmin; 33 import org.jacorb.notification.servant.ProxyPushSupplierImpl; 34 import org.jacorb.test.notification.NotificationTestCase; 35 import org.jacorb.test.notification.NotificationTestCaseSetup; 36 import org.omg.CORBA.Any ; 37 import org.omg.CosNotifyChannelAdmin.ConsumerAdmin; 38 import org.omg.CosNotifyComm.PushConsumer; 39 40 44 public class ProxyPushSupplierImplTest extends NotificationTestCase 45 { 46 private MockControl controlTaskProcessor_; 47 48 private TaskProcessor mockTaskProcessor_; 49 50 private ProxyPushSupplierImpl objectUnderTest_; 51 52 57 public ProxyPushSupplierImplTest(String name, NotificationTestCaseSetup setup) 58 { 59 super(name, setup); 60 } 61 62 public void setUpTest() throws Exception 63 { 64 MockControl controlAdmin = MockControl.createControl(IAdmin.class); 65 IAdmin mockAdmin = (IAdmin) controlAdmin.getMock(); 66 67 mockAdmin.isIDPublic(); 68 controlAdmin.setReturnValue(true); 69 70 mockAdmin.getProxyID(); 71 controlAdmin.setReturnValue(10); 72 73 mockAdmin.getContainer(); 74 controlAdmin.setReturnValue(null); 75 76 controlAdmin.replay(); 77 78 MockControl controlConsumerAdmin = MockControl.createControl(ConsumerAdmin.class); 79 ConsumerAdmin mockConsumerAdmin = (ConsumerAdmin) controlConsumerAdmin.getMock(); 80 81 controlConsumerAdmin.replay(); 82 83 controlTaskProcessor_ = MockControl.createControl(TaskProcessor.class); 84 mockTaskProcessor_ = (TaskProcessor) controlTaskProcessor_.getMock(); 85 86 objectUnderTest_ = new ProxyPushSupplierImpl(mockAdmin, getORB(), getPOA(), 87 getConfiguration(), mockTaskProcessor_, new DefaultPushTaskExecutorFactory(1), new OfferManager(), 88 new SubscriptionManager(), mockConsumerAdmin); 89 90 assertEquals(new Integer (10), objectUnderTest_.getID()); 91 } 92 93 public void testDeliverMessage_Error() throws Exception 94 { 95 Any any = getORB().create_any(); 96 97 MockControl controlMessage = MockControl.createControl(Message.class); 98 Message mockMessage = (Message) controlMessage.getMock(); 99 100 mockMessage.toAny(); 101 controlMessage.setReturnValue(any); 102 103 mockMessage.clone(); 104 controlMessage.setReturnValue(mockMessage, 2); 105 106 mockMessage.dispose(); 107 108 controlMessage.replay(); 109 110 MockControl controlPushConsumer = MockControl.createControl(PushConsumer.class); 111 PushConsumer mockPushConsumer = (PushConsumer) controlPushConsumer.getMock(); 112 113 mockPushConsumer.push(any); 114 controlPushConsumer.setThrowable(new RuntimeException ()); 115 116 controlPushConsumer.replay(); 117 118 mockTaskProcessor_.executeTaskAfterDelay(0, null); 119 controlTaskProcessor_.setMatcher(MockControl.ALWAYS_MATCHER); 120 controlTaskProcessor_.setReturnValue(new Object ()); 121 122 mockTaskProcessor_.schedulePushOperation(objectUnderTest_); 123 124 controlTaskProcessor_.replay(); 125 126 objectUnderTest_.connect_any_push_consumer(mockPushConsumer); 127 objectUnderTest_.deliverMessage(mockMessage); 128 } 129 130 public static Test suite() throws Exception 131 { 132 return NotificationTestCase.suite(ProxyPushSupplierImplTest.class); 133 } 134 } | Popular Tags |