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_oou_CRW_EC2.java 10102 2007-03-28 07:36:30Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import javax.ejb.ObjectNotFoundException;
029: import javax.naming.NamingException;
030: import javax.rmi.PortableRemoteObject;
031:
032: import junit.framework.Test;
033: import junit.framework.TestSuite;
034:
035: import org.objectweb.jonas.jtests.beans.relation.oou.AHomeRemote;
036: import org.objectweb.jonas.jtests.beans.relation.oou.ARemote;
037: import org.objectweb.jonas.jtests.beans.relation.oou.BHomeRemote;
038: import org.objectweb.jonas.jtests.beans.relation.oou.BRemote;
039:
040: /**
041: * This is an advanced test suite for home interface on entity bean CMP2.
042: */
043: public class F_oou_CRW_EC2 extends A_oou {
044:
045: private static String BEAN_HOME_A = "relation_oou_AtxHome";
046: private static String BEAN_HOME_B = "relation_oou_BtxHome";
047: protected static AHomeRemote ahome = null;
048: protected static BHomeRemote bhome = null;
049:
050: public F_oou_CRW_EC2(String name) {
051: super (name);
052: }
053:
054: public AHomeRemote getAHome() {
055: if (ahome == null) {
056: try {
057: ahome = (AHomeRemote) PortableRemoteObject.narrow(ictx
058: .lookup(BEAN_HOME_A), AHomeRemote.class);
059: } catch (NamingException e) {
060: fail("Cannot get bean home: " + e.getMessage());
061: }
062: }
063: return ahome;
064: }
065:
066: public BHomeRemote getBHome() {
067: if (bhome == null) {
068: try {
069: bhome = (BHomeRemote) PortableRemoteObject.narrow(ictx
070: .lookup(BEAN_HOME_B), BHomeRemote.class);
071: } catch (NamingException e) {
072: fail("Cannot get bean home: " + e.getMessage());
073: }
074: }
075: return bhome;
076: }
077:
078: public void testRollback2() throws Exception {
079: ARemote a = getAHome().findByPrimaryKey("a1");
080: int valref = a.getValueInB();
081: utx.begin();
082: a.setValueInB(33);
083: utx.rollback();
084: assertEquals(valref, a.getValueInB());
085: }
086:
087: public static Test suite() {
088: return new TestSuite(F_oou_CRW_EC2.class);
089: }
090:
091: public static void main(String args[]) {
092: String testtorun = null;
093: // Get args
094: for (int argn = 0; argn < args.length; argn++) {
095: String s_arg = args[argn];
096: Integer i_arg;
097: if (s_arg.equals("-n")) {
098: testtorun = args[++argn];
099: }
100: }
101: if (testtorun == null) {
102: junit.textui.TestRunner.run(suite());
103: } else {
104: junit.textui.TestRunner.run(new F_oou_CRW_EC2(testtorun));
105: }
106: }
107: }
|