1 package org.jacorb.test.notification; 2 3 import junit.framework.Test; 4 5 import org.jacorb.notification.util.QoSPropertySet; 6 import org.omg.CORBA.Any ; 7 import org.omg.CosNotification.BestEffort; 8 import org.omg.CosNotification.ConnectionReliability; 9 import org.omg.CosNotification.DiscardPolicy; 10 import org.omg.CosNotification.FifoOrder; 11 import org.omg.CosNotification.NamedPropertyRangeSeqHolder; 12 import org.omg.CosNotification.Priority; 13 import org.omg.CosNotification.Property; 14 import org.omg.CosNotification.QoSError_code; 15 import org.omg.CosNotification.UnsupportedQoS; 16 17 public class PropertyValidatorTest extends NotificationTestCase 18 { 19 private QoSPropertySet objectUnderTest_; 20 21 public PropertyValidatorTest(String name, NotificationTestCaseSetup setup) 22 { 23 super(name, setup); 24 } 25 26 public QoSPropertySet createInstance() throws Exception 27 { 28 QoSPropertySet _props = new QoSPropertySet(getConfiguration(), QoSPropertySet.CHANNEL_QOS); 29 30 return _props; 31 } 32 33 public void setUpTest() throws Exception 34 { 35 objectUnderTest_ = createInstance(); 36 } 37 38 public void testValidateQoS() throws Exception 39 { 40 Property[] _props = new Property[3]; 41 Any _bestEffortAny = getORB().create_any(); 42 _bestEffortAny.insert_short(BestEffort.value); 43 _props[0] = new Property(ConnectionReliability.value, _bestEffortAny); 44 45 Any _priorityAny = getORB().create_any(); 46 _priorityAny.insert_short((short) 20); 47 _props[1] = new Property(Priority.value, _priorityAny); 48 49 Any _discardPolicyAny = getORB().create_any(); 50 _discardPolicyAny.insert_short(FifoOrder.value); 51 52 _props[2] = new Property(DiscardPolicy.value, _discardPolicyAny); 53 54 56 objectUnderTest_.validate_qos(_props, new NamedPropertyRangeSeqHolder()); 57 58 60 _props[2] = new Property("OtherPolicy", _discardPolicyAny); 61 try 62 { 63 objectUnderTest_.validate_qos(_props, new NamedPropertyRangeSeqHolder()); 64 fail(); 65 } catch (UnsupportedQoS e) 66 { 67 } 69 70 72 Any wrongType = getORB().create_any(); 73 wrongType.insert_long(10); 74 _props[2] = new Property(DiscardPolicy.value, wrongType); 75 try 76 { 77 objectUnderTest_.validate_qos(_props, new NamedPropertyRangeSeqHolder()); 78 fail(); 79 } catch (UnsupportedQoS ex) 80 { 81 for (int x = 0; x < ex.qos_err.length; ++x) 83 { 84 if (ex.qos_err[x].name.equals(DiscardPolicy.value)) 85 { 86 assertEquals(QoSError_code._BAD_TYPE, ex.qos_err[x].code.value()); 87 } 88 } 89 } 90 } 91 92 public static Test suite() throws Exception 93 { 94 return NotificationTestCase.suite(PropertyValidatorTest.class); 95 } 96 } | Popular Tags |