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_IsolationEC2.java 7299 2005-08-25 17:34:16Z ashah $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import java.rmi.RemoteException;
029: import javax.ejb.FinderException;
030: import javax.naming.NamingException;
031: import javax.rmi.PortableRemoteObject;
032: import junit.framework.Test;
033: import junit.framework.TestSuite;
034: import org.objectweb.jonas.jtests.beans.ebasic.SimpleHome;
035:
036: /**
037: * These tests are about transaction isolation on CMP version 2 entity beans.
038: * Only specific tests to CMP are here, all tests common to BMP and CMP
039: * are in the inherited class IsolationTests.
040: * @author Helene Joanin (jonas team)
041: */
042: public class F_IsolationEC2 extends A_Isolation {
043:
044: private static String BEAN_HOME = "ebasicSimpleEC2Home";
045: protected static SimpleHome home = null;
046:
047: public F_IsolationEC2(String name) {
048: super (name);
049: }
050:
051: public SimpleHome getHome() {
052: if (home == null) {
053: try {
054: home = (SimpleHome) PortableRemoteObject.narrow(ictx
055: .lookup(BEAN_HOME), SimpleHome.class);
056: } catch (NamingException e) {
057: fail("Cannot get bean home");
058: }
059: }
060: return home;
061: }
062:
063: /**
064: * init environment:
065: * - load beans
066: * - create/init database for entities.
067: */
068: protected void setUp() {
069: super .setUp();
070: try {
071: getHome().findByPrimaryKey("pk1");
072: } catch (FinderException fe) {
073: // init here tables if CMP2
074: try {
075: utx.begin();
076: home.create("pk1", 10, 4);
077: home.create("pk2", 10, 4);
078: home.create("pk3", 10, 4);
079: home.create("pk4", 40, 8);
080: home.create("pk5", 50, 8);
081: home.create("pk6", 60, 8);
082: home.create("pk7", 70, 8);
083: home.create("pk8", 45, 20);
084: home.create("pk9", 55, 30);
085: home.create("pk10", 80, 80);
086: home.create("pk11", 80, 80);
087: home.create("pk12", 90, 90);
088: home.create("pk13", 100, 90);
089: home.create("pk14", 110, 90);
090: utx.commit();
091: } catch (Exception i) {
092: throw new RuntimeException(i);
093: }
094: } catch (RemoteException re) {
095: throw new RuntimeException(re);
096: }
097: }
098:
099: /**
100: * This suite is all CMP test cases
101: */
102: public static Test suite() {
103: return new TestSuite(F_IsolationEC2.class);
104: }
105:
106: public static void main(String args[]) {
107: String testtorun = null;
108: // Get args
109: for (int argn = 0; argn < args.length; argn++) {
110: String s_arg = args[argn];
111: Integer i_arg;
112: if (s_arg.equals("-n")) {
113: testtorun = args[++argn];
114: }
115: }
116: if (testtorun == null) {
117: junit.textui.TestRunner.run(suite());
118: } else {
119: junit.textui.TestRunner.run(new F_IsolationEC2(testtorun));
120: }
121: }
122: }
|