KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > TestUtils


1 package org.jacorb.test.notification;
2
3 import org.omg.CORBA.Any JavaDoc;
4 import org.omg.CORBA.LongSeqHelper JavaDoc;
5 import org.omg.CORBA.ORB JavaDoc;
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 /**
13  * @author Alphonse Bendt
14  */

15
16 public class TestUtils
17 {
18     private final static ORB JavaDoc sOrb_ = ORB.init();
19
20     ////////////////////////////////////////
21

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         // prepare test data
38
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 JavaDoc[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 JavaDoc[] { "Alias0", "Alias1", "Alias2" };
56         _p.numbers = new int[] { 10, 20, 30, 40, 50 };
57
58         return _p;
59     }
60
61     public Any JavaDoc getTestPersonAny()
62     {
63         Any JavaDoc _testPerson;
64
65         _testPerson = sOrb_.create_any();
66         PersonHelper.insert(_testPerson, getTestPerson());
67
68         return _testPerson;
69     }
70
71     public Any JavaDoc getAnyLongSequence(int size)
72     {
73         Any JavaDoc _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