KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > jca15 > F_inboundTest


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: F_inboundTest.java,v 1.1 2004/04/15 17:09:34 bobkruse Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.jca15;
27
28 import junit.framework.*;
29 import java.io.BufferedReader JavaDoc;
30 import java.io.FileInputStream JavaDoc;
31 import java.io.InputStreamReader JavaDoc;
32 import java.io.IOException JavaDoc;
33 import java.lang.String JavaDoc;
34 import java.rmi.RemoteException JavaDoc;
35 import javax.rmi.PortableRemoteObject JavaDoc;
36 import java.util.Collection JavaDoc;
37 import java.util.Enumeration JavaDoc;
38 import java.util.Hashtable JavaDoc;
39 import java.util.Properties JavaDoc;
40 import javax.ejb.FinderException JavaDoc;
41 import javax.ejb.RemoveException JavaDoc;
42 import javax.naming.Context JavaDoc;
43 import javax.naming.InitialContext JavaDoc;
44 import javax.naming.NamingException JavaDoc;
45
46 import org.objectweb.jonas.jtests.beans.jca15.InboundCAHome;
47 import org.objectweb.jonas.jtests.beans.jca15.InboundCA;
48 import org.objectweb.jonas.jtests.util.JTestCase;
49
50 /**
51  * Tests JOnAS Connector Architecture Inbound Resource Adapter
52  */

53 public class F_inboundTest extends JTestCase {
54
55     static Context JavaDoc ctx = null;
56
57     // Lookup bean home
58

59     protected static String JavaDoc BEAN_HOME = "InboundCAHome";
60     static InboundCAHome home = null;
61     static InboundCA bean = null;
62     private static final String JavaDoc RAR_JNDI_NAME = "eis/ErsatzEIS";
63     int CloseType = 0;
64     
65     public F_inboundTest(String JavaDoc name) {
66         super(name);
67     }
68
69     protected void setUp() {
70         super.setUp();
71
72     // Get InitialContext
73

74         try {
75
76             // get JNDI initial context
77

78             if (ctx == null) {
79                 ctx = new InitialContext JavaDoc();
80             }
81
82             if (home == null) {
83                 useBeans("jca15", false); // does "jonas admin -j jca15.jar"
84
}
85
86             // Connecting to InboundCAHome thru JNDI
87

88             if (home == null) {
89                 home = (InboundCAHome)PortableRemoteObject.narrow(
90                                  ctx.lookup(BEAN_HOME),
91                                  InboundCAHome.class);
92                 bean = home.create();
93             }
94         
95             assertTrue (5 == 5);
96
97         } catch (Exception JavaDoc e) {
98             fail("Cannot do setUp: " +e);
99         }
100     }
101     /**
102      *
103      * Common tearDown method, used for every test.
104      * Verify some Application Server tests by reviewing the log file.
105      *
106      * The application server also calls ManagedConnection.destroy when it
107      * receives a connection error event notification that signals a fatal error
108      * on the physical connection. When method closeUp(int x) is called by
109      * tearDown with x>0, a connection error event notification is sent to
110      * the application server. Look for <code>ManagedConnection.destroy</code> entry.
111      *
112      */

113     protected void tearDown() throws Exception JavaDoc {
114         bean.closeUp(CloseType);
115     }
116     protected void startUp(String JavaDoc testName) {
117         try {
118             bean.method1(RAR_JNDI_NAME, testName);
119         } catch (Exception JavaDoc ee) {
120             ee.printStackTrace();
121             System.exit(2);
122         }
123     }
124 // test list ****************************************************
125
/**
126      * The application server calls setter methods on the ResourceAdapterImpl
127      * instance to set various configuration properties on this instance.
128      * ra.xml deployment supplies value
129      *
130      * This test compares the "set" value in ra.xml, EIS_URL=ErsatzEIS
131      */

132     public void testSetEIS_URLMethod() throws Exception JavaDoc {
133         startUp("testSetEIS_URLMethod");
134         String JavaDoc url = bean.getEIS_URL();
135         assertEquals("ErsatzEIS", url);
136     }
137     /**
138      * Send these messages to the Message Driven Bean MessageTakerMD.java
139      * >InboundCASLR > ResourceAdapterImpl > WorkImpl > MessageTakerMD > WorkAdapterImpl
140      * which is the "WorkListener"
141      *
142      * This test verifies the work submission call back mechanism in JCA 1.5, Figure 42
143      * and endpoint deployment in Figure 12-6.
144      *
145      * The Message Driven Bean is the endpoint which receives the messages.
146      */

147     public void testDeliverMsg() throws Exception JavaDoc {
148         startUp("testDeliverMsg");
149         boolean b = bean.deliverMsg("String message 11111111111111111111 to endpoint.");
150         assertTrue(b);
151         b = bean.deliverMsg("String message 22222222222222222222 to endpoint.");
152         assertTrue(b);
153     }
154 // end test list ****************************************************
155

156     public static Test suite() {
157         return new TestSuite(F_inboundTest.class);
158     }
159
160     public static void main (String JavaDoc args[]) {
161
162         String JavaDoc testtorun = null;
163
164         // Get args
165

166         for (int argn = 0; argn < args.length; argn++) {
167
168             String JavaDoc s_arg = args[argn];
169             Integer JavaDoc i_arg;
170
171             if (s_arg.equals("-n")) {
172                 testtorun = args[++argn];
173             }
174         }
175
176         if (testtorun == null) {
177             junit.textui.TestRunner.run(suite());
178         } else {
179             junit.textui.TestRunner.run(new F_inboundTest(testtorun));
180         }
181     }
182 }
183
Popular Tags