How to use faultDetails method of com.consol.citrus.ws.message.SoapFault class

Best Citrus code snippet using com.consol.citrus.ws.message.SoapFault.faultDetails

Source:SendSoapFaultAction.java Github

copy

Full Screen

...50 private final String faultActor;51 /**52 * List of fault detail contents53 */54 private final List<String> faultDetails;55 /**56 * List of fault detail resource paths57 */58 private final List<String> faultDetailResourcePaths;59 public SendSoapFaultAction(Builder builder) {60 super(builder);61 this.faultCode = builder.faultCode;62 this.faultString = builder.faultString;63 this.faultActor = builder.faultActor;64 this.faultDetails = builder.faultDetails;65 this.faultDetailResourcePaths = builder.faultDetailResourcePaths;66 }67 @Override68 protected SoapMessage createMessage(TestContext context, String messageType) {69 SoapMessage soapMessage = super.createMessage(context, messageType);70 SoapFault soapFault = new SoapFault();71 soapFault.setPayload(soapMessage.getPayload());72 if (!StringUtils.hasText(faultCode)) {73 throw new CitrusRuntimeException("Missing fault code definition for SOAP fault generation. Please specify a proper SOAP fault code!");74 }75 soapFault.faultCode(context.replaceDynamicContentInString(faultCode));76 for (Map.Entry<String, Object> header : soapMessage.getHeaders().entrySet()) {77 if (!header.getKey().equals(MessageHeaders.ID)) {78 soapFault.setHeader(header.getKey(), header.getValue());79 }80 }81 for (String headerData : soapMessage.getHeaderData()) {82 soapFault.addHeaderData(headerData);83 }84 for (SoapAttachment soapAttachment : soapMessage.getAttachments()) {85 soapFault.addAttachment(soapAttachment);86 }87 if (StringUtils.hasText(faultActor)) {88 soapFault.faultActor(context.replaceDynamicContentInString(faultActor));89 }90 if (faultString != null) {91 soapFault.faultString(context.replaceDynamicContentInString(faultString));92 }93 for (String faultDetail : faultDetails) {94 soapFault.addFaultDetail(context.replaceDynamicContentInString(faultDetail));95 }96 try {97 for (String faultDetailPath : faultDetailResourcePaths) {98 String resourcePath = context.replaceDynamicContentInString(faultDetailPath);99 soapFault.addFaultDetail(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(resourcePath, context), FileUtils.getCharset(resourcePath))));100 }101 } catch (IOException e) {102 throw new CitrusRuntimeException("Failed to create SOAP fault detail from file resource", e);103 }104 return soapFault;105 }106 /**107 * Gets the faultActor.108 *109 * @return the faultActor the faultActor to get.110 */111 public String getFaultActor() {112 return faultActor;113 }114 /**115 * Gets the faultCode.116 *117 * @return the faultCode118 */119 public String getFaultCode() {120 return faultCode;121 }122 /**123 * Gets the faultString.124 *125 * @return the faultString126 */127 public String getFaultString() {128 return faultString;129 }130 /**131 * Gets the faultDetails.132 *133 * @return the faultDetails the faultDetails to get.134 */135 public List<String> getFaultDetails() {136 return faultDetails;137 }138 /**139 * Gets the fault detail resource paths.140 *141 * @return142 */143 public List<String> getFaultDetailResourcePaths() {144 return faultDetailResourcePaths;145 }146 /**147 * Action builder.148 */149 public static final class Builder extends SendSoapMessageBuilder<SendSoapFaultAction, Builder.SoapFaultMessageBuilderSupport, Builder> {150 private String faultCode;151 private String faultString;152 private String faultActor;153 private final List<String> faultDetails = new ArrayList<>();154 private final List<String> faultDetailResourcePaths = new ArrayList<>();155 public Builder() {156 message(new StaticMessageBuilder(soapMessage));157 }158 @Override159 public SoapFaultMessageBuilderSupport getMessageBuilderSupport() {160 if (messageBuilderSupport == null) {161 messageBuilderSupport = new SoapFaultMessageBuilderSupport(soapMessage, this);162 }163 return super.getMessageBuilderSupport();164 }165 public static class SoapFaultMessageBuilderSupport extends SoapMessageBuilderSupport<SendSoapFaultAction, Builder, SoapFaultMessageBuilderSupport> {166 protected SoapFaultMessageBuilderSupport(SoapMessage soapMessage, Builder delegate) {167 super(soapMessage, delegate);168 }169 /**170 * Adds custom SOAP fault code.171 *172 * @param code173 * @return174 */175 public SoapFaultMessageBuilderSupport faultCode(String code) {176 delegate.faultCode = code;177 return this;178 }179 /**180 * Add custom fault string to SOAP fault message.181 *182 * @param faultString183 * @return184 */185 public SoapFaultMessageBuilderSupport faultString(String faultString) {186 delegate.faultString = faultString;187 return this;188 }189 /**190 * Add custom fault string to SOAP fault message.191 *192 * @param faultActor193 * @return194 */195 public SoapFaultMessageBuilderSupport faultActor(String faultActor) {196 delegate.faultActor = faultActor;197 return this;198 }199 /**200 * Adds a fault detail to SOAP fault message.201 *202 * @param faultDetail203 * @return204 */205 public SoapFaultMessageBuilderSupport faultDetail(String faultDetail) {206 delegate.faultDetails.add(faultDetail);207 return this;208 }209 /**210 * Adds a fault detail from file resource.211 *212 * @param resource213 * @return214 */215 public SoapFaultMessageBuilderSupport faultDetailResource(Resource resource) {216 return faultDetailResource(resource, FileUtils.getDefaultCharset());217 }218 /**219 * Adds a fault detail from file resource.220 *221 * @param resource222 * @param charset223 * @return224 */225 public SoapFaultMessageBuilderSupport faultDetailResource(Resource resource, Charset charset) {226 try {227 delegate.faultDetails.add(FileUtils.readToString(resource, charset));228 } catch (IOException e) {229 throw new CitrusRuntimeException("Failed to read fault detail resource", e);230 }231 return this;232 }233 /**234 * Adds a fault detail from file resource path.235 *236 * @param filePath237 * @return238 */239 public SoapFaultMessageBuilderSupport faultDetailResource(String filePath) {240 delegate.faultDetailResourcePaths.add(filePath);241 return this;...

Full Screen

Full Screen

Source:SoapFault.java Github

copy

Full Screen

...47 private String faultActor;48 /** Locale used in fault */49 private Locale locale = Locale.ENGLISH;50 /** List of fault detail elements */51 private List<String> faultDetails = new ArrayList<String>();52 /**53 * Default constructor.54 */55 public SoapFault() {56 super();57 }58 /**59 * Default constructor using parent message.60 * @param message61 */62 public SoapFault(Message message) {63 super(message);64 }65 /**66 * Default constructor using payload.67 * @param payload68 */69 public SoapFault(Object payload) {70 super(payload);71 }72 /**73 * Returns fault code as qualified name.74 * @return75 */76 public QName getFaultCodeQName() {77 return QNameUtils.parseQNameString(faultCode);78 }79 /**80 * Sets the fault code.81 * @param faultCode82 */83 public SoapFault faultCode(String faultCode) {84 this.faultCode = faultCode;85 return this;86 }87 /**88 * Sets the fault string or reason.89 * @param faultString90 */91 public SoapFault faultString(String faultString) {92 this.faultString = faultString;93 return this;94 }95 /**96 * Sets the faultActor.97 * @param faultActor the faultActor to set98 */99 public SoapFault faultActor(String faultActor) {100 this.faultActor = faultActor;101 return this;102 }103 /**104 * Sets the faultDetails.105 * @param faultDetails the faultDetails to set106 */107 public SoapFault faultDetails(List<String> faultDetails) {108 this.faultDetails = faultDetails;109 return this;110 }111 /**112 * Adds a new fault detail in builder pattern style.113 * @param faultDetail114 * @return115 */116 public SoapFault addFaultDetail(String faultDetail) {117 this.faultDetails.add(faultDetail);118 return this;119 }120 /**121 * Sets the locale used in SOAP fault.122 * @param locale123 */124 public SoapFault locale(Locale locale) {125 this.locale = locale;126 return this;127 }128 /**129 * Sets the locale used in SOAP fault.130 * @param locale131 */132 public SoapFault locale(String locale) {133 LocaleEditor localeEditor = new LocaleEditor();134 localeEditor.setAsText(locale);135 this.locale = (Locale) localeEditor.getValue();136 return this;137 }138 /**139 * Gets the faultActor.140 * @return the faultActor the faultActor to get.141 */142 public String getFaultActor() {143 return faultActor;144 }145 /**146 * Gets the faultCode.147 * @return the faultCode148 */149 public String getFaultCode() {150 return faultCode;151 }152 /**153 * Gets the faultString.154 * @return the faultString155 */156 public String getFaultString() {157 return faultString;158 }159 /**160 * Gets the faultDetails.161 * @return the faultDetails the faultDetails to get.162 */163 public List<String> getFaultDetails() {164 return faultDetails;165 }166 /**167 * Gets the locale used in SOAP fault.168 * @return169 */170 public Locale getLocale() {171 return locale;172 }173 /**174 * Builder method from Spring WS SOAP fault object.175 * @param fault176 * @return177 */178 public static SoapFault from(org.springframework.ws.soap.SoapFault fault) {...

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.ws.message.SoapFault;5import org.springframework.http.HttpStatus;6import org.testng.annotations.Test;7public class SoapFaultTest extends TestNGCitrusTestRunner {8 public void testSoapFault() {9 variable("faultCode", "soap:Server");10 variable("faultString", "Server Error");11 variable("faultDetail", "<faultDetail><faultCode>500</faultCode><faultString>Internal Server Error</faultString></faultDetail>");12 soap().client("soapClient")13 .send()14 .soapAction("sayHelloFault")15 "</ns0:sayHelloFault>");16 soap().client("soapClient")17 .receive()18 .fault(SoapFault.serverFault("${faultCode}", "${faultString}", "${faultActor}").faultDetail("${faultDetail}"));19 }20}21package com.consol.citrus.samples;22import com.consol.citrus.annotations.CitrusTest;23import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;24import com.consol.citrus.ws.message.SoapFault;25import org.springframework.http.HttpStatus;26import org.testng.annotations.Test;27public class SoapFaultTest extends TestNGCitrusTestRunner {28 public void testSoapFault() {29 variable("faultCode", "soap:Server");30 variable("faultString", "Server Error");31 variable("faultDetail", "<faultDetail><faultCode>500</faultCode><faultString>Internal Server Error</faultString></faultDetail>");32 soap().client("soapClient")33 .send()34 .soapAction("sayHelloFault")35 .payload("<ns0:sayHelloFault xmlns:ns0=\"http

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapFault;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.http.HttpStatus;8import org.testng.annotations.Test;9public class SoapFaultTest extends TestNGCitrusTestDesigner {10 private WebServiceClient webServiceClient;11 public void soapFaultTest() {12 variable("faultCode", "soap:Sender");13 variable("faultString", "Invalid Request");14 variable("faultDetail", "<detail>Invalid Request</detail>");15 soap().client(webServiceClient)16 .send()17 .soapAction("GetTimeFault")18 "<ns0:FaultCode>" + "${faultCode}" + "</ns0:FaultCode>" +19 "<ns0:FaultString>" + "${faultString}" + "</ns0:FaultString>" +20 "<ns0:FaultActor>" + "${faultActor}" + "</ns0:FaultActor>" +21 "<ns0:FaultDetail>" + "${faultDetail}" + "</ns0:FaultDetail>" +22 "</ns0:GetTimeFault>");23 soap().client(webServiceClient)24 .receive()25 .fault()26 .faultCode("${faultCode}")27 .faultString("${faultString}")28 .faultActor("${faultActor}")29 .faultDetail("${faultDetail}");30 soap().client(webServiceClient)31 .receive()32 .fault()33 .faultCode("${faultCode}")34 .faultString("${faultString}")35 .faultActor("${faultActor}")36 .faultDetail(new SoapFault().faultCode("${faultCode}").faultString("${faultString}").faultActor("${faultActor}").faultDetail("${faultDetail}"));37 soap().client(webServiceClient)38 .receive()39 .fault()40 .faultCode("${faultCode}")

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;4import com.consol.citrus.ws.message.SoapFault;5import org.testng.annotations.Test;6import java.util.Collections;7public class SoapFaultIT extends JUnit4CitrusTestDesigner {8 public void soapFault() {9 variable("faultCode", "Server");10 variable("faultString", "Internal Server Error");11 variable("faultDetail", "Fault occurred!");12 soap().client("soapClient")13 .send()14 .soapFault()15 .faultCode("${faultCode}")16 .faultString("${faultString}")17 .faultActor("${faultActor}")18 .faultDetails(Collections.singletonMap("detail", "${faultDetail}"));19 soap().server("soapServer")20 .receive()21 .soapFault()22 .faultCode("${faultCode}")23 .faultString("${faultString}")24 .faultActor("${faultActor}")25 .faultDetails(Collections.singletonMap("detail", "${faultDetail}"));26 soap().server("soapServer")27 .send()28 .soapFault(SoapFault.serverFault()29 .faultCode("${faultCode}")30 .faultString("${faultString}")31 .faultActor("${faultActor}")32 .faultDetails(Collections.singletonMap("detail", "${faultDetail}")));33 }34}35package com.consol.citrus.samples;36import com.consol.citrus.annotations.CitrusTest;37import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;38import com.consol.citrus.ws.message.SoapFault;39import org.testng.annotations.Test;40import java.util.Collections;41public class SoapFaultIT extends JUnit4CitrusTestDesigner {42 public void soapFault() {43 variable("faultCode", "Server");44 variable("faultString", "Internal Server Error");45 variable("faultDetail", "Fault occurred!");46 soap().client("soapClient")47 .send()48 .soapFault()49 .faultCode("${faultCode}")50 .faultString("${faultString}")51 .faultActor("${faultActor

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import org.springframework.context.annotation.Bean;3import org.springframework.context.annotation.Configuration;4import org.springframework.context.annotation.ImportResource;5import com.consol.citrus.dsl.endpoint.CitrusEndpoints;6import com.consol.citrus.dsl.runner.TestRunner;7import com.consol.citrus.dsl.runner.TestRunnerBeforeTestSupport;8import com.consol.citrus.message.MessageType;9import com.consol.citrus.ws.client.WebServiceClient;10import com.consol.citrus.ws.message.SoapFault;11@ImportResource("classpath:com/consol/citrus/samples/3.xml")12public class SoapFaultTest extends TestRunnerBeforeTestSupport {13 public WebServiceClient webServiceClient() {14 return CitrusEndpoints.soap()15 .client()16 .build();17 }18 public void execute(TestRunner runner) {19 runner.http(builder -> builder.server(httpServer)20 .receive()21 .post()22 .messageType(MessageType.XML)23 "</soap:Envelope>"));24 runner.http(builder -> builder.server(httpServer)25 .send()26 .response(HttpStatus.BAD_REQUEST)27 .messageType(MessageType.XML)28 "</soap:Envelope>"));29 runner.receive(webServiceClient())30 .payload("<ns2:sayHello

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import java.util.ArrayList;3import java.util.List;4import org.springframework.context.annotation.Bean;5import org.springframework.context.annotation.Configuration;6import org.springframework.context.annotation.Import;7import com.consol.citrus.dsl.builder.BuilderSupport;8import com.consol.citrus.dsl.builder.CitrusTestBuilder;9import com.consol.citrus.dsl.builder.HttpServerActionBuilder;10import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder;11import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpResponseMessageBuilder;12import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponseBuilder;13import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadBuilder;14import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadDataBuilder;15import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadTemplateBuilder;16import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadVariablesBuilder;17import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlBuilder;18import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlDataBuilder;19import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlTemplateBuilder;20import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlVariablesBuilder;21import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithNamespacesBuilder;22import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithNamespacesDataBuilder;23import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithNamespacesTemplateBuilder;24import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithNamespacesVariablesBuilder;25import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithXpathBuilder;26import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithXpathDataBuilder;27import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithXpathTemplateBuilder;28import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponsePayloadXmlWithXpath

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.ws.message.SoapFault;5import org.testng.annotations.Test;6public class SoapFaultTest extends TestNGCitrusTestDesigner {7 public void testSoapFault() {8 TestRunner runner = this;9 runner.http(action -> action.client("httpClient")10 .send()11 .post()12 .fork(true)13 "</soapenv:Envelope>"));14 runner.receive(action -> action.endpoint("webServiceEndpoint")15 .messageType("SOAP")16 .extractFromHeader("citrus_jms_messageId", "correlationId"));17 runner.send(action -> action.endpoint("webServiceEndpoint")18 .messageType("SOAP")

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import org.springframework.context.annotation.Bean;3import org.springframework.context.annotation.Configuration;4import org.springframework.context.annotation.Import;5import org.springframework.ws.soap.SoapFault;6import org.springframework.ws.soap.SoapFaultDetailElement;7import org.springframework.ws.soap.SoapMessage;8import org.springframework.xml.transform.StringSource;9import com.consol.citrus.dsl.builder.BuilderSupport;10import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder;11import com.consol.citrus.dsl.builder.SendSoapFaultBuilder;12import com.consol.citrus.dsl.runner.TestRunner;13import com.consol.citrus.dsl.runner.TestRunnerSupport;14import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;15import com.consol.citrus.http.server.HttpServer;16import com.consol.citrus.ws.client.WebServiceClient;17import com.consol.citrus.ws.server.WebServiceServer;18@Import(SoapFaultTestConfig.class)19public class SoapFaultTest extends TestNGCitrusTestDesigner {20 public WebServiceServer webServiceServer() {21 .soap()22 .server()23 .port(8080)24 .autoStart(true)25 .build();26 }27 public WebServiceClient webServiceClient() {28 .soap()29 .client()30 .build();31 }32 public HttpServer httpServer() {33 .http()34 .server()35 .port(8081)36 .autoStart(true)37 .build();38 }39 protected void configure() {40 parallel(builder -> builder41 .http(httpServer -> httpServer42 .receive()43 .post()44 .soap(webServiceServer -> webServiceServer45 .receive()46 .fault()47 .faultString("Test fault message")

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.runner.TestRunnerSupport;4import com.consol.citrus.ws.message.SoapFault;5import org.springframework.core.io.ClassPathResource;6import org.springframework.ws.soap.SoapBody;7import org.springframework.ws.soap.SoapFaultDetail;8public class FaultDetails extends TestRunnerSupport {9 public static void main(String[] args) {10 TestRunner runner = new TestRunner();11 runner.http(builder -> builder.client("httpClient")12 .send()13 .post()14 .fork(true)15 .payload(new ClassPathResource("3_request.xml")));16 runner.http(builder -> builder.server("httpServer")17 .receive()18 .post()19 .payload(new ClassPathResource("3_request.xml")));20 runner.http(builder -> builder.server("httpServer")21 .send()22 .response()23 .faultDetails((SoapFaultDetail detail) -> {24 soapBody.addDocument(new ClassPathResource("3_faultDetail.xml"));25 })));26 runner.http(builder -> builder.client("httpClient")27 .receive()28 .response()29 .fault()30 .faultCode("Client")31 .faultString("Error in the request")32 .faultDetails((SoapFaultDetail detail) -> {33 soapBody.addDocument(new ClassPathResource("3_faultDetail.xml"));34 }));35 }36}

Full Screen

Full Screen

faultDetails

Using AI Code Generation

copy

Full Screen

1public void testFaultDetails() {2 http().client(client)3 .send()4 .post("/soap/echo")5 "</soapenv:Envelope>");6 http().client(client)7 .receive()8 .response(HttpStatus.BAD_REQUEST)9 .faultDetails(fault -> fault10 .faultCode("soapenv:Client")11 .faultString("Client Error")12}13public void testFaultDetails() {14 http().client(client)15 .send()16 .post("/soap/echo")17 .payload("<soapenv:Envelope xmlns:

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