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_BeanToLocalTx.java 6437 2005-03-17 15:21:44Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.transaction;
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.transacted.Simple;
033: import org.objectweb.jonas.jtests.beans.transacted.SynchroSimple;
034: import org.objectweb.jonas.jtests.beans.transacted.SimpleSHome;
035: import org.objectweb.jonas.jtests.util.JTestCase;
036:
037: /**
038: * Test for Bean to Bean transactions
039: * @author Ph.Durieux
040: */
041: public class F_BeanToLocalTx extends JTestCase {
042:
043: protected static SimpleSHome syhome = null;
044:
045: public F_BeanToLocalTx(String name) {
046: super (name);
047: }
048:
049: protected void setUp() {
050: super .setUp();
051: useBeans("transacted", true);
052: if (syhome == null) {
053: String BEAN_HOME = "transactedSimpleSYHome";
054: try {
055: syhome = (SimpleSHome) PortableRemoteObject.narrow(ictx
056: .lookup(BEAN_HOME), SimpleSHome.class);
057: } catch (NamingException e) {
058: fail("Cannot get " + BEAN_HOME + ":" + e);
059: }
060: }
061: }
062:
063: /**
064: * SY/Required -> Local/RequiresNew
065: */
066: public void testSY2LRN() throws Exception {
067: // Without this PortableRemoteObject, we got a ClassCastException
068: // Maybe a jacorb issue ?
069: SynchroSimple s1 = (SynchroSimple) PortableRemoteObject.narrow(
070: syhome.create(), SynchroSimple.class);
071: assertEquals(true, s1.call_requires_new_local());
072: s1.remove();
073: }
074:
075: /**
076: * SY/Required -> Local/NotSupported
077: */
078: public void testSY2LNS() throws Exception {
079: SynchroSimple s1 = (SynchroSimple) PortableRemoteObject.narrow(
080: syhome.create(), SynchroSimple.class);
081: assertEquals(true, s1.call_notsupported_local());
082: s1.remove();
083: }
084:
085: public static Test suite() {
086: return new TestSuite(F_BeanToLocalTx.class);
087: }
088:
089: public static void main(String args[]) {
090: String testtorun = null;
091: // Get args
092: for (int argn = 0; argn < args.length; argn++) {
093: String sarg = args[argn];
094: if (sarg.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_BeanToLocalTx(testtorun));
102: }
103: }
104: }
|