KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > typed > TypedEventChannelTest


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

21
22 package org.jacorb.test.notification.typed;
23
24 import java.util.Properties JavaDoc;
25
26 import junit.framework.Test;
27 import junit.framework.TestCase;
28 import junit.framework.TestSuite;
29
30 import org.jacorb.notification.AbstractChannelFactory;
31 import org.jacorb.notification.conf.Attributes;
32 import org.omg.CORBA.IntHolder JavaDoc;
33 import org.omg.CosNotification.Property;
34 import org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator;
35 import org.omg.CosTypedEventChannelAdmin.TypedConsumerAdmin;
36 import org.omg.CosTypedEventChannelAdmin.TypedSupplierAdmin;
37 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannel;
38 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactory;
39 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactoryHelper;
40
41 /**
42  * @author Alphonse Bendt
43  * @version $Id: TypedEventChannelTest.java,v 1.1 2005/04/10 14:31:57 alphonse.bendt Exp $
44  */

45 public class TypedEventChannelTest extends TestCase
46 {
47     private TypedEventChannelFactory typedChannelFactory_;
48     private TypedEventChannel objectUnderTest_;
49     private AbstractChannelFactory servant_;
50
51     /*
52      * @see TestCase#setUp()
53      */

54     protected void setUp() throws Exception JavaDoc
55     {
56         super.setUp();
57
58         Properties JavaDoc props = new Properties JavaDoc();
59         props.put(Attributes.ENABLE_TYPED_CHANNEL, "on");
60
61         servant_ = AbstractChannelFactory.newFactory(props);
62         org.omg.CORBA.Object JavaDoc obj = servant_.activate();
63
64         typedChannelFactory_ = TypedEventChannelFactoryHelper.narrow(obj);
65         
66         objectUnderTest_ = typedChannelFactory_.create_typed_channel(new Property[0],
67                 new Property[0], new IntHolder JavaDoc());
68     }
69
70     /* (non-Javadoc)
71      * @see junit.framework.TestCase#tearDown()
72      */

73     protected void tearDown() throws Exception JavaDoc
74     {
75         super.tearDown();
76         
77         servant_.destroy();
78     }
79     
80     /**
81      * Constructor for TypedEventChannelTest.
82      *
83      * @param name
84      */

85     public TypedEventChannelTest(String JavaDoc name)
86     {
87         super(name);
88     }
89
90     public void testCreateTypedEventChannel() throws Exception JavaDoc
91     {
92         IntHolder JavaDoc id = new IntHolder JavaDoc();
93         TypedEventChannel channel = typedChannelFactory_.create_typed_channel(new Property[0],
94                 new Property[0], id);
95
96         assertEquals(typedChannelFactory_, channel.MyFactory());
97     }
98
99     public void testForConsumers() throws Exception JavaDoc
100     {
101         TypedConsumerAdmin admin = objectUnderTest_.for_consumers();
102         assertNotNull(admin);
103     }
104
105     public void testForSuppliers() throws Exception JavaDoc
106     {
107         TypedSupplierAdmin admin = objectUnderTest_.for_suppliers();
108         assertNotNull(admin);
109     }
110
111     public void testDefaults() throws Exception JavaDoc
112     {
113         assertNotNull(objectUnderTest_.default_consumer_admin());
114         assertNotNull(objectUnderTest_.default_supplier_admin());
115         assertNotNull(objectUnderTest_.default_filter_factory());
116     }
117     
118     public void testCreateConsumerAdmin() throws Exception JavaDoc
119     {
120         IntHolder JavaDoc id = new IntHolder JavaDoc();
121         
122         org.omg.CosTypedNotifyChannelAdmin.TypedConsumerAdmin admin = objectUnderTest_.new_for_typed_notification_consumers(InterFilterGroupOperator.OR_OP, id);
123         
124         int[] ids = objectUnderTest_.get_all_consumeradmins();
125         
126         assertEquals(1, ids.length);
127         assertEquals(id.value, ids[0]);
128         
129         assertEquals(admin, objectUnderTest_.get_consumeradmin(id.value));
130     }
131     
132     public void testCreateSupplierAdmin() throws Exception JavaDoc
133     {
134         IntHolder JavaDoc id = new IntHolder JavaDoc();
135         
136         org.omg.CosTypedNotifyChannelAdmin.TypedSupplierAdmin admin = objectUnderTest_.new_for_typed_notification_suppliers(InterFilterGroupOperator.OR_OP, id);
137         
138         int[] ids = objectUnderTest_.get_all_supplieradmins();
139         
140         assertEquals(1, ids.length);
141         assertEquals(id.value, ids[0]);
142         
143         assertEquals(admin, objectUnderTest_.get_supplieradmin(id.value));
144     }
145     
146     public static Test suite()
147     {
148         return new TestSuite(TypedEventChannelTest.class);
149     }
150 }
151
Popular Tags