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

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

Source:AssertSoapFault.java Github

copy

Full Screen

...49 /** OName representing fault code */50 private String faultCode = null;51 52 /** Fault actor */53 private String faultActor = null;54 55 /** List of fault details, either inline data or file resource path */56 private List<String> faultDetails = new ArrayList<String>();57 /** List of fault detail resource paths */58 private List<String> faultDetailResourcePaths = new ArrayList<String>();59 60 /** Soap fault validator implementation */61 private SoapFaultValidator validator = new SimpleSoapFaultValidator();62 63 /** Validation context */64 private ValidationContext validationContext;65 66 /** Logger */67 private static Logger log = LoggerFactory.getLogger(AssertSoapFault.class);68 /**69 * Default constructor.70 */71 public AssertSoapFault() {72 setName("soap-fault");73 }74 @Override75 public void doExecute(TestContext context) {76 log.debug("Asserting SOAP fault ...");77 try {78 action.execute(context);79 } catch (SoapFaultClientException soapFaultException) {80 log.debug("Validating SOAP fault ...");81 82 SoapFault controlFault = constructControlFault(context);83 84 validator.validateSoapFault(SoapFault.from(soapFaultException.getSoapFault()), controlFault, context, validationContext);85 86 log.debug("Asserted SOAP fault as expected: " + soapFaultException.getFaultCode() + ": " + soapFaultException.getFaultStringOrReason());87 log.info("Assert SOAP fault validation successful");88 89 return;90 } catch (RuntimeException e) {91 throw new ValidationException("SOAP fault validation failed for asserted exception type - expected: '" + 92 SoapFaultClientException.class + "' but was: '" + e.getClass().getName() + "'", e);93 } catch (Exception e) {94 throw new ValidationException("SOAP fault validation failed for asserted exception type - expected: '" + 95 SoapFaultClientException.class + "' but was: '" + e.getClass().getName() + "'", e);96 }97 98 throw new ValidationException("SOAP fault validation failed! Missing asserted SOAP fault exception");99 }100 /**101 * Constructs the control soap fault holding all expected fault information102 * like faultCode, faultString and faultDetail.103 * 104 * @return the constructed SoapFault instance.105 */106 private SoapFault constructControlFault(TestContext context) {107 SoapFault controlFault= new SoapFault();108 if (StringUtils.hasText(faultActor)) {109 controlFault.faultActor(context.replaceDynamicContentInString(faultActor));110 }111 controlFault.faultCode(context.replaceDynamicContentInString(faultCode));112 controlFault.faultString(context.replaceDynamicContentInString(faultString));113 for (String faultDetail : faultDetails) {114 controlFault.addFaultDetail(context.replaceDynamicContentInString(faultDetail));115 }116 try {117 for (String faultDetailPath : faultDetailResourcePaths) {118 String resourcePath = context.replaceDynamicContentInString(faultDetailPath);119 controlFault.addFaultDetail(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(resourcePath, context), FileUtils.getCharset(resourcePath))));120 }121 } catch (IOException e) {122 throw new CitrusRuntimeException("Failed to create SOAP fault detail from file resource", e);123 }124 return controlFault;125 }126 /**127 * Set the nested test action.128 * @param action the action to set129 */130 public AssertSoapFault setAction(TestAction action) {131 addTestAction(action);132 return this;133 }134 /**135 * Set the fault code.136 * @param faultCode the faultCode to set137 */138 public AssertSoapFault setFaultCode(String faultCode) {139 this.faultCode = faultCode;140 return this;141 }142 /**143 * Set the fault string.144 * @param faultString the faultString to set145 */146 public AssertSoapFault setFaultString(String faultString) {147 this.faultString = faultString;148 return this;149 }150 /**151 * @param validator the validator to set152 */153 public AssertSoapFault setValidator(SoapFaultValidator validator) {154 this.validator = validator;155 return this;156 }157 @Override158 public AssertSoapFault addTestAction(TestAction action) {159 this.action = action;160 super.addTestAction(action);161 return this;162 }163 @Override164 public TestAction getTestAction(int index) {165 if (index == 0) {166 return action;167 } else {168 throw new IndexOutOfBoundsException("Illegal index in action list:" + index);169 }170 }171 @Override172 public AssertSoapFault setActions(List<TestAction> actions) {173 if (actions.size() > 1) {174 throw new CitrusRuntimeException("Invalid number of nested test actions - only one single nested action is allowed");175 }176 action = actions.get(0);177 super.setActions(actions);178 return this;179 }180 /**181 * Gets the action.182 * @return the action183 */184 public TestAction getAction() {185 return action;186 }187 /**188 * Gets the faultString.189 * @return the faultString190 */191 public String getFaultString() {192 return faultString;193 }194 /**195 * Gets the faultCode.196 * @return the faultCode197 */198 public String getFaultCode() {199 return faultCode;200 }201 /**202 * Gets the list of fault details.203 * @return the faultDetails204 */205 public List<String> getFaultDetails() {206 return faultDetails;207 }208 209 /**210 * Sets the faultDetails.211 * @param faultDetails the faultDetails to set212 */213 public AssertSoapFault setFaultDetails(List<String> faultDetails) {214 this.faultDetails = faultDetails;215 return this;216 }217 /**218 * Gets the fault detail resource paths.219 * @return220 */221 public List<String> getFaultDetailResourcePaths() {222 return faultDetailResourcePaths;223 }224 /**225 * Sets the fault detail resource paths.226 * @param faultDetailResourcePaths227 */228 public AssertSoapFault setFaultDetailResourcePaths(List<String> faultDetailResourcePaths) {229 this.faultDetailResourcePaths = faultDetailResourcePaths;230 return this;231 }232 /**233 * Gets the validator.234 * @return the validator235 */236 public SoapFaultValidator getValidator() {237 return validator;238 }239 /**240 * Gets the faultActor.241 * @return the faultActor the faultActor to get.242 */243 public String getFaultActor() {244 return faultActor;245 }246 /**247 * Sets the faultActor.248 * @param faultActor the faultActor to set249 */250 public AssertSoapFault setFaultActor(String faultActor) {251 this.faultActor = faultActor;252 return this;253 }254 /**255 * Gets the validationContext.256 * @return the validationContext the validationContext to get.257 */258 public ValidationContext getValidationContext() {259 return validationContext;260 }261 /**262 * Sets the validationContext.263 * @param validationContext the validationContext to set264 */265 public AssertSoapFault setValidationContext(ValidationContext validationContext) {...

Full Screen

Full Screen

Source:SendSoapFaultAction.java Github

copy

Full Screen

...31 private String faultCode;32 /** Fault reason string describing the fault */33 private String faultString;34 /** Optional fault actor */35 private String faultActor;36 /** List of fault detail contents */37 private List<String> faultDetails = new ArrayList<>();38 /** List of fault detail resource paths */39 private List<String> faultDetailResourcePaths = new ArrayList<>();40 @Override41 protected SoapMessage createMessage(TestContext context, String messageType) {42 SoapMessage soapMessage = super.createMessage(context, messageType);43 SoapFault soapFault = new SoapFault();44 soapFault.setPayload(soapMessage.getPayload());45 if (!StringUtils.hasText(faultCode)) {46 throw new CitrusRuntimeException("Missing fault code definition for SOAP fault generation. Please specify a proper SOAP fault code!");47 }48 soapFault.faultCode(context.replaceDynamicContentInString(faultCode));49 for (Map.Entry<String, Object> header : soapMessage.getHeaders().entrySet()) {50 if (!header.getKey().equals(MessageHeaders.ID)) {51 soapFault.setHeader(header.getKey(), header.getValue());52 }53 }54 for (String headerData : soapMessage.getHeaderData()) {55 soapFault.addHeaderData(headerData);56 }57 for (SoapAttachment soapAttachment : soapMessage.getAttachments()) {58 soapFault.addAttachment(soapAttachment);59 }60 if (StringUtils.hasText(faultActor)) {61 soapFault.faultActor(context.replaceDynamicContentInString(faultActor));62 }63 if (faultString != null) {64 soapFault.faultString(context.replaceDynamicContentInString(faultString));65 }66 for (String faultDetail : faultDetails) {67 soapFault.addFaultDetail(context.replaceDynamicContentInString(faultDetail));68 }69 try {70 for (String faultDetailPath : faultDetailResourcePaths) {71 String resourcePath = context.replaceDynamicContentInString(faultDetailPath);72 soapFault.addFaultDetail(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(resourcePath, context), FileUtils.getCharset(resourcePath))));73 }74 } catch (IOException e) {75 throw new CitrusRuntimeException("Failed to create SOAP fault detail from file resource", e);76 }77 return soapFault;78 }79 /**80 * Set the fault code QName string. This can be either81 * a fault code in {@link org.springframework.ws.soap.server.endpoint.SoapFaultDefinition}82 * or a custom QName like {http://www.consol.de/citrus}citrus:TEC-100083 *84 * @param faultCode the faultCode to set85 */86 public SendSoapFaultAction setFaultCode(String faultCode) {87 this.faultCode = faultCode;88 return this;89 }90 /**91 * Set the fault reason string describing the fault.92 * @param faultString the faultString to set93 */94 public SendSoapFaultAction setFaultString(String faultString) {95 this.faultString = faultString;96 return this;97 }98 /**99 * Sets the faultActor.100 * @param faultActor the faultActor to set101 */102 public SendSoapFaultAction setFaultActor(String faultActor) {103 this.faultActor = faultActor;104 return this;105 }106 /**107 * Gets the faultActor.108 * @return the faultActor the faultActor to get.109 */110 public String getFaultActor() {111 return faultActor;112 }113 /**114 * Gets the faultCode.115 * @return the faultCode116 */117 public String getFaultCode() {118 return faultCode;119 }120 /**121 * Gets the faultString.122 * @return the faultString123 */124 public String getFaultString() {125 return faultString;...

Full Screen

Full Screen

faultActor

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 FaultActorTest extends TestNGCitrusTestRunner {8 public void FaultActorTest() {9 send("faultActorSender")10 "</ns0:FaultActor>");11 receive("faultActorReceiver")12 "</ns0:FaultActorResponse>");13 send("faultActorSender")14 .fault(SoapFault.server("Server Fault").faultActor("faultActor"));15 receive("faultActorReceiver")16 .fault(HttpStatus.INTERNAL_SERVER_ERROR)17 .fault(SoapFault.server("Server Fault").faultActor("faultActor"));18 }19}

Full Screen

Full Screen

faultActor

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.annotations.CitrusXmlTest;2import com.consol.citrus.testng.CitrusParameters;3import com.consol.citrus.testng.TestNGCitrusSupport;4import org.testng.annotations.Test;5public class 3 extends TestNGCitrusSupport {6 @CitrusParameters({"actor"})7 @CitrusXmlTest(name = "3")8 public void _3() {}9}10import com.consol.citrus.annotations.CitrusXmlTest;11import com.consol.citrus.testng.CitrusParameters;12import com.consol.citrus.testng.TestNGCitrusSupport;13import org.testng.annotations.Test;14public class 4 extends TestNGCitrusSupport {15 @CitrusParameters({"code"})16 @CitrusXmlTest(name = "4")17 public void _4() {}18}19import com.consol.citrus.annotations.CitrusXmlTest;20import com.consol.citrus.testng.CitrusParameters;21import com.consol.citrus.testng.TestNGCitrusSupport;22import org.testng.annotations.Test;23public class 5 extends TestNGCitrusSupport {24 @CitrusParameters({"string"})25 @CitrusXmlTest(name = "5")26 public void _5() {}27}28import com.consol.citrus.annotations.CitrusXmlTest;29import com.consol.citrus.testng.CitrusParameters;30import com.consol.citrus.testng.TestNGCitrusSupport;31import org.testng.annotations.Test;32public class 6 extends TestNGCitrusSupport {33 @CitrusParameters({"detail"})34 @CitrusXmlTest(name = "6")35 public void _6() {}36}37import com.consol.citrus.annotations.CitrusXmlTest

Full Screen

Full Screen

faultActor

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;2import com.consol.citrus.ws.message.SoapFault;3import org.springframework.http.HttpStatus;4import org.testng.annotations.Test;5public class SoapFaultActorIT extends TestNGCitrusTestDesigner {6 public void soapFaultActor() {7 http().client("httpClient")8 .send()9 .post()10 .fork(true)11 "</soapenv:Envelope>");12 http().client("httpClient")13 .receive()14 .response(HttpStatus.INTERNAL_SERVER_ERROR)15 .payload(new SoapFault().faultCode("Client").faultString("Invalid request").faultActor("TestActor"));16 http().client("httpClient")17 .send()18 .response(HttpStatus.OK)19 "</soapenv:Envelope>");20 }21}22import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;23import com.consol.citrus.ws.message.SoapFault;24import org.springframework.http.HttpStatus;25import org.testng.annotations.Test;

Full Screen

Full Screen

faultActor

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class FaultActorSample extends TestNGCitrusTestDesigner {5 public void faultActorSample() {6 http()7 .client("httpClient")8 .send()9 .post()10 .fork(true)11 "</soap:Envelope>");12 receive("helloServiceRequestEndpoint")13 .message()14 .soap()15 send("helloServiceResponseEndpoint")16 .message()17 .soap()18 .fault()19 .faultString("Invalid request")20 }21}22package com.consol.citrus.samples;23import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;24import org.testng.annotations.Test;25public class FaultCodeSample extends TestNGCitrusTestDesigner {26 public void faultCodeSample() {27 http()28 .client("httpClient")29 .send()30 .post()31 .fork(true)

Full Screen

Full Screen

faultActor

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 org.springframework.beans.factory.annotation.Autowired;6import org.springframework.core.io.ClassPathResource;7import org.testng.annotations.Test;8public class SoapFaultActorIT extends TestNGCitrusTestDesigner {9 private WebServiceClient webServiceClient;10 public void soapFaultActor() {11 http()12 .client(webServiceClient)13 .send()14 .post("/services/samples/sayHelloService")15 .payload(new ClassPathResource("templates/soap_fault_actor_request.xml"));16 http()17 .client(webServiceClient)18 .receive()19 .response(HttpStatus.BAD_REQUEST)20 .payload(new ClassPathResource("templates/soap_fault_actor_response.xml"));21 }22}23package com.consol.citrus;24import com.consol.citrus.annotations.CitrusTest;25import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;26import com.consol.citrus.ws.client.WebServiceClient;27import org.springframework.beans.factory.annotation.Autowired;28import org.springframework.core.io.ClassPathResource;29import org.testng.annotations.Test;30public class SoapFaultActorIT extends TestNGCitrusTestDesigner {31 private WebServiceClient webServiceClient;32 public void soapFaultActor() {33 http()34 .client(webServiceClient)35 .send()36 .post("/services/samples/sayHelloService")37 .payload(new ClassPathResource("templates/soap_fault_actor_request.xml"));38 http()39 .client(webServiceClient)40 .receive()41 .response(HttpStatus.BAD_REQUEST)42 .payload(new ClassPathResource("templates/soap_fault_actor_response.xml"));43 }44}

Full Screen

Full Screen

faultActor

Using AI Code Generation

copy

Full Screen

1public class 3.java {2 public static void main(String[] args) {3 SoapFault soapFault = new SoapFault();4 soapFault.faultActor("test");5 }6}7public class 4.java {8 public static void main(String[] args) {9 SoapFault soapFault = new SoapFault();10 soapFault.faultCode("test");11 }12}13public class 5.java {14 public static void main(String[] args) {15 SoapFault soapFault = new SoapFault();16 soapFault.faultCodeAsQName(new QName("test"));17 }18}19public class 6.java {20 public static void main(String[] args) {21 SoapFault soapFault = new SoapFault();22 soapFault.faultCodeAsQName("test");23 }24}25public class 7.java {26 public static void main(String[] args) {27 SoapFault soapFault = new SoapFault();28 soapFault.faultCodeLocalPart("test");29 }30}31public class 8.java {32 public static void main(String[] args) {33 SoapFault soapFault = new SoapFault();34 soapFault.faultCodeNamespace("test");35 }36}37public class 9.java {38 public static void main(String[] args) {39 SoapFault soapFault = new SoapFault();40 soapFault.faultCodePrefix("test");41 }42}43public class 10.java {44 public static void main(String

Full Screen

Full Screen

faultActor

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.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapFault;6import org.junit.Test;7import org.springframework.beans.factory.annotation.Autowired;8public class FaultActorTest extends JUnit4CitrusTestDesigner {9 private WebServiceClient soapClient;10 public void faultActorTest() {11 soap()12 .client(soapClient)13 .send()14 .faultActor("faultActor")15 .soapFault(SoapFault.server("Server error"));16 soap()17 .client(soapClient)18 .receive()19 .faultActor("faultActor");20 }21}

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