KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jacorb.test.notification;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2003 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

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 /**
31  * @author Alphonse Bendt
32  * @version $Id: StructuredEventMessageTest.java,v 1.4 2005/02/14 00:15:46 alphonse.bendt Exp $
33  */

34 public class StructuredEventMessageTest extends NotificationTestCase
35 {
36     private StructuredEventMessage objectUnderTest_;
37
38     private StructuredEvent structuredEvent_;
39
40     public StructuredEventMessageTest(String JavaDoc name, NotificationTestCaseSetup setup)
41     {
42         super(name, setup);
43     }
44
45     public void setUpTest() throws Exception JavaDoc
46     {
47         objectUnderTest_ = new StructuredEventMessage();
48         structuredEvent_ = getTestUtils().getEmptyStructuredEvent();
49     }
50
51     public void testToTypedEvent() throws Exception JavaDoc
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             // expected
82
}
83     }
84
85     public static Test suite() throws Exception JavaDoc
86     {
87         return NotificationTestCase.suite(StructuredEventMessageTest.class);
88     }
89 }
Popular Tags