How to use setMessageFactory method of com.consol.citrus.ws.client.WebServiceEndpointConfiguration class

Best Citrus code snippet using com.consol.citrus.ws.client.WebServiceEndpointConfiguration.setMessageFactory

Source:SoapMessageConverterTest.java Github

copy

Full Screen

...86 @Test87 public void testOutboundSoapMessageCreation() {88 final Message testMessage = new DefaultMessage(payload);89 final WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();90 endpointConfiguration.setMessageFactory(soapMessageFactory);91 final StringResult soapBodyResult = new StringResult();92 when(soapMessageFactory.createWebServiceMessage()).thenReturn(soapRequest);93 when(soapRequest.getSoapBody()).thenReturn(soapBody);94 when(soapBody.getPayloadResult()).thenReturn(soapBodyResult);95 soapMessageConverter.convertOutbound(testMessage, endpointConfiguration, context);96 Assert.assertEquals(soapBodyResult.toString(), XML_PROCESSING_INSTRUCTION + payload);97 }98 @Test99 public void testOutboundSoapBody() {100 final Message testMessage = new DefaultMessage(payload);101 final StringResult soapBodyResult = new StringResult();102 when(soapRequest.getSoapBody()).thenReturn(soapBody);103 when(soapBody.getPayloadResult()).thenReturn(soapBodyResult);104 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);105 Assert.assertEquals(soapBodyResult.toString(), XML_PROCESSING_INSTRUCTION + payload);106 }107 @Test108 public void testOutboundSoapAction() {109 final Message testMessage = new DefaultMessage(payload)110 .setHeader(SoapMessageHeaders.SOAP_ACTION, "soapAction");111 when(soapRequest.getSoapBody()).thenReturn(soapBody);112 when(soapBody.getPayloadResult()).thenReturn(new StringResult());113 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);114 verify(soapRequest).setSoapAction("soapAction");115 }116 @Test117 public void testOutboundSoapHeaderContent() {118 final String soapHeaderContent = "<header>" +119 "<operation>unitTest</operation>" +120 "<messageId>123456789</messageId>" +121 "</header>";122 final Message testMessage = new DefaultMessage(payload)123 .addHeaderData(soapHeaderContent);124 final StringResult soapHeaderResult = new StringResult();125 when(soapRequest.getSoapBody()).thenReturn(soapBody);126 when(soapBody.getPayloadResult()).thenReturn(new StringResult());127 when(soapRequest.getSoapHeader()).thenReturn(soapHeader);128 when(soapHeader.getResult()).thenReturn(soapHeaderResult);129 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);130 Assert.assertEquals(soapHeaderResult.toString(), soapHeaderContent);131 }132 @Test133 public void testMultipleOutboundSoapHeaderContent() {134 final String soapHeaderContent = "<header>" +135 "<operation>unitTest</operation>" +136 "<messageId>123456789</messageId>" +137 "</header>";138 final Message testMessage = new DefaultMessage(payload)139 .addHeaderData(soapHeaderContent)140 .addHeaderData("<AppInfo><appId>123456789</appId></AppInfo>");141 final StringResult soapHeaderResult = new StringResult();142 when(soapRequest.getSoapBody()).thenReturn(soapBody);143 when(soapBody.getPayloadResult()).thenReturn(new StringResult());144 when(soapRequest.getSoapHeader()).thenReturn(soapHeader);145 when(soapHeader.getResult()).thenReturn(soapHeaderResult);146 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);147 Assert.assertEquals(soapHeaderResult.toString(), soapHeaderContent + "<AppInfo><appId>123456789</appId></AppInfo>");148 }149 @Test150 public void testOutboundSoapHeader() {151 final Message testMessage = new DefaultMessage(payload)152 .setHeader("operation", "unitTest")153 .setHeader("messageId", "123456789");154 when(soapRequest.getSoapBody()).thenReturn(soapBody);155 when(soapBody.getPayloadResult()).thenReturn(new StringResult());156 when(soapRequest.getSoapHeader()).thenReturn(soapHeader);157 when(soapHeader.addHeaderElement(eq(new QName("", "operation", "")))).thenReturn(soapHeaderElement);158 when(soapHeader.addHeaderElement(eq(new QName("", "messageId", "")))).thenReturn(soapHeaderElement);159 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);160 verify(soapHeaderElement).setText("unitTest");161 verify(soapHeaderElement).setText("123456789");162 }163 @Test164 public void testOutboundSoapHeaderQNameString() {165 final Message testMessage = new DefaultMessage(payload)166 .setHeader("{http://www.citrus.com}citrus:operation", "unitTest")167 .setHeader("{http://www.citrus.com}citrus:messageId", "123456789");168 when(soapRequest.getSoapBody()).thenReturn(soapBody);169 when(soapBody.getPayloadResult()).thenReturn(new StringResult());170 when(soapRequest.getSoapHeader()).thenReturn(soapHeader);171 when(soapHeader.addHeaderElement(eq(new QName("http://www.citrus.com", "operation", "citrus")))).thenReturn(soapHeaderElement);172 when(soapHeader.addHeaderElement(eq(new QName("http://www.citrus.com", "messageId", "citrus")))).thenReturn(soapHeaderElement);173 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);174 verify(soapHeaderElement).setText("unitTest");175 verify(soapHeaderElement).setText("123456789");176 }177 @Test178 @SuppressWarnings("rawtypes")179 public void testOutboundSoapMimeHeader() {180 final Message testMessage = new DefaultMessage(payload)181 .setHeader(SoapMessageHeaders.HTTP_PREFIX + "operation", "unitTest")182 .setHeader(SoapMessageHeaders.HTTP_PREFIX + "messageId", "123456789");183 final SaajSoapMessage saajSoapRequest = mock(SaajSoapMessage.class);184 final SOAPMessage saajMessage = mock(SOAPMessage.class);185 final MimeHeaders mimeHeaders = new MimeHeaders();186 when(saajSoapRequest.getEnvelope()).thenReturn(soapEnvelope);187 when(soapEnvelope.getBody()).thenReturn(soapBody);188 when(soapBody.getPayloadResult()).thenReturn(new StringResult());189 when(saajSoapRequest.getSaajMessage()).thenReturn(saajMessage);190 when(saajMessage.getMimeHeaders()).thenReturn(mimeHeaders);191 soapMessageConverter.convertOutbound(saajSoapRequest, testMessage, new WebServiceEndpointConfiguration(), context);192 final Iterator it = mimeHeaders.getAllHeaders();193 Assert.assertEquals(((MimeHeader)it.next()).getName(), "operation");194 Assert.assertEquals(((MimeHeader)it.next()).getValue(), "123456789");195 Assert.assertFalse(it.hasNext());196 }197 @Test198 @SuppressWarnings("rawtypes")199 public void testOutboundSoapMimeHeaderSkipped() {200 final Message testMessage = new DefaultMessage(payload)201 .setHeader(SoapMessageHeaders.HTTP_PREFIX + "operation", "unitTest")202 .setHeader(SoapMessageHeaders.HTTP_PREFIX + "messageId", "123456789");203 final WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();204 endpointConfiguration.setHandleMimeHeaders(false);205 final SaajSoapMessage saajSoapRequest = mock(SaajSoapMessage.class);206 when(saajSoapRequest.getEnvelope()).thenReturn(soapEnvelope);207 when(soapEnvelope.getBody()).thenReturn(soapBody);208 when(soapBody.getPayloadResult()).thenReturn(new StringResult());209 soapMessageConverter.convertOutbound(saajSoapRequest, testMessage, endpointConfiguration, context);210 }211 @Test212 public void testOutboundSoapAttachment() {213 final SoapAttachment attachment = new SoapAttachment();214 attachment.setContentId("attContentId");215 attachment.setContent("This is a SOAP attachment\nwith multi-line");216 attachment.setContentType("plain/text");217 final SoapMessage testMessage = new SoapMessage(payload);218 testMessage.addAttachment(attachment);219 when(soapRequest.getSoapBody()).thenReturn(soapBody);220 when(soapBody.getPayloadResult()).thenReturn(new StringResult());221 doAnswer(invocation -> {222 InputStreamSource contentStream = (InputStreamSource)invocation.getArguments()[1];223 BufferedReader reader = new BufferedReader(new InputStreamReader(contentStream.getInputStream()));224 Assert.assertEquals(reader.readLine(), "This is a SOAP attachment");225 Assert.assertEquals(reader.readLine(), "with multi-line");226 reader.close();227 return null;228 }).when(soapRequest).addAttachment(eq("<attContentId>"), any(InputStreamSource.class), eq(attachment.getContentType()));229 soapMessageConverter.convertOutbound(soapRequest, testMessage, new WebServiceEndpointConfiguration(), context);230 231 verify(soapRequest).addAttachment(eq("<attContentId>"), any(InputStreamSource.class), eq(attachment.getContentType()));232 }233 @Test234 public void testInboundSoapBody() {235 final StringSource soapBodySource = new StringSource(payload);236 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);237 when(soapEnvelope.getSource()).thenReturn(new StringSource(getSoapRequestPayload()));238 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);239 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);240 when(soapEnvelope.getHeader()).thenReturn(soapHeader);241 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());242 when(soapHeader.getSource()).thenReturn(null);243 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());244 when(soapResponse.getSoapAction()).thenReturn("");245 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);246 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + payload);247 Assert.assertNull(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION));248 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);249 }250 @Test251 public void testInboundSoapBodyOnlyRootElement() {252 final StringSource soapBodySource = new StringSource("<testMessage/>");253 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);254 when(soapEnvelope.getSource()).thenReturn(new StringSource(getSoapRequestPayload()));255 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);256 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);257 when(soapEnvelope.getHeader()).thenReturn(soapHeader);258 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());259 when(soapHeader.getSource()).thenReturn(null);260 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());261 when(soapResponse.getSoapAction()).thenReturn("");262 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);263 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + "<testMessage/>");264 Assert.assertNull(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION));265 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);266 }267 @Test268 public void testInboundSoapAction() {269 final StringSource soapBodySource = new StringSource(payload);270 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);271 when(soapEnvelope.getSource()).thenReturn(new StringSource(getSoapRequestPayload()));272 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);273 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);274 when(soapEnvelope.getHeader()).thenReturn(soapHeader);275 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());276 when(soapHeader.getSource()).thenReturn(null);277 when(soapResponse.getSoapAction()).thenReturn("soapOperation");278 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());279 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);280 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + payload);281 Assert.assertEquals(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION), "soapOperation");282 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);283 }284 @Test285 public void testInboundSoapHeaderContent() {286 final String soapHeaderContent = "<header>" +287 "<operation>unitTest</operation>" +288 "<messageId>123456789</messageId>" +289 "</header>";290 final StringSource soapBodySource = new StringSource(payload);291 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);292 when(soapEnvelope.getSource()).thenReturn(new StringSource(getSoapRequestPayload()));293 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);294 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);295 when(soapEnvelope.getHeader()).thenReturn(soapHeader);296 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());297 when(soapHeader.getSource()).thenReturn(new StringSource(soapHeaderContent));298 when(soapResponse.getSoapAction()).thenReturn("\"\"");299 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());300 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);301 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + payload);302 Assert.assertEquals(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION), "");303 Assert.assertEquals(responseMessage.getHeaderData().size(), 1L);304 Assert.assertEquals(responseMessage.getHeaderData().get(0), XML_PROCESSING_INSTRUCTION + soapHeaderContent);305 }306 @Test307 public void testInboundSoapHeader() {308 final StringSource soapBodySource = new StringSource(payload);309 final Set<SoapHeaderElement> soapHeaders = new HashSet<>();310 soapHeaders.add(soapHeaderElement);311 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);312 when(soapEnvelope.getSource()).thenReturn(new StringSource(getSoapRequestPayload()));313 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);314 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);315 when(soapEnvelope.getHeader()).thenReturn(soapHeader);316 when(soapHeader.examineAllHeaderElements()).thenReturn(soapHeaders.iterator());317 when(soapHeader.getSource()).thenReturn(null);318 when(soapHeaderElement.getName()).thenReturn(new QName("{http://citrusframework.org}citrus:messageId"));319 when(soapHeaderElement.getText()).thenReturn("123456789");320 when(soapResponse.getSoapAction()).thenReturn("soapOperation");321 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());322 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);323 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + payload);324 Assert.assertEquals(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION), "soapOperation");325 Assert.assertEquals(responseMessage.getHeader("{http://citrusframework.org}citrus:messageId"), "123456789");326 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);327 }328 @Test329 public void testInboundSoapAttachment() throws IOException {330 final SoapAttachment attachment = new SoapAttachment();331 attachment.setContentId("attContentId");332 attachment.setContent("This is a SOAP attachment" + System.getProperty("line.separator") + "with multi-line");333 attachment.setContentType("plain/text");334 final StringSource soapBodySource = new StringSource(payload);335 final Set<Attachment> soapAttachments = new HashSet<>();336 soapAttachments.add(attachment);337 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);338 when(soapEnvelope.getSource()).thenReturn(new StringSource(getSoapRequestPayload()));339 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);340 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);341 when(soapEnvelope.getHeader()).thenReturn(soapHeader);342 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());343 when(soapHeader.getSource()).thenReturn(null);344 when(soapResponse.getSoapAction()).thenReturn("soapOperation");345 when(soapResponse.getAttachments()).thenReturn(soapAttachments.iterator());346 final SoapMessage responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);347 Assert.assertNotNull(responseMessage);348 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + payload);349 Assert.assertEquals(responseMessage.getSoapAction(), "soapOperation");350 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);351 final List<SoapAttachment> attachments = responseMessage.getAttachments();352 Assert.assertEquals(attachments.size(), 1L);353 Assert.assertEquals(attachments.get(0).getContentId(), attachment.getContentId());354 Assert.assertEquals(attachments.get(0).getContentType(), attachment.getContentType());355 Assert.assertEquals(FileUtils.readToString(attachments.get(0).getInputStream()), attachment.getContent());356 }357 @Test358 public void testInboundSoapBodyWithNamespaceTranslation() {359 final StringSource soapBodySource = new StringSource(payload);360 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);361 when(soapEnvelope.getSource()).thenReturn(new DOMSource(XMLUtils.parseMessagePayload(getSoapRequestPayload(payload, "xmlns:foo=\"http://citruframework.org/foo\"")).getFirstChild()));362 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);363 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);364 when(soapEnvelope.getHeader()).thenReturn(soapHeader);365 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());366 when(soapHeader.getSource()).thenReturn(null);367 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());368 when(soapResponse.getSoapAction()).thenReturn("");369 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);370 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + "<testMessage xmlns:foo=\"http://citruframework.org/foo\">Hello</testMessage>");371 Assert.assertNull(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION));372 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);373 }374 @Test375 public void testInboundSoapBodyWithNamespaceTranslationXmlProcessingInstruction() {376 final StringSource soapBodySource = new StringSource(XML_PROCESSING_INSTRUCTION + payload);377 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);378 when(soapEnvelope.getSource()).thenReturn(new DOMSource(XMLUtils.parseMessagePayload(getSoapRequestPayload(payload, "xmlns:foo=\"http://citruframework.org/foo\"")).getFirstChild()));379 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);380 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);381 when(soapEnvelope.getHeader()).thenReturn(soapHeader);382 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());383 when(soapHeader.getSource()).thenReturn(null);384 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());385 when(soapResponse.getSoapAction()).thenReturn("");386 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);387 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + "<testMessage xmlns:foo=\"http://citruframework.org/foo\">Hello</testMessage>");388 Assert.assertNull(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION));389 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);390 }391 @Test392 public void testInboundSoapBodyWithNamespaceTranslationOnlyRootElement() {393 final String payload = "<testMessage xmlns:foo=\"http://citruframework.org/foo\" xmlns:bar=\"http://citruframework.org/bar\" " +394 "other=\"true\"/>";395 final StringSource soapBodySource = new StringSource(payload);396 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);397 when(soapEnvelope.getSource()).thenReturn(new DOMSource(XMLUtils.parseMessagePayload(getSoapRequestPayload(payload, "skip=\"true\"", "xmlns:foo=\"http://citruframework.org/foo\"",398 "xmlns:new=\"http://citruframework.org/new\"")).getFirstChild()));399 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);400 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);401 when(soapEnvelope.getHeader()).thenReturn(soapHeader);402 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());403 when(soapHeader.getSource()).thenReturn(null);404 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());405 when(soapResponse.getSoapAction()).thenReturn("");406 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);407 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + "<testMessage xmlns:foo=\"http://citruframework.org/foo\" xmlns:bar=\"http://citruframework.org/bar\" " +408 "other=\"true\" xmlns:new=\"http://citruframework.org/new\"/>");409 Assert.assertNull(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION));410 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);411 }412 @Test413 public void testInboundSoapBodyWithNamespaceTranslationDuplicates() {414 final String payload = "<testMessage xmlns:foo=\"http://citruframework.org/foo\" xmlns:bar=\"http://citruframework.org/bar\" " +415 "other=\"true\">Hello</testMessage>";416 final StringSource soapBodySource = new StringSource(payload);417 when(soapResponse.getEnvelope()).thenReturn(soapEnvelope);418 when(soapEnvelope.getSource()).thenReturn(new DOMSource(XMLUtils.parseMessagePayload(getSoapRequestPayload(payload, "skip=\"true\"", "xmlns:foo=\"http://citruframework.org/foo\"",419 "xmlns:new=\"http://citruframework.org/new\"")).getFirstChild()));420 when(soapResponse.getPayloadSource()).thenReturn(soapBodySource);421 when(soapResponse.getSoapHeader()).thenReturn(soapHeader);422 when(soapEnvelope.getHeader()).thenReturn(soapHeader);423 when(soapHeader.examineAllHeaderElements()).thenReturn(new HashSet<SoapHeaderElement>().iterator());424 when(soapHeader.getSource()).thenReturn(null);425 when(soapResponse.getAttachments()).thenReturn(new HashSet<Attachment>().iterator());426 when(soapResponse.getSoapAction()).thenReturn("");427 final Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration(), context);428 Assert.assertEquals(responseMessage.getPayload(), XML_PROCESSING_INSTRUCTION + "<testMessage xmlns:foo=\"http://citruframework.org/foo\" xmlns:bar=\"http://citruframework.org/bar\" " +429 "other=\"true\" xmlns:new=\"http://citruframework.org/new\">Hello</testMessage>");430 Assert.assertNull(responseMessage.getHeader(SoapMessageHeaders.SOAP_ACTION));431 Assert.assertEquals(responseMessage.getHeaderData().size(), 0L);432 }433 @Test434 public void testInboundSoapKeepEnvelope() throws IOException {435 final SaajSoapMessageFactory soapMessageFactory = new SaajSoapMessageFactory();436 soapMessageFactory.afterPropertiesSet();437 final WebServiceMessage soapMessage = soapMessageFactory.createWebServiceMessage(new ByteArrayInputStream((XML_PROCESSING_INSTRUCTION + getSoapRequestPayload()).getBytes()));438 final WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();439 endpointConfiguration.setKeepSoapEnvelope(true);440 final Message responseMessage = soapMessageConverter.convertInbound(soapMessage, endpointConfiguration, context);441 Assert.assertEquals(StringUtils.trimAllWhitespace(responseMessage.getPayload(String.class)), StringUtils.trimAllWhitespace(XML_PROCESSING_INSTRUCTION + getSoapRequestPayload()));442 Assert.assertEquals(responseMessage.getHeaderData().size(), 1L);443 Assert.assertEquals(responseMessage.getHeaderData().get(0), XML_PROCESSING_INSTRUCTION + "<SOAP-ENV:Header xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"/>");444 }445 @Test446 public void testEmptyOutboundSoapBodyNotParsed(){447 //GIVEN448 final DefaultMessage emptyMessage = new DefaultMessage("");449 final WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();450 endpointConfiguration.setMessageFactory(soapMessageFactory);451 when(soapRequest.getSoapBody()).thenReturn(soapBody);452 when(soapBody.getPayloadResult()).thenReturn(new StringResult());453 //WHEN454 soapMessageConverter.convertOutbound(soapRequest, emptyMessage, endpointConfiguration, context);455 //THEN456 verify(soapRequest, never()).getPayloadResult();457 }458 private String getSoapRequestPayload() {459 return getSoapRequestPayload(payload);460 }461 private String getSoapRequestPayload(final String payload, final String ... namespaces) {462 return "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" " + StringUtils.arrayToDelimitedString(namespaces, " ") + ">\n" +463 "<SOAP-ENV:Header/>\n" +464 "<SOAP-ENV:Body>\n" +...

Full Screen

Full Screen

Source:WebServiceEndpointConfiguration.java Github

copy

Full Screen

...126 if (webServiceTemplate == null) {127 webServiceTemplate = createWebServiceTemplate();128 }129 if (this.messageFactory != null) {130 webServiceTemplate.setMessageFactory(messageFactory);131 }132 if (this.messageSender != null) {133 webServiceTemplate.setMessageSender(messageSender);134 }135 if (defaultUri != null) {136 webServiceTemplate.setDefaultUri(defaultUri);137 }138 return webServiceTemplate;139 }140 /**141 * Sets the web service template.142 * @param webServiceTemplate143 */144 public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {145 interceptors.addAll(Optional.ofNullable(webServiceTemplate.getInterceptors()).map(Arrays::asList).orElse(Collections.emptyList()));146 this.webServiceTemplate = webServiceTemplate;147 webServiceTemplate.setInterceptors(interceptors.toArray(new ClientInterceptor[0]));148 }149 /**150 * Gets the message factory.151 * @return152 */153 public WebServiceMessageFactory getMessageFactory() {154 return messageFactory;155 }156 /**157 * Sets the message factory.158 * @param messageFactory159 */160 public void setMessageFactory(WebServiceMessageFactory messageFactory) {161 this.messageFactory = messageFactory;162 }163 /**164 * Gets the message sender.165 * @return166 */167 public WebServiceMessageSender getMessageSender() {168 return messageSender;169 }170 /**171 * Sets the message sender.172 * @param messageSender173 */174 public void setMessageSender(WebServiceMessageSender messageSender) {...

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.client;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.message.Message;4import com.consol.citrus.message.MessageCorrelator;5import com.consol.citrus.message.MessageDirection;6import com.consol.citrus.message.MessageProcessor;7import com.consol.citrus.message.MessageQueue;8import com.consol.citrus.message.MessageQueueManager;9import com.consol.citrus.message.MessageQueueReceiver;10import com.consol.citrus.message.MessageQueueSender;11import com.consol.citrus.message.MessageQueueSupport;12import com.consol.citrus.message.MessageReceiver;13import com.consol.citrus.message.MessageSender;14import com.consol.citrus.message.MessageSelector;15import com.consol.citrus.message.MessageSelectorBuilder;16import com.consol.citrus.message.MessageSelectorBuilderImpl;17import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilder;18import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl;19import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilder;20import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImpl;21import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilder;22import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImpl;23import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImplBuilder;24import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImplBuilderImpl;25import com.consol.citrus.message.MessageSelectorBuilderImpl.MessageSelectorBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilderImplBuilderImplBuilderImpl.MessageSelectorBuilderImplBuilderImplBuilder

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;2import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;3public class 3 {4 public static void main(String[] args) {5 WebServiceEndpointConfiguration webServiceEndpointConfiguration = new WebServiceEndpointConfiguration();6 webServiceEndpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());7 }8}9import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;10import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;11public class 4 {12 public static void main(String[] args) {13 WebServiceEndpointConfiguration webServiceEndpointConfiguration = new WebServiceEndpointConfiguration();14 webServiceEndpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());15 }16}17import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;18import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;19public class 5 {20 public static void main(String[] args) {21 WebServiceEndpointConfiguration webServiceEndpointConfiguration = new WebServiceEndpointConfiguration();22 webServiceEndpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());23 }24}25import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;26import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;27public class 6 {28 public static void main(String[] args) {29 WebServiceEndpointConfiguration webServiceEndpointConfiguration = new WebServiceEndpointConfiguration();30 webServiceEndpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());31 }32}33import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;34import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;35public class 7 {36 public static void main(String[] args) {37 WebServiceEndpointConfiguration webServiceEndpointConfiguration = new WebServiceEndpointConfiguration();38 webServiceEndpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.ws.message.SoapMessageFactory;2import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;3import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;4import org.springframework.ws.soap.SoapMessage;5import org.springframework.ws.soap.SoapVersion;6import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;7import org.springframework.ws.soap.saaj.SaajSoapMessage;8import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;9import org.springframework.ws.soap.saaj.SaajSoapMessage;10import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;11import org.springframework.ws.soap.saaj.SaajSoapMessage;12import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;13import org.springframework.ws.soap.saaj.SaajSoapMessage;14import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;15import org.springframework.ws.soap.saaj.SaajSoapMessage;16import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;17import org.springframework.ws.soap.saaj.SaajSoapMessage;18import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;19import org.springframework.ws.soap.saaj.SaajSoapMessage;20import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;21import org.springframework.ws.soap.saaj.SaajSoapMessage;22import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;23import org.springframework.ws.soap.saaj.SaajSoapMessage;24import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;25import org.springframework.ws.soap.saaj.SaajSoapMessage;26import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;27import org.springframework.ws.soap.saaj.SaajSoapMessage;28import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;29import org.springframework.ws.soap.saaj.SaajSoapMessage;30import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;31import org.springframework.ws.soap.saaj.SaajSoapMessage;32import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;33import org.springframework.ws.soap.saaj.SaajSoapMessage;34import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;35import org.springframework.ws.soap.saaj.SaajSoapMessage;

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.client;2import org.springframework.context.ApplicationContext;3import org.springframework.context.support.ClassPathXmlApplicationContext;4import com.consol.citrus.ws.message.SoapMessage;5import com.consol.citrus.ws.message.SoapMessageFactory;6public class setMessageFactory {7 public static void main(String[] args) {8 ApplicationContext context = new ClassPathXmlApplicationContext("setmessagefactory.xml");9 WebServiceEndpointConfiguration config = context.getBean("wsEndpoint", WebServiceEndpointConfiguration.class);10 SoapMessageFactory factory = new SoapMessageFactory();11 config.setMessageFactory(factory);12 SoapMessage message = (SoapMessage) config.getMessageFactory().createMessage();13 System.out.println("Message: " + message);14 }15}

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import org.springframework.context.support.ClassPathXmlApplicationContext;3public class 3 {4 public static void main(String[] args) {5 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");6 WebServiceClient webServiceClient = context.getBean("myWebServiceClient", WebServiceClient.class);7 webServiceClient.setMessageFactory(new DefaultSoapMessageFactory());8 }9}

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1public class 3 {2 public static void main(String[] args) {3 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();4 endpointConfiguration.setMessageFactory(new DefaultSoapMessageFactory());5 }6}7public class 4 {8 public static void main(String[] args) {9 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();10 endpointConfiguration.setSoapVersion(SoapVersion.SOAP_12);11 }12}13public class 5 {14 public static void main(String[] args) {15 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();16 endpointConfiguration.setWsdl("classpath:com/consol/citrus/ws/HelloService.wsdl");17 }18}19public class 6 {20 public static void main(String[] args) {21 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();22 endpointConfiguration.setWsdlResource(new ClassPathResource("com/consol/citrus/ws/HelloService.wsdl"));23 }24}25public class 7 {26 public static void main(String[] args) {27 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();28 }29}30public class 8 {31 public static void main(String[] args) {32 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();33 endpointConfiguration.setMarshaller(new DefaultMarshaller());34 }35}36public class 9 {37 public static void main(String[] args) {

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import org.springframework.context.annotation.Bean;3import org.springframework.context.annotation.Configuration;4import org.springframework.context.annotation.Import;5import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;6import com.consol.citrus.dsl.endpoint.CitrusEndpoints;7import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;8@Import({CitrusEndpointConfig.class})9public class WebServiceEndpointConfig {10 public WebServiceEndpointConfiguration webServiceEndpointConfiguration() {11 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();12 endpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());13 return endpointConfiguration;14 }15 public WebServiceClient webServiceClient() {16 .soap()17 .client()18 .endpointConfiguration(webServiceEndpointConfiguration())19 .build();20 }21}22package com.consol.citrus;23import org.springframework.context.annotation.Bean;24import org.springframework.context.annotation.Configuration;25import org.springframework.context.annotation.Import;26import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;27import com.consol.citrus.dsl.endpoint.CitrusEndpoints;28import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;29@Import({CitrusEndpointConfig.class})30public class WebServiceEndpointConfig {31 public WebServiceEndpointConfiguration webServiceEndpointConfiguration() {32 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();33 endpointConfiguration.setMessageFactory(new SaajSoapMessageFactory());34 return endpointConfiguration;35 }36 public WebServiceClient webServiceClient() {37 .soap()38 .client()39 .endpointConfiguration(webServiceEndpointConfiguration())40 .build();41 }42}43package com.consol.citrus;44import org.springframework.context.annotation.Bean;45import org.springframework.context.annotation.Configuration;46import

Full Screen

Full Screen

setMessageFactory

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.endpoint.CitrusEndpoints;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.runner.TestRunnerSupport;5import com.consol.citrus.message.DefaultMessageFactory;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.ws.message.SoapAttachment;8import com.consol.citrus.ws.message.SoapMessage;9import com.consol.citrus.ws.message.SoapMessageFactory;10import org.springframework.core.io.ClassPathResource;11import org.springframework.ws.soap.SoapMessageFactory;12public class 3 extends TestRunnerSupport {13 public void configure(TestRunner builder) {14 builder.http()15 .client(CitrusEndpoints.http()16 .client()17 .messageFactory(new DefaultMessageFactory())18 .build())19 .send()20 .post("/citrus-ws-sample/services/helloWorld")21 .contentType("text/xml;charset=UTF-8")22 "</soapenv:Envelope>");23 builder.http()24 .client(CitrusEndpoints.http()25 .client()26 .messageFactory(new SoapMessageFactory())27 .build())28 .receive()29 .response(HttpStatus.OK)30 .messageType(MessageType.XML)

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful