1 package org.jacorb.test.notification; 2 3 import org.omg.CORBA.Any ; 4 import org.omg.CORBA.LongSeqHelper ; 5 import org.omg.CORBA.ORB ; 6 import org.omg.CosNotification.EventHeader; 7 import org.omg.CosNotification.EventType; 8 import org.omg.CosNotification.FixedEventHeader; 9 import org.omg.CosNotification.Property; 10 import org.omg.CosNotification.StructuredEvent; 11 12 15 16 public class TestUtils 17 { 18 private final static ORB sOrb_ = ORB.init(); 19 20 22 public StructuredEvent getStructuredEvent() 23 { 24 FixedEventHeader _fixedHeader = new FixedEventHeader(); 25 _fixedHeader.event_name = "ALARM"; 26 _fixedHeader.event_type = new EventType("TESTING", "TESTING"); 27 EventHeader _header = new EventHeader(_fixedHeader, new Property[0]); 28 29 StructuredEvent _structuredEvent = new StructuredEvent(_header, new Property[0], 30 getTestPersonAny()); 31 32 return _structuredEvent; 33 } 34 35 public Person getTestPerson() 36 { 37 Person _p = new Person(); 39 Address _a = new Address(); 40 41 _p.first_name = "firstname"; 42 _p.last_name = "lastname"; 43 _p.age = 5; 44 _p.phone_numbers = new String [2]; 45 _p.phone_numbers[0] = "12345678"; 46 _p.phone_numbers[1] = ""; 47 _p.nv = new NamedValue[2]; 48 _p.nv[0] = new NamedValue(); 49 _p.nv[1] = new NamedValue(); 50 _p.person_profession = Profession.STUDENT; 51 _a.street = "Takustr."; 52 _a.number = 9; 53 _a.city = "Berlin"; 54 _p.home_address = _a; 55 _p.aliases = new String [] { "Alias0", "Alias1", "Alias2" }; 56 _p.numbers = new int[] { 10, 20, 30, 40, 50 }; 57 58 return _p; 59 } 60 61 public Any getTestPersonAny() 62 { 63 Any _testPerson; 64 65 _testPerson = sOrb_.create_any(); 66 PersonHelper.insert(_testPerson, getTestPerson()); 67 68 return _testPerson; 69 } 70 71 public Any getAnyLongSequence(int size) 72 { 73 Any _any = sOrb_.create_any(); 74 int[] _sequence = new int[size]; 75 76 for (int x = 0; x < size; ++x) 77 { 78 _sequence[x] = x; 79 } 80 81 LongSeqHelper.insert(_any, _sequence); 82 83 return _any; 84 } 85 } | Popular Tags |