1 21 22 package org.jacorb.test.notification.container; 23 24 import junit.framework.Test; 25 import junit.framework.TestCase; 26 import junit.framework.TestSuite; 27 28 import org.easymock.MockControl; 29 import org.jacorb.notification.container.CORBAObjectComponentAdapter; 30 import org.omg.CosNotifyChannelAdmin.EventChannel; 31 import org.omg.CosNotifyChannelAdmin.EventChannelHelper; 32 import org.picocontainer.MutablePicoContainer; 33 import org.picocontainer.defaults.AssignabilityRegistrationException; 34 import org.picocontainer.defaults.DefaultPicoContainer; 35 36 40 public class CORBAObjectComponentAdapterTest extends TestCase 41 { 42 private MutablePicoContainer container; 43 44 private MockControl controlObject; 45 46 private org.omg.CORBA.Object mockObject; 47 48 protected void setUp() throws Exception 49 { 50 super.setUp(); 51 52 container = new DefaultPicoContainer(); 53 54 controlObject = MockControl.createControl(org.omg.CORBA.Object .class); 55 56 mockObject = (org.omg.CORBA.Object ) controlObject.getMock(); 57 } 58 59 public void testAddReference() 60 { 61 mockObject._is_a(""); 62 controlObject.setReturnValue(true); 63 64 controlObject.replay(); 65 66 container.registerComponent(new CORBAObjectComponentAdapter(org.omg.CORBA.Object .class, 67 mockObject)); 68 69 assertEquals(mockObject, container.getComponentInstance(org.omg.CORBA.Object .class)); 70 71 controlObject.verify(); 72 } 73 74 public void testAddWrongReference() 75 { 76 mockObject._is_a(EventChannelHelper.id()); 77 controlObject.setReturnValue(false); 78 79 controlObject.replay(); 80 try 81 { 82 new CORBAObjectComponentAdapter(EventChannel.class, mockObject); 83 fail(); 84 } catch (AssignabilityRegistrationException e) 85 { 86 } 88 controlObject.verify(); 89 } 90 91 public CORBAObjectComponentAdapterTest(String name) 92 { 93 super(name); 94 } 95 96 public static Test suite() 97 { 98 return new TestSuite(CORBAObjectComponentAdapterTest.class); 99 } 100 } | Popular Tags |