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