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: A_bankWrite.java 9917 2007-01-12 09:56:24Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.distribution;
027:
028: import java.rmi.NoSuchObjectException;
029: import java.rmi.ServerException;
030:
031: public abstract class A_bankWrite extends A_bank {
032:
033: public A_bankWrite(String name) {
034: super (name);
035: }
036:
037: public void testBasicMove() throws Exception {
038: ope(OP_MOVE, 0, 9, 1, 1);
039: }
040:
041: public void testBasicMoveNC() throws Exception {
042: ope(OP_MOVE, 0, 9, 1, 1, 5, false);
043: }
044:
045: public void testBasicRemove() throws Exception {
046: createOpe(OP_REMOVE, 3000, 3001, 1, 1);
047: }
048:
049: public void testMultiRemove() throws Exception {
050: createOpe(OP_REMOVE, 3010, 3040, 1, 4);
051: }
052:
053: public void testManyRemove() throws Exception {
054: createOpe(OP_REMOVE, 3000, 3200, 200, 1);
055: }
056:
057: /**
058: * Test the rollback
059: */
060: public void testBasicRB() throws Exception {
061: ope(OP_MOVE, 0, 2, 4, 1, 700);
062: }
063:
064: public void testMultiRB() throws Exception {
065: createOpe(OP_MOVE, 0, 4, 4, 5, 600);
066: }
067:
068: public void testBasicCreate() throws Exception {
069: ope(OP_CREATE, 100, 150, 1, 1);
070: }
071:
072: public void testShortCreate() throws Exception {
073: ope(OP_CREATE, 6000, 8000, 100, 1);
074: }
075:
076: public void testMultiCreate() throws Exception {
077: ope(OP_CREATE, 1000, 1900, 1, 12);
078: }
079:
080: public void testMultiMove() throws Exception {
081: ope(OP_MOVE, 0, 5, 1, 5);
082: }
083:
084: /**
085: * test access on removed account
086: * spec EJB 2.1 page 406 (18.3.6/18.3.7) says that the container
087: * must throw a NoSuchObjectException to the client.
088: */
089: public void testAccessRemoved() throws Exception {
090: int num = 700;
091: // create the account if it doesn't exist yet
092: manager.readBalance(num);
093: manager.delAccount(num);
094: try {
095: // read balance for last accessed account
096: manager.readBalance();
097: fail("must throw NoSuchObjectException");
098: } catch (NoSuchObjectException e) {
099: manager = null; // avoids that all other tests fail
100: } catch (ServerException e) {
101: manager = null; // avoids that all other tests fail
102: if (!(e.getCause() instanceof NoSuchObjectException)) {
103: fail("Should receive NoSuchObjectException instead of :"
104: + e);
105: }
106: }
107: }
108:
109: /**
110: * Test that an entity created inside a transaction rollback only is not accessible
111: * Emulate a problem raised by safir project
112: */
113: public void testCreateRollbackOnly() throws Exception {
114: int num = 800;
115: manager.createRollbackOnly(num);
116: try {
117: // read balance for last accessed account
118: manager.readBalance();
119: fail("must throw NoSuchObjectException");
120: } catch (NoSuchObjectException e) {
121: manager = null; // avoids that all other tests fail
122: } catch (ServerException e) {
123: manager = null; // avoids that all other tests fail
124: if (!(e.getCause() instanceof NoSuchObjectException)) {
125: fail("Should receive NoSuchObjectException instead of :"
126: + e);
127: }
128: }
129: }
130: }
|