KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > entity > G_BasicHomeInterfaceEC2


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_BasicHomeInterfaceEC2.java,v 1.2 2004/01/21 14:51:28 legrasi Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.entity;
27
28 import javax.naming.NamingException JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30 import junit.framework.Test;
31 import junit.framework.TestSuite;
32 import org.objectweb.jonas.jtests.beans.fbasic.SimpleHome;
33 import org.objectweb.jonas.jtests.beans.fbasic.Simple;
34 import org.objectweb.jonas.jtests.util.JTestCase;
35 import java.util.Enumeration JavaDoc;
36
37 /**
38  * This set of test are basic tests on CMP version 2 entity home interface.
39  * All tests common to CMP are in the inherited class A_BasicHomeInterfaceEC.
40  * @author Helene Joanin (JOnAS team)
41  */

42 public class G_BasicHomeInterfaceEC2 extends B_BasicHomeInterfaceEC {
43
44     private static String JavaDoc BEAN_HOME = "fbasicSimpleEC2Home";
45
46     public G_BasicHomeInterfaceEC2(String JavaDoc name) {
47         super(name);
48     }
49      
50     public void testEmpty() throws Exception JavaDoc {
51         getHome();
52     }
53
54     public SimpleHome getHome() {
55         if (home == null) {
56             try {
57                 home = (SimpleHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleHome.class);
58             } catch (NamingException JavaDoc e) {
59                 fail("Cannot get bean home");
60             }
61             // init here tables if CMP2
62
try {
63                 home.findByPrimaryKey("pk1");
64             } catch (Exception JavaDoc e) {
65                 // pk1 not found: we can create
66
try {
67                     home.create("pk1", 10, 4);
68                     home.create("pk2", 10, 4);
69                     home.create("pk3", 10, 4);
70                     home.create("pk4", 40, 8);
71                     home.create("pk5", 50, 8);
72                     home.create("pk6", 60, 8);
73                     home.create("pk7", 70, 8);
74                     home.create("pk8", 45, 20);
75                     home.create("pk9", 55, 30);
76                     home.create("pk10",80, 80);
77                     home.create("pk11",80, 80);
78                     home.create("pk12",90, 90);
79                     home.create("pk13",100, 90);
80                     home.create("pk14",110, 90);
81                     // to get a big table
82
for (int i = 0; i < 1000; i++) {
83                         home.create(Integer.toString(i), 0, 0);
84                     }
85
86                 } catch (Exception JavaDoc i) {
87                     fail ("cannot create elements of table");
88                 }
89             }
90         }
91         return home;
92     }
93
94     /**
95      * This suite is all CMP test cases
96      */

97     public static Test suite() {
98         return new TestSuite(G_BasicHomeInterfaceEC2.class);
99     }
100
101     public static void main (String JavaDoc args[]) throws Exception JavaDoc {
102    
103         String JavaDoc testtorun = null;
104         // Get args
105
for (int argn = 0; argn < args.length; argn++) {
106             String JavaDoc s_arg = args[argn];
107             Integer JavaDoc i_arg;
108             if (s_arg.equals("-n")) {
109                 testtorun = args[++argn];
110             }
111         }
112         if (testtorun == null) {
113             junit.textui.TestRunner.run(suite());
114         } else {
115        
116             junit.textui.TestRunner.run(new G_BasicHomeInterfaceEC2(testtorun));
117        
118         }
119     }
120 }
121
Popular Tags