1 package org.jacorb.test.notification; 2 3 22 23 import junit.framework.Test; 24 25 import org.jacorb.notification.NoTranslationException; 26 import org.jacorb.notification.StructuredEventMessage; 27 import org.omg.CosNotification.Property; 28 import org.omg.CosNotification.StructuredEvent; 29 30 34 public class StructuredEventMessageTest extends NotificationTestCase 35 { 36 private StructuredEventMessage objectUnderTest_; 37 38 private StructuredEvent structuredEvent_; 39 40 public StructuredEventMessageTest(String name, NotificationTestCaseSetup setup) 41 { 42 super(name, setup); 43 } 44 45 public void setUpTest() throws Exception 46 { 47 objectUnderTest_ = new StructuredEventMessage(); 48 structuredEvent_ = getTestUtils().getEmptyStructuredEvent(); 49 } 50 51 public void testToTypedEvent() throws Exception 52 { 53 Property[] _props1 = new Property[] { new Property("operation", toAny("operationName")), 54 new Property("p1", toAny("param1")), new Property("p2", toAny(20)) }; 55 56 structuredEvent_.filterable_data = _props1; 57 58 objectUnderTest_.setStructuredEvent(structuredEvent_, false, false); 59 60 Property[] _props2 = objectUnderTest_.toTypedEvent(); 61 62 assertEquals("operation", _props2[0].name); 63 assertEquals("operationName", _props2[0].value.extract_string()); 64 } 65 66 public void testToTypedEvent_FailedConversion() 67 { 68 Property[] _props = new Property[] { new Property("p1", toAny("param1")), 69 new Property("p2", toAny(20)) }; 70 71 structuredEvent_.filterable_data = _props; 72 73 objectUnderTest_.setStructuredEvent(structuredEvent_, false, false); 74 75 try 76 { 77 objectUnderTest_.toTypedEvent(); 78 fail(); 79 } catch (NoTranslationException e) 80 { 81 } 83 } 84 85 public static Test suite() throws Exception 86 { 87 return NotificationTestCase.suite(StructuredEventMessageTest.class); 88 } 89 } | Popular Tags |