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: * --------------------------------------------------------------------------
022: * $Id: F_mou_CS_EC2.java 7420 2005-09-26 14:16:26Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import java.util.Enumeration;
029: import java.util.Hashtable;
030:
031: import javax.naming.NamingException;
032: import javax.rmi.PortableRemoteObject;
033:
034: import junit.framework.Test;
035: import junit.framework.TestSuite;
036:
037: import org.objectweb.jonas.jtests.beans.relation.mou.AHomeRemote;
038: import org.objectweb.jonas.jtests.beans.relation.mou.ARemote;
039: import org.objectweb.jonas.jtests.beans.relation.mou.BHomeRemote;
040: import org.objectweb.jonas.jtests.beans.relation.mou.BRemote;
041:
042: /**
043: * For testing many-to-one unidirectional relationships
044: * @author Ph.Durieux
045: *
046: * This is an advanced test suite for home interface on entity bean CMP2.
047: **/
048: public class F_mou_CS_EC2 extends A_mou {
049:
050: private static String BEAN_HOME_A = "relation_mou_AHome";
051: protected static AHomeRemote ahome = null;
052: private static String BEAN_HOME_B = "relation_mou_BHome";
053: protected static BHomeRemote bhome = null;
054:
055: public F_mou_CS_EC2(String name) {
056: super (name);
057: debug("F_mou_CS_EC2(" + name + ")");
058: }
059:
060: public AHomeRemote getAHome() {
061: if (ahome == null) {
062: try {
063: ahome = (AHomeRemote) PortableRemoteObject.narrow(ictx
064: .lookup(BEAN_HOME_A), AHomeRemote.class);
065: } catch (NamingException e) {
066: fail("Cannot get bean home: " + e.getMessage());
067: }
068: }
069: return ahome;
070: }
071:
072: public BHomeRemote getBHome() {
073: if (bhome == null) {
074: try {
075: bhome = (BHomeRemote) PortableRemoteObject.narrow(ictx
076: .lookup(BEAN_HOME_B), BHomeRemote.class);
077: } catch (NamingException e) {
078: fail("Cannot get bean home: " + e.getMessage());
079: }
080: }
081: return bhome;
082: }
083:
084: public static Test suite() {
085: return new TestSuite(F_mou_CS_EC2.class);
086: }
087:
088: public static void main(String args[]) {
089: String testtorun = null;
090: // Get args
091: for (int argn = 0; argn < args.length; argn++) {
092: String s_arg = args[argn];
093: Integer i_arg;
094: if (s_arg.equals("-n")) {
095: testtorun = args[++argn];
096: }
097: }
098: if (testtorun == null) {
099: junit.textui.TestRunner.run(suite());
100: } else {
101: junit.textui.TestRunner.run(new F_mou_CS_EC2(testtorun));
102: }
103: }
104:
105: }
|