Best Citrus code snippet using com.consol.citrus.dsl.builder.SoapServerRequestActionBuilder
Source:SoapServerRequestActionBuilder.java
...29/**30 * @author Christoph Deppisch31 * @since 2.632 */33public class SoapServerRequestActionBuilder extends ReceiveMessageBuilder<ReceiveSoapMessageAction, SoapServerRequestActionBuilder> {34 /** Soap message to send or receive */35 private SoapMessage soapMessage = new SoapMessage();36 /**37 * Default constructor using soap client endpoint.38 * @param delegate39 * @param soapServer40 */41 public SoapServerRequestActionBuilder(DelegatingTestAction<TestAction> delegate, Endpoint soapServer) {42 super(delegate);43 delegate.setDelegate(new ReceiveSoapMessageAction());44 getAction().setEndpoint(soapServer);45 message(soapMessage);46 messageType(MessageType.XML);47 headerNameIgnoreCase(true);48 }49 @Override50 protected void setPayload(String payload) {51 soapMessage.setPayload(payload);52 }53 /**54 * Sets special SOAP action message header.55 * @param soapAction56 * @return57 */58 public SoapServerRequestActionBuilder soapAction(String soapAction) {59 soapMessage.header(SoapMessageHeaders.SOAP_ACTION, soapAction);60 return this;61 }62 /**63 * Sets the control attachment with string content.64 * @param contentId65 * @param contentType66 * @param content67 * @return68 */69 public SoapServerRequestActionBuilder attachment(String contentId, String contentType, String content) {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 contentType139 * @return140 */141 public SoapServerRequestActionBuilder contentType(String contentType) {142 soapMessage.header(SoapMessageHeaders.HTTP_CONTENT_TYPE, contentType);143 return this;144 }145 /**146 * Sets the request accept header.147 * @param accept148 * @return149 */150 public SoapServerRequestActionBuilder accept(String accept) {151 soapMessage.header(SoapMessageHeaders.HTTP_ACCEPT, accept);152 return this;153 }154 @Override155 protected ReceiveSoapMessageAction getAction() {156 return (ReceiveSoapMessageAction) super.getAction();157 }158}...
Source:SoapServerActionBuilder.java
...39 /**40 * Generic request builder for receiving SOAP messages on server.41 * @return42 */43 public SoapServerRequestActionBuilder receive() {44 SoapServerRequestActionBuilder soapServerRequestActionBuilder = new SoapServerRequestActionBuilder(action, soapServer)45 .withApplicationContext(applicationContext);46 return soapServerRequestActionBuilder;47 }48 /**49 * Generic response builder for sending SOAP response messages to client.50 * @return51 */52 public SoapServerResponseActionBuilder send() {53 SoapServerResponseActionBuilder soapServerResponseActionBuilder = new SoapServerResponseActionBuilder(action, soapServer)54 .withApplicationContext(applicationContext);55 return soapServerResponseActionBuilder;56 }57 /**58 * Generic response builder for sending SOAP fault messages to client....
Source:SoapScenarioRunnerActionBuilder.java
...21 /**22 * Default scenario receive operation.23 * @return24 */25 public TestAction receive(SoapBuilderSupport<SoapServerRequestActionBuilder> configurer) {26 SoapScenarioActionBuilder builder = new SoapScenarioActionBuilder(scenarioEndpoint)27 .withApplicationContext(applicationContext);28 configurer.configure(builder.receive());29 return runner.run(builder.build()).getDelegate();30 }31 /**32 * Default scenario send response operation.33 * @return34 */35 public TestAction send(SoapBuilderSupport<SoapServerResponseActionBuilder> configurer) {36 SoapScenarioActionBuilder builder = new SoapScenarioActionBuilder(scenarioEndpoint)37 .withApplicationContext(applicationContext);38 configurer.configure(builder.send());39 return runner.run(builder.build()).getDelegate();...
SoapServerRequestActionBuilder
Using AI Code Generation
1import com.consol.citrus.dsl.builder.SoapServerRequestActionBuilder;2import com.consol.citrus.dsl.builder.SoapServerResponseActionBuilder;3import com.consol.citrus.soap.SoapServer;4import com.consol.citrus.dsl.builder.SoapServerBuilder;5import com.consol.citrus.soap.SoapServerConfigBuilder;6public class SoapServerBuilderTest {7 public void soapServerBuilderTest() {8 SoapServerBuilder soapServerBuilder = new SoapServerBuilder();9 soapServerBuilder.server(new SoapServer());10 soapServerBuilder.autoStart(true);11 soapServerBuilder.port(8080);12 soapServerBuilder.timeout(5000);13 soapServerBuilder.autoStart(true);14 soapServerBuilder.config(new SoapServerConfigBuilder());15 soapServerBuilder.request(new SoapServerRequestActionBuilder());16 soapServerBuilder.response(new SoapServerResponseActionBuilder());17 }18}
SoapServerRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.builder.SoapServerRequestActionBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.testng.TestNGCitrusTest;5import com.consol.citrus.message.MessageType;6import org.testng.annotations.Test;7public class soapServerRequestActionBuilderTest extends TestNGCitrusTest {8 public void soapServerRequestActionBuilderTest() {9 TestRunner runner = citrus.createTestRunner();10 SoapServerRequestActionBuilder soapServerRequestActionBuilder = runner.soap(builder -> builder.server("soapServer")11 .receive()12 " <web:StockName>citrus:randomNumber(3)</web:StockName>\r13 .header("Operation", "GetStockPrice")14 .extractFromHeader("Operation", "operation"));15 }16}17package com.consol.citrus;18import com.consol.citrus.dsl.builder.SoapServerResponseActionBuilder;19import com.consol.citrus.dsl.runner.TestRunner;20import com.consol.citrus.dsl.testng.TestNGCitrusTest;21import com.consol.citrus.message.MessageType;22import org.testng.annotations.Test;23public class soapServerResponseActionBuilderTest extends TestNGCitrusTest {24 public void soapServerResponseActionBuilderTest() {25 TestRunner runner = citrus.createTestRunner();26 SoapServerResponseActionBuilder soapServerResponseActionBuilder = runner.soap(builder -> builder.server("soapServer")27 .send()28 .payload("<soapenv:Envelope xmlns:soapenv=\"http
SoapServerRequestActionBuilder
Using AI Code Generation
1package com.citrus;2import com.consol.citrus.dsl.builder.SoapServerRequestActionBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.runner.TestRunnerSupport;5import com.consol.citrus.http.message.HttpMessage;6import com.consol.citrus.message.MessageType;7import org.springframework.http.HttpStatus;8import org.springframework.util.StringUtils;9import java.util.HashMap;10import java.util.Map;11public class SoapServerRequestActionBuilderTest extends TestRunnerSupport {12 public static void main(String[] args) {13 builderTest();14 }15 public static void builderTest() {16 TestRunner runner = createTestRunner();17 SoapServerRequestActionBuilder builder = new SoapServerRequestActionBuilder(runner);18 builder.server("soapServer")19 .receive()20 .header("operation", "echo")21 .header("citrus_http_method", "POST")22 .header("citrus_http_request_uri", "/services/echo")23 .header("citrus_http_version", "HTTP/1.1")24 .header("citrus_http_query_params", "param1=value1¶m2=value2")25 .header("citrus_http_request_path", "/services/echo")26 .header("citrus_http_request_path_info", "/services/echo")27 .header("citrus_http_request_context_path", "/")28 .header("citrus_http_request_servlet_path", "")29 .header("citrus_http_request_session_id", "12345")30 .header("citrus_http_request_user_principal", "citrus-user")31 .header("citrus_http_request_remote_addr", "
SoapServerRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.builder.SoapServerRequestActionBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.message.MessageType;5import com.consol.citrus.message.builder.PayloadTemplateMessageBuilder;6import com.consol.citrus.ws.actions.SoapServerRequestAction;7import com.consol.citrus.ws.message.SoapMessage;8import com.consol.citrus.ws.message.SoapMessageHeaders;9import org.springframework.ws.soap.SoapVersion;10import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;11import java.util.HashMap;12import java.util.Map;13public class SoapServerRequestActionBuilder extends AbstractTestActionBuilder<SoapServerRequestAction> {14 public SoapServerRequestActionBuilder(String name, TestRunner runner) {15 super(name, runner);16 action = new SoapServerRequestAction();17 }18 public SoapServerRequestActionBuilder messageType(MessageType messageType) {19 action.setMessageType(messageType);20 return this;21 }22 public SoapServerRequestActionBuilder messageType(String messageType) {23 action.setMessageType(MessageType.valueOf(messageType));24 return this;25 }26 public SoapServerRequestActionBuilder soapVersion(SoapVersion soapVersion) {27 action.setSoapVersion(soapVersion);28 return this;29 }30 public SoapServerRequestActionBuilder soapVersion(String soapVersion) {31 action.setSoapVersion(SoapVersion.valueOf(soapVersion));32 return this;33 }34 public SoapServerRequestActionBuilder messageFactory(SaajSoapMessageFactory messageFactory) {35 action.setMessageFactory(messageFactory);36 return this;37 }
SoapServerRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.TestActionBuilder;3import com.consol.citrus.dsl.UnitTestSupport;4import com.consol.citrus.message.MessageType;5import com.consol.citrus.soap.client.SoapClient;6import com.consol.citrus.ws.actions.SoapServerRequestAction;7import com.consol.citrus.ws.client.WebServiceClient;8import org.springframework.core.io.ClassPathResource;9import org.springframework.util.StringUtils;10import org.testng.Assert;11import org.testng.annotations.Test;12import java.io.IOException;13import static com.consol.citrus.actions.ReceiveMessageAction.Builder.receive;14import static com.consol.citrus.actions.SendMessageAction.Builder.send;15public class SoapServerRequestActionBuilderTest extends UnitTestSupport {16 public void testSoapServerRequestBuilder() throws IOException {17 SoapClient soapClient = new SoapClient();18 soapClient.setEndpointConfiguration(endpointConfiguration);19 soapClient.setMessageConverter(messageConverter);20 SoapServerRequestActionBuilder builder = new SoapServerRequestActionBuilder(applicationContext, soapClient);21 builder.client("soapClient")22 .payload(new ClassPathResource("com/consol/citrus/ws/soap-request-payload.xml"))23 .header("operation", "sayHello")24 .header("citrus_soap_action", "sayHello")25 .messageType(MessageType.XML);26 TestActionBuilder testActionBuilder = builder.build();27 Assert.assertEquals(testActionBuilder.getClass(), SoapServerRequestAction.Builder.class);28 SoapServerRequestAction action = (SoapServerRequestAction) testActionBuilder.build();29 Assert.assertEquals(action.getEndpoint(), soapClient);30 Assert.assertEquals(action.getHeaders().size(), 2L);31 Assert.assertEquals(action.getHeaders().get("operation"), "sayHello");32 Assert.assertEquals(action.getHeaders().get("citrus_soap_action"), "sayHello");33 Assert.assertEquals(action.getMessageType(), MessageType.XML);
SoapServerRequestActionBuilder
Using AI Code Generation
1SoapServerRequestActionBuilder soapServerRequestActionBuilder = new SoapServerRequestActionBuilder();2soapServerRequestActionBuilder.server(soapServer)3.messageType(MessageType.XML)4SoapServerResponseActionBuilder soapServerResponseActionBuilder = new SoapServerResponseActionBuilder();5soapServerResponseActionBuilder.server(soapServer)6.messageType(MessageType.XML)7soapServerRequestActionBuilder.server(soapServer)8.messageType(MessageType.XML)9soapServerResponseActionBuilder.server(soapServer)10.messageType(MessageType.XML)11soapServerRequestActionBuilder.server(soapServer)12.messageType(MessageType.XML)13soapServerResponseActionBuilder.server(soapServer)14.messageType(MessageType.XML)15.payload("<Hello
SoapServerRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.message.MessageType;4import com.consol.citrus.testng.AbstractTestNGUnitTest;5import org.testng.annotations.Test;6import static com.consol.citrus.actions.SoapServerRequestActionBuilder.soap;7import static com.consol.citrus.validation.xml.XmlMessageValidationContext.Builder.xmlMessage;8import static com.consol.citrus.validation.xml.XmlMessageValidationContext.Builder.xmlMessageValidationContext;9public class SoapServerRequestActionBuilderTest extends AbstractTestNGUnitTest {10 public void testSoapServerRequestActionBuilder() {11 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext) {12 public void execute() {13 soap(server -> server.soap()14 .client("SoapClient")15 .send()16 .messageType(MessageType.XML)17 .payload("<TestRequestMessage>" +18 .receive()19 .payload("<TestResponseMessage>" +20 .validator(xmlMessageValidationContext()21 .schemaValidation(true)22 .schemaRepository("schemaRepository")23 .build());24 }25 };26 builder.run();27 builder.validate();28 }29 private static class MockTestRunner extends TestRunner {30 public MockTestRunner(String name, ApplicationContext applicationContext) {31 super(name, applicationContext);32 }33 public void run() {34 execute();35 }36 }37}38package com.consol.citrus.dsl.builder;39import com.consol.citrus.dsl.runner.TestRunner;40import com.consol.citrus.message.MessageType;41import com.consol.citrus.testng.AbstractTestNGUnitTest;42import org.testng.annotations.Test;43import static com.consol.cit
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!