KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > container > CORBAObjectComponentAdapterTest


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.container;
23
24 import junit.framework.Test;
25 import junit.framework.TestCase;
26 import junit.framework.TestSuite;
27
28 import org.easymock.MockControl;
29 import org.jacorb.notification.container.CORBAObjectComponentAdapter;
30 import org.omg.CosNotifyChannelAdmin.EventChannel;
31 import org.omg.CosNotifyChannelAdmin.EventChannelHelper;
32 import org.picocontainer.MutablePicoContainer;
33 import org.picocontainer.defaults.AssignabilityRegistrationException;
34 import org.picocontainer.defaults.DefaultPicoContainer;
35
36 /**
37  * @author Alphonse Bendt
38  * @version $Id: CORBAObjectComponentAdapterTest.java,v 1.1 2005/04/27 10:50:27 alphonse.bendt Exp $
39  */

40 public class CORBAObjectComponentAdapterTest extends TestCase
41 {
42     private MutablePicoContainer container;
43
44     private MockControl controlObject;
45
46     private org.omg.CORBA.Object JavaDoc mockObject;
47
48     protected void setUp() throws Exception JavaDoc
49     {
50         super.setUp();
51
52         container = new DefaultPicoContainer();
53
54         controlObject = MockControl.createControl(org.omg.CORBA.Object JavaDoc.class);
55
56         mockObject = (org.omg.CORBA.Object JavaDoc) controlObject.getMock();
57     }
58
59     public void testAddReference()
60     {
61         mockObject._is_a("");
62         controlObject.setReturnValue(true);
63
64         controlObject.replay();
65
66         container.registerComponent(new CORBAObjectComponentAdapter(org.omg.CORBA.Object JavaDoc.class,
67                 mockObject));
68
69         assertEquals(mockObject, container.getComponentInstance(org.omg.CORBA.Object JavaDoc.class));
70
71         controlObject.verify();
72     }
73
74     public void testAddWrongReference()
75     {
76         mockObject._is_a(EventChannelHelper.id());
77         controlObject.setReturnValue(false);
78
79         controlObject.replay();
80         try
81         {
82             new CORBAObjectComponentAdapter(EventChannel.class, mockObject);
83             fail();
84         } catch (AssignabilityRegistrationException e)
85         {
86             // expected
87
}
88         controlObject.verify();
89     }
90
91     public CORBAObjectComponentAdapterTest(String JavaDoc name)
92     {
93         super(name);
94     }
95
96     public static Test suite()
97     {
98         return new TestSuite(CORBAObjectComponentAdapterTest.class);
99     }
100 }
Popular Tags