KickJava   Java API By Example, From Geeks To Geeks.

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


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  * $Id: F_Relation_lcpEC2.java,v 1.1 2003/10/06 15:05:59 joaninh Exp $
22  * --------------------------------------------------------------------------
23  */

24
25 package org.objectweb.jonas.jtests.clients.entity;
26
27 import javax.naming.NamingException JavaDoc;
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.relation.lcp.Session2;
34 import org.objectweb.jonas.jtests.beans.relation.lcp.Session2Home;
35 import org.objectweb.jonas.jtests.util.JTestCase;
36
37
38 /**
39  * This is a test suite on CMP 2 and relations ships.
40  * It reproduces a problem found by a JOnAS user.
41  * @author Helene Joanin
42  */

43 public class F_Relation_lcpEC2 extends JTestCase {
44
45     private static Session2Home home = null;
46
47     public F_Relation_lcpEC2(String JavaDoc name) {
48         super(name);
49     }
50
51     protected static boolean isInit = false;
52
53     protected void setUp() {
54         super.setUp();
55         if (!isInit) {
56             useBeans("lcp", true);
57             try {
58                 home = (Session2Home) PortableRemoteObject.narrow(ictx.lookup("relation_lcp_Session2"),
59                                                                   Session2Home.class);
60             } catch (NamingException JavaDoc e) {
61                 fail("Cannot get bean home: " + e.getMessage());
62             }
63             isInit = true;
64         }
65     }
66
67     /**
68      * Test the getting of existing children.
69      * @throws Exception
70      */

71     public void testGetExistChildren() throws Exception JavaDoc {
72         Session2 s = home.create();
73         assertEquals("c1_1,c1_2", s.getSimpleChildren("p1"));
74     }
75
76     /**
77      * Test the getting of no existing children.
78      * @throws Exception
79      */

80     public void testGetNoExistChildren() throws Exception JavaDoc {
81         Session2 s = home.create();
82         assertEquals("", s.getSimpleChildren("p0"));
83     }
84
85     /**
86      * Test the getting of existing parent.
87      * @throws Exception
88      */

89     public void testGetExistParent() throws Exception JavaDoc {
90         Session2 s = home.create();
91         assertEquals("p1", s.getChildParent("c1_1"));
92     }
93
94     /**
95      * Test the getting of no existing parent.
96      * @throws Exception
97      */

98     public void testGetNoExistParent() throws Exception JavaDoc {
99         Session2 s = home.create();
100         assertEquals("", s.getChildParent("c0"));
101     }
102
103     protected boolean initStateOK() throws Exception JavaDoc {
104         return true;
105     }
106
107     
108     public static Test suite() {
109         return new TestSuite(F_Relation_lcpEC2.class);
110     }
111
112     public static void main (String JavaDoc args[]) {
113         String JavaDoc testtorun = null;
114         // Get args
115
for (int argn = 0; argn < args.length; argn++) {
116             String JavaDoc sarg = args[argn];
117             if (sarg.equals("-n")) {
118                 testtorun = args[++argn];
119             }
120         }
121         if (testtorun == null) {
122             junit.textui.TestRunner.run(suite());
123         } else {
124             junit.textui.TestRunner.run(new F_Relation_lcpEC2(testtorun));
125         }
126     }
127 }
128
Popular Tags