How to use getAttachments method of com.consol.citrus.ws.actions.ReceiveSoapMessageAction class

Best Citrus code snippet using com.consol.citrus.ws.actions.ReceiveSoapMessageAction.getAttachments

Source:ReceiveSoapMessageTestRunnerTest.java Github

copy

Full Screen

...101 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);102 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);103 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "Foo");104 Assert.assertNotNull(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getHeader("operation"));105 Assert.assertEquals(action.getAttachments().size(), 1L);106 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());107 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent());108 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());109 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());110 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());111 }112 @Test113 public void testSoapAttachment() {114 reset(server, messageConsumer, configuration);115 when(server.createConsumer()).thenReturn(messageConsumer);116 when(server.getEndpointConfiguration()).thenReturn(configuration);117 when(configuration.getTimeout()).thenReturn(100L);118 when(server.getActor()).thenReturn(null);119 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")120 .setHeader("operation","foo")121 .addAttachment(testAttachment));122 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {123 @Override124 public void execute() {125 soap(action -> action.server(server)126 .receive()127 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>").setHeader("operation", "foo"))128 .attachment(testAttachment));129 }130 };131 TestCase test = builder.getTestCase();132 Assert.assertEquals(test.getActionCount(), 1);133 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);134 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);135 ReceiveSoapMessageAction action = ((ReceiveSoapMessageAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate());136 Assert.assertEquals(action.getName(), "receive");137 138 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());139 Assert.assertEquals(action.getEndpoint(), server);140 Assert.assertEquals(action.getValidationContexts().size(), 3);141 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);142 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);143 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);144 145 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);146 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");147 Assert.assertNotNull(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getHeader("operation"));148 Assert.assertEquals(action.getAttachments().size(), 1L);149 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());150 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent());151 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());152 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());153 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());154 }155 @Test156 public void testSoapAttachmentData() {157 reset(server, messageConsumer, configuration);158 when(server.createConsumer()).thenReturn(messageConsumer);159 when(server.getEndpointConfiguration()).thenReturn(configuration);160 when(configuration.getTimeout()).thenReturn(100L);161 when(server.getActor()).thenReturn(null);162 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")163 .setHeader("operation","foo")164 .addAttachment(testAttachment));165 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {166 @Override167 public void execute() {168 soap(action -> action.server(server)169 .receive()170 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")171 .attachment(testAttachment.getContentId(), testAttachment.getContentType(), testAttachment.getContent()));172 }173 };174 TestCase test = builder.getTestCase();175 Assert.assertEquals(test.getActionCount(), 1);176 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);177 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);178 ReceiveSoapMessageAction action = ((ReceiveSoapMessageAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate());179 Assert.assertEquals(action.getName(), "receive");180 181 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());182 Assert.assertEquals(action.getEndpoint(), server);183 Assert.assertEquals(action.getValidationContexts().size(), 3);184 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);185 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);186 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);187 188 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);189 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");190 Assert.assertEquals(action.getAttachments().size(), 1L);191 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());192 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent());193 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());194 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());195 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());196 }197 @Test198 public void testSoapAttachmentResource() throws IOException {199 final Resource attachmentResource = Mockito.mock(Resource.class);200 reset(server, messageConsumer, configuration, resource, attachmentResource);201 when(server.createConsumer()).thenReturn(messageConsumer);202 when(server.getEndpointConfiguration()).thenReturn(configuration);203 when(configuration.getTimeout()).thenReturn(100L);204 when(server.getActor()).thenReturn(null);205 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")206 .setHeader("operation","foo")207 .addAttachment(testAttachment));208 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<TestRequest><Message>Hello World!</Message></TestRequest>".getBytes()));209 when(attachmentResource.getInputStream()).thenReturn(new ByteArrayInputStream("This is an attachment".getBytes()));210 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {211 @Override212 public void execute() {213 soap(action -> action.server(server)214 .receive()215 .payload(resource)216 .attachment(testAttachment.getContentId(), testAttachment.getContentType(), attachmentResource));217 }218 };219 TestCase test = builder.getTestCase();220 Assert.assertEquals(test.getActionCount(), 1);221 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);222 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);223 ReceiveSoapMessageAction action = ((ReceiveSoapMessageAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate());224 Assert.assertEquals(action.getName(), "receive");225 226 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());227 Assert.assertEquals(action.getEndpoint(), server);228 Assert.assertEquals(action.getValidationContexts().size(), 3);229 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);230 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);231 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);232 233 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);234 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");235 236 Assert.assertEquals(action.getAttachments().get(0).getContent(), "This is an attachment");237 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());238 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());239 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());240 }241 @Test242 public void testMultipleSoapAttachmentData() {243 final SoapAttachment attachment1 = new SoapAttachment();244 attachment1.setContentId("attachment01");245 attachment1.setContent("This is an attachment");246 attachment1.setContentType("text/plain");247 attachment1.setCharsetName("UTF-8");248 final SoapAttachment attachment2 = new SoapAttachment();249 attachment2.setContentId("attachment02");250 attachment2.setContent("This is an attachment");251 attachment2.setContentType("text/plain");252 attachment2.setCharsetName("UTF-8");253 reset(server, messageConsumer, configuration);254 when(server.createConsumer()).thenReturn(messageConsumer);255 when(server.getEndpointConfiguration()).thenReturn(configuration);256 when(configuration.getTimeout()).thenReturn(100L);257 when(server.getActor()).thenReturn(null);258 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")259 .setHeader("operation","foo")260 .addAttachment(attachment1)261 .addAttachment(attachment2));262 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {263 @Override264 public void execute() {265 soap(action -> action.server(server)266 .receive()267 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")268 .attachment(attachment1.getContentId(), attachment1.getContentType(), attachment1.getContent())269 .attachment(attachment2.getContentId(), attachment2.getContentType(), attachment2.getContent()));270 }271 };272 TestCase test = builder.getTestCase();273 Assert.assertEquals(test.getActionCount(), 1);274 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);275 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);276 ReceiveSoapMessageAction action = ((ReceiveSoapMessageAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate());277 Assert.assertEquals(action.getName(), "receive");278 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());279 Assert.assertEquals(action.getEndpoint(), server);280 Assert.assertEquals(action.getValidationContexts().size(), 3);281 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);282 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);283 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);284 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);285 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");286 Assert.assertEquals(action.getAttachments().size(), 2L);287 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());288 Assert.assertEquals(action.getAttachments().get(0).getContent(), attachment1.getContent());289 Assert.assertEquals(action.getAttachments().get(0).getContentId(), attachment1.getContentId());290 Assert.assertEquals(action.getAttachments().get(0).getContentType(), attachment1.getContentType());291 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), attachment1.getCharsetName());292 Assert.assertNull(action.getAttachments().get(1).getContentResourcePath());293 Assert.assertEquals(action.getAttachments().get(1).getContent(), attachment2.getContent());294 Assert.assertEquals(action.getAttachments().get(1).getContentId(), attachment2.getContentId());295 Assert.assertEquals(action.getAttachments().get(1).getContentType(), attachment2.getContentType());296 Assert.assertEquals(action.getAttachments().get(1).getCharsetName(), attachment2.getCharsetName());297 }298 @Test299 public void testReceiveBuilderWithEndpointName() {300 TestContext context = applicationContext.getBean(TestContext.class);301 context.setApplicationContext(applicationContextMock);302 reset(applicationContextMock);303 reset(server, messageConsumer, configuration);304 when(server.createConsumer()).thenReturn(messageConsumer);305 when(server.getEndpointConfiguration()).thenReturn(configuration);306 when(configuration.getTimeout()).thenReturn(100L);307 when(server.getActor()).thenReturn(null);308 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")309 .setHeader("operation","foo"));310 when(applicationContextMock.getBean(TestContext.class)).thenReturn(context);...

Full Screen

Full Screen

Source:ReceiveSoapMessageTestDesignerTest.java Github

copy

Full Screen

...90 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);91 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);92 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "Foo");93 Assert.assertNotNull(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getHeader("operation"));94 Assert.assertEquals(action.getAttachments().size(), 1L);95 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());96 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent());97 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());98 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());99 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());100 }101 @Test102 public void testSoapAttachment() {103 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {104 @Override105 public void configure() {106 soap().server(server)107 .receive()108 .message(new DefaultMessage("Foo").setHeader("operation", "foo"))109 .attachment(testAttachment);110 }111 };112 builder.configure();113 TestCase test = builder.getTestCase();114 Assert.assertEquals(test.getActionCount(), 1);115 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);116 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);117 ReceiveSoapMessageAction action = (ReceiveSoapMessageAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();118 Assert.assertEquals(action.getName(), "receive");119 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());120 Assert.assertEquals(action.getEndpoint(), server);121 Assert.assertEquals(action.getValidationContexts().size(), 3);122 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);123 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);124 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);125 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);126 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "Foo");127 Assert.assertNotNull(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getHeader("operation"));128 Assert.assertEquals(action.getAttachments().size(), 1L);129 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());130 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent());131 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());132 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());133 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());134 }135 136 @Test137 public void testSoapAttachmentData() {138 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {139 @Override140 public void configure() {141 soap().server(server)142 .receive()143 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")144 .attachment(testAttachment.getContentId(), testAttachment.getContentType(), testAttachment.getContent());145 }146 };147 builder.configure();148 TestCase test = builder.getTestCase();149 Assert.assertEquals(test.getActionCount(), 1);150 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);151 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);152 153 ReceiveSoapMessageAction action = (ReceiveSoapMessageAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();154 Assert.assertEquals(action.getName(), "receive");155 156 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());157 Assert.assertEquals(action.getEndpoint(), server);158 Assert.assertEquals(action.getValidationContexts().size(), 3);159 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);160 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);161 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);162 163 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);164 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");165 Assert.assertEquals(action.getAttachments().size(), 1L);166 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());167 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent());168 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());169 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());170 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());171 }172 @Test173 public void testSoapAttachmentResource() throws IOException {174 final Resource attachmentResource = Mockito.mock(Resource.class);175 176 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {177 @Override178 public void configure() {179 soap().server(server)180 .receive()181 .payload(resource)182 .attachment(testAttachment.getContentId(), testAttachment.getContentType(), attachmentResource);183 }184 };185 186 reset(resource, attachmentResource);187 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("somePayloadData".getBytes()));188 when(attachmentResource.getInputStream()).thenReturn(new ByteArrayInputStream("someAttachmentData".getBytes()));189 builder.configure();190 TestCase test = builder.getTestCase();191 Assert.assertEquals(test.getActionCount(), 1);192 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);193 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);194 195 ReceiveSoapMessageAction action = (ReceiveSoapMessageAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();196 Assert.assertEquals(action.getName(), "receive");197 198 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());199 Assert.assertEquals(action.getEndpoint(), server);200 Assert.assertEquals(action.getValidationContexts().size(), 3);201 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);202 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);203 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);204 205 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);206 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "somePayloadData");207 208 Assert.assertEquals(action.getAttachments().get(0).getContent(), "someAttachmentData");209 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId());210 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());211 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());212 }213 @Test214 public void testMultipleSoapAttachmentData() {215 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {216 @Override217 public void configure() {218 soap().server(server)219 .receive()220 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")221 .attachment(testAttachment.getContentId() + 1, testAttachment.getContentType(), testAttachment.getContent() + 1)222 .attachment(testAttachment.getContentId() + 2, testAttachment.getContentType(), testAttachment.getContent() + 2);223 }224 };225 builder.configure();226 TestCase test = builder.getTestCase();227 Assert.assertEquals(test.getActionCount(), 1);228 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);229 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), ReceiveSoapMessageAction.class);230 ReceiveSoapMessageAction action = (ReceiveSoapMessageAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();231 Assert.assertEquals(action.getName(), "receive");232 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());233 Assert.assertEquals(action.getEndpoint(), server);234 Assert.assertEquals(action.getValidationContexts().size(), 3);235 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);236 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);237 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);238 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);239 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");240 Assert.assertEquals(action.getAttachments().size(), 2L);241 Assert.assertNull(action.getAttachments().get(0).getContentResourcePath());242 Assert.assertEquals(action.getAttachments().get(0).getContent(), testAttachment.getContent() + 1);243 Assert.assertEquals(action.getAttachments().get(0).getContentId(), testAttachment.getContentId() + 1);244 Assert.assertEquals(action.getAttachments().get(0).getContentType(), testAttachment.getContentType());245 Assert.assertEquals(action.getAttachments().get(0).getCharsetName(), testAttachment.getCharsetName());246 Assert.assertNull(action.getAttachments().get(1).getContentResourcePath());247 Assert.assertEquals(action.getAttachments().get(1).getContent(), testAttachment.getContent() + 2);248 Assert.assertEquals(action.getAttachments().get(1).getContentId(), testAttachment.getContentId() + 2);249 Assert.assertEquals(action.getAttachments().get(1).getContentType(), testAttachment.getContentType());250 Assert.assertEquals(action.getAttachments().get(1).getCharsetName(), testAttachment.getCharsetName());251 }252 @Test253 public void testReceiveBuilderWithEndpointName() {254 reset(applicationContextMock);255 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());256 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());257 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());258 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {259 @Override260 public void configure() {261 receive("replyMessageEndpoint")262 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>");263 receive("fooMessageEndpoint")264 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>");...

Full Screen

Full Screen

Source:SoapServerRequestActionBuilder.java Github

copy

Full Screen

...70 SoapAttachment attachment = new SoapAttachment();71 attachment.setContentId(contentId);72 attachment.setContentType(contentType);73 attachment.setContent(content);74 getAction().getAttachments().add(attachment);75 return this;76 }77 /**78 * Sets the control attachment with content resource.79 * @param contentId80 * @param contentType81 * @param contentResource82 * @return83 */84 public SoapServerRequestActionBuilder attachment(String contentId, String contentType, Resource contentResource) {85 return attachment(contentId, contentType, contentResource, FileUtils.getDefaultCharset());86 }87 /**88 * Sets the control attachment with content resource.89 * @param contentId90 * @param contentType91 * @param contentResource92 * @param charset93 * @return94 */95 public SoapServerRequestActionBuilder attachment(String contentId, String contentType, Resource contentResource, Charset charset) {96 SoapAttachment attachment = new SoapAttachment();97 attachment.setContentId(contentId);98 attachment.setContentType(contentType);99 try {100 attachment.setContent(FileUtils.readToString(contentResource, charset));101 } catch (IOException e) {102 throw new CitrusRuntimeException("Failed to read attachment content resource", e);103 }104 getAction().getAttachments().add(attachment);105 return this;106 }107 /**108 * Sets the charset name for this send action builder's control attachment.109 * @param charsetName110 * @return111 */112 public SoapServerRequestActionBuilder charset(String charsetName) {113 if (!getAction().getAttachments().isEmpty()) {114 getAction().getAttachments().get(getAction().getAttachments().size() - 1).setCharsetName(charsetName);115 }116 return this;117 }118 /**119 * Sets the control attachment from Java object instance.120 * @param attachment121 * @return122 */123 public SoapServerRequestActionBuilder attachment(SoapAttachment attachment) {124 getAction().getAttachments().add(attachment);125 return this;126 }127 /**128 * Set explicit SOAP attachment validator.129 * @param validator130 * @return131 */132 public SoapServerRequestActionBuilder attachmentValidator(SoapAttachmentValidator validator) {133 getAction().setAttachmentValidator(validator);134 return this;135 }136 /**137 * Sets the request content type header.138 * @param contentType...

Full Screen

Full Screen

getAttachments

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.exceptions.CitrusRuntimeException;4import com.consol.citrus.message.Message;5import com.consol.citrus.message.MessageType;6import com.consol.citrus.ws.message.SoapAttachment;7import com.consol.citrus.ws.message.SoapMessage;8import org.springframework.util.CollectionUtils;9import org.springframework.util.StringUtils;10import org.springframework.ws.WebServiceMessage;11import org.springframework.ws.soap.SoapMessage;12import org.springframework.ws.soap.SoapMessageFactory;13import org.springframework.ws.soap.SoapMessageUtils;14import org.springframework.ws.soap.SoapVersion;15import org.springframework.ws.soap.saaj.SaajSoapMessage;16import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;17import org.springframework.ws.soap.saaj.SaajSoapMessageUtils;18import org.springframework.ws.soap.saaj.SaajUtils;19import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition;20import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionEditor;21import org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver;22import org.springframework.ws.soap.server.endpoint.annotation.FaultCode;23import org.springframework.ws.soap.server.endpoint.annotation.SoapAction;24import org.springframework.ws.soap.server.endpoint.annotation.SoapHeader;25import org.springframework.ws.soap.server.endpoint.annotation.SoapHeaderMap;26import org.springframework.ws.soap.server.endpoint.annotation.SoapHeaders;27import org.springframework.ws.soap.server.endpoint.annotation.SoapResponse;28import org.springframework.ws.soap.server.endpoint.annotation.SoapResponseAttachment;29import org.springframework.ws.soap.server.endpoint.annotation.SoapResponseAttachments;30import org.springframework.ws.soap.server.endpoint.annotation.SoapResponsePayload;31import org.springframework.ws.soap.server.endpoint.annotation.SoapResponsePayloads;32import org.springframework.ws.soap.server.endpoint.annotation.SoapVersionAnnotation;33import org.springframework.ws.soap.server.endpoint.annotation.SwaRef;34import org.springframework.ws.soap.server.endpoint.annotation.SwaRefs;35import org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping;36import org.springframework.ws.soap.server.endpoint.mapping.SoapHeaderEndpointMapping;37import org.springframework.ws.soap.soap11.Soap11Body;38import org.springframework.ws.soap.soap11.Soap11Envelope;39import org.springframework.ws.soap.soap11.Soap11Fault;40import org.springframework.ws.soap.so

Full Screen

Full Screen

getAttachments

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import org.testng.annotations.Test;3import com.consol.citrus.annotations.CitrusTest;4import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;5import com.consol.citrus.ws.client.WebServiceClient;6import com.consol.citrus.ws.message.SoapAttachment;7import com.consol.citrus.ws.message.SoapMessage;8import com.consol.citrus.ws.message.SoapMessageBuilder;9import com.consol.citrus.ws.message.SoapMessageHeaders;10import com.consol.citrus.ws.message.SoapMessageValidator;11import com.consol.citrus.ws.validation.SoapAttachmentValidator;12import com.consol.citrus.ws.validation.SoapFaultDetailValidator;13import com.consol.citrus.ws.validation.SoapFaultValidator;14import com.consol.citrus.ws.validation.SoapHeaderValidator;15import com.consol.citrus.ws.validation.SoapPayloadElementValidator;16import com.consol.citrus.ws.validation.SoapSchemaValidationContext;17import com.consol.citrus.ws.validation.SoapSchemaValidator;18import com.consol.citrus.ws.validation.SoapValidationContext;19import com.consol.citrus.ws.validation.SoapValidationContextBuilder;20import com.consol.citrus.ws.validation.SoapValidationContextBuilder.SoapValidationContextBuilderSupport;21import com.consol.citrus.ws.validation.SoapValidationContextBuilder.SoapValidationContextBuilderSupport.SoapValidationContextBuilderSupportBuilder;22import com.consol.citrus.ws.validation.SoapValidationContextBuilder.SoapValidationContextBuilderSupport.SoapValidationContextBuilderSupportBuilder.SoapValidationContextBuilderSupportBuilderBuilder;23import com.consol.citrus.ws.validation.SoapValidationContextBuilder.SoapValidationContextBuilderSupport.SoapValidationContextBuilderSupportBuilder.SoapValidationContextBuilderSupportBuilderBuilder.SoapValidationContextBuilderSupportBuilderBuilderBuilder;24import com.consol.citrus.ws.validation.SoapValidationContextBuilder.SoapValidationContextBuilderSupport.SoapValidationContextBuilderSupportBuilder.SoapValidationContextBuilderSupportBuilderBuilder.SoapValidationContextBuilderSupportBuilderBuilderBuilder.SoapValidationContextBuilderSupportBuilderBuilderBuilderBuilder;25import com.consol.citrus.ws.validation.SoapValidationContextBuilder.SoapValidationContextBuilderSupport.SoapValidationContextBuilderSupportBuilder.SoapValidationContextBuilderSupportBuilderBuilder.SoapValidationContextBuilderSupportBuilderBuilderBuilder.SoapValidationContextBuilderSupportBuilderBuilderBuilderBuilder.SoapValidation

Full Screen

Full Screen

getAttachments

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import org.springframework.http.HttpStatus;5import org.testng.annotations.Test;6public class SoapAttachmentTest extends TestNGCitrusTestDesigner {7 public void soapAttachmentTest() {8 variable("firstName", "John");9 variable("lastName", "Doe");10 variable("email", "

Full Screen

Full Screen

getAttachments

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.springframework.core.io.ClassPathResource;4import org.testng.annotations.Test;5public class 3 extends TestNGCitrusTestDesigner {6 public void configure() {7 http(httpActionBuilder -> httpActionBuilder.client("httpClient")8 .send()9 .post()10 .payload(new ClassPathResource("request.xml")));11 http(httpActionBuilder -> httpActionBuilder.client("httpClient")12 .receive()13 .response(HttpStatus.OK)14 .payload(new ClassPathResource("response.xml")));15 http(httpActionBuilder -> httpActionBuilder.client("httpClient")16 .receive()17 .response(HttpStatus.OK)18 .payload(new ClassPathResource("response.xml"))19 .attachment("attachment1", new ClassPathResource("attachment1.txt"))20 .attachment("attachment2", new ClassPathResource("attachment2.txt")));21 http(httpActionBuilder -> httpActionBuilder.client("httpClient")22 .send()23 .post()24 .payload(new ClassPathResource("request.xml")));25 http(httpActionBuilder -> httpActionBuilder.client("httpClient")26 .receive()27 .response(HttpStatus.OK)28 .payload(new ClassPathResource("response.xml"))29 .attachment("attachment1", new ClassPathResource("attachment1.txt"))30 .attachment("attachment2", new ClassPathResource("attachment2.txt")));31 }32}33package com.consol.citrus;34import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;35import org.springframework.core.io.ClassPathResource;36import org.testng.annotations.Test;37public class 4 extends TestNGCitrusTestDesigner {38 public void configure() {39 http(httpActionBuilder -> httpActionBuilder.client("httpClient")40 .send()41 .post()42 .payload(new ClassPathResource("request.xml")));43 http(httpActionBuilder -> httpActionBuilder.client("httpClient")44 .receive()45 .response(HttpStatus.OK)46 .payload(new ClassPathResource("response.xml")));47 http(httpActionBuilder -> httpActionBuilder.client("httpClient")48 .receive()49 .response(HttpStatus.OK)50 .payload(new ClassPathResource("response.xml"))51 .attachment("attachment1", new ClassPath

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful