KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > jaxrpchandlereval > JAXRPCHandlerEvalTestCase


1 package test.wsdl.jaxrpchandlereval;
2
3 import junit.framework.TestCase;
4
5 import org.apache.axis.client.AdminClient;
6 import org.apache.axis.utils.Admin;
7
8 import java.rmi.RemoteException JavaDoc;
9 import javax.xml.rpc.JAXRPCException JavaDoc;
10
11 public class JAXRPCHandlerEvalTestCase extends TestCase {
12
13     public JAXRPCHandlerEvalTestCase() {
14         super("JAXRPCHandlerEvalTest");
15     }
16
17     public JAXRPCHandlerEvalTestCase(String JavaDoc name) {
18         super(name);
19     }
20
21     public void testHappyPath() throws Exception JavaDoc {
22         doClientDeploy();
23         HandlerTracker.init();
24         try {
25             updateInfo("Using the happy path");
26             HandlerTracker.assertClientHandlerOrder(new String JavaDoc[] {
27                 "clienthandler1.handleRequest", "clienthandler2.handleRequest",
28                 "clienthandler2.handleResponse", "clienthandler1.handleResponse" });
29             HandlerTracker.assertServerHandlerOrder(new String JavaDoc[] {
30                 "serverhandler2.handleResponse", "serverhandler1.handleResponse" });
31         } finally {
32             doClientUndeploy();
33         }
34     }
35
36     public void testServerReturnFalse() throws Exception JavaDoc {
37         doClientDeploy();
38         HandlerTracker.init();
39         try {
40             updateInfo("server-return-false");
41         } catch (RemoteException JavaDoc e) {
42             HandlerTracker.assertClientHandlerOrder(new String JavaDoc[] {
43                 "clienthandler1.handleRequest", "clienthandler2.handleRequest",
44                 "clienthandler2.handleResponse", "clienthandler1.handleResponse" });
45             HandlerTracker.assertServerHandlerOrder(new String JavaDoc[] {
46                 "serverhandler2.handleResponse", "serverhandler1.handleResponse" });
47         } finally {
48             doClientUndeploy();
49         }
50     }
51
52     public void testServerThrowSoapFaultException() throws Exception JavaDoc {
53         doClientDeploy();
54         HandlerTracker.init();
55         try {
56             updateInfo("server-throw-soapfaultexception");
57         } catch (RemoteException JavaDoc e) {
58             HandlerTracker.assertClientHandlerOrder(new String JavaDoc[] {
59                 "clienthandler1.handleRequest", "clienthandler2.handleRequest",
60                 "clienthandler2.handleResponse", "clienthandler1.handleResponse" });
61             HandlerTracker.assertServerHandlerOrder(new String JavaDoc[] {
62                 "serverhandler2.handleFault", "serverhandler1.handleFault" });
63         } finally {
64             doClientUndeploy();
65         }
66     }
67
68     public void testClientReturnFalse() throws Exception JavaDoc {
69         doClientDeploy();
70         HandlerTracker.init();
71         try {
72             updateInfo("client-return-false");
73         } catch (RemoteException JavaDoc e) {
74             HandlerTracker.assertClientHandlerOrder(new String JavaDoc[] {
75                 "clienthandler1.handleRequest", "clienthandler1.handleResponse" });
76             HandlerTracker.assertServerHandlerOrder(new String JavaDoc[] {});
77         } finally {
78             doClientUndeploy();
79         }
80     }
81
82     public void testClientThrowJaxRpcException() throws Exception JavaDoc {
83         doClientDeploy();
84         HandlerTracker.init();
85         try {
86             updateInfo("client-throw-jaxrpcexception");
87         } catch (RemoteException JavaDoc e) {
88             HandlerTracker.assertClientHandlerOrder(new String JavaDoc[] {
89                 "clienthandler1.handleRequest", "clienthandler2.handleRequest" });
90             HandlerTracker.assertServerHandlerOrder(new String JavaDoc[] {});
91         } finally {
92             doClientUndeploy();
93         }
94     }
95
96     public String JavaDoc updateInfo(String JavaDoc payload) throws Exception JavaDoc {
97         UserAccountServiceLocator locator = new UserAccountServiceLocator();
98         UserAccount port = locator.getUserAccount();
99         String JavaDoc retval = null;
100     
101         try {
102             retval = port.updateInfo(payload);
103         } catch (Exception JavaDoc ex) {
104             throw ex;
105         }
106         return retval;
107     }
108
109     public void doClientDeploy() throws Exception JavaDoc {
110         String JavaDoc[] args1 = { "client", "test/wsdl/jaxrpchandlereval/client-deploy.wsdd" };
111         Admin.main(args1);
112     }
113
114     public void doClientUndeploy() throws Exception JavaDoc {
115         String JavaDoc[] args1 = { "client", "test/wsdl/jaxrpchandlereval/client-undeploy.wsdd" };
116         Admin.main(args1);
117     }
118 }
119
120
121
122
Popular Tags