1 21 22 package org.jacorb.test.notification.servant; 23 24 import java.util.List ; 25 26 import junit.framework.Test; 27 28 import org.easymock.MockControl; 29 import org.jacorb.notification.OfferManager; 30 import org.jacorb.notification.SubscriptionManager; 31 import org.jacorb.notification.interfaces.Message; 32 import org.jacorb.notification.interfaces.MessageConsumer; 33 import org.jacorb.notification.servant.AbstractProxySupplier; 34 import org.jacorb.notification.servant.IAdmin; 35 import org.jacorb.test.notification.NotificationTestCase; 36 import org.jacorb.test.notification.NotificationTestCaseSetup; 37 import org.omg.CORBA.Object ; 38 import org.omg.CosNotifyChannelAdmin.ConsumerAdmin; 39 import org.omg.CosNotifyChannelAdmin.ProxyType; 40 import org.omg.PortableServer.POA ; 41 import org.omg.PortableServer.Servant ; 42 43 47 public class AbstractProxySupplierTest extends NotificationTestCase 48 { 49 private AbstractProxySupplier objectUnderTest_; 50 51 private MockControl controlMessage_; 52 53 private Message mockMessage_; 54 55 private MockControl controlClient_; 56 57 private org.omg.CORBA.Object mockClient_; 58 59 62 protected void setUpTest() throws Exception 63 { 64 MockControl controlIAdmin = MockControl.createControl(IAdmin.class); 65 IAdmin mockIAdmin = (IAdmin) controlIAdmin.getMock(); 66 67 mockIAdmin.getProxyID(); 68 controlIAdmin.setReturnValue(0); 69 70 mockIAdmin.isIDPublic(); 71 controlIAdmin.setReturnValue(false); 72 73 mockIAdmin.getContainer(); 74 controlIAdmin.setReturnValue(null); 75 76 controlIAdmin.replay(); 77 78 MockControl controlConsumerAdmin = MockControl.createControl(ConsumerAdmin.class); 79 ConsumerAdmin mockConsumerAdmin = (ConsumerAdmin) controlConsumerAdmin.getMock(); 80 81 MockControl controlPOA = MockControl.createNiceControl(POA .class); 82 POA mockPOA = (POA ) controlPOA.getMock(); 83 84 objectUnderTest_ = new AbstractProxySupplier(mockIAdmin, getORB(), mockPOA, 85 getConfiguration(), getTaskProcessor(), new OfferManager(), 86 new SubscriptionManager(), mockConsumerAdmin) 87 { 88 protected long getCost() 89 { 90 return 0; 91 } 92 93 public ProxyType MyType() 94 { 95 return ProxyType.PULL_ANY; 96 } 97 98 protected void disconnectClient() 99 { 100 } 102 103 protected Servant getServant() 104 { 105 return null; 106 } 107 108 public void deliverPendingData() 109 { 110 } 112 113 public MessageConsumer getMessageConsumer() 114 { 115 return null; 116 } 117 118 public List getSubsequentFilterStages() 119 { 120 return null; 121 } 122 123 public Object activate() 124 { 125 return null; 126 } 127 }; 128 129 controlMessage_ = MockControl.createControl(Message.class); 130 mockMessage_ = (Message) controlMessage_.getMock(); 131 132 controlClient_ = MockControl.createControl(org.omg.CORBA.Object .class); 133 mockClient_ = (org.omg.CORBA.Object ) controlClient_.getMock(); 134 } 135 136 public AbstractProxySupplierTest(String name, NotificationTestCaseSetup setup) 137 { 138 super(name, setup); 139 } 140 141 public void testNotConnectedSupplierDoesNotAccessMessage() 142 { 143 controlMessage_.replay(); 144 145 objectUnderTest_.deliverMessage(mockMessage_); 146 147 controlMessage_.verify(); 148 } 149 150 public void testConnectedSupplierDoesCloneMessage() 151 { 152 mockMessage_.clone(); 153 controlMessage_.setReturnValue(mockMessage_); 154 155 controlMessage_.replay(); 156 157 controlClient_.replay(); 158 159 objectUnderTest_.connectClient(mockClient_); 160 161 objectUnderTest_.deliverMessage(mockMessage_); 162 163 controlMessage_.verify(); 164 } 165 166 public void testDisposeDisposesPendingMessages() throws Exception 167 { 168 mockMessage_.clone(); 169 controlMessage_.setReturnValue(mockMessage_); 170 171 mockMessage_.dispose(); 172 controlMessage_.replay(); 173 174 objectUnderTest_.connectClient(mockClient_); 175 objectUnderTest_.deliverMessage(mockMessage_); 176 objectUnderTest_.dispose(); 177 178 controlMessage_.verify(); 179 } 180 181 public static Test suite() throws Exception 182 { 183 return NotificationTestCase.suite(AbstractProxySupplierTest.class); 184 } 185 } 186 | Popular Tags |