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_VariousPKEC2.java 2515 2003-06-04 14:56:00Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import javax.naming.NamingException;
029: import javax.rmi.PortableRemoteObject;
030: import junit.framework.Test;
031: import junit.framework.TestSuite;
032: import org.objectweb.jonas.jtests.beans.ebasic.AccountHome;
033: import org.objectweb.jonas.jtests.beans.ebasic.PersonHome;
034:
035: /**
036: * These are tests about the different cases of the primary key type for CMP version 2 entity.
037: * All common tests to CMP version 1 and CMP version 2 are in the inherited class.
038: * @author Helene Joanin (jonas team)
039: */
040: public class F_VariousPKEC2 extends A_VariousPKEC {
041:
042: private static String BEAN_HOME_ACCOUNT = "ebasicAccountEC2Home";
043: protected static AccountHome ahome = null;
044: private static String BEAN_HOME_PERSON = "ebasicPersonEC2Home";
045: protected static PersonHome phome = null;
046:
047: public F_VariousPKEC2(String name) {
048: super (name);
049: }
050:
051: protected void setUp() {
052: super .setUp();
053: }
054:
055: public AccountHome getAccountHome() {
056: if (ahome == null) {
057: try {
058: ahome = (AccountHome) PortableRemoteObject.narrow(ictx
059: .lookup(BEAN_HOME_ACCOUNT), AccountHome.class);
060: } catch (NamingException e) {
061: fail("Cannot get bean home: " + BEAN_HOME_ACCOUNT);
062: }
063: // init here tables if CMP2
064: try {
065: ahome.create(0, "to be removed");
066: ahome.create(10, "Eric");
067: ahome.create(20, "Helene");
068: ahome.create(30, "Guilhem");
069: ahome.create(40, "Malva");
070: } catch (Exception i) {
071: }
072: }
073: return ahome;
074: }
075:
076: public PersonHome getPersonHome() {
077: if (phome == null) {
078: try {
079: phome = (PersonHome) PortableRemoteObject.narrow(ictx
080: .lookup(BEAN_HOME_PERSON), PersonHome.class);
081: } catch (NamingException e) {
082: fail("Cannot get bean home: " + BEAN_HOME_PERSON);
083: }
084: // init here tables if CMP2
085: try {
086: phome.create(0, "to be removed");
087: phome.create(10, "Eric");
088: phome.create(20, "Helene");
089: phome.create(30, "Guilhem");
090: phome.create(40, "Malva");
091: } catch (Exception i) {
092: }
093: }
094: return phome;
095: }
096:
097: public static Test suite() {
098: return new TestSuite(F_VariousPKEC2.class);
099: }
100:
101: public static void main(String args[]) {
102: String testtorun = null;
103: // Get args
104: for (int argn = 0; argn < args.length; argn++) {
105: String s_arg = args[argn];
106: Integer i_arg;
107: if (s_arg.equals("-n")) {
108: testtorun = args[++argn];
109: }
110: }
111: if (testtorun == null) {
112: junit.textui.TestRunner.run(suite());
113: } else {
114: junit.textui.TestRunner.run(new F_VariousPKEC2(testtorun));
115: }
116: }
117: }
|