How to use testAssertSoapFaultDetail method of com.consol.citrus.ws.actions.AssertSoapFaultTest class

Best Citrus code snippet using com.consol.citrus.ws.actions.AssertSoapFaultTest.testAssertSoapFaultDetail

Source:AssertSoapFaultTest.java Github

copy

Full Screen

...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 {...

Full Screen

Full Screen

testAssertSoapFaultDetail

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapFault;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.core.io.ClassPathResource;8import org.testng.annotations.Test;9import static com.consol.citrus.actions.EchoAction.Builder.echo;10import static com.consol.citrus.container.Assert.Builder.assertException;11import static com.consol.citrus.container.Sequence.Builder.sequential;12import static com.consol.citrus.ws.actions.AssertSoapFault.Builder.assertSoapFault;13import static com.consol.citrus.ws.actions.SoapAction.Builder.soap;14public class AssertSoapFaultTestIT extends AbstractSoapActionIT {15 private WebServiceClient webServiceClient;16 @CitrusParameters({"faultCode", "faultString", "faultDetail", "faultActor"})17 public void testAssertSoapFault(String faultCode, String faultString, String faultDetail, String faultActor) {18 run(assertSoapFault()19 .faultCode(faultCode)20 .faultString(faultString)21 .faultDetail(faultDetail)22 .faultActor(faultActor));23 }24 @CitrusParameters({"faultCode", "faultString", "faultDetail", "faultActor"})25 public void testAssertSoapFaultWithFaultDetailResourcePath(String faultCode, String faultString, String faultDetail, String faultActor) {26 run(assertSoapFault()27 .faultCode(faultCode)28 .faultString(faultString)29 .faultDetailResource(new ClassPathResource(faultDetail))30 .faultActor(faultActor));31 }32 @CitrusParameters({"faultCode", "faultString", "faultDetail", "faultActor"})33 public void testAssertSoapFaultDetail(String faultCode, String faultString, String faultDetail, String faultActor) {34 run(assertSoapFault()35 .faultCode(faultCode)36 .faultString(faultString)37 .faultDetail(faultDetail)38 .faultActor(faultActor)

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful