Best Citrus code snippet using com.consol.citrus.ws.actions.AssertSoapFault.setFaultActor
Source:AssertSoapFaultTest.java
...56 Soap11Fault fault = ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 57 "Internal server error", 58 Locale.GERMANY);59 60 fault.setFaultActorOrRole("SERVER");61 62 throw new SoapFaultClientException(faultMessage);63 }64 });65 66 assertAction.setFaultString("Internal server error");67 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");68 assertAction.setFaultActor("SERVER");69 70 assertAction.execute(context);71 }72 73 @Test74 public void testAssertSoapFaultWithValidationMatchers() throws Exception {75 AssertSoapFault assertAction = new AssertSoapFault();76 assertAction.setValidator(soapFaultValidator);77 assertAction.setAction(new AbstractTestAction() {78 @Override79 public void doExecute(TestContext context) {80 SoapMessage faultMessage;81 82 faultMessage = messageFactory.createWebServiceMessage();83 84 Soap11Fault fault = ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 85 "Internal server error", 86 Locale.GERMANY);87 88 fault.setFaultActorOrRole("SERVER");89 90 throw new SoapFaultClientException(faultMessage);91 }92 });93 94 assertAction.setFaultString("@equalsIgnoreCase('internal server error')@");95 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");96 assertAction.setFaultActor("@equalsIgnoreCase('server')@");97 98 assertAction.execute(context);99 }100 101 @Test102 public void testNoPrefix() throws Exception {103 AssertSoapFault assertAction = new AssertSoapFault();104 assertAction.setValidator(soapFaultValidator);105 assertAction.setAction(new AbstractTestAction() {106 @Override107 public void doExecute(TestContext context) {108 SoapMessage faultMessage;109 110 faultMessage = messageFactory.createWebServiceMessage();111 112 ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}TEC-1001"), 113 "Internal server error", 114 Locale.GERMANY);115 116 throw new SoapFaultClientException(faultMessage);117 }118 });119 120 assertAction.setFaultString("Internal server error");121 assertAction.setFaultCode("{http://citrusframework.org}TEC-1001");122 123 assertAction.execute(context);124 }125 126 @Test127 public void testWrongFaultCode() throws Exception {128 AssertSoapFault assertAction = new AssertSoapFault();129 assertAction.setValidator(soapFaultValidator);130 assertAction.setAction(new AbstractTestAction() {131 @Override132 public void doExecute(TestContext context) {133 SoapMessage faultMessage;134 135 faultMessage = messageFactory.createWebServiceMessage();136 137 ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-2002"), 138 "Internal server error", 139 Locale.GERMANY);140 141 throw new SoapFaultClientException(faultMessage);142 }143 });144 145 assertAction.setFaultString("Internal server error");146 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");147 148 try {149 assertAction.execute(context);150 } catch(IllegalArgumentException e) {151 Assert.assertEquals(e.getMessage(), "SOAP fault validation failed! Fault code does not match - expected: '{http://citrusframework.org}TEC-1001' but was: '{http://citrusframework.org}TEC-2002'");152 return;153 }154 155 Assert.fail("Missing validation exception");156 }157 158 @Test159 public void testWrongFaultActor() throws Exception {160 AssertSoapFault assertAction = new AssertSoapFault();161 assertAction.setValidator(soapFaultValidator);162 assertAction.setAction(new AbstractTestAction() {163 @Override164 public void doExecute(TestContext context) {165 SoapMessage faultMessage;166 faultMessage = messageFactory.createWebServiceMessage();167 168 Soap11Fault fault = ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 169 "Internal server error", 170 Locale.GERMANY);171 172 fault.setFaultActorOrRole("CLIENT");173 174 throw new SoapFaultClientException(faultMessage);175 }176 });177 178 assertAction.setFaultString("Internal server error");179 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");180 assertAction.setFaultActor("SERVER");181 182 try {183 assertAction.execute(context);184 } catch(IllegalArgumentException e) {185 Assert.assertEquals(e.getMessage(), "SOAP fault validation failed! Fault actor does not match - expected: 'SERVER' but was: 'CLIENT'");186 return;187 }188 189 Assert.fail("Missing validation exception");190 }191 192 @Test193 public void testWrongFaultString() throws Exception {194 AssertSoapFault assertAction = new AssertSoapFault();...
Source:AssertSoapFault.java
...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 */...
Source:AssertSoapFaultBuilder.java
...95 * @param faultActor96 * @return97 */98 public AssertSoapFaultBuilder faultActor(String faultActor) {99 action.setFaultActor(faultActor);100 return this;101 }102 103 /**104 * Expect fault detail in SOAP fault message.105 * @param faultDetail106 * @return107 */108 public AssertSoapFaultBuilder faultDetail(String faultDetail) {109 action.getFaultDetails().add(faultDetail);110 return this;111 }112 113 /**...
setFaultActor
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import org.springframework.http.HttpStatus;5import org.testng.annotations.Test;6public class Test3 extends TestNGCitrusTestDesigner {7 public void test3() {8 echo("This test case is to use setFaultActor method of com.consol.citrus.ws.actions.AssertSoapFault class");9 send("soapClient")10 "</soapenv:Envelope>");11 receive("soapServer")12 "</soapenv:Envelope>");13 send("soapServer")14 " <faultactor>${faultActor}</fault
setFaultActor
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.ws.actions.AssertSoapFault;5import org.springframework.http.HttpStatus;6import org.springframework.web.client.HttpClientErrorException;7import org.testng.annotations.Test;8import static com.consol.citrus.actions.EchoAction.Builder.echo;9public class AssertSoapFaultTest extends TestNGCitrusTestRunner {10 public void testAssertSoapFault() {11 run(new TestRunner() {12 public void execute() {13 variable("faultCode", "Server");14 variable("faultString", "Some fault");15 variable("faultDetail", "<detail>Some fault detail</detail>");16 soap(builder -> builder.client("soapFaultClient")17 .send()18 .soapAction("sayHelloFault")19 "</ns0:sayHelloFault>"));20 soap(builder -> builder.client("soapFaultClient")21 .receive()22 "</ns0:sayHelloFaultResponse>"));23 soap(builder -> builder.client("soapFaultClient")24 .send()25 .soapAction("sayHelloFault")26 "</ns0:sayHelloFault>"));27 soap(builder -> builder.client("soapFaultClient")28 .receive()29 .fault()30 "<faultCode>${faultCode}</faultCode>" +31 "<faultActor>${faultActor}</faultActor>" +32 "<faultString>${faultString}</faultString>" +33 "${faultDetail}" +34 "</ns0:Fault>"));35 echo("Asserting SOAP
setFaultActor
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.testng.AbstractTestNGUnitTest;3import com.consol.citrus.ws.message.SoapFault;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.ws.soap.SoapBody;6import org.springframework.ws.soap.SoapBodyException;7import org.springframework.ws.soap.SoapFaultDetail;8import org.springframework.ws.soap.SoapMessage;9import org.springframework.ws.soap.SoapMessageFactory;10import org.springframework.ws.soap.SoapVersion;11import org.springframework.ws.soap.client.SoapFaultClientException;12import org.springframework.ws.soap.server.SoapFaultException;13import org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver;14import org.springframework.ws.soap.server.endpoint.SoapFaultResolver;15import org.testng.Assert;16import org.testng.annotations.Test;17public class AssertSoapFaultTest extends AbstractTestNGUnitTest {18 private SoapFault soapFault = new SoapFault();19 private SoapMessageFactory messageFactory;20 public void testAssertSoapFault() {21 soapFault.setFaultActor("faultActor");22 AssertSoapFault assertSoapFault = new AssertSoapFault();23 assertSoapFault.setFaultActor("faultActor");24 assertSoapFault.setSoapFault(soapFault);25 assertSoapFault.execute(context);26 }27 @Test(expectedExceptions = AssertSoapFault.SoapFaultException.class,28 public void testAssertSoapFaultWithWrongFaultActor() {29 soapFault.setFaultActor("faultActor");30 AssertSoapFault assertSoapFault = new AssertSoapFault();31 assertSoapFault.setFaultActor("wrongActor");32 assertSoapFault.setSoapFault(soapFault);33 assertSoapFault.execute(context);34 }35 public void testSoapFaultException() {36 SoapFault soapFault = new SoapFault();37 soapFault.setFaultActor("faultActor");38 SoapFaultException soapFaultException = new SoapFaultException(soapFault);39 AssertSoapFault.SoapFaultException soapFaultException1 = new AssertSoapFault.SoapFaultException(soapFaultException);40 Assert.assertEquals(soapFaultException1.getMessage(), "SOAP fault assertion failed: " + soapFaultException.getMessage());41 }42 public void testSoapFaultClientException() {43 SoapFault soapFault = new SoapFault();
setFaultActor
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.testng.AbstractTestNGUnitTest;3import org.testng.annotations.Test;4public class AssertSoapFaultSetFaultActorTest extends AbstractTestNGUnitTest {5 public void testSetFaultActor() {6 AssertSoapFault assertSoapFault = new AssertSoapFault();7 assertSoapFault.setFaultActor("faultActor");8 assertSoapFault.setFaultCode("faultCode");9 assertSoapFault.setFaultString("faultString");10 assertSoapFault.setFaultDetail("faultDetail");11 assertSoapFault.setFaultCodeNamespace("faultCodeNamespace");12 assertSoapFault.setFaultStringOrReason("faultStringOrReason");13 assertSoapFault.setFaultDetailType("faultDetailType");14 assertSoapFault.setFaultRole("faultRole");15 assertSoapFault.setFaultNode("faultNode");16 assertSoapFault.setFaultSubcode("faultSubcode");17 assertSoapFault.setFaultReason("faultReason");18 assertSoapFault.setFaultReasonText("faultReasonText");19 assertSoapFault.setFaultReasonLang("faultReasonLang");20 assertSoapFault.setFaultDetailText("faultDetailText");21 assertSoapFault.setFaultDetailXmlLang("faultDetailXmlLang");22 assertSoapFault.setFaultDetailEncodingStyle("faultDetailEncodingStyle");23 assertSoapFault.setFaultDetailNamespace("faultDetailNamespace");24 assertSoapFault.setFaultDetailQName("faultDetailQName");25 assertSoapFault.setFaultDetailQNameNamespace("faultDetailQNameNamespace");26 assertSoapFault.setFaultDetailQNamePrefix("faultDetailQNamePrefix");27 assertSoapFault.setFaultDetailQNameLocalPart("faultDetailQNameLocalPart");28 assertSoapFault.setFaultDetailQNameValue("faultDetailQNameValue");29 assertSoapFault.setFaultDetailQNameAttributes("faultDetailQNameAttributes");30 assertSoapFault.setFaultDetailQNameNamespaces("faultDetailQNameNamespaces");31 assertSoapFault.setFaultDetailQNamePrefixes("faultDetailQNamePrefixes");32 assertSoapFault.setFaultDetailQNameDefaultNamespace("faultDetailQNameDefaultNamespace");33 assertSoapFault.setFaultDetailQNameDefaultNamespacePrefix("faultDetailQNameDefaultNamespacePrefix");34 assertSoapFault.setFaultDetailQNameSchemaLocation("faultDetailQNameSchemaLocation");35 assertSoapFault.setFaultDetailQNameNoNamespaceSchemaLocation("faultDetail
setFaultActor
Using AI Code Generation
1package com.consol.citrus.dsl.design;2import org.testng.annotations.Test;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4public class SetFaultActor extends TestNGCitrusTestDesigner {5public void setFaultActor() {6http().client(client)7.send()8.post()9.soap()10http().client(client)11.receive()12.response(HttpStatus.BAD_REQUEST)13}14}
setFaultActor
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.springframework.http.HttpStatus;4import org.testng.annotations.Test;5public class AssertSoapFaultJavaIT extends TestNGCitrusTestDesigner {6 public void AssertSoapFaultJavaIT() {7 http().client("httpClient")8 .send()9 .post()10 .fork(true)11 "</soapenv:Envelope>");12 http().client("httpClient")13 .receive()14 .response(HttpStatus.OK)15 "</soapenv:Envelope>");16 soap().client("soapClient")17 .receive()
setFaultActor
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class AssertSoapFaultSampleJavaIT extends TestNGCitrusTestDesigner {5 protected void configure() {6 soap()7 .client("soapClient")8 .send()9 "</ns0:sayHello>");10 soap()11 .server("soapServer")12 .receive()13 "</ns0:sayHello>");14 soap()15 .server("soapServer")16 .send()17 .fault("Server", "Internal server error");18 soap()19 .client("soapClient")20 .receive()21 .fault("Server", "Internal server error");22 soap()23 .client("soapClient")24 .send()25 "</ns0:sayHello>");26 soap()27 .server("soapServer")28 .receive()29 "</ns0:sayHello>");30 soap()31 .server("soapServer")32 .send()33 "</ns0:sayHelloResponse>");34 soap()35 .client("soapClient")36 .receive()
setFaultActor
Using AI Code Generation
1package com.consol.citrus.dsl.testng;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import org.springframework.core.io.ClassPathResource;5import org.testng.annotations.Test;6public class AssertSoapFaultJavaITest extends TestNGCitrusTestDesigner {7public void assertSoapFaultJavaITest() {8 description("AssertSoapFault Java DSL test");9 http().client("httpClient")10 .send()11 .post()12 .fork(true)13 .payload(new ClassPathResource("com/consol/citrus/actions/soap-fault-payload.xml"));14 http().server("httpServerRequestEndpoint")15 .receive()16 .post()17 .payload(new ClassPathResource("com/consol/citrus/actions/soap-fault-payload.xml"));18 http().server("httpServerResponseEndpoint")19 .send()20 .response(HttpStatus.BAD_REQUEST)21 .payload(new ClassPathResource("com/consol/citrus/actions/soap-fault-response.xml"));22 http().client("httpClient")23 .receive()24 .response(HttpStatus.BAD_REQUEST);25 soap().client("soapClient")26 .send()27 soap().server("soapServer")28 .receive()29 soap().server("soapServer")30 .send()31 .faultActor("${actor}")32 soap().client("soapClient")33 .receive()34 .faultActor("${actor}")35 soap().client("soapClient")36 .send()37 .payload("<ns0:FaultRequest xmlns
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!!