1 package org.jacorb.test.notification; 2 3 22 23 import junit.framework.Test; 24 25 import org.jacorb.notification.TypedEventMessage; 26 import org.jacorb.test.notification.typed.CoffeeHelper; 27 import org.omg.CORBA.Any ; 28 import org.omg.CosNotification.EventType; 29 import org.omg.CosNotification.EventTypeHelper; 30 import org.omg.CosNotification.Property; 31 import org.omg.CosNotification.PropertySeqHelper; 32 import org.omg.CosNotification.StructuredEvent; 33 34 38 public class TypedEventMessageTest extends NotificationTestCase 39 { 40 private static final Property[] EMPTY_PROPS = new Property[0]; 41 42 private TypedEventMessage objectUnderTest_; 43 44 private static String DRINKING_COFFEE_ID = "::org::jacorb::test::notification::typed::Coffee::drinking_coffee"; 45 46 public void setUpTest() throws Exception 47 { 48 objectUnderTest_ = new TypedEventMessage(); 49 } 50 51 public TypedEventMessageTest(String name, NotificationTestCaseSetup setup) 52 { 53 super(name, setup); 54 } 55 56 public void testToProperty() 57 { 58 objectUnderTest_.setTypedEvent(CoffeeHelper.id(), "drinking_coffee", EMPTY_PROPS); 59 60 Property[] _props = objectUnderTest_.toTypedEvent(); 61 62 assertEquals(1, _props.length); 63 assertEquals("event_type", _props[0].name); 64 65 EventType et = EventTypeHelper.extract(_props[0].value); 66 assertEquals(CoffeeHelper.id(), et.domain_name); 67 assertEquals("drinking_coffee", et.type_name); 68 } 69 70 public void testToAny() 71 { 72 objectUnderTest_.setTypedEvent(CoffeeHelper.id(), DRINKING_COFFEE_ID, EMPTY_PROPS); 73 74 Any _any = objectUnderTest_.toAny(); 75 76 assertEquals(PropertySeqHelper.type(), _any.type()); 77 78 Property[] _props = PropertySeqHelper.extract(_any); 79 80 assertEquals(1, _props.length); 81 82 assertEquals("operation", _props[0].name); 83 84 assertEquals(DRINKING_COFFEE_ID, _props[0].value.extract_string()); 85 } 86 87 public void testToStructured() 88 { 89 objectUnderTest_.setTypedEvent(CoffeeHelper.id(), DRINKING_COFFEE_ID, EMPTY_PROPS); 90 91 StructuredEvent _structEvent = objectUnderTest_.toStructuredEvent(); 92 93 assertEquals(1, _structEvent.filterable_data.length); 94 95 assertEquals("operation", _structEvent.filterable_data[0].name); 96 97 assertEquals(DRINKING_COFFEE_ID, _structEvent.filterable_data[0].value.extract_string()); 98 99 assertEquals("%TYPED", _structEvent.header.fixed_header.event_type.type_name); 100 } 101 102 public static Test suite() throws Exception 103 { 104 return NotificationTestCase.suite(TypedEventMessageTest.class); 105 } 106 } 107 | Popular Tags |