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_Applimet.java 5070 2004-07-06 09:45:43Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.session;
027:
028: import junit.framework.Test;
029: import junit.framework.TestSuite;
030: import javax.rmi.PortableRemoteObject;
031: import org.objectweb.jonas.jtests.beans.applimet.Appli;
032: import org.objectweb.jonas.jtests.beans.applimet.AppliHome;
033: import org.objectweb.jonas.jtests.beans.applimet.Met;
034: import org.objectweb.jonas.jtests.beans.applimet.MetHome;
035: import org.objectweb.jonas.jtests.util.JTestCase;
036:
037: /**
038: * testcases specific for stateful session beans
039: */
040: public class F_Applimet extends JTestCase {
041:
042: protected static AppliHome applihome = null;
043: protected static MetHome methome = null;
044:
045: public F_Applimet(String name) {
046: super (name);
047: }
048:
049: protected void setUp() {
050: super .setUp();
051: useBeans("applimet", true); // must create tables (no entity bean)
052: }
053:
054: public AppliHome getAppliHome() throws Exception {
055: if (applihome == null) {
056: applihome = (AppliHome) PortableRemoteObject.narrow(ictx
057: .lookup("AppliBean"), AppliHome.class);
058: }
059: assertTrue(applihome != null);
060: return applihome;
061: }
062:
063: public MetHome getMetHome() throws Exception {
064: if (methome == null) {
065: methome = (MetHome) PortableRemoteObject.narrow(ictx
066: .lookup("MetBean"), MetHome.class);
067: }
068: assertTrue(methome != null);
069: return methome;
070: }
071:
072: public void testScenario1() throws Exception {
073: Met met = getMetHome().create();
074: met.methode1();
075: met.remove();
076: }
077:
078: public void testScenario2() throws Exception {
079: Appli appli = getAppliHome().create();
080: appli.methodeApplicative();
081: appli.remove();
082: }
083:
084: public void testMoscone1() throws Exception {
085: Met met = getMetHome().create();
086: met.moscone1();
087: met.remove();
088: }
089:
090: public void testMoscone2() throws Exception {
091: Met met = getMetHome().create();
092: met.getconn();
093: met.useconn();
094: met.closeconn();
095: met.remove();
096: }
097:
098: public void testMoscone3() throws Exception {
099: Met met = getMetHome().create();
100: met.getconntx();
101: met.useconn();
102: met.closeconn();
103: met.remove();
104: }
105:
106: public void testRollbackOnlyNoTx() throws Exception {
107: Appli appli = getAppliHome().create();
108: appli.noTxMethod();
109: appli.remove();
110: }
111:
112: public static Test suite() {
113: return new TestSuite(F_Applimet.class);
114: }
115:
116: public static void main(String args[]) throws Exception {
117: String testtorun = null;
118: // Get args
119: for (int argn = 0; argn < args.length; argn++) {
120: String s_arg = args[argn];
121: Integer i_arg;
122: if (s_arg.equals("-n")) {
123: testtorun = args[++argn];
124: }
125: }
126: if (testtorun == null) {
127: junit.textui.TestRunner.run(suite());
128: } else {
129: junit.textui.TestRunner.run(new F_Applimet(testtorun));
130: }
131: }
132: }
|