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

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

Source:SendSoapFaultActionTest.java Github

copy

Full Screen

...45 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction.Builder()46 .endpoint(endpoint)47 .message()48 .faultCode("{http://citrusframework.org}ws:TEC-1000")49 .faultString("Internal server error")50 .build();51 reset(endpoint, producer, endpointConfiguration);52 when(endpoint.createProducer()).thenReturn(producer);53 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);54 when(endpointConfiguration.getTimeout()).thenReturn(5000L);55 doAnswer(new Answer() {56 @Override57 public Object answer(InvocationOnMock invocation) throws Throwable {58 Message sentMessage = (Message)invocation.getArguments()[0];59 Assert.assertTrue(sentMessage instanceof SoapFault);60 SoapFault soapFault = (SoapFault) sentMessage;61 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");62 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");63 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);64 return null;65 }66 }).when(producer).send(any(Message.class), any(TestContext.class));67 when(endpoint.getActor()).thenReturn(null);68 sendSoapFaultAction.execute(context);69 }70 @Test71 @SuppressWarnings("rawtypes")72 public void testSendSoapFaultWithActor() {73 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction.Builder()74 .endpoint(endpoint)75 .message()76 .faultCode("{http://citrusframework.org}ws:TEC-1000")77 .faultString("Internal server error")78 .faultActor("SERVER")79 .build();80 reset(endpoint, producer, endpointConfiguration);81 when(endpoint.createProducer()).thenReturn(producer);82 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);83 when(endpointConfiguration.getTimeout()).thenReturn(5000L);84 doAnswer(new Answer() {85 @Override86 public Object answer(InvocationOnMock invocation) throws Throwable {87 Message sentMessage = (Message)invocation.getArguments()[0];88 Assert.assertTrue(sentMessage instanceof SoapFault);89 SoapFault soapFault = (SoapFault) sentMessage;90 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");91 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");92 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);93 Assert.assertEquals(soapFault.getFaultActor(), "SERVER");94 return null;95 }96 }).when(producer).send(any(Message.class), any(TestContext.class));97 when(endpoint.getActor()).thenReturn(null);98 sendSoapFaultAction.execute(context);99 }100 @Test101 @SuppressWarnings("rawtypes")102 public void testSendSoapFaultMissingFaultString() {103 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction.Builder()104 .endpoint(endpoint)105 .message()106 .faultCode("{http://citrusframework.org}ws:TEC-1000")107 .build();108 reset(endpoint, producer, endpointConfiguration);109 when(endpoint.createProducer()).thenReturn(producer);110 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);111 when(endpointConfiguration.getTimeout()).thenReturn(5000L);112 doAnswer(new Answer() {113 @Override114 public Object answer(InvocationOnMock invocation) throws Throwable {115 Message sentMessage = (Message)invocation.getArguments()[0];116 Assert.assertTrue(sentMessage instanceof SoapFault);117 SoapFault soapFault = (SoapFault) sentMessage;118 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");119 Assert.assertNull(soapFault.getFaultString());120 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);121 return null;122 }123 }).when(producer).send(any(Message.class), any(TestContext.class));124 when(endpoint.getActor()).thenReturn(null);125 sendSoapFaultAction.execute(context);126 }127 @Test128 @SuppressWarnings("rawtypes")129 public void testSendSoapFaultWithVariableSupport() {130 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction.Builder()131 .endpoint(endpoint)132 .message()133 .faultCode("citrus:concat('{http://citrusframework.org}ws:', ${faultCode})")134 .faultString("${faultString}")135 .build();136 context.setVariable("faultCode", "TEC-1000");137 context.setVariable("faultString", "Internal server error");138 reset(endpoint, producer, endpointConfiguration);139 when(endpoint.createProducer()).thenReturn(producer);140 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);141 when(endpointConfiguration.getTimeout()).thenReturn(5000L);142 doAnswer(new Answer() {143 @Override144 public Object answer(InvocationOnMock invocation) throws Throwable {145 Message sentMessage = (Message)invocation.getArguments()[0];146 Assert.assertTrue(sentMessage instanceof SoapFault);147 SoapFault soapFault = (SoapFault) sentMessage;148 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");149 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");150 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);151 return null;...

Full Screen

Full Screen

Source:SendSoapFaultAction.java Github

copy

Full Screen

...29public class SendSoapFaultAction extends SendSoapMessageAction {30 /** Fault code as QName string */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;126 }127 /**128 * Gets the faultDetails.129 * @return the faultDetails the faultDetails to get.130 */131 public List<String> getFaultDetails() {132 return faultDetails;133 }134 /**135 * Sets the faultDetails.136 * @param faultDetails the faultDetails to set137 */138 public SendSoapFaultAction setFaultDetails(List<String> faultDetails) {139 this.faultDetails = faultDetails;...

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import org.springframework.context.annotation.Bean;4import org.springframework.context.annotation.Configuration;5import org.springframework.context.annotation.Import;6import org.springframework.ws.soap.SoapMessageFactory;7import org.testng.annotations.Test;8public class FaultStringTest extends TestNGCitrusTestRunner {9 public void faultStringTest() {10 variable("faultString", "Fault String");11 soap(builder -> builder.client(soapClient)12 .send()13 .soapAction("HelloWorld")14 + "</HelloWorld>"));15 soap(builder -> builder.server(soapServer)16 .receive()17 + "</HelloWorld>"));18 soap(builder -> builder.server(soapServer)19 .send()20 .fault()21 .faultString("${faultString}")22 + "</fault>"));23 soap(builder -> builder.client(soapClient)24 .receive()25 .fault()26 .faultString("${faultString}"));27 }28 @Import(DefaultTestConfig.class)29 public static class Config {30 public SoapMessageFactory messageFactory() {31 return CitrusSoapMessageFactory.createDefault();32 }33 }34}

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1public void testFaultString() {2 SoapFault soapFault = new SoapFault();3 soapFault.faultString("faultString");4 assertEquals(soapFault.faultString(), "faultString");5}6public void testFaultString() {7 SoapFault soapFault = new SoapFault();8 soapFault.faultString("faultString");9 assertEquals(soapFault.faultString(), "faultString");10}11public void testFaultString() {12 SoapFault soapFault = new SoapFault();13 soapFault.faultString("faultString");14 assertEquals(soapFault.faultString(), "faultString");15}16public void testFaultString() {17 SoapFault soapFault = new SoapFault();18 soapFault.faultString("faultString");19 assertEquals(soapFault.faultString(), "faultString");20}21public void testFaultString() {22 SoapFault soapFault = new SoapFault();23 soapFault.faultString("faultString");24 assertEquals(soapFault.faultString(), "faultString");25}26public void testFaultString() {27 SoapFault soapFault = new SoapFault();28 soapFault.faultString("faultString");29 assertEquals(soapFault.faultString(), "faultString");30}31public void testFaultString() {32 SoapFault soapFault = new SoapFault();33 soapFault.faultString("faultString");34 assertEquals(soapFault.faultString(), "faultString");35}36public void testFaultString() {

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws;2import com.consol.citrus.dsl.runner.DefaultTestCase;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.ws.message.SoapFault;5import org.testng.annotations.Test;6public class SoapFaultTest extends DefaultTestCase {7 public void soapFaultTest() {8 SoapFault soapFault = new SoapFault();9 soapFault.faultString("faultString");10 soapFault.faultCode("faultCode");11 soapFault.faultActor("faultActor");12 soapFault.detail("detail");13 TestRunner runner = this.createTestRunner();14 runner.send("faultEndpoint").payload(soapFault);15 }16}

Full Screen

Full Screen

faultString

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.testng.annotations.Test;6public class SoapFaultTest extends TestRunnerSupport {7 public void testSoapFault() {8 run(new TestRunner() {9 public void execute() {10 soapFault()11 .faultString("fault string")12 .faultActor("fault actor")13 .faultDetail("<detail>some detail</detail>");14 }15 });16 }17}18package com.consol.citrus.samples;19import com.consol.citrus.dsl.runner.TestRunner;20import com.consol.citrus.dsl.runner.TestRunnerSupport;21import com.consol.citrus.ws.message.SoapFault;22import org.testng.annotations.Test;23public class SoapFaultTest extends TestRunnerSupport {24 public void testSoapFault() {25 run(new TestRunner() {26 public void execute() {27 soapFault()28 .faultString("fault string")29 .faultActor("fault actor")30 .faultDetail("<detail>some detail</detail>");31 }32 });33 }34}35package com.consol.citrus.samples;36import com.consol.citrus.dsl.runner.TestRunner;37import com.consol.citrus.dsl.runner.TestRunnerSupport;38import com.consol.citrus.ws.message.SoapFault;39import org.testng.annotations.Test;40public class SoapFaultTest extends TestRunnerSupport {41 public void testSoapFault() {42 run(new TestRunner() {43 public void execute() {44 soapFault()

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import org.testng.annotations.Test;3import org.testng.Assert;4import org.testng.AssertJUnit;5import com.consol.citrus.annotations.CitrusTest;6import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;7import com.consol.citrus.dsl.design.TestDesigner;8import com.consol.citrus.dsl.design.TestDesignerBeforeTestSupport;9import com.consol.citrus.ws.actions.SoapFaultAction;10import com.consol.citrus.ws.message.SoapFault;11import com.consol.citrus.ws.actions.SendSoapFaultAction;12import com.consol.citrus.ws.client.WebServiceClient;13import com.consol.citrus.ws.message.SoapMessage;14import com.consol.citrus.message.MessageType;15import com.consol.citrus.dsl.builder.BuilderSupport;16import com.consol.citrus.context.TestContext;17import com.consol.citrus.ws.actions.ReceiveSoapFaultAction;18public class 3 extends TestNGCitrusTestRunner {19 public void 3() {20 description("code to use faultString method of com.consol.citrus.ws.message.SoapFault class to get the fault string of the fault message");21 variable("faultString", "Fault string");22 SoapFaultAction.Builder soapFaultActionBuilder = soapFaultAction();23 soapFaultActionBuilder.faultString("${faultString}");24 soapFaultActionBuilder.messageType(MessageType.XML);

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import org.testng.annotations.Test;3import org.testng.Assert;4import org.testng.AssertJUnit;5import com.consol.citrus.annotations.CitrusTest;6import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;7import com.consol.citrus.dsl.design.TestDesigner;8import com.consol.citrus.dsl.design.TestDesignerBeforeTestSupport;9import com.consol.citrus.ws.actions.SoapFaultAction;10import com.consol.citrus.ws.message.SoapFault;11import com.consol.citrus.ws.actions.SendSoapFaultAction;12import com.consol.citrus.ws.client.WebServiceClient;13import com.consol.citrus.ws.message.SoapMessage;14import com.consol.citrus.message.MessageType;15import com.consol.citrus.dsl.builder.BuilderSupport;16import com.consol.citrus.context.TestContext;17import com.consol.citrus.ws.actions.ReceiveSoapFaultAction;18public class 3 extends TestNGCitrusTestRunner {19 public void 3() {20 description("code to use faultString method of com.consol.citrus.ws.message.SoapFault class to get the fault string of the fault message");21 variable("faultString", "Fault string");22 SoapFaultAction.Builder soapFaultActionBuilder = soapFaultAction();23 soapFaultActionBuilder.faultString("${faultString}");24 soapFaultActionBuilder.messageType(MessageType.XML);

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws;2import com.consol.citrus.dsl.runner.DefaultTestCase;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.ws.message.SoapFault;5import org.testng.annotations.Test;6public class SoapFaultTest extends DefaultTestCase {7 public void soapFaultTest() {8 SoapFault soapFault = new SoapFault();9 soapFault.faultString("faultString");10 soapFault.faultCode("faultCode");11 soapFault.faultActor("faultActor");12 soapFault.detail("detail");13 TestRunner runner = this.createTestRunner();14 runner.send("faultEndpoint").payload(soapFault);15 }16}

Full Screen

Full Screen

faultString

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.testng.annotations.Test;6public class SoapFaultTest extends TestRunnerSupport {7 public void testSoapFault() {8 run(new TestRunner() {9 public void execute() {10 soapFault()11 .faultString("fault string")12 .faultActor("fault actor")13 .faultDetail("<detail>some detail</detail>");14 }15 });16 }17}18package com.consol.citrus.samples;19import com.consol.citrus.dsl.runner.TestRunner;20import com.consol.citrus.dsl.runner.TestRunnerSupport;21import com.consol.citrus.ws.message.SoapFault;22import org.testng.annotations.Test;23public class SoapFaultTest extends TestRunnerSupport {24 public void testSoapFault() {25 run(new TestRunner() {26 public void execute() {27 soapFault()28 .faultString("fault string")29 .faultActor("fault actor")30 .faultDetail("<detail>some detail</detail>");31 }32 });33 }34}35package com.consol.citrus.samples;36import com.consol.citrus.dsl.runner.TestRunner;37import com.consol.citrus.dsl.runner.TestRunnerSupport;38import com.consol.citrus.ws.message.SoapFault;39import org.testng.annotations.Test;40public class SoapFaultTest extends TestRunnerSupport {41 public void testSoapFault() {42 run(new TestRunner() {43 public void execute() {44 soapFault()

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.builder.ReceiveMessageBuilder;2import com.consol.citrus.dsl.builder.SendSoapFaultBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.testng.TestNGCitrusTest;5import com.consol.citrus.message.MessageType;6import com.consol.citrus.ws.message.SoapFault;7import org.springframework.http.HttpStatus;8import org.testng.annotations.Test;9import static org.hamcrest.CoreMatchers.containsString;10import static org.hamcrest.CoreMatchers.equalTo;11import static org.hamcrest.CoreMatchers.is;12import static org.hamcrest.CoreMatchers.notNullValue;13import static org.hamcrest.CoreMatchers.startsWith;14import static org.hamcrest.CoreMatchers.nullValue;15import static org.hamcrest.MatcherAssert.assertThat;16public class SoapFaultTest extends TestNGCitrusTest {17public void testSoapFault() {18TestRunner runner = createTestRunner();19runner.soap(builder -> builder.client("soapClient")20.send()21.soapFault()22.faultString("Hello World!")23runner.soap(builder -> builder.server("soapServer")24.receive()25"</soapenv:Envelope>"));26runner.soap(builder -> builder.server("soapServer")27.send()28.soapFault());29runner.soap(builder -> builder.client("soapClient")30.receive()31.messageType(MessageType.SOAP)32.validate((message, context) -> {33SoapFault soapFault = SoapFault.fromMessage(message);34assertThat(soapFault, notNullValue());

Full Screen

Full Screen

faultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import org.testng.annotations.Test;3import org.testng.Assert;4import com.consol.citrus.dsl.testng.TestNGCitrusTestBuilder;5import com.consol.citrus.ws.actions.SendMessageAction;6import com.consol.citrus.ws.message.SoapFault;7import com.consol.citrus.ws.client.WebServiceClient;8import com.consol.citrus.ws.actions.ReceiveMessageAction;9import com.consol.citrus.dsl.builder.ReceiveMessageBuilder;10import com.consol.citrus.dsl.builder.SendMessageBuilder;11public class 3 extends TestNGCitrusTestBuilder {12 public void 3() {13 variable("myvar", "Hello World");14 parallel(15 sequential(16 soap(sendMessageActionBuilder -> {17 .client(webServiceClientBuilder -> {18 .fault(true);19 })20 })21 sequential(22 soap(receiveMessageBuilder -> {23 .client(webServiceClientBuilder -> {24 .fault(true);25 })26 }),27 soap(sendMessageActionBuilder -> {28 .client(webServiceClientBuilder -> {29 .fault(true);30 })

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