01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.cts.test;
23:
24: import java.rmi.RemoteException;
25: import java.rmi.server.UnicastRemoteObject;
26: import javax.naming.InitialContext;
27: import javax.rmi.PortableRemoteObject;
28: import org.jboss.test.cts.interfaces.ClientCallback;
29: import org.jboss.test.cts.interfaces.StatelessSession;
30: import org.jboss.test.cts.interfaces.StatelessSessionHome;
31:
32: import junit.framework.Test;
33:
34: import org.jboss.test.JBossTestCase;
35:
36: /**
37: * Class StatelessSessionStressTestCase
38: *
39: *
40: * @author d_jencks converted to JBossTestCase and logging.
41: * @author Scott.Stark@jboss.org
42: * @version $Revision: 57211 $
43: */
44: public class StatelessSessionStressTestCase extends JBossTestCase {
45: StatelessSession sessionBean;
46:
47: public StatelessSessionStressTestCase(String name) {
48: super (name);
49: }
50:
51: protected void setUp() throws Exception {
52: InitialContext ctx = new InitialContext();
53: StatelessSessionHome home = (StatelessSessionHome) ctx
54: .lookup("ejbcts/StatelessSessionHome");
55: sessionBean = home.create();
56: }
57:
58: protected void tearDown() throws Exception {
59: if (sessionBean != null)
60: sessionBean.remove();
61: }
62:
63: public void testBasicStatelessSession() throws Exception {
64: getLog().debug("+++ testBasicStatelessSession()");
65: String result = sessionBean
66: .method1("testBasicStatelessSession");
67: // Test response
68: assertTrue(result.equals("testBasicStatelessSession"));
69: sessionBean.remove();
70: }
71:
72: public void testClientCallback() throws Exception {
73: getLog().debug("+++ testClientCallback()");
74: ClientCallbackImpl callback = new ClientCallbackImpl();
75: UnicastRemoteObject.exportObject(callback);
76: sessionBean.callbackTest(callback, "testClientCallback");
77: // Test callback data
78: this .assertTrue(callback.wasCalled());
79: UnicastRemoteObject.unexportObject(callback, true);
80: sessionBean.remove();
81: }
82:
83: public void testRuntimeError() throws Exception {
84: getLog().debug("+++ testRuntimeError()");
85: try {
86: sessionBean.npeError();
87: fail("npeError should have thrown an exception");
88: } catch (Exception e) {
89: getLog().debug("Call threw exception", e);
90: }
91: sessionBean.remove();
92: }
93:
94: public static Test suite() throws Exception {
95: return getDeploySetup(StatelessSessionStressTestCase.class,
96: "cts.jar");
97: }
98:
99: }
|