1 21 22 package org.jacorb.test.notification.typed; 23 24 import java.util.Properties ; 25 26 import junit.framework.Test; 27 import junit.framework.TestCase; 28 import junit.framework.TestSuite; 29 30 import org.jacorb.notification.AbstractChannelFactory; 31 import org.jacorb.notification.conf.Attributes; 32 import org.omg.CORBA.IntHolder ; 33 import org.omg.CosNotification.Property; 34 import org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator; 35 import org.omg.CosTypedEventChannelAdmin.TypedConsumerAdmin; 36 import org.omg.CosTypedEventChannelAdmin.TypedSupplierAdmin; 37 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannel; 38 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactory; 39 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactoryHelper; 40 41 45 public class TypedEventChannelTest extends TestCase 46 { 47 private TypedEventChannelFactory typedChannelFactory_; 48 private TypedEventChannel objectUnderTest_; 49 private AbstractChannelFactory servant_; 50 51 54 protected void setUp() throws Exception 55 { 56 super.setUp(); 57 58 Properties props = new Properties (); 59 props.put(Attributes.ENABLE_TYPED_CHANNEL, "on"); 60 61 servant_ = AbstractChannelFactory.newFactory(props); 62 org.omg.CORBA.Object obj = servant_.activate(); 63 64 typedChannelFactory_ = TypedEventChannelFactoryHelper.narrow(obj); 65 66 objectUnderTest_ = typedChannelFactory_.create_typed_channel(new Property[0], 67 new Property[0], new IntHolder ()); 68 } 69 70 73 protected void tearDown() throws Exception 74 { 75 super.tearDown(); 76 77 servant_.destroy(); 78 } 79 80 85 public TypedEventChannelTest(String name) 86 { 87 super(name); 88 } 89 90 public void testCreateTypedEventChannel() throws Exception 91 { 92 IntHolder id = new IntHolder (); 93 TypedEventChannel channel = typedChannelFactory_.create_typed_channel(new Property[0], 94 new Property[0], id); 95 96 assertEquals(typedChannelFactory_, channel.MyFactory()); 97 } 98 99 public void testForConsumers() throws Exception 100 { 101 TypedConsumerAdmin admin = objectUnderTest_.for_consumers(); 102 assertNotNull(admin); 103 } 104 105 public void testForSuppliers() throws Exception 106 { 107 TypedSupplierAdmin admin = objectUnderTest_.for_suppliers(); 108 assertNotNull(admin); 109 } 110 111 public void testDefaults() throws Exception 112 { 113 assertNotNull(objectUnderTest_.default_consumer_admin()); 114 assertNotNull(objectUnderTest_.default_supplier_admin()); 115 assertNotNull(objectUnderTest_.default_filter_factory()); 116 } 117 118 public void testCreateConsumerAdmin() throws Exception 119 { 120 IntHolder id = new IntHolder (); 121 122 org.omg.CosTypedNotifyChannelAdmin.TypedConsumerAdmin admin = objectUnderTest_.new_for_typed_notification_consumers(InterFilterGroupOperator.OR_OP, id); 123 124 int[] ids = objectUnderTest_.get_all_consumeradmins(); 125 126 assertEquals(1, ids.length); 127 assertEquals(id.value, ids[0]); 128 129 assertEquals(admin, objectUnderTest_.get_consumeradmin(id.value)); 130 } 131 132 public void testCreateSupplierAdmin() throws Exception 133 { 134 IntHolder id = new IntHolder (); 135 136 org.omg.CosTypedNotifyChannelAdmin.TypedSupplierAdmin admin = objectUnderTest_.new_for_typed_notification_suppliers(InterFilterGroupOperator.OR_OP, id); 137 138 int[] ids = objectUnderTest_.get_all_supplieradmins(); 139 140 assertEquals(1, ids.length); 141 assertEquals(id.value, ids[0]); 142 143 assertEquals(admin, objectUnderTest_.get_supplieradmin(id.value)); 144 } 145 146 public static Test suite() 147 { 148 return new TestSuite(TypedEventChannelTest.class); 149 } 150 } 151 | Popular Tags |