1 package org.jacorb.test.notification; 2 3 23 24 import junit.framework.Test; 25 26 import org.jacorb.notification.impl.DefaultMessageFactory; 27 import org.jacorb.notification.interfaces.FilterStage; 28 import org.jacorb.notification.interfaces.Message; 29 import org.jacorb.notification.servant.AbstractProxyConsumerI; 30 import org.omg.CORBA.Any ; 31 import org.omg.CosNotification.EventHeader; 32 import org.omg.CosNotification.EventType; 33 import org.omg.CosNotification.FixedEventHeader; 34 import org.omg.CosNotification.Property; 35 import org.omg.CosNotification.StructuredEvent; 36 import org.omg.CosNotification.Timeout; 37 import org.omg.TimeBase.TimeTHelper; 38 39 42 43 public class TimeoutTest extends NotificationTestCase 44 { 45 DefaultMessageFactory messageFactory_; 46 StructuredEvent structuredEvent_; 47 48 public TimeoutTest (String name, NotificationTestCaseSetup setup) 49 { 50 super(name, setup); 51 } 52 53 54 public void setUpTest() throws Exception 55 { 56 messageFactory_ = new DefaultMessageFactory(getConfiguration()); 57 58 structuredEvent_ = new StructuredEvent(); 59 EventHeader _header = new EventHeader(); 60 FixedEventHeader _fixed = new FixedEventHeader(); 61 _fixed.event_name = "eventname"; 62 _fixed.event_type = new EventType("domain", "type"); 63 _header.fixed_header = _fixed; 64 _header.variable_header = new Property[0]; 65 66 structuredEvent_.header = _header; 67 68 structuredEvent_.filterable_data = new Property[0]; 69 70 structuredEvent_.remainder_of_body = getORB().create_any(); 71 } 72 73 public void tearDownTest() throws Exception 74 { 75 messageFactory_.dispose(); 76 } 77 78 public void testStructuredEventWithoutTimeoutProperty() throws Exception 79 { 80 Message _event = messageFactory_.newMessage(structuredEvent_); 81 assertTrue(!_event.hasTimeout()); 82 } 83 84 85 public void testAnyEventHasNoStopTime() throws Exception 86 { 87 Message _event = messageFactory_.newMessage(getORB().create_any()); 88 89 assertTrue(!_event.hasTimeout()); 90 } 91 92 93 public void testStructuredEventWithTimeoutProperty() throws Exception 94 { 95 structuredEvent_.header.variable_header = new Property[1]; 96 97 long _timeout = 1234L; 98 99 Any _any = getORB().create_any(); 100 101 TimeTHelper.insert(_any, _timeout); 102 103 structuredEvent_.header.variable_header[0] = new Property(Timeout.value, _any); 104 105 Message _event = messageFactory_.newMessage(structuredEvent_, 106 new AbstractProxyConsumerI() { 107 public boolean isStartTimeSupported() { 108 return true; 109 } 110 111 public boolean isTimeOutSupported() { 112 return true; 113 } 114 115 public FilterStage getFirstStage() { 116 return null; 117 } 118 }); 119 assertTrue(_event.hasTimeout()); 120 assertEquals(_timeout, _event.getTimeout()); 121 } 122 123 public static Test suite() throws Exception 124 { 125 return NotificationTestCase.suite(TimeoutTest.class); 126 } 127 } 128 | Popular Tags |