Best Citrus code snippet using com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder
Source:SoapClientRequestActionBuilder.java
...29/**30 * @author Christoph Deppisch31 * @since 2.632 */33public class SoapClientRequestActionBuilder extends SendMessageBuilder<SendSoapMessageAction, SoapClientRequestActionBuilder> {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 soapClient40 */41 public SoapClientRequestActionBuilder(DelegatingTestAction<TestAction> delegate, Endpoint soapClient) {42 super(delegate);43 delegate.setDelegate(new SendSoapMessageAction());44 getAction().setEndpoint(soapClient);45 getAction().setMessageBuilder(new StaticMessageContentBuilder(soapMessage));46 }47 /**48 * Default constructor using soap client uri.49 * @param delegate50 * @param soapClientUri51 */52 public SoapClientRequestActionBuilder(DelegatingTestAction<TestAction> delegate, String soapClientUri) {53 super(delegate);54 delegate.setDelegate(new SendSoapMessageAction());55 getAction().setEndpointUri(soapClientUri);56 getAction().setMessageBuilder(new StaticMessageContentBuilder(soapMessage));57 }58 @Override59 protected void setPayload(String payload) {60 soapMessage.setPayload(payload);61 }62 /**63 * Sets special SOAP action message header.64 * @param soapAction65 * @return66 */67 public SoapClientRequestActionBuilder soapAction(String soapAction) {68 soapMessage.header(SoapMessageHeaders.SOAP_ACTION, soapAction);69 return this;70 }71 /**72 * Sets the attachment with string content.73 * @param contentId74 * @param contentType75 * @param content76 * @return77 */78 public SoapClientRequestActionBuilder attachment(String contentId, String contentType, String content) {79 SoapAttachment attachment = new SoapAttachment();80 attachment.setContentId(contentId);81 attachment.setContentType(contentType);82 attachment.setContent(content);83 getAction().getAttachments().add(attachment);84 return this;85 }86 /**87 * Sets the attachment with content resource.88 * @param contentId89 * @param contentType90 * @param contentResource91 * @return92 */93 public SoapClientRequestActionBuilder attachment(String contentId, String contentType, Resource contentResource) {94 return attachment(contentId, contentType, contentResource, FileUtils.getDefaultCharset());95 }96 /**97 * Sets the attachment with content resource.98 * @param contentId99 * @param contentType100 * @param contentResource101 * @param charset102 * @return103 */104 public SoapClientRequestActionBuilder attachment(String contentId, String contentType, Resource contentResource, Charset charset) {105 SoapAttachment attachment = new SoapAttachment();106 attachment.setContentId(contentId);107 attachment.setContentType(contentType);108 try {109 attachment.setContent(FileUtils.readToString(contentResource, charset));110 } catch (IOException e) {111 throw new CitrusRuntimeException("Failed to read attachment resource", e);112 }113 getAction().getAttachments().add(attachment);114 return this;115 }116 /**117 * Sets the charset name for this send action builder's attachment.118 * @param charsetName119 * @return120 */121 public SoapClientRequestActionBuilder charset(String charsetName) {122 if (!getAction().getAttachments().isEmpty()) {123 getAction().getAttachments().get(getAction().getAttachments().size() - 1).setCharsetName(charsetName);124 }125 return this;126 }127 /**128 * Sets the attachment from Java object instance.129 * @param attachment130 * @return131 */132 public SoapClientRequestActionBuilder attachment(SoapAttachment attachment) {133 getAction().getAttachments().add(attachment);134 return this;135 }136 /**137 * Set the endpoint URI for the request. This works only if the HTTP endpoint used138 * doesn't provide an own endpoint URI resolver.139 *140 * @param uri absolute URI to use for the endpoint141 * @return self142 */143 public SoapClientRequestActionBuilder uri(String uri) {144 soapMessage.header(DynamicEndpointUriResolver.ENDPOINT_URI_HEADER_NAME, uri);145 return this;146 }147 /**148 * Sets the request content type header.149 * @param contentType150 * @return151 */152 public SoapClientRequestActionBuilder contentType(String contentType) {153 soapMessage.header(SoapMessageHeaders.HTTP_CONTENT_TYPE, contentType);154 return this;155 }156 /**157 * Sets the request accept header.158 * @param accept159 * @return160 */161 public SoapClientRequestActionBuilder accept(String accept) {162 soapMessage.header(SoapMessageHeaders.HTTP_ACCEPT, accept);163 return this;164 }165 166 public SoapClientRequestActionBuilder mtomEnabled(boolean mtomEnabled) {167 soapMessage.mtomEnabled(mtomEnabled);168 getAction().setMtomEnabled(mtomEnabled);169 return this;170 }171 @Override172 protected SendSoapMessageAction getAction() {173 return (SendSoapMessageAction) super.getAction();174 }175}...
Source:SoapClientActionBuilder.java
...61 /**62 * Generic request builder with request method and path.63 * @return64 */65 public SoapClientRequestActionBuilder send() {66 SoapClientRequestActionBuilder soapClientRequestActionBuilder;67 if (soapClient != null) {68 soapClientRequestActionBuilder = new SoapClientRequestActionBuilder(action, soapClient);69 } else {70 soapClientRequestActionBuilder = new SoapClientRequestActionBuilder(action, soapClientUri);71 }72 soapClientRequestActionBuilder.withApplicationContext(applicationContext);73 return soapClientRequestActionBuilder;74 }75 /**76 * Sets the Spring bean application context.77 * @param applicationContext78 */79 public SoapClientActionBuilder withApplicationContext(ApplicationContext applicationContext) {80 this.applicationContext = applicationContext;81 return this;82 }83}...
SoapClientRequestActionBuilder
Using AI Code Generation
1import com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder;2import com.consol.citrus.dsl.builder.SoapClientResponseActionBuilder;3import com.consol.citrus.dsl.builder.SoapServerResponseActionBuilder;4import com.consol.citrus.dsl.builder.SoapServerRequestActionBuilder;5import com.consol.citrus.dsl.builder.HttpClientRequestActionBuilder;6import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder;7import com.consol.citrus.dsl.builder.HttpServerRequestActionBuilder;8import com.consol.citrus.dsl.builder.HttpClientResponseActionBuilder;9import com.consol.citrus.dsl.builder.EchoActionBuilder;10import com.consol.citrus.dsl.builder.PurgeEndpointActionBuilder;11import com.consol.citrus.dsl.builder.ReceiveTimeoutActionBuilder;12import com.consol.citrus.dsl.builder.SendMessageActionBuilder;13import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;14import com.consol.citrus.dsl.builder.PurgeQueuesActionBuilder;15import com.consol.citrus.dsl.builder.StopTimeActionBuilder;16import com.consol.citrus.dsl.builder.SetTimeActionBuilder;17import com.consol.citrus.dsl.builder.StartTimeActionBuilder;18import com.consol.citrus.dsl.builder.SleepActionBuilder;19import com.consol.citrus.dsl.builder.StopTimerActionBuilder;20import com.consol.citrus.dsl.builder.StartTimerActionBuilder;21import com.consol.citrus.dsl.bu
SoapClientRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.actions.SoapClientRequestAction;3import com.consol.citrus.dsl.builder.AbstractTestActionBuilder;4import com.consol.citrus.message.MessageType;5public class SoapClientRequestActionBuilder extends AbstractTestActionBuilder<SoapClientRequestAction> {6 public SoapClientRequestActionBuilder(SoapClientRequestAction action) {7 super(action);8 }9 public SoapClientRequestActionBuilder() {10 super(new SoapClientRequestAction());11 }12 public SoapClientRequestActionBuilder messageType(MessageType type) {13 action.setMessageType(type);14 return this;15 }16 public SoapClientRequestActionBuilder soapAction(String soapAction) {17 action.setSoapAction(soapAction);18 return this;19 }20 public SoapClientRequestActionBuilder soapVersion(String soapVersion) {21 action.setSoapVersion(soapVersion);22 return this;23 }24 public SoapClientRequestActionBuilder soapVersion(SoapVersion soapVersion) {25 action.setSoapVersion(soapVersion.toString());26 return this;27 }28 public SoapClientRequestActionBuilder fault(boolean fault) {29 action.setFault(fault);30 return this;31 }32 public SoapClientRequestActionBuilder faultCode(String faultCode) {33 action.setFaultCode(faultCode);34 return this;35 }36 public SoapClientRequestActionBuilder faultString(String faultString) {37 action.setFaultString(faultString);38 return this;39 }
SoapClientRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder;3public class SoapClientRequestActionBuilderTest {4 public static void main(String[] args) {5 SoapClientRequestActionBuilder soapClientRequestActionBuilder = new SoapClientRequestActionBuilder();6 soapClientRequestActionBuilder.client("soapClient")7 .send()8 .soapAction("sayHello")9 .header("operation", "sayHello")10 .header("header1", "value1")11 .header("header2", "value2");12 soapClientRequestActionBuilder.receive()13 .header("operation", "sayHello")14 .header("header1", "value1")15 .header("header2", "value2");16 soapClientRequestActionBuilder.build();17 }18}19 SoapClientRequestActionBuilder soapClientRequestActionBuilder = new SoapClientRequestActionBuilder();20 soapClientRequestActionBuilder.client("soapClient")21 soapClientRequestActionBuilder.client("soapClient")22 symbol: method client(String)23 soapClientRequestActionBuilder.send()
SoapClientRequestActionBuilder
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.ws.client.WebServiceClient;5public class SoapClientRequestActionBuilder extends AbstractSoapClientActionBuilder<SoapClientRequestActionBuilder> {6 public SoapClientRequestActionBuilder(TestRunner testRunner, WebServiceClient action) {7 super(testRunner, action);8 }9 public SoapClientRequestActionBuilder messageType(MessageType messageType) {10 action.setMessageType(messageType);11 return this;12 }13 public SoapClientRequestActionBuilder soapAction(String soapAction) {14 action.setSoapAction(soapAction);15 return this;16 }17 public SoapClientRequestActionBuilder soapAction(String soapAction, Object... args) {18 action.setSoapAction(String.format(soapAction, args));19 return this;20 }21 public SoapClientRequestActionBuilder messageName(String messageName) {22 action.setMessageName(messageName);23 return this;24 }25 public SoapClientRequestActionBuilder messageName(String messageName, Object... args) {26 action.setMessageName(String.format(messageName, args));27 return this;28 }29 public SoapClientRequestActionBuilder messageSelector(String messageSelector) {30 action.setMessageSelector(messageSelector);31 return this;32 }33 public SoapClientRequestActionBuilder faultMessageSelector(String messageSelector) {34 action.setFaultMessageSelector(messageSelector);35 return this;36 }
SoapClientRequestActionBuilder
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder;3import com.consol.citrus.dsl.builder.SoapClientResponseActionBuilder;4public class SoapClientRequestSample {5 public static void main(String[] args) {6 SoapClientRequestActionBuilder soapClientRequestActionBuilder = new SoapClientRequestActionBuilder();7 " <customerId>citrus:randomNumber(5)</customerId>\r\n" + 8 " <itemId>citrus:randomNumber(5)</itemId>\r\n" + 9 " <name>citrus:concat('Item ', citrus:randomNumber(5))</name>\r\n" + 10 " <price>citrus:randomNumber(2)</price>\r\n" + 11 "</soap:Body></soap:Envelope>").header("Operation", "placeOrder").header("Content-Type", "text/xml");12 " <orderId>citrus:randomNumber(5)</orderId>\r\n" + 13 "</soap:Body></soap:Envelope>").header("Operation", "placeOrderResponse").header("Content-Type", "text/xml");14 }15}
SoapClientRequestActionBuilder
Using AI Code Generation
1import com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.runner.TestRunnerSupport;4import com.consol.citrus.message.MessageType;5import org.testng.annotations.Test;6public class SoapClientRequestActionBuilderTest {7 private TestRunner runner = new TestRunnerSupport();8 public void testSoapClientRequestActionBuilder() {9 runner.soap(builder -> builder.client("soapClient")10 .send()11 .soapAction("getQuote")12 "</q0:getQuote>"));13 runner.soap(builder -> builder.client("soapClient")14 .receive()15 .messageType(MessageType.XML)
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!!