KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > session > F_Applimet


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_Applimet.java,v 1.4 2004/07/06 09:45:43 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.session;
27
28 import junit.framework.Test;
29 import junit.framework.TestSuite;
30 import javax.rmi.PortableRemoteObject JavaDoc;
31 import org.objectweb.jonas.jtests.beans.applimet.Appli;
32 import org.objectweb.jonas.jtests.beans.applimet.AppliHome;
33 import org.objectweb.jonas.jtests.beans.applimet.Met;
34 import org.objectweb.jonas.jtests.beans.applimet.MetHome;
35 import org.objectweb.jonas.jtests.util.JTestCase;
36
37
38 /**
39  * testcases specific for stateful session beans
40  */

41 public class F_Applimet extends JTestCase {
42
43     protected static AppliHome applihome = null;
44     protected static MetHome methome = null;
45
46     public F_Applimet(String JavaDoc name) {
47         super(name);
48     }
49
50     protected void setUp() {
51         super.setUp();
52         useBeans("applimet", true); // must create tables (no entity bean)
53
}
54
55     public AppliHome getAppliHome() throws Exception JavaDoc {
56         if (applihome == null) {
57             applihome = (AppliHome) PortableRemoteObject.narrow(ictx.lookup("AppliBean"), AppliHome.class) ;
58         }
59         assertTrue(applihome != null);
60         return applihome;
61     }
62
63     public MetHome getMetHome() throws Exception JavaDoc {
64         if (methome == null) {
65             methome = (MetHome) PortableRemoteObject.narrow(ictx.lookup("MetBean"), MetHome.class) ;
66         }
67         assertTrue(methome != null);
68         return methome;
69     }
70
71     public void testScenario1() throws Exception JavaDoc {
72         Met met = getMetHome().create();
73         met.methode1();
74         met.remove();
75     }
76
77     public void testScenario2() throws Exception JavaDoc {
78         Appli appli = getAppliHome().create();
79         appli.methodeApplicative();
80         appli.remove();
81     }
82
83     public void testMoscone1() throws Exception JavaDoc {
84         Met met = getMetHome().create();
85         met.moscone1();
86         met.remove();
87     }
88
89     public void testMoscone2() throws Exception JavaDoc {
90         Met met = getMetHome().create();
91         met.getconn();
92         met.useconn();
93         met.closeconn();
94         met.remove();
95     }
96
97     public void testMoscone3() throws Exception JavaDoc {
98         Met met = getMetHome().create();
99         met.getconntx();
100         met.useconn();
101         met.closeconn();
102         met.remove();
103     }
104
105     public void testRollbackOnlyNoTx() throws Exception JavaDoc {
106         Appli appli = getAppliHome().create();
107         appli.noTxMethod();
108         appli.remove();
109     }
110
111     public static Test suite() {
112         return new TestSuite(F_Applimet.class);
113     }
114
115
116     public static void main (String JavaDoc args[]) throws Exception JavaDoc {
117         String JavaDoc testtorun = null;
118         // Get args
119
for (int argn = 0; argn < args.length; argn++) {
120             String JavaDoc s_arg = args[argn];
121             Integer JavaDoc i_arg;
122             if (s_arg.equals("-n")) {
123                 testtorun = args[++argn];
124             }
125         }
126         if (testtorun == null) {
127             junit.textui.TestRunner.run(suite());
128         } else {
129             junit.textui.TestRunner.run(new F_Applimet(testtorun));
130          }
131     }
132 }
133
Popular Tags