Best Citrus code snippet using com.consol.citrus.ws.actions.SendSoapFaultAction
Source:SendSoapFaultActionTest.java
...31import static org.mockito.Mockito.*;32/**33 * @author Christoph Deppisch34 */35public class SendSoapFaultActionTest extends AbstractTestNGUnitTest {36 private Endpoint endpoint = Mockito.mock(Endpoint.class);37 private Producer producer = Mockito.mock(Producer.class);38 private EndpointConfiguration endpointConfiguration = Mockito.mock(EndpointConfiguration.class);39 @Test40 @SuppressWarnings("rawtypes")41 public void testSendSoapFault() {42 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();43 sendSoapFaultAction.setEndpoint(endpoint);44 45 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");46 sendSoapFaultAction.setFaultString("Internal server error");47 48 reset(endpoint, producer, endpointConfiguration);49 when(endpoint.createProducer()).thenReturn(producer);50 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);51 when(endpointConfiguration.getTimeout()).thenReturn(5000L);52 doAnswer(new Answer() {53 @Override54 public Object answer(InvocationOnMock invocation) throws Throwable {55 Message sentMessage = (Message)invocation.getArguments()[0];56 Assert.assertTrue(sentMessage instanceof SoapFault);57 SoapFault soapFault = (SoapFault) sentMessage;58 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");59 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");60 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);61 return null;62 }63 }).when(producer).send(any(Message.class), any(TestContext.class));64 when(endpoint.getActor()).thenReturn(null);65 66 sendSoapFaultAction.execute(context);67 }68 69 @Test70 @SuppressWarnings("rawtypes")71 public void testSendSoapFaultWithActor() {72 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();73 sendSoapFaultAction.setEndpoint(endpoint);74 75 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");76 sendSoapFaultAction.setFaultString("Internal server error");77 sendSoapFaultAction.setFaultActor("SERVER");78 79 reset(endpoint, producer, endpointConfiguration);80 when(endpoint.createProducer()).thenReturn(producer);81 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);82 when(endpointConfiguration.getTimeout()).thenReturn(5000L);83 doAnswer(new Answer() {84 @Override85 public Object answer(InvocationOnMock invocation) throws Throwable {86 Message sentMessage = (Message)invocation.getArguments()[0];87 Assert.assertTrue(sentMessage instanceof SoapFault);88 SoapFault soapFault = (SoapFault) sentMessage;89 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");90 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");91 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);92 Assert.assertEquals(soapFault.getFaultActor(), "SERVER");93 return null;94 }95 }).when(producer).send(any(Message.class), any(TestContext.class));96 when(endpoint.getActor()).thenReturn(null);97 98 sendSoapFaultAction.execute(context);99 }100 101 @Test102 @SuppressWarnings("rawtypes")103 public void testSendSoapFaultMissingFaultString() {104 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();105 sendSoapFaultAction.setEndpoint(endpoint);106 107 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");108 109 reset(endpoint, producer, endpointConfiguration);110 when(endpoint.createProducer()).thenReturn(producer);111 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);112 when(endpointConfiguration.getTimeout()).thenReturn(5000L);113 doAnswer(new Answer() {114 @Override115 public Object answer(InvocationOnMock invocation) throws Throwable {116 Message sentMessage = (Message)invocation.getArguments()[0];117 Assert.assertTrue(sentMessage instanceof SoapFault);118 SoapFault soapFault = (SoapFault) sentMessage;119 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");120 Assert.assertNull(soapFault.getFaultString());121 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);122 return null;123 }124 }).when(producer).send(any(Message.class), any(TestContext.class));125 when(endpoint.getActor()).thenReturn(null);126 127 sendSoapFaultAction.execute(context);128 }129 130 @Test131 @SuppressWarnings("rawtypes")132 public void testSendSoapFaultWithVariableSupport() {133 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();134 sendSoapFaultAction.setEndpoint(endpoint);135 136 sendSoapFaultAction.setFaultCode("citrus:concat('{http://citrusframework.org}ws:', ${faultCode})");137 sendSoapFaultAction.setFaultString("${faultString}");138 139 context.setVariable("faultCode", "TEC-1000");140 context.setVariable("faultString", "Internal server error");141 reset(endpoint, producer, endpointConfiguration);142 when(endpoint.createProducer()).thenReturn(producer);143 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);144 when(endpointConfiguration.getTimeout()).thenReturn(5000L);145 doAnswer(new Answer() {146 @Override147 public Object answer(InvocationOnMock invocation) throws Throwable {148 Message sentMessage = (Message)invocation.getArguments()[0];149 Assert.assertTrue(sentMessage instanceof SoapFault);150 SoapFault soapFault = (SoapFault) sentMessage;151 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");152 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");153 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);154 return null;155 }156 }).when(producer).send(any(Message.class), any(TestContext.class));157 when(endpoint.getActor()).thenReturn(null);158 159 sendSoapFaultAction.execute(context);160 }161 162 @Test163 public void testSendSoapFaultMissingFaultCode() {164 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();165 sendSoapFaultAction.setEndpoint(endpoint);166 167 reset(endpoint, producer, endpointConfiguration);168 when(endpoint.createProducer()).thenReturn(producer);169 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);170 when(endpointConfiguration.getTimeout()).thenReturn(5000L);171 when(endpoint.getActor()).thenReturn(null);172 173 try {174 sendSoapFaultAction.execute(context);175 } catch(CitrusRuntimeException e) {176 Assert.assertEquals(e.getLocalizedMessage(), "Missing fault code definition for SOAP fault generation. Please specify a proper SOAP fault code!");177 return;178 }...
Source:ScenarioRunner.java
...23import com.consol.citrus.simulator.correlation.CorrelationHandlerBuilder;24import com.consol.citrus.simulator.correlation.StartCorrelationHandlerAction;25import com.consol.citrus.simulator.http.HttpScenarioRunnerActionBuilder;26import com.consol.citrus.simulator.ws.SoapScenarioRunnerActionBuilder;27import com.consol.citrus.ws.actions.SendSoapFaultAction;28import org.springframework.context.ApplicationContext;29/**30 * @author Christoph Deppisch31 */32public class ScenarioRunner extends DefaultTestRunner {33 /**34 * Scenario direct endpoint35 */36 private final ScenarioEndpoint scenarioEndpoint;37 /**38 * Default constructor using fields.39 *40 * @param scenarioEndpoint41 * @param applicationContext42 * @param context43 */44 public ScenarioRunner(ScenarioEndpoint scenarioEndpoint, ApplicationContext applicationContext, TestContext context) {45 super(applicationContext, context);46 this.scenarioEndpoint = scenarioEndpoint;47 }48 /**49 * Start new message correlation so scenario is provided with additional inbound messages.50 *51 * @return52 */53 public StartCorrelationHandlerAction correlation(CorrelationBuilderSupport configurer) {54 CorrelationHandlerBuilder builder = new CorrelationHandlerBuilder(scenarioEndpoint, getApplicationContext());55 configurer.configure(() -> builder);56 doFinally().actions(builder.stop());57 return run(builder.build());58 }59 /**60 * Special scenario endpoint http operation.61 *62 * @return63 */64 public HttpScenarioRunnerActionBuilder http() {65 return new HttpScenarioRunnerActionBuilder(this, scenarioEndpoint)66 .withApplicationContext(getApplicationContext());67 }68 /**69 * Special scenario endpoint http operation.70 *71 * @return72 */73 public SoapScenarioRunnerActionBuilder soap() {74 return new SoapScenarioRunnerActionBuilder(this, scenarioEndpoint)75 .withApplicationContext(getApplicationContext());76 }77 /**78 * Sends SOAP fault as scenario response.79 *80 * @return81 */82 public SendSoapFaultAction sendFault(BuilderSupport<SoapServerFaultResponseActionBuilder> configurer) {83 SoapServerFaultResponseActionBuilder actionBuilder = (SoapServerFaultResponseActionBuilder)84 new SoapServerFaultResponseActionBuilder(new DelegatingTestAction<>(), scenarioEndpoint)85 .withApplicationContext(getApplicationContext())86 .description("Sending SOAP fault");87 configurer.configure(actionBuilder);88 run(actionBuilder);89 return (SendSoapFaultAction) actionBuilder.build().getDelegate();90 }91 /**92 * Gets the scenario inbound endpoint.93 *94 * @return95 */96 public ScenarioEndpoint scenarioEndpoint() {97 return scenarioEndpoint;98 }99}...
SendSoapFaultAction
Using AI Code Generation
1import com.consol.citrus.ws.actions.SendSoapFaultAction;2import org.springframework.context.support.ClassPathXmlApplicationContext;3public class 3 {4 public static void main(String[] args) {5 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");6 SendSoapFaultAction sendSoapFaultAction = context.getBean("sendSoapFaultAction", SendSoapFaultAction.class);7 sendSoapFaultAction.execute(context);8 }9}
SendSoapFaultAction
Using AI Code Generation
1import com.consol.citrus.dsl.design.TestDesigner;2import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;3import com.consol.citrus.ws.actions.SendSoapFaultAction;4public class SendSoapFaultActionTest extends TestDesignerBeforeSuiteSupport {5 public void configure(TestDesigner designer) {6 designer.send(SendSoapFaultAction.sendSoapFaultActionBuilder()7 .faultString("Test error message")8 .faultActor("Test actor")9 .build());10 }11}12import com.consol.citrus.dsl.design.TestDesigner;13import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;14import com.consol.citrus.ws.actions.SendMessageAction;15public class SendMessageActionTest extends TestDesignerBeforeSuiteSupport {16 public void configure(TestDesigner designer) {17 designer.send(SendMessageAction.sendSoapMessageActionBuilder()18 .build());19 }20}21import com.consol.citrus.dsl.design.TestDesigner;22import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;23import com.consol.citrus.ws.actions.SendMessageAction;24public class SendMessageActionTest extends TestDesignerBeforeSuiteSupport {25 public void configure(TestDesigner designer) {26 designer.send(SendMessageAction.sendSoapMessageActionBuilder()27 .soapAction("test:TestMessage")28 .build());29 }30}31import com.consol.citrus.dsl.design.TestDesigner;32import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;33import com.consol.citrus.ws.actions.SendMessageAction;34public class SendMessageActionTest extends TestDesignerBeforeSuiteSupport {35 public void configure(TestDesigner designer) {36 designer.send(SendMessageAction.sendSoapMessageActionBuilder()37 .message("<TestMessage
SendSoapFaultAction
Using AI Code Generation
1public class SendSoapFaultActionTest extends TestNGCitrusTestDesigner {2 public void sendSoapFaultAction() {3 sendSoapFaultAction()4 .faultString("Test exception")5 .faultActor("Test actor")6 .detail("<detail><message>Test message</message></detail>")7 .faultDetail("Test detail")8 .faultDetailXml("<detail><message>Test message</message></detail>");9 }10}11public class SendSoapFaultActionTest extends TestNGCitrusTestDesigner {12 public void sendSoapFaultAction() {13 sendSoapFaultAction()14 .faultString("Test exception")15 .faultActor("Test actor")16 .detail("<detail><message>Test message</message></detail>")17 .faultDetail("Test detail")18 .faultDetailXml("<detail><message>Test message</message></detail>")19 .endpoint("soapFaultClient")20 .messageName("soapFaultMessage")21 .header("operation", "soapFault")22 .header("operation", "soapFault")23 .header("operation", "soapFault")24 }25}
SendSoapFaultAction
Using AI Code Generation
1public class 3 extends TestCase {2 public void 3() {3 variable("faultCode", "soap:Server");4 variable("faultString", "Internal Server Error");5 variable("faultDetail", "Invalid input");6 sendFault().faultCode("${faultCode}").faultString("${faultString}").faultActor("${faultActor}").faultDetail("${faultDetail}");7 }8}9public class 4 extends TestCase {10 public void 4() {11 variable("faultCode", "soap:Server");12 variable("faultString", "Internal Server Error");13 variable("faultDetail", "Invalid input");14 sendFault().faultCode("${faultCode}").faultString("${faultString}").faultActor("${faultActor}").faultDetail("${faultDetail}");15 }16}17public class 5 extends TestCase {18 public void 5() {19 variable("faultCode", "soap:Server");20 variable("faultString", "Internal Server Error");21 variable("faultDetail", "Invalid input");22 sendFault().faultCode("${faultCode}").faultString("${faultString}").faultActor("${faultActor}").faultDetail("${faultDetail}");23 }24}25public class 6 extends TestCase {26 public void 6() {27 variable("faultCode", "soap:Server");28 variable("faultString", "Internal Server Error");29 variable("faultDetail", "Invalid input");
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!!