KickJava   Java API By Example, From Geeks To Geeks.

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


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: G_ClientViewSF.java,v 1.2 2004/03/19 11:57:18 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.session;
27
28 import javax.rmi.PortableRemoteObject JavaDoc;
29
30 import junit.framework.Test;
31 import junit.framework.TestSuite;
32
33 import org.objectweb.jonas.jtests.beans.local.Target;
34 import org.objectweb.jonas.jtests.beans.local.TargetSFHome;
35 import org.objectweb.jonas.jtests.beans.local.TargetSLHome;
36
37
38 /**
39  * testcases specifics for stateful session beans must be here
40  *
41  * - isIdentical, create<Method>
42  */

43 public class G_ClientViewSF extends B_ClientView {
44
45     protected static String JavaDoc BEAN_HOME = "EJB/localTargetSFHome";
46     protected static TargetSFHome home = null;
47
48     public G_ClientViewSF(String JavaDoc name) {
49         super(name);
50     }
51   
52
53     public void testEmpty() throws Exception JavaDoc {System.out.println("load bean localTargetSF");
54     }
55
56     /**
57      * test create with parameters
58      */

59     public void testCreateWithParameter() throws Exception JavaDoc {
60         String JavaDoc s1 = "String1";
61         TargetSFHome tsfh = (TargetSFHome)getHome();
62         Target tr = tsfh.create(s1, 1000);
63         assertEquals(tr.getString(), s1);
64         assertEquals(tr.getNumber(), 1000);
65         assertTrue(!tr.isCreatedViaCreateXX());
66         tr.remove();
67     }
68
69     /**
70      * test create<METHOD>
71      *
72      */

73     public void testCreateMethod() throws Exception JavaDoc {
74         String JavaDoc s2 = "String2";
75         TargetSFHome tsfh = (TargetSFHome)getHome();
76         Target tr = tsfh.createXX(s2,2000);
77         assertEquals(tr.getString(),s2);
78         assertEquals(tr.getNumber(),2000);
79         assertTrue(tr.isCreatedViaCreateXX());
80         tr.remove();
81     }
82
83
84     /**
85      * init environment:
86      */

87     protected void setUp() {
88         super.setUp();
89         useBeans("local", false);
90     }
91
92     public TargetSLHome getHome() throws Exception JavaDoc {
93         if (home == null) {
94             home = (TargetSFHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME),TargetSFHome.class) ;
95         }
96         assertTrue(home != null);
97         return home;
98     }
99
100     public static Test suite() {
101         return new TestSuite(G_ClientViewSF.class);
102     }
103
104    
105
106     public static void main (String JavaDoc args[]) throws Exception JavaDoc {
107         String JavaDoc testtorun = null;
108         // Get args
109
for (int argn = 0; argn < args.length; argn++) {
110             String JavaDoc s_arg = args[argn];
111             Integer JavaDoc i_arg;
112             if (s_arg.equals("-n")) {
113                 testtorun = args[++argn];
114             }
115         }
116         if (testtorun == null) {
117             junit.textui.TestRunner.run(suite());
118     
119         } else {
120             junit.textui.TestRunner.run(new G_ClientViewSF(testtorun));
121         }
122     }
123 }
124
Popular Tags