javax.xml.ws.handler.LogicalMessageContext Java Examples
The following examples show how to use
javax.xml.ws.handler.LogicalMessageContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerHandleMessageThrowsRuntimeExceptionClientInbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) { public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1); try { handlerTest.ping(); fail("did not get expected exception"); } catch (RuntimeException e) { assertTrue(e.getMessage().contains(clientHandlerMessage)); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(2, handler2.getHandleMessageInvoked()); assertEquals(2, soapHandler1.getHandleMessageInvoked()); assertEquals(0, handler2.getHandleFaultInvoked()); assertEquals(0, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(1, soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #2
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerHandleMessageThrowsProtocolExceptionClientInbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) { public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1); try { handlerTest.ping(); //fail("did not get expected exception"); } catch (ProtocolException e) { assertEquals(clientHandlerMessage, e.getMessage()); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(2, handler2.getHandleMessageInvoked()); assertEquals(2, soapHandler1.getHandleMessageInvoked()); assertEquals(0, handler2.getHandleFaultInvoked()); assertEquals(0, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(1, soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #3
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerHandleMessageThrowsProtocolExceptionClientOutbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) { public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1); try { handlerTest.ping(); fail("did not get expected exception"); } catch (ProtocolException e) { assertEquals(clientHandlerMessage, e.getMessage()); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); assertEquals(0, soapHandler1.getHandleMessageInvoked()); assertEquals(0, handler2.getHandleFaultInvoked()); assertEquals(1, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(0, soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #4
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSOAPHandlerHandleMessageReturnFalseClientInbound() throws Exception { TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); TestSOAPHandler soapHandler2 = new TestSOAPHandler(false) { public boolean handleMessage(SOAPMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { return false; } return true; } }; addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2); handlerTest.ping(); assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); assertEquals(1, soapHandler1.getHandleMessageInvoked()); assertEquals(2, soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called", 1, handler1.getCloseInvoked()); assertEquals("close must be called", 1, handler2.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler1.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler2.getCloseInvoked()); assertTrue(soapHandler2.getInvokeOrderOfClose() < soapHandler1.getInvokeOrderOfClose()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #5
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerHandleMessageReturnFalseClientInBound() throws Exception { TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) { public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { return false; } return true; } }; TestHandler<LogicalMessageContext> handler3 = new TestHandler<>(false); TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, handler3, soapHandler1); handlerTest.ping(); assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(2, handler2.getHandleMessageInvoked()); assertEquals(2, handler3.getHandleMessageInvoked()); assertEquals(2, soapHandler1.getHandleMessageInvoked()); assertEquals("close must be called", 1, handler1.getCloseInvoked()); assertEquals("close must be called", 1, handler2.getCloseInvoked()); assertEquals("close must be called", 1, handler3.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler1.getCloseInvoked()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler3.getInvokeOrderOfClose()); assertTrue(handler3.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #6
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerHandleMessageThrowsRuntimeExceptionClientOutbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) { public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1); try { handlerTest.ping(); fail("did not get expected exception"); } catch (RuntimeException e) { assertTrue(e.getMessage().contains(clientHandlerMessage)); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); assertEquals(0, soapHandler1.getHandleMessageInvoked()); assertEquals(0, handler2.getHandleFaultInvoked()); assertEquals(0, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(0, soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #7
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerTwoWay() throws Exception { TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2); handlerTest.pingWithArgs("hello"); assertEquals(2, handler1.getHandleMessageInvoked()); assertEquals(2, handler2.getHandleMessageInvoked()); }
Example #8
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLogicalHandlerOneWay() { TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2); handlerTest.pingOneWay(); assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); }
Example #9
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testAddHandlerThroughHandlerResolverClientSide() throws Exception { TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); MyHandlerResolver myHandlerResolver = new MyHandlerResolver(handler1, handler2); service.setHandlerResolver(myHandlerResolver); HandlerTest handlerTestNew = service.getPort(portName, HandlerTest.class); setAddress(handlerTestNew, "http://localhost:" + port + "/HandlerTest/SoapPort"); handlerTestNew.pingOneWay(); String bindingID = myHandlerResolver.bindingID; assertEquals("http://schemas.xmlsoap.org/wsdl/soap/http", bindingID); assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); //CXF-3956 - check to make sure a Dispatch can also get the handlers JAXBContext context = JAXBContext.newInstance(org.apache.handler_test.types.ObjectFactory.class); Dispatch<Object> disp = service.createDispatch(portName, context, Service.Mode.PAYLOAD); setAddress(disp, "http://localhost:" + port + "/HandlerTest/SoapPort"); disp.invokeOneWay(new org.apache.handler_test.types.PingOneWay()); assertEquals(2, handler1.getHandleMessageInvoked()); assertEquals(2, handler2.getHandleMessageInvoked()); }
Example #10
Source File: DispatchHandlerInvocationTest.java From cxf with Apache License 2.0 | 5 votes |
public boolean handleMessage(LogicalMessageContext ctx) { LogicalMessage msg = ctx.getMessage(); Source payload = msg.getPayload(); assertNotNull(payload); return true; }
Example #11
Source File: HandlerChainInvoker.java From cxf with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private boolean invokeReversedHandleFault(MessageContext ctx) { boolean continueProcessing = true; try { int index = invokedHandlers.size() - 2; while (index >= 0 && continueProcessing) { Handler<? extends MessageContext> h = invokedHandlers.get(index); if (h instanceof LogicalHandler) { LogicalHandler<LogicalMessageContext> lh = (LogicalHandler<LogicalMessageContext>)h; continueProcessing = lh.handleFault(logicalMessageContext); } else { Handler<MessageContext> ph = (Handler<MessageContext>)h; continueProcessing = ph.handleFault(protocolMessageContext); } if (!continueProcessing) { invokeReversedClose(); break; } index--; } } catch (RuntimeException e) { LOG.log(Level.WARNING, "HANDLER_RAISED_RUNTIME_EXCEPTION", e); invokeReversedClose(); continueProcessing = false; closed = true; throw e; } invokeReversedClose(); return continueProcessing; }
Example #12
Source File: ModifyNumberHandler.java From cxf with Apache License 2.0 | 5 votes |
public final boolean handleMessage(LogicalMessageContext messageContext) { //System.out.println("LogicalMessageHandler handleMessage called"); try { // get the LogicalMessage from our context LogicalMessage msg = messageContext.getMessage(); // check the payload, if its an AddNumbers request, we'll intervene JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Object payload = msg.getPayload(jaxbContext); Object value = payload; if (payload instanceof JAXBElement) { value = ((JAXBElement<?>)payload).getValue(); } if (value instanceof AddNumbers) { AddNumbers req = (AddNumbers)value; int a = req.getArg0(); req.setArg0(a * 10); msg.setPayload(payload, jaxbContext); } return true; } catch (JAXBException ex) { throw new ProtocolException(ex); } }
Example #13
Source File: TestUnusedHandler.java From cxf with Apache License 2.0 | 4 votes |
public boolean handleFault(LogicalMessageContext ctx) { return true; }
Example #14
Source File: TestLogicalHandler.java From cxf with Apache License 2.0 | 4 votes |
public boolean handleFault(LogicalMessageContext ctx) { return true; }
Example #15
Source File: FaultThrowingHandler.java From cxf with Apache License 2.0 | 4 votes |
@Override public boolean handleFault(LogicalMessageContext context) { return false; }
Example #16
Source File: FaultThrowingHandler.java From cxf with Apache License 2.0 | 4 votes |
@Override public boolean handleMessage(LogicalMessageContext context) { throw new CustomSoapFault(); }
Example #17
Source File: AnnotationHandlerChainBuilderTest.java From cxf with Apache License 2.0 | 4 votes |
public boolean handleMessage(LogicalMessageContext arg0) { return false; }
Example #18
Source File: HandlerChainInvoker.java From cxf with Apache License 2.0 | 4 votes |
public LogicalMessageContext getLogicalMessageContext() { return logicalMessageContext; }
Example #19
Source File: HandlerChainInvoker.java From cxf with Apache License 2.0 | 4 votes |
public void setLogicalMessageContext(LogicalMessageContext mc) { logicalMessageContext = mc; }
Example #20
Source File: HandlerChainInvoker.java From cxf with Apache License 2.0 | 4 votes |
public boolean invokeLogicalHandlers(boolean requestor, LogicalMessageContext context) { return invokeHandlerChain(logicalHandlers, context); }
Example #21
Source File: HandlerChainInvoker.java From cxf with Apache License 2.0 | 4 votes |
public boolean invokeLogicalHandlersHandleFault(boolean requestor, LogicalMessageContext context) { return invokeHandlerChainHandleFault(logicalHandlers, context); }
Example #22
Source File: AnnotationHandlerChainBuilderTest.java From cxf with Apache License 2.0 | 4 votes |
public boolean handleFault(LogicalMessageContext arg0) { return false; }
Example #23
Source File: SmallNumberHandler.java From cxf with Apache License 2.0 | 4 votes |
public final boolean handleMessage(LogicalMessageContext messageContext) { System.out.println("LogicalMessageHandler handleMessage called"); try { boolean outbound = (Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { // get the LogicalMessage from our context // LogicalMessage msg = messageContext.getMessage(); // check the payload, if its an AddNumbers request, we'll intervene // JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Object payload = msg.getPayload(jaxbContext); if (payload instanceof JAXBElement) { payload = ((JAXBElement<?>)payload).getValue(); } if (payload instanceof AddNumbers) { AddNumbers req = (AddNumbers)payload; // now, if the arguments are small, let's do the calculation here // int a = req.getArg0(); int b = req.getArg1(); if (isSmall(a) && isSmall(b)) { int answer = a + b; //System.out.printf("SmallNumberHandler addNumbers(%d, %d) == %d\n", a, b, answer); // ok, we've done the calculation, so build the // response and set it as the payload of the message AddNumbersResponse resp = new AddNumbersResponse(); resp.setReturn(answer); msg.setPayload(new ObjectFactory().createAddNumbersResponse(resp), jaxbContext); Source src = msg.getPayload(); msg.setPayload(src); payload = msg.getPayload(jaxbContext); if (payload instanceof JAXBElement) { payload = ((JAXBElement<?>)payload).getValue(); } AddNumbersResponse resp2 = (AddNumbersResponse)payload; if (resp2 == resp) { throw new WebServiceException("Shouldn't be the same object"); } // finally, return false, indicating that request // processing stops here and our answer will be // returned to the client return false; } } } return true; } catch (JAXBException ex) { throw new ProtocolException(ex); } }
Example #24
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testHandlersInvokedForDispatch() throws Exception { Dispatch<SOAPMessage> disp = service .createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); setAddress(disp, "http://localhost:" + port + "/HandlerTest/SoapPort"); TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); TestSOAPHandler soapHandler2 = new TestSOAPHandler(false); addHandlersToChain(disp, handler1, handler2, soapHandler1, soapHandler2); InputStream is = getClass().getResourceAsStream("PingReq.xml"); SOAPMessage outMsg = MessageFactory.newInstance().createMessage(null, is); SOAPMessage inMsg = disp.invoke(outMsg); assertNotNull(inMsg); assertEquals("handle message was not invoked", 2, handler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked", 2, handler2.getHandleMessageInvoked()); assertEquals("handle message was not invoked", 2, soapHandler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked", 2, soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called", 1, handler1.getCloseInvoked()); assertEquals("close must be called", 1, handler2.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler1.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler2.getCloseInvoked()); // the server has encoded into the response the order in // which the handlers have been invoked, parse it and make // sure everything is ok // expected order for inbound interceptors String[] handlerNames = {"soapHandler4", "soapHandler3", "handler2", "handler1", "servant", "handler1", "handler2", "soapHandler3", "soapHandler4"}; List<String> resp = getHandlerNames(inMsg.getSOAPPart().getEnvelope().getBody()); assertEquals(handlerNames.length, resp.size()); Iterator<String> iter = resp.iterator(); for (String expected : handlerNames) { assertEquals(expected, iter.next()); } }
Example #25
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testSOAPHandlerHandleMessageThrowsRuntimeExceptionClientOutbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); TestSOAPHandler soapHandler1 = new TestSOAPHandler(false) { public boolean handleMessage(SOAPMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler2 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2); try { handlerTest.ping(); fail("did not get expected exception"); } catch (RuntimeException e) { assertTrue(e.getMessage().contains(clientHandlerMessage)); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); assertEquals(1, soapHandler1.getHandleMessageInvoked()); assertEquals(0, soapHandler2.getHandleMessageInvoked()); assertEquals(0, handler2.getHandleFaultInvoked()); assertEquals(0, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(0, soapHandler2.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(1, soapHandler1.getCloseInvoked()); assertEquals(0, soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #26
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionClientInbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); TestSOAPHandler soapHandler1 = new TestSOAPHandler(false) { public boolean handleMessage(SOAPMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler2 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2); try { handlerTest.ping(); //fail("did not get expected exception"); } catch (ProtocolException e) { assertEquals(clientHandlerMessage, e.getMessage()); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); assertEquals(2, soapHandler1.getHandleMessageInvoked()); assertEquals(2, soapHandler2.getHandleMessageInvoked()); assertEquals(0, handler2.getHandleFaultInvoked()); assertEquals(0, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(0, soapHandler2.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(1, soapHandler1.getCloseInvoked()); assertEquals(1, soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #27
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionClientOutbound() throws Exception { final String clientHandlerMessage = "handler1 client side"; TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<>(false); TestSOAPHandler soapHandler1 = new TestSOAPHandler(false) { public boolean handleMessage(SOAPMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } }; TestSOAPHandler soapHandler2 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2); try { handlerTest.ping(); fail("did not get expected exception"); } catch (ProtocolException e) { assertEquals(clientHandlerMessage, e.getMessage()); } assertEquals(1, handler1.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleMessageInvoked()); assertEquals(1, soapHandler1.getHandleMessageInvoked()); assertEquals(0, soapHandler2.getHandleMessageInvoked()); assertEquals(1, handler2.getHandleFaultInvoked()); assertEquals(1, handler1.getHandleFaultInvoked()); assertEquals(0, soapHandler1.getHandleFaultInvoked()); assertEquals(0, soapHandler2.getHandleFaultInvoked()); assertEquals(1, handler1.getCloseInvoked()); assertEquals(1, handler2.getCloseInvoked()); assertEquals(1, soapHandler1.getCloseInvoked()); assertEquals(0, soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }
Example #28
Source File: HandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testSOAPHandlerHandleMessageReturnTrueClient() throws Exception { TestHandler<LogicalMessageContext> handler1 = new TestHandler<>(false); TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) { public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); try { Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { LogicalMessage msg = ctx.getMessage(); Source source = msg.getPayload(); assertNotNull(source); } } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } }; TestSOAPHandler soapHandler1 = new TestSOAPHandler(false); TestSOAPHandler soapHandler2 = new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2); List<String> resp = handlerTest.ping(); assertNotNull(resp); assertEquals("handle message was not invoked", 2, handler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked", 2, handler2.getHandleMessageInvoked()); assertEquals("handle message was not invoked", 2, soapHandler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked", 2, soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called", 1, handler1.getCloseInvoked()); assertEquals("close must be called", 1, handler2.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler1.getCloseInvoked()); assertEquals("close must be called", 1, soapHandler2.getCloseInvoked()); assertTrue(soapHandler2.getInvokeOrderOfClose() < soapHandler1.getInvokeOrderOfClose()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); // the server has encoded into the response the order in // which the handlers have been invoked, parse it and make // sure everything is ok expected order for inbound interceptors String[] handlerNames = {"soapHandler4", "soapHandler3", "handler2", "handler1", "servant", "handler1", "handler2", "soapHandler3", "soapHandler4"}; assertEquals(handlerNames.length, resp.size()); Iterator<String> iter = resp.iterator(); for (String expected : handlerNames) { assertEquals(expected, iter.next()); } }
Example #29
Source File: DispatchHandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
public boolean handleFault(LogicalMessageContext ctx) { return true; }
Example #30
Source File: DispatchHandlerInvocationTest.java From cxf with Apache License 2.0 | 4 votes |
public boolean handleFault(LogicalMessageContext ctx) { return true; }