1 package test.jaxrpc; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import java.util.List ; 6 import java.util.Map ; 7 8 import javax.xml.rpc.handler.HandlerChain ; 9 import javax.xml.rpc.handler.HandlerInfo ; 10 11 import junit.framework.TestCase; 12 13 import org.apache.axis.AxisFault; 14 import org.apache.axis.MessageContext; 15 import org.apache.axis.handlers.BasicHandler; 16 import org.apache.axis.handlers.HandlerInfoChainFactory; 17 18 19 24 public abstract class AJAXRPC extends TestCase { 25 26 HandlerInfo handlerInfo0 = null; 27 HandlerInfo handlerInfo1 = null; 28 HandlerInfo handlerInfo2 = null; 29 Map handler0Config = null; 30 protected Map handler1Config = null; 31 protected Map handler2Config = null; 32 33 40 protected void setUp() throws Exception { 41 handlerInfo0 = new HandlerInfo (); 42 handlerInfo0.setHandlerClass(AAAHandler.class); 43 handlerInfo1 = new HandlerInfo (); 44 handlerInfo1.setHandlerClass(AAAHandler.class); 45 handlerInfo2 = new HandlerInfo (); 46 handlerInfo2.setHandlerClass(AAAHandler.class); 47 handler0Config = new HashMap (); 48 handler1Config = new HashMap (); 49 handler2Config = new HashMap (); 50 handlerInfo0.setHandlerConfig(handler0Config); 51 handlerInfo1.setHandlerConfig(handler1Config); 52 handlerInfo2.setHandlerConfig(handler2Config); 53 } 54 55 68 protected void assertHandlerRuntime(String message, AAAHandler handler, int numHandleRequest, int numHandleResponse, int numHandleFault) { 69 assertEquals(message + ": handleRequest", numHandleRequest, 70 handler.getHandleRequestInvocations()); 71 assertEquals(message + ": handleResponse", numHandleResponse, 72 handler.getHandleResponseInvocations()); 73 assertEquals(message + ": handleFault", numHandleFault, 74 handler.getHandleFaultInvocations()); 75 } 76 77 82 protected TestHandlerInfoChainFactory buildInfoChainFactory() { 83 List handlerInfos = new ArrayList (); 84 handlerInfos.add(handlerInfo0); 85 handlerInfos.add(handlerInfo1); 86 handlerInfos.add(handlerInfo2); 87 TestHandlerInfoChainFactory factory = new TestHandlerInfoChainFactory( 88 handlerInfos); 89 return factory; 90 } 91 95 protected class MockServiceHandler extends BasicHandler { 96 public void invoke(MessageContext msgContext) throws AxisFault { 97 throw new AxisFault(); 98 } 99 } 100 101 109 protected class TestHandlerInfoChainFactory extends HandlerInfoChainFactory { 110 AAAHandler[] handlers; 111 112 public TestHandlerInfoChainFactory(List handlerInfos) { 113 super(handlerInfos); 114 } 115 116 public HandlerChain createHandlerChain() { 117 HandlerChain chain = super.createHandlerChain(); 118 handlers = new AAAHandler[chain.size()]; 119 for (int i = 0; i < chain.size(); i++) { 120 handlers[i] = (AAAHandler) chain.get(i); 121 } 122 return chain; 123 } 124 125 public AAAHandler[] getHandlers() { 126 return handlers; 127 } 128 129 } 130 131 } 132 | Popular Tags |