Package com.consol.citrus.message

Examples of com.consol.citrus.message.Message


    public void testMessageProcessingWithSoapAttachment() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final Message responseMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestResponse><Message>Hello World!</Message></TestResponse>");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertTrue(SoapMessage.class.isInstance(message));

                SoapMessage soapMessage = (SoapMessage) message;

                Assert.assertEquals(soapMessage.getAttachments().size(), 1L);

                Attachment attachment = soapMessage.getAttachments().get(0);
                Assert.assertEquals(attachment.getContentId(), "myContentId");
                Assert.assertEquals(attachment.getContentType(), "text/xml");

                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });

        org.springframework.ws.soap.SoapMessage soapRequest = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
        SoapHeader soapRequestHeader = EasyMock.createMock(SoapHeader.class);

        org.springframework.ws.soap.SoapMessage soapResponse = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
       
        StringResult soapResponsePayload = new StringResult();
       
        Set<Attachment> attachments = new HashSet<Attachment>();
        Attachment attachment = EasyMock.createMock(Attachment.class);
        attachments.add(attachment);
       
        reset(messageContext, soapRequest, soapRequestHeader, soapResponse, attachment);
       
        expect(messageContext.getRequest()).andReturn(soapRequest).anyTimes();
       
        expect(soapRequest.getPayloadSource()).andReturn(new StringSource("<TestRequest><Message>Hello World!</Message></TestRequest>")).times(2);
       
        expect(messageContext.getPropertyNames()).andReturn(new String[]{}).once();
       
        expect(soapRequest.getSoapHeader()).andReturn(soapRequestHeader).once();
        expect(soapRequestHeader.getSource()).andReturn(null).once();
       
        Set<SoapHeaderElement> emptyHeaderSet = Collections.emptySet();
        expect(soapRequestHeader.examineAllHeaderElements()).andReturn(emptyHeaderSet.iterator()).once();
       
        expect(soapRequest.getSoapAction()).andReturn("sayHello").anyTimes();
       
        expect(soapRequest.getAttachments()).andReturn(attachments.iterator()).once();
        expect(attachment.getContentId()).andReturn("myContentId").anyTimes();
        expect(attachment.getContentType()).andReturn("text/xml").anyTimes();
       
        expect(messageContext.getResponse()).andReturn(soapResponse).once();

        expect(soapResponse.getPayloadResult()).andReturn(soapResponsePayload).once();
       
        expect(attachment.getInputStream()).andReturn(new ByteArrayInputStream("AttachmentBody".getBytes())).once();

        replay(messageContext, soapRequest, soapRequestHeader, soapResponse, attachment);
       
        endpoint.invoke(messageContext);
       
        Assert.assertEquals(soapResponsePayload.toString(), responseMessage.getPayload());
       
        verify(messageContext, soapRequest, soapRequestHeader, soapResponse, attachment);
    }
View Full Code Here


    public void testMessageProcessingWithServerSoapFaultInResponse() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final SoapFault responseMessage = new SoapFault();
        responseMessage.setFaultCode("SERVER");
        responseMessage.setFaultString("Invalid request, because of unknown error");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });
View Full Code Here

    public void testMessageProcessingWithClientSoapFaultInResponse() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final SoapFault responseMessage = new SoapFault();
        responseMessage.setFaultCode("CLIENT");
        responseMessage.setFaultString("Invalid request");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });
View Full Code Here

    public void testMessageProcessingWithSoapFaultDetail() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final SoapFault responseMessage = new SoapFault();
        responseMessage.setPayload("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ResponseMessage><text>This request was not OK!</text></ResponseMessage>");
        responseMessage.setFaultCode("SERVER");
        responseMessage.setFaultString("Invalid request");
        responseMessage.addFaultDetail("<DetailMessage><text>This request was not OK!</text></DetailMessage>");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });
View Full Code Here

    public void testMessageProcessingWithMultipleSoapFaultDetails() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final SoapFault responseMessage = new SoapFault();
        responseMessage.setPayload("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ResponseMessage><text>This request was not OK!</text></ResponseMessage>");
        responseMessage.setFaultCode("SERVER");
        responseMessage.setFaultString("Invalid request");
        responseMessage.addFaultDetail("<DetailMessage><text>This request was not OK!</text></DetailMessage>");
        responseMessage.addFaultDetail("<Error><text>This request was not OK!</text></Error>");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });
View Full Code Here

    public void testMessageProcessingWithSoapActionInResponse() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        Map<String, Object> responseHeaders = new HashMap<String, Object>();
        responseHeaders.put(SoapMessageHeaders.SOAP_ACTION, "answerHello");
        final Message responseMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestResponse><Message>Hello World!</Message></TestResponse>", responseHeaders);

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });

        org.springframework.ws.soap.SoapMessage soapRequest = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
        SoapHeader soapRequestHeader = EasyMock.createMock(SoapHeader.class);

        org.springframework.ws.soap.SoapMessage soapResponse = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
       
        StringResult soapResponsePayload = new StringResult();
       
        reset(messageContext, soapRequest, soapRequestHeader, soapResponse);
       
        expect(messageContext.getRequest()).andReturn(soapRequest).anyTimes();
       
        expect(soapRequest.getPayloadSource()).andReturn(new StringSource("<TestRequest><Message>Hello World!</Message></TestRequest>")).times(2);
       
        expect(messageContext.getPropertyNames()).andReturn(new String[]{}).once();
       
        expect(soapRequest.getSoapHeader()).andReturn(soapRequestHeader).once();
        expect(soapRequestHeader.getSource()).andReturn(null).once();
       
        Set<SoapHeaderElement> emptyHeaderSet = Collections.emptySet();
        expect(soapRequestHeader.examineAllHeaderElements()).andReturn(emptyHeaderSet.iterator()).once();
       
        expect(soapRequest.getSoapAction()).andReturn("sayHello").anyTimes();
       
        Set<Attachment> emptyAttachmentSet = Collections.emptySet();
        expect(soapRequest.getAttachments()).andReturn(emptyAttachmentSet.iterator()).once();
       
        expect(messageContext.getResponse()).andReturn(soapResponse).once();

        expect(soapResponse.getPayloadResult()).andReturn(soapResponsePayload).once();
       
        soapResponse.setSoapAction("answerHello");
        expectLastCall().once();
       
        replay(messageContext, soapRequest, soapRequestHeader, soapResponse);
       
        endpoint.invoke(messageContext);
       
        Assert.assertEquals(soapResponsePayload.toString(), responseMessage.getPayload());
       
        verify(messageContext, soapRequest, soapRequestHeader, soapResponse);
    }
View Full Code Here

    public void testMessageProcessingWithSoap11FaultInResponse() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final SoapFault responseMessage = new SoapFault();
        responseMessage.setFaultCode("{http://www.consol.de/citrus}citrus:TEC-1000");
        responseMessage.setFaultString("Invalid request");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });
View Full Code Here

    public void testMessageProcessingWithSoap12FaultInResponse() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        Map<String, Object> requestHeaders = new HashMap<String, Object>();
        requestHeaders.put(SoapMessageHeaders.SOAP_ACTION, "sayHello");
        final Message requestMessage = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestRequest><Message>Hello World!</Message></TestRequest>", requestHeaders);

        final SoapFault responseMessage = new SoapFault();
        responseMessage.setFaultCode("{http://www.consol.de/citrus}citrus:TEC-1000");
        responseMessage.setFaultString("Invalid request");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());

                Assert.assertNotNull(message.getHeader(SoapMessageHeaders.SOAP_ACTION));
                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");

                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });
View Full Code Here

   
    @Test
    public void testEmptySoapMessageProcessing() throws Exception {
        WebServiceEndpoint endpoint = new WebServiceEndpoint();

        final Message requestMessage = new DefaultMessage("");
        final Message responseMessage = new DefaultMessage("");

        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertEquals(message.copyHeaders().size(), requestMessage.copyHeaders().size());
                Assert.assertEquals(message.getPayload(), requestMessage.getPayload());

                return responseMessage;
            }
        });

        org.springframework.ws.soap.SoapMessage soapRequest = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
        SoapHeader soapRequestHeader = EasyMock.createMock(SoapHeader.class);

        org.springframework.ws.soap.SoapMessage soapResponse = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
       
        StringResult soapResponsePayload = new StringResult();
       
        reset(messageContext, soapRequest, soapRequestHeader, soapResponse);
       
        expect(messageContext.getRequest()).andReturn(soapRequest).anyTimes();
       
        expect(soapRequest.getPayloadSource()).andReturn(null).once();
       
        expect(messageContext.getPropertyNames()).andReturn(new String[]{}).once();
       
        expect(soapRequest.getSoapHeader()).andReturn(soapRequestHeader).once();
        expect(soapRequestHeader.getSource()).andReturn(null).once();
       
        Set<SoapHeaderElement> emptyHeaderSet = Collections.emptySet();
        expect(soapRequestHeader.examineAllHeaderElements()).andReturn(emptyHeaderSet.iterator()).once();
       
        expect(soapRequest.getSoapAction()).andReturn(null).anyTimes();
       
        Set<Attachment> emptyAttachmentSet = Collections.emptySet();
        expect(soapRequest.getAttachments()).andReturn(emptyAttachmentSet.iterator()).once();
       
        expect(messageContext.getResponse()).andReturn(soapResponse).once();

        replay(messageContext, soapRequest, soapRequestHeader, soapResponse);
       
        endpoint.invoke(messageContext);
       
        Assert.assertEquals(soapResponsePayload.toString(), responseMessage.getPayload());
       
        verify(messageContext, soapRequest, soapRequestHeader, soapResponse);
    }
View Full Code Here

        SoapAttachment attachment = new SoapAttachment();
        attachment.setContent("TestAttachment!");
        soapMessageAction.setAttachments(Collections.singletonList(attachment));

        Message controlMessage = new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");

        reset(endpoint, consumer, endpointConfiguration, attachmentValidator);
        expect(endpoint.createConsumer()).andReturn(consumer).anyTimes();
        expect(endpoint.getEndpointConfiguration()).andReturn(endpointConfiguration).anyTimes();
        expect(endpointConfiguration.getTimeout()).andReturn(5000L).anyTimes();
View Full Code Here

TOP

Related Classes of com.consol.citrus.message.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.