Best Citrus code snippet using com.consol.citrus.ws.actions.AssertSoapFault.setFaultString
Source:AssertSoapFaultTest.java
...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();195 assertAction.setValidator(soapFaultValidator);196 assertAction.setAction(new AbstractTestAction() {197 @Override198 public void doExecute(TestContext context) {199 SoapMessage faultMessage;200 201 faultMessage = messageFactory.createWebServiceMessage();202 203 ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 204 "Internal server error", 205 Locale.GERMANY);206 207 throw new SoapFaultClientException(faultMessage);208 }209 });210 211 assertAction.setFaultString("Invalid request");212 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");213 214 try {215 assertAction.execute(context);216 } catch(ValidationException e) {217 Assert.assertEquals(e.getMessage(), "SOAP fault validation failed! Fault string does not match - expected: 'Invalid request' but was: 'Internal server error'");218 return;219 }220 221 Assert.fail("Missing validation exception");222 }223 224 @Test225 public void testAssertSoapFaultDetail() throws Exception {226 AssertSoapFault assertAction = new AssertSoapFault();227 assertAction.setValidator(soapFaultValidator);228 assertAction.setAction(new AbstractTestAction() {229 @Override230 public void doExecute(TestContext context) {231 SoapMessage faultMessage;232 233 faultMessage = messageFactory.createWebServiceMessage();234 235 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 236 "Internal server error", 237 Locale.GERMANY);238 239 try {240 TransformerFactory transformerFactory = TransformerFactory.newInstance();241 Transformer transformer = transformerFactory.newTransformer();242 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());243 } catch (TransformerException e) {244 throw new CitrusRuntimeException(e);245 }246 247 throw new SoapFaultClientException(faultMessage);248 }249 });250 251 assertAction.setFaultString("Internal server error");252 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");253 assertAction.getFaultDetails().add("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>");254 255 assertAction.execute(context);256 }257 258 @Test259 public void testAssertSoapFaultDetailVariableSupport() throws Exception {260 AssertSoapFault assertAction = new AssertSoapFault();261 assertAction.setValidator(soapFaultValidator);262 assertAction.setAction(new AbstractTestAction() {263 @Override264 public void doExecute(TestContext context) {265 SoapMessage faultMessage;266 267 faultMessage = messageFactory.createWebServiceMessage();268 269 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 270 "Internal server error", 271 Locale.GERMANY);272 273 try {274 TransformerFactory transformerFactory = TransformerFactory.newInstance();275 Transformer transformer = transformerFactory.newTransformer();276 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());277 } catch (TransformerException e) {278 throw new CitrusRuntimeException(e);279 }280 281 throw new SoapFaultClientException(faultMessage);282 }283 });284 285 context.setVariable("faultReason", "Invalid request");286 287 assertAction.setFaultString("Internal server error");288 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");289 assertAction.getFaultDetails().add("<FaultDetail><Reason>${faultReason}</Reason></FaultDetail>");290 291 assertAction.execute(context);292 }293 294 @Test295 public void testAssertSoapFaultDetailResource() throws Exception {296 AssertSoapFault assertAction = new AssertSoapFault();297 assertAction.setValidator(soapFaultValidator);298 assertAction.setAction(new AbstractTestAction() {299 @Override300 public void doExecute(TestContext context) {301 SoapMessage faultMessage;302 303 faultMessage = messageFactory.createWebServiceMessage();304 305 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 306 "Internal server error", 307 Locale.GERMANY);308 309 try {310 TransformerFactory transformerFactory = TransformerFactory.newInstance();311 Transformer transformer = transformerFactory.newTransformer();312 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());313 } catch (TransformerException e) {314 throw new CitrusRuntimeException(e);315 }316 317 throw new SoapFaultClientException(faultMessage);318 }319 });320 321 assertAction.setFaultString("Internal server error");322 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");323 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail.xml");324 325 assertAction.execute(context);326 }327 328 @Test329 public void testAssertSoapFaultDetailResourceVariableSupport() throws Exception {330 AssertSoapFault assertAction = new AssertSoapFault();331 assertAction.setValidator(soapFaultValidator);332 assertAction.setAction(new AbstractTestAction() {333 @Override334 public void doExecute(TestContext context) {335 SoapMessage faultMessage;336 337 faultMessage = messageFactory.createWebServiceMessage();338 339 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 340 "Internal server error", 341 Locale.GERMANY);342 343 try {344 TransformerFactory transformerFactory = TransformerFactory.newInstance();345 Transformer transformer = transformerFactory.newTransformer();346 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());347 } catch (TransformerException e) {348 throw new CitrusRuntimeException(e);349 }350 351 throw new SoapFaultClientException(faultMessage);352 }353 });354 355 context.setVariable("faultReason", "Invalid request");356 357 assertAction.setFaultString("Internal server error");358 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");359 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail-with-variables.xml");360 361 assertAction.execute(context);362 }363 364 @Test365 public void testAssertMultipleSoapFaultDetails() throws Exception {366 AssertSoapFault assertAction = new AssertSoapFault();367 assertAction.setValidator(soapFaultValidator);368 assertAction.setAction(new AbstractTestAction() {369 @Override370 public void doExecute(TestContext context) {371 SoapMessage faultMessage;372 373 faultMessage = messageFactory.createWebServiceMessage();374 375 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 376 "Internal server error", 377 Locale.GERMANY);378 379 SoapFaultDetail faultDetail = fault.addFaultDetail();380 try {381 TransformerFactory transformerFactory = TransformerFactory.newInstance();382 Transformer transformer = transformerFactory.newTransformer();383 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), faultDetail.getResult());384 transformer.transform(new StringSource("<ErrorDetail><Code>1001</Code></ErrorDetail>"), faultDetail.getResult());385 } catch (TransformerException e) {386 throw new CitrusRuntimeException(e);387 }388 389 throw new SoapFaultClientException(faultMessage);390 }391 });392 393 assertAction.setFaultString("Internal server error");394 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");395 assertAction.getFaultDetails().add("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>");396 assertAction.getFaultDetails().add("<ErrorDetail><Code>1001</Code></ErrorDetail>");397 398 assertAction.execute(context);399 }400 401 @Test402 public void testAssertMultipleSoapFaultDetailsWithResource() throws Exception {403 AssertSoapFault assertAction = new AssertSoapFault();404 assertAction.setValidator(soapFaultValidator);405 assertAction.setAction(new AbstractTestAction() {406 @Override407 public void doExecute(TestContext context) {408 SoapMessage faultMessage;409 410 faultMessage = messageFactory.createWebServiceMessage();411 412 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 413 "Internal server error", 414 Locale.GERMANY);415 416 SoapFaultDetail faultDetail = fault.addFaultDetail();417 try {418 TransformerFactory transformerFactory = TransformerFactory.newInstance();419 Transformer transformer = transformerFactory.newTransformer();420 transformer.transform(new StringSource("<ErrorDetail><Code>1001</Code></ErrorDetail>"), faultDetail.getResult());421 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), faultDetail.getResult());422 } catch (TransformerException e) {423 throw new CitrusRuntimeException(e);424 }425 426 throw new SoapFaultClientException(faultMessage);427 }428 });429 430 assertAction.setFaultString("Internal server error");431 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");432 assertAction.getFaultDetails().add("<ErrorDetail><Code>1001</Code></ErrorDetail>");433 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail.xml");434 435 assertAction.execute(context);436 }437}...
Source:AssertSoapFault.java
...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);...
Source:AssertSoapFaultBuilder.java
...85 * @param faultString86 * @return87 */88 public AssertSoapFaultBuilder faultString(String faultString) {89 action.setFaultString(faultString);90 return this;91 }92 93 /**94 * Expect fault actor in SOAP fault message.95 * @param faultActor96 * @return97 */98 public AssertSoapFaultBuilder faultActor(String faultActor) {99 action.setFaultActor(faultActor);100 return this;101 }102 103 /**...
setFaultString
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.exceptions.CitrusRuntimeException;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4import com.consol.citrus.ws.message.SoapFault;5import org.mockito.Mockito;6import org.springframework.ws.soap.SoapFaultDetail;7import org.springframework.ws.soap.SoapFaultDetailElement;8import org.springframework.ws.soap.SoapFaultDetailException;9import org.springframework.ws.soap.SoapFaultException;10import org.springframework.ws.soap.SoapMessage;11import org.springframework.ws.soap.SoapMessageFactory;12import org.springframework.ws.soap.SoapVersion;13import org.springframework.ws.soap.client.SoapFaultClientException;14import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;15import org.testng.Assert;16import org.testng.annotations.Test;17import java.util.Iterator;18public class AssertSoapFaultTest extends AbstractTestNGUnitTest {19 private SoapMessageFactory messageFactory = new SaajSoapMessageFactory();20 private SoapFault soapFault = new SoapFault();21 public void testSoapFaultDetailException() throws Exception {22 soapFault.setFaultString("This is a test fault");23 SoapFaultDetailElement faultDetailElement = Mockito.mock(SoapFaultDetailElement.class);24 Mockito.when(faultDetailElement.getText()).thenReturn("This is a fault detail");25 SoapFaultDetail faultDetail = Mockito.mock(SoapFaultDetail.class);26 Mockito.when(faultDetail.getDetailEntries()).thenReturn(new Iterator<SoapFaultDetailElement>() {27 public boolean hasNext() {28 return true;29 }30 public SoapFaultDetailElement next() {31 return faultDetailElement;32 }33 public void remove() {34 }35 });36 SoapFaultDetailException faultException = new SoapFaultDetailException("This is a test fault", faultDetail);37 AssertSoapFault assertFault = new AssertSoapFault();38 assertFault.setFault(soapFault);39 assertFault.setSoapFaultException(faultException);40 assertFault.execute(context);41 }42 public void testSoapFaultException() throws Exception {43 soapFault.setFaultString("This is a test fault");
setFaultString
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.junit.JUnit4CitrusTest;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.runner.TestRunnerSupport;5import com.consol.citrus.ws.actions.AssertSoapFault;6import com.consol.citrus.ws.actions.SendSoapFault;7import com.consol.citrus.ws.client.WebServiceClient;8import com.consol.citrus.ws.server.WebServiceServer;9import com.consol.citrus.ws.validation.SoapFaultValidator;10import org.springframework.context.annotation.Bean;11import org.springframework.context.annotation.Configuration;12import org.springframework.context.annotation.Import;13import org.springframework.ws.soap.SoapFault;14import java.util.HashMap;15import java.util.Map;16public class AssertSoapFaultTest extends JUnit4CitrusTest {17 @Import({CitrusSpringConfig.class})18 public static class SpringConfig {19 public WebServiceServer webServiceServer() {20 return CitrusSpringConfig.webServiceServer();21 }22 public WebServiceClient webServiceClient() {23 return CitrusSpringConfig.webServiceClient();24 }25 public AssertSoapFault assertSoapFault() {26 AssertSoapFault assertSoapFault = new AssertSoapFault();27 assertSoapFault.setSoapFaultValidator(soapFaultValidator());28 return assertSoapFault;29 }30 public SoapFaultValidator soapFaultValidator() {31 SoapFaultValidator soapFaultValidator = new SoapFaultValidator();32 soapFaultValidator.setFaultString("SOAP Fault");33 Map<String, String> namespaces = new HashMap<>();34 soapFaultValidator.setNamespaces(namespaces);35 return soapFaultValidator;36 }37 }38 public void run(TestRunner runner) {39 runner.http(action -> action.client(webServiceClient())40 .send()41 .post()42 .fork(true)
setFaultString
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class 3 extends TestNGCitrusTestDesigner {5public void test() {6http()7.client(httpClient)8.send()9.post()10.soap()11.header("Content-Type", "text/xml; charset=UTF-8")12.header("SOAPAction", "HelloWorld");13receive()14.response(HttpStatus.OK)15.header("Content-Type", "text/xml; charset=UTF-8");16http()17.client(httpClient)18.send()19.post()20.soap()21.header("Content-Type", "text/xml; charset=UTF-8")22.header("SOAPAction", "HelloWorld");23receive()24.response(HttpStatus.OK)25.header("Content-Type", "text/xml; charset=UTF-8");26http()27.client(httpClient)28.send()29.post()30.soap()31.header("Content-Type", "text/xml; charset=UTF-8")32.header("SOAPAction", "HelloWorld");33receive()34.response(HttpStatus.OK)35.header("Content-Type", "text/xml; charset=UTF-8");36http()37.client(httpClient)38.send()39.post()40.soap()41.payload("<ns0:HelloWorldRequest xmlns:ns0
setFaultString
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {5 public void assertSoapFaultTest() {6 variable("faultString", "SOAP fault occurred");7 variable("faultCode", "soap:Server");8 variable("faultDetail", "Some error occurred");9 soap()10 .client("soapClient")11 .send()12 .soapAction("echo")13 "</ns0:echo>");14 soap()15 .client("soapClient")16 .receive()17 .fault()18 .faultCode("${faultCode}")19 .faultString("${faultString}")20 .faultActor("${faultActor}")21 .faultDetail("${faultDetail}");22 }23}
setFaultString
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.design.TestDesigner;3import com.consol.citrus.dsl.design.TestDesignerBeforeTestSupport;4import org.testng.annotations.Test;5public class 3 extends TestDesignerBeforeTestSupport {6 public void test3() {7 variable("faultString", "This is a fault string");8 send("client")9 .header("SOAPAction", "echo");10 receive("server")11 "</s:Envelope>");12 assertSoapFault("client")13 .faultString("${faultString}")14 "</TestException>");15 }16}
setFaultString
Using AI Code Generation
1import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;2import org.junit.Test;3import org.springframework.core.io.ClassPathResource;4public class 3 extends JUnit4CitrusTestDesigner {5 public void 3() {6 http().client("httpClient")7 .send()8 .post()9 .fork(true)10 .payload(new ClassPathResource("templates/3_request.xml"));11 receiveTimeout().messageType(MessageType.XML)12 .payload(new ClassPathResource("templates/3_response.xml"))13 .timeout(5000L);14 http().client("httpClient")15 .receive()16 .response(HttpStatus.OK)17 .payload(new ClassPathResource("templates/3_response.xml"));18 echo("3");19 soap().client("soapClient")20 .send()21 .payload(new ClassPathResource("templates/3_request.xml"));22 soap().client("soapClient")23 .receive()24 .fault()25 .messageType(MessageType.XML)26 .validateScript("3.js");27 soap().client("soapClient")28 .receive()29 .fault()30 .messageType(MessageType.XML)31 .validateScript("3.js")32 .setFaultString("3");33 echo("3");34 soap().client("soapClient")35 .send()36 .payload(new ClassPathResource("templates/3_request.xml"));37 soap().client("soapClient")38 .receive()39 .fault()40 .messageType(MessageType.XML)41 .validateScript("3.js")42 .setFaultString("3");43 echo("3");44 soap().client("soapClient")45 .send()46 .payload(new ClassPathResource("templates/3_request.xml"));47 soap().client("soapClient")48 .receive()49 .fault()50 .messageType(MessageType.XML)51 .validateScript("3.js");52 soap().client("soapClient")53 .receive()54 .fault()55 .messageType(MessageType.XML)56 .validateScript("3.js")57 .setFaultString("3");58 echo("
setFaultString
Using AI Code Generation
1import com.consol.citrus.dsl.runner.TestRunner;2import com.consol.citrus.dsl.builder.BuilderSupport;3import com.consol.citrus.dsl.builder.BuilderSupport;4import com.consol.citrus.message.MessageType;5import com.consol.citrus.ws.actions.AssertSoapFault;6import com.consol.citrus.ws.actions.SoapAction;7import com.consol.citrus.ws.client.WebServiceClient;8import com.consol.citrus.ws.message.SoapMessage;9import org.springframework.context.annotation.Bean;10import org.springframework.context.annotation.Configuration;11import org.springframework.context.annotation.Import;12import org.springframework.core.io.ClassPathResource;13import org.springframework.ws.soap.SoapMessageFactory;14import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;15import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;16import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;17public class 3 extends BuilderSupport<AssertSoapFault> {18 public AssertSoapFaultBuilder faultString(String faultString) {19 action.setFaultString(faultString);20 return this;21 }22 public AssertSoapFault getObject() {23 return action;24 }25 public void configure() {26 }27}28import com.consol.citrus.dsl.runner.TestRunner;29import com.consol.citrus.dsl.builder.BuilderSupport;30import com.consol.citrus.dsl.builder.BuilderSupport;31import com.consol.citrus.message.MessageType;32import com.consol.citrus.ws.actions.AssertSoapFault;33import com.consol.citrus.ws.actions.SoapAction;34import com.consol.citrus.ws.client.WebServiceClient;35import com.consol.citrus.ws.message.SoapMessage;36import org.springframework.context.annotation.Bean;37import org.springframework.context.annotation.Configuration;38import org.springframework.context.annotation.Import;39import org.springframework.core.io.ClassPathResource;40import org.springframework.ws.soap.SoapMessageFactory;41import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;42import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;43import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
setFaultString
Using AI Code Generation
1public void test3() {2 run(new TestCase() {3 public void configure() {4 soap().client(soapClient)5 .send()6 + "<ns2:accountNumber>1234567890</ns2:accountNumber></ns2:verifyAccount></S:Body></S:Envelope>");7 soap().client(soapClient)8 .receive()9 .fault()10 .faultString("AccountServiceException: Account number 1234567890 not found");11 }12 });13}14public void test4() {15 run(new TestCase() {16 public void configure() {17 soap().client(soapClient)18 .send()19 + "<ns2:accountNumber>1234567890</ns2:accountNumber></ns2:verifyAccount></S:Body></S:Envelope>");20 soap().client(soapClient)21 .receive()22 .fault()23 .faultString("AccountServiceException: Account number 1234567890 not found")24 + "<ns2:accountNumber>1234567890</ns2:accountNumber></ns2:AccountServiceException>");25 }26 });27}
setFaultString
Using AI Code Generation
1package com.consol.citrus.samples.ws;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import org.testng.annotations.Test;5public class SetFaultStringJavaIT extends TestNGCitrusTestDesigner {6 public void setFaultStringJavaIT() {7 variable("faultString", "Invalid request");8 variable("faultCode", "soap:Client");9 send("soapClient")10 "</s:Envelope>");11 receive("soapServer")12 " <faultcode>${faultCode}</faultcode>\n" +13 " <faultstring>${faultString}</faultstring>\n" +14 "</s:Envelope>");15 assertSoapFault("soapServer")16 .setFaultString("${faultString}");17 }18}
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!!