KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossnet > state > StateUnitTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: StateUnitTestCase.java,v 1.1.1.1.6.4 2004/12/01 15:41:52 tdiesler Exp $
9

10 package org.jboss.test.jbossnet.state;
11
12 import junit.framework.Test;
13 import org.jboss.test.jbossnet.JBossNetTestBase;
14
15 import javax.xml.namespace.QName JavaDoc;
16 import java.net.URL JavaDoc;
17
18 /**
19  * Tests remote accessibility of stateful ejb bean
20  * @since 2. Oktober 2002, 12:11
21  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
22  * @author Thomas.Diesler@jboss.org
23  * @version $Revision: 1.1.1.1.6.4 $
24  */

25
26 public class StateUnitTestCase extends JBossNetTestBase
27 {
28    private QName JavaDoc STATE_SERVICE = new QName JavaDoc("http://" + getServerHost() + ":8080/jboss-net/services/State", "StateService");
29    private QName JavaDoc NOSTATE_SERVICE = new QName JavaDoc("http://" + getServerHost() + ":8080/jboss-net/services/NoState", "NoStateService");
30    private QName JavaDoc FULLSTATE_SERVICE = new QName JavaDoc("http://" + getServerHost() + ":8080/jboss-net/services/FullState", "FullStateService");
31
32    // Constructors --------------------------------------------------
33
public StateUnitTestCase(String JavaDoc name)
34    {
35       super(name);
36    }
37
38    /** the session bean with which we interact */
39    State state;
40    NoState noState;
41    FullState fullState;
42
43    /** setup the bean */
44    public void setUp() throws Exception JavaDoc
45    {
46       super.setUp();
47       URL JavaDoc wsdlState = new URL JavaDoc(SERVICES_LOCATION + "/State?wsdl");
48       URL JavaDoc wsdlNoState = new URL JavaDoc(SERVICES_LOCATION + "/NoState?wsdl");
49       URL JavaDoc wsdlFullState = new URL JavaDoc(SERVICES_LOCATION + "/FullState?wsdl");
50
51       state = (State)createService(wsdlState, STATE_SERVICE, true).getPort(State.class);
52       noState = (NoState)createService(wsdlNoState, NOSTATE_SERVICE, true).getPort(NoState.class);
53       fullState = (FullState)createService(wsdlFullState, FULLSTATE_SERVICE, true).getPort(FullState.class);
54    }
55
56    /** test stateful behaviour*/
57    public void testState() throws Exception JavaDoc
58    {
59       assertEquals("Initial return value must be zero.", 0, state.count());
60       assertEquals("Next return value must be incremented.", 1, state.count());
61       assertEquals("Next return value must be incremented.", 2, state.count());
62       setUp();
63       assertEquals("Fresh return value must be zero.", 0, state.count());
64       assertEquals("Fresh next return value must be incremented.", 1, state.count());
65       assertEquals("Fresh next return value must be incremented.", 2, state.count());
66    }
67
68    /** test stateless behaviour */
69    public void testNoState() throws Exception JavaDoc
70    {
71       assertEquals("Initial return value must be zero.", 0, noState.count());
72       assertEquals("Next return value must not be incremented.", 0, noState.count());
73       assertEquals("Next return value must not be incremented.", 0, noState.count());
74    }
75
76    /** test stateful behaviour*/
77    public void testFullState() throws Exception JavaDoc
78    {
79       assertEquals("Initial return value must be zero.", 0, fullState.count());
80       assertEquals("Next return value must be incremented.", 1, fullState.count());
81       assertEquals("Next return value must be incremented.", 2, fullState.count());
82       setUp();
83       assertEquals("Fresh return value must be incremented.", 3, fullState.count());
84       assertEquals("Fresh next return value must be incremented.", 4, fullState.count());
85       assertEquals("Fresh next return value must be incremented.", 5, fullState.count());
86    }
87
88    /** this is to deploy the whole ear */
89    public static Test suite() throws Exception JavaDoc
90    {
91       return getDeploySetup(StateUnitTestCase.class, "jbossnet-state.ear");
92    }
93
94    public static void main(String JavaDoc[] args)
95    {
96       junit.textui.TestRunner.run(StateUnitTestCase.class);
97    }
98
99 }
Popular Tags