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