001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: * --------------------------------------------------------------------------
021: * $Id: F_Relation_lcpEC2.java 7533 2005-10-19 15:55:05Z durieuxp $
022: * --------------------------------------------------------------------------
023: */
024:
025: package org.objectweb.jonas.jtests.clients.entity;
026:
027: import javax.naming.NamingException;
028: import javax.rmi.PortableRemoteObject;
029:
030: import junit.framework.Test;
031: import junit.framework.TestSuite;
032:
033: import org.objectweb.jonas.jtests.beans.relation.lcp.Session2;
034: import org.objectweb.jonas.jtests.beans.relation.lcp.Session2Home;
035: import org.objectweb.jonas.jtests.util.JTestCase;
036:
037: /**
038: * This is a test suite on CMP 2 and relations ships.
039: * It reproduces a problem found by a JOnAS user.
040: * @author Helene Joanin
041: */
042: public class F_Relation_lcpEC2 extends JTestCase {
043:
044: private static Session2Home home = null;
045:
046: public F_Relation_lcpEC2(String name) {
047: super (name);
048: }
049:
050: protected boolean isInit = false;
051:
052: protected void setUp() {
053: super .setUp();
054: if (!isInit) {
055: useBeans("lcp", true);
056: try {
057: home = (Session2Home) PortableRemoteObject.narrow(ictx
058: .lookup("relation_lcp_Session2"),
059: Session2Home.class);
060: } catch (NamingException e) {
061: fail("Cannot get bean home: " + e.getMessage());
062: }
063: isInit = true;
064: }
065: }
066:
067: /**
068: * Test the getting of existing children.
069: * @throws Exception
070: */
071: public void testGetExistChildren() throws Exception {
072: Session2 s = home.create();
073: assertEquals("c1_1,c1_2", s.getSimpleChildren("p1"));
074: }
075:
076: /**
077: * Test the getting of no existing children.
078: * @throws Exception
079: */
080: public void testGetNoExistChildren() throws Exception {
081: Session2 s = home.create();
082: assertEquals("", s.getSimpleChildren("p0"));
083: }
084:
085: /**
086: * Test the getting of existing parent.
087: * @throws Exception
088: */
089: public void testGetExistParent() throws Exception {
090: Session2 s = home.create();
091: assertEquals("p1", s.getChildParent("c1_1"));
092: }
093:
094: /**
095: * Test the getting of no existing parent.
096: * @throws Exception
097: */
098: public void testGetNoExistParent() throws Exception {
099: Session2 s = home.create();
100: assertEquals("", s.getChildParent("c0"));
101: }
102:
103: protected boolean initStateOK() throws Exception {
104: return true;
105: }
106:
107: public static Test suite() {
108: return new TestSuite(F_Relation_lcpEC2.class);
109: }
110:
111: public static void main(String args[]) {
112: String testtorun = null;
113: // Get args
114: for (int argn = 0; argn < args.length; argn++) {
115: String sarg = args[argn];
116: if (sarg.equals("-n")) {
117: testtorun = args[++argn];
118: }
119: }
120: if (testtorun == null) {
121: junit.textui.TestRunner.run(suite());
122: } else {
123: junit.textui.TestRunner
124: .run(new F_Relation_lcpEC2(testtorun));
125: }
126: }
127: }
|