Package com.consol.citrus.ws.message

Examples of com.consol.citrus.ws.message.SoapAttachment


*/
public class SimpleSoapAttachmentValidatorTest {
   
    @Test
    public void testSimpleValidation() throws IOException {
        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("soapAttachmentId");
        controlAttachment.setContentType("text/plain");
        controlAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(controlAttachment);

        SimpleSoapAttachmentValidator validator = new SimpleSoapAttachmentValidator();
View Full Code Here


        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
   
    @Test
    public void testSimpleValidationNoControlContentId() throws IOException {
        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentType("text/plain");
        controlAttachment.setContent("This is a test!");
       
        SimpleSoapAttachmentValidator validator = new SimpleSoapAttachmentValidator();
        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
View Full Code Here

        PayloadTemplateMessageBuilder controlMessageBuilder = new PayloadTemplateMessageBuilder();
        XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
        validationContext.setMessageBuilder(controlMessageBuilder);
        controlMessageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

        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();

        expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();
       
        attachmentValidator.validateAttachment((SoapMessage)anyObject(), anyObject(List.class));
        expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                Assert.assertEquals(((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).size(), 1L);
                SoapAttachment soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(0);
                Assert.assertEquals(soapAttachment.getContent(), "TestAttachment!");
                Assert.assertNull(soapAttachment.getContentId());
                Assert.assertEquals(soapAttachment.getContentType(), "text/plain");
                return null;
            }
        });

        expect(endpoint.getActor()).andReturn(null).anyTimes();
View Full Code Here

        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
   
    @Test(expectedExceptions = ValidationException.class)
    public void testSimpleValidationWrongContentId() throws IOException {
        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("wrongAttachmentId");
        controlAttachment.setContentType("text/plain");
        controlAttachment.setContent("This is a test!");
       
        SimpleSoapAttachmentValidator validator = new SimpleSoapAttachmentValidator();
        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
View Full Code Here

        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
   
    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSimpleValidationWrongContent() throws IOException {
        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("soapAttachmentId");
        controlAttachment.setContentType("text/plain");
        controlAttachment.setContent("This is not OK!");
       
        SimpleSoapAttachmentValidator validator = new SimpleSoapAttachmentValidator();
        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
View Full Code Here

        PayloadTemplateMessageBuilder controlMessageBuilder = new PayloadTemplateMessageBuilder();
        XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
        validationContext.setMessageBuilder(controlMessageBuilder);
        controlMessageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

        SoapAttachment attachment = new SoapAttachment();
        attachment.setContentId("myAttachment");
        attachment.setContentType("text/xml");
        attachment.setContent("<TestAttachment><Message>Hello World!</Message></TestAttachment>");
        attachment.setCharsetName("UTF-16");
        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();

        expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();
       
        attachmentValidator.validateAttachment((SoapMessage)anyObject(), (List)anyObject());
        expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                Assert.assertEquals(((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).size(), 1L);
                SoapAttachment soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(0);
                Assert.assertEquals(soapAttachment.getContent(), "<TestAttachment><Message>Hello World!</Message></TestAttachment>");
                Assert.assertEquals(soapAttachment.getContentId(), "myAttachment");
                Assert.assertEquals(soapAttachment.getContentType(), "text/xml");
                Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-16");
                return null;
            }
        });

        expect(endpoint.getActor()).andReturn(null).anyTimes();
View Full Code Here

        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
   
    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSimpleValidationWrongContentType() throws IOException {
        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("soapAttachmentId");
        controlAttachment.setContentType("text/xml");
        controlAttachment.setContent("This is a test!");
       
        SimpleSoapAttachmentValidator validator = new SimpleSoapAttachmentValidator();
        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
View Full Code Here

        XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
        validationContext.setMessageBuilder(controlMessageBuilder);
        controlMessageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

        List<SoapAttachment> attachments = new ArrayList<SoapAttachment>();
        SoapAttachment attachment = new SoapAttachment();
        attachment.setContentId("1stAttachment");
        attachment.setContentType("text/xml");
        attachment.setContent("<TestAttachment><Message>Hello World1!</Message></TestAttachment>");
        attachment.setCharsetName("UTF-8");
        attachments.add(attachment);

        SoapAttachment attachment2 = new SoapAttachment();
        attachment2.setContentId("2ndAttachment");
        attachment2.setContentType("text/xml");
        attachment2.setContent("<TestAttachment><Message>Hello World2!</Message></TestAttachment>");
        attachment2.setCharsetName("UTF-16");
        attachments.add(attachment2);
        soapMessageAction.setAttachments(attachments);

        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();

        expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();

        attachmentValidator.validateAttachment((SoapMessage)anyObject(), (List)anyObject());
        expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                Assert.assertEquals(((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).size(), 2L);

                SoapAttachment soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(0);
                Assert.assertEquals(soapAttachment.getContent(), "<TestAttachment><Message>Hello World1!</Message></TestAttachment>");
                Assert.assertEquals(soapAttachment.getContentId(), "1stAttachment");
                Assert.assertEquals(soapAttachment.getContentType(), "text/xml");
                Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-8");

                soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(1);
                Assert.assertEquals(soapAttachment.getContent(), "<TestAttachment><Message>Hello World2!</Message></TestAttachment>");
                Assert.assertEquals(soapAttachment.getContentId(), "2ndAttachment");
                Assert.assertEquals(soapAttachment.getContentType(), "text/xml");
                Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-16");
                return null;
            }
        });

        expect(endpoint.getActor()).andReturn(null).anyTimes();
View Full Code Here

        PayloadTemplateMessageBuilder controlMessageBuilder = new PayloadTemplateMessageBuilder();
        XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
        validationContext.setMessageBuilder(controlMessageBuilder);
        controlMessageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

        SoapAttachment attachment = new SoapAttachment();
        attachment.setContentId("myAttachment");
        attachment.setContent("");
        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();

        expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();
       
        attachmentValidator.validateAttachment((SoapMessage)anyObject(), (List) anyObject());
        expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                Assert.assertEquals(((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).size(), 1L);
                SoapAttachment soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(0);
                Assert.assertEquals(soapAttachment.getContent(), "");
                Assert.assertEquals(soapAttachment.getContentId(), "myAttachment");
                Assert.assertEquals(soapAttachment.getContentType(), "text/plain");
                Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-8");
                return null;
            }
        });

        expect(endpoint.getActor()).andReturn(null).anyTimes();
View Full Code Here

        PayloadTemplateMessageBuilder controlMessageBuilder = new PayloadTemplateMessageBuilder();
        XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
        validationContext.setMessageBuilder(controlMessageBuilder);
        controlMessageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

        SoapAttachment attachment = new SoapAttachment();
        attachment.setContentId("myAttachment");
        attachment.setContentType("text/xml");
        attachment.setContentResourcePath("classpath:com/consol/citrus/ws/actions/test-attachment.xml");
        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();

        expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();
       
        attachmentValidator.validateAttachment((SoapMessage)anyObject(), (List) anyObject());
        expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                Assert.assertEquals(((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).size(), 1L);
                SoapAttachment soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(0);
                Assert.assertEquals(soapAttachment.getContent(), "<TestAttachment><Message>Hello World!</Message></TestAttachment>");
                Assert.assertEquals(soapAttachment.getContentId(), "myAttachment");
                Assert.assertEquals(soapAttachment.getContentType(), "text/xml");
                Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-8");
                return null;
            }
        });

        expect(endpoint.getActor()).andReturn(null).anyTimes();
View Full Code Here

TOP

Related Classes of com.consol.citrus.ws.message.SoapAttachment

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.