KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > stress > invocation > TestStatefulThreadSafe


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TestStatefulThreadSafe.java 1146 2006-10-10 12:47:48Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.stress.invocation;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28
29 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.basic.SFSBStressBean;
30 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.basic.SFSBStressBeanRemote;
31 import org.testng.annotations.BeforeSuite;
32 import org.testng.annotations.Test;
33
34 /**
35  * Tests the support for multiple lookups and method invocations.
36  * @requirement Application Server must be running.<br> (Ant task:
37  * install.jar.tests.sessionbean + jar.tests.basic)
38  * @author Eduardo Studzinski Estima de Castro
39  * @author Gisele Pinheiro Souza
40  */

41 public class TestStatefulThreadSafe {
42
43     /**
44      * Number of threads for each client.
45      */

46     public static final int NUMBER_LOOKUPS = 3;
47
48
49     /**
50      * Bean 1.
51      */

52     private SFSBStressBeanRemote bean;
53
54     /**
55      * Gets bean instances used in the tests.
56      * @throws Exception if there is a problem with bean initialization.
57      */

58     @BeforeSuite
59     public void startUp() throws Exception JavaDoc {
60         bean = getBeanRemoteInstance(SFSBStressBean.class, SFSBStressBeanRemote.class);
61         bean.initValue();
62     }
63
64     /**
65      * Tests the support for many calls in parallel on the same stateful bean.
66      * @throws Exception if a problem occurs.
67      */

68     @Test(threadPoolSize = NUMBER_LOOKUPS, invocationCount = NUMBER_LOOKUPS)
69     public void testMultipleThreadsCalls() throws Exception JavaDoc {
70         bean.testThreadSafe();
71     }
72
73 }
74
Popular Tags