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: G_ClientViewSF.java 3845 2003-12-05 14:19:55Z legrasi $
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.flocal.Target;
032: import org.objectweb.jonas.jtests.beans.flocal.TargetSFHome;
033: import org.objectweb.jonas.jtests.beans.flocal.TargetSLHome;
034: import org.objectweb.jonas.jtests.util.JTestCase;
035:
036: /**
037: * testcases specifics for stateful session beans must be here
038: *
039: * - isIdentical, create<Method>
040: */
041: public class G_ClientViewSF extends B_ClientView {
042:
043: protected static String BEAN_HOME = "flocalTargetSFHome";
044: protected static TargetSFHome home = null;
045:
046: public G_ClientViewSF(String name) {
047: super (name);
048: }
049:
050: public void testEmpty() throws Exception {
051: System.out.println("load bean localTargetSF");
052: }
053:
054: /**
055: * test create with parameters
056: */
057: public void testCreateWithParameter() throws Exception {
058: String s1 = "String1";
059: TargetSFHome tsfh = (TargetSFHome) getHome();
060: Target tr = tsfh.create(s1, 1000);
061: assertEquals(tr.getString(), s1);
062: assertEquals(tr.getNumber(), 1000);
063: assertTrue(!tr.isCreatedViaCreateXX());
064: tr.remove();
065: }
066:
067: /**
068: * test create<METHOD>
069: *
070: */
071: public void testCreateMethod() throws Exception {
072: String s2 = "String2";
073: TargetSFHome tsfh = (TargetSFHome) getHome();
074: Target tr = tsfh.createXX(s2, 2000);
075: assertEquals(tr.getString(), s2);
076: assertEquals(tr.getNumber(), 2000);
077: assertTrue(tr.isCreatedViaCreateXX());
078: tr.remove();
079: }
080:
081: /**
082: * init environment:
083: */
084: protected void setUp() {
085: super .setUp();
086: useBeans("flocal", false);
087: }
088:
089: public TargetSLHome getHome() throws Exception {
090: if (home == null) {
091: home = (TargetSFHome) PortableRemoteObject.narrow(ictx
092: .lookup(BEAN_HOME), TargetSFHome.class);
093: }
094: assertTrue(home != null);
095: return home;
096: }
097:
098: public static Test suite() {
099: return new TestSuite(G_ClientViewSF.class);
100: }
101:
102: public static void main(String args[]) throws Exception {
103: String testtorun = null;
104: // Get args
105: for (int argn = 0; argn < args.length; argn++) {
106: String s_arg = args[argn];
107: Integer i_arg;
108: if (s_arg.equals("-n")) {
109: testtorun = args[++argn];
110: }
111: }
112: if (testtorun == null) {
113: junit.textui.TestRunner.run(suite());
114:
115: } else {
116: junit.textui.TestRunner.run(new G_ClientViewSF(testtorun));
117: }
118: }
119: }
|