1 7 8 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 ; 16 import java.net.URL ; 17 18 25 26 public class StateUnitTestCase extends JBossNetTestBase 27 { 28 private QName STATE_SERVICE = new QName ("http://" + getServerHost() + ":8080/jboss-net/services/State", "StateService"); 29 private QName NOSTATE_SERVICE = new QName ("http://" + getServerHost() + ":8080/jboss-net/services/NoState", "NoStateService"); 30 private QName FULLSTATE_SERVICE = new QName ("http://" + getServerHost() + ":8080/jboss-net/services/FullState", "FullStateService"); 31 32 public StateUnitTestCase(String name) 34 { 35 super(name); 36 } 37 38 39 State state; 40 NoState noState; 41 FullState fullState; 42 43 44 public void setUp() throws Exception 45 { 46 super.setUp(); 47 URL wsdlState = new URL (SERVICES_LOCATION + "/State?wsdl"); 48 URL wsdlNoState = new URL (SERVICES_LOCATION + "/NoState?wsdl"); 49 URL wsdlFullState = new URL (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 57 public void testState() throws Exception 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 69 public void testNoState() throws Exception 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 77 public void testFullState() throws Exception 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 89 public static Test suite() throws Exception 90 { 91 return getDeploySetup(StateUnitTestCase.class, "jbossnet-state.ear"); 92 } 93 94 public static void main(String [] args) 95 { 96 junit.textui.TestRunner.run(StateUnitTestCase.class); 97 } 98 99 } | Popular Tags |