How to use execute method of com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest class

Best Citrus code snippet using com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest.execute

Source:AssertSoapFaultTestRunnerTest.java Github

copy

Full Screen

...64 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());65 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());66 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {67 @Override68 public void execute() {69 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())70 .faultString(INTERNAL_SERVER_ERROR)71 .when(new AbstractTestAction() {72 @Override73 public void doExecute(TestContext context) {74 throw new SoapFaultClientException(soapMessage);75 }76 });77 }78 };79 TestCase test = builder.getTestCase();80 Assert.assertEquals(test.getActionCount(), 1);81 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);82 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");83 84 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));85 86 Assert.assertEquals(container.getActionCount(), 1);87 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());88 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());89 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);90 }91 @Test92 public void testAssertSoapFaultDefaultValidatorBuilder() {93 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);94 when(soapMessage.getSoapBody()).thenReturn(soapBody);95 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);96 when(soapBody.getFault()).thenReturn(soapFault);97 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());98 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);99 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);100 when(soapFault.getFaultDetail()).thenReturn(null);101 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));102 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);103 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);104 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());105 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());106 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());107 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {108 @Override109 public void execute() {110 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())111 .faultString(INTERNAL_SERVER_ERROR)112 .when(new AbstractTestAction() {113 @Override114 public void doExecute(TestContext context) {115 throw new SoapFaultClientException(soapMessage);116 }117 });118 }119 };120 TestCase test = builder.getTestCase();121 Assert.assertEquals(test.getActionCount(), 1);122 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);123 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");124 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));125 Assert.assertEquals(container.getActionCount(), 1);126 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());127 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());128 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);129 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),130 any(TestContext.class), any(ValidationContext.class));131 }132 @Test133 public void testFaultDetail() {134 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);135 when(soapMessage.getSoapBody()).thenReturn(soapBody);136 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);137 when(soapBody.getFault()).thenReturn(soapFault);138 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());139 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);140 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);141 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);142 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());143 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));144 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));145 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);146 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());147 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());148 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());149 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {150 @Override151 public void execute() {152 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())153 .faultString(INTERNAL_SERVER_ERROR)154 .faultDetail("<ErrorDetail><message>Something went wrong</message></ErrorDetail>")155 .when(new AbstractTestAction() {156 @Override157 public void doExecute(TestContext context) {158 throw new SoapFaultClientException(soapMessage);159 }160 });161 }162 };163 TestCase test = builder.getTestCase();164 Assert.assertEquals(test.getActionCount(), 1);165 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);166 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");167 168 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));169 170 Assert.assertEquals(container.getActionCount(), 1);171 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());172 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());173 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);174 Assert.assertEquals(container.getFaultDetails().size(), 1L);175 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>Something went wrong</message></ErrorDetail>");176 }177 178 @Test179 public void testMultipleFaultDetails() {180 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);181 when(soapMessage.getSoapBody()).thenReturn(soapBody);182 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);183 when(soapBody.getFault()).thenReturn(soapFault);184 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());185 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);186 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);187 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);188 when(soapFaultDetail.getDetailEntries()).thenReturn(Arrays.asList(soapFaultDetailElement, soapFaultDetailElement).iterator());189 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><code>1001</code></ErrorDetail>"))190 .thenReturn(new StringSource("<MessageDetail><message>Something went wrong</message></MessageDetail>"));191 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));192 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);193 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());194 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());195 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());196 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {197 @Override198 public void execute() {199 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())200 .faultString(INTERNAL_SERVER_ERROR)201 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")202 .faultDetail("<MessageDetail><message>Something went wrong</message></MessageDetail>")203 .when(new AbstractTestAction() {204 @Override205 public void doExecute(TestContext context) {206 throw new SoapFaultClientException(soapMessage);207 }208 });209 }210 };211 TestCase test = builder.getTestCase();212 Assert.assertEquals(test.getActionCount(), 1);213 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);214 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");215 216 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));217 218 Assert.assertEquals(container.getActionCount(), 1);219 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());220 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());221 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);222 Assert.assertEquals(container.getFaultDetails().size(), 2L);223 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");224 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>Something went wrong</message></MessageDetail>");225 }226 227 @Test228 public void testFaultDetailResource() throws IOException {229 reset(resource, applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);230 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<ErrorDetail><message>Something went wrong</message></ErrorDetail>".getBytes()));231 when(soapMessage.getSoapBody()).thenReturn(soapBody);232 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);233 when(soapBody.getFault()).thenReturn(soapFault);234 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());235 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);236 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);237 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);238 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());239 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));240 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));241 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);242 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());243 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());244 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());245 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {246 @Override247 public void execute() {248 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())249 .faultString(INTERNAL_SERVER_ERROR)250 .faultDetailResource(resource)251 .when(new AbstractTestAction() {252 @Override253 public void doExecute(TestContext context) {254 throw new SoapFaultClientException(soapMessage);255 }256 });257 }258 };259 TestCase test = builder.getTestCase();260 Assert.assertEquals(test.getActionCount(), 1);261 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);262 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");263 264 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));265 266 Assert.assertEquals(container.getActionCount(), 1);267 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());268 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());269 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);270 Assert.assertEquals(container.getFaultDetails().size(), 1L);271 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>Something went wrong</message></ErrorDetail>");272 }273 @Test274 public void testFaultDetailResourcePath() {275 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);276 when(soapMessage.getSoapBody()).thenReturn(soapBody);277 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);278 when(soapBody.getFault()).thenReturn(soapFault);279 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());280 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);281 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);282 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);283 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());284 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));285 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));286 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);287 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());288 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());289 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());290 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {291 @Override292 public void execute() {293 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())294 .faultString(INTERNAL_SERVER_ERROR)295 .faultDetailResource("classpath:com/consol/citrus/dsl/runner/soap-fault-detail.xml")296 .when(new AbstractTestAction() {297 @Override298 public void doExecute(TestContext context) {299 throw new SoapFaultClientException(soapMessage);300 }301 });302 }303 };304 TestCase test = builder.getTestCase();305 Assert.assertEquals(test.getActionCount(), 1);306 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);307 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");308 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));309 Assert.assertEquals(container.getActionCount(), 1);310 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());311 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());312 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);313 Assert.assertEquals(container.getFaultDetails().size(), 0L);314 Assert.assertEquals(container.getFaultDetailResourcePaths().size(), 1L);315 Assert.assertEquals(container.getFaultDetailResourcePaths().get(0), "classpath:com/consol/citrus/dsl/runner/soap-fault-detail.xml");316 }317 318 @Test319 public void testMultipleFaultDetailsInlineAndResource() throws IOException {320 reset(resource, applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);321 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<MessageDetail><message>Something went wrong</message></MessageDetail>".getBytes()));322 when(soapMessage.getSoapBody()).thenReturn(soapBody);323 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);324 when(soapBody.getFault()).thenReturn(soapFault);325 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());326 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);327 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);328 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);329 when(soapFaultDetail.getDetailEntries()).thenReturn(Arrays.asList(soapFaultDetailElement, soapFaultDetailElement).iterator());330 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><code>1001</code></ErrorDetail>"))331 .thenReturn(new StringSource("<MessageDetail><message>Something went wrong</message></MessageDetail>"));332 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));333 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);334 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());335 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());336 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());337 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {338 @Override339 public void execute() {340 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())341 .faultString(INTERNAL_SERVER_ERROR)342 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")343 .faultDetailResource(resource)344 .when(new AbstractTestAction() {345 @Override346 public void doExecute(TestContext context) {347 throw new SoapFaultClientException(soapMessage);348 }349 });350 }351 };352 TestCase test = builder.getTestCase();353 Assert.assertEquals(test.getActionCount(), 1);354 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);355 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");356 357 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));358 359 Assert.assertEquals(container.getActionCount(), 1);360 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());361 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());362 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);363 Assert.assertEquals(container.getFaultDetails().size(), 2L);364 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");365 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>Something went wrong</message></MessageDetail>");366 }367 368 @Test369 public void testAssertSoapFaultBuilderWithValidator() {370 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);371 when(soapMessage.getSoapBody()).thenReturn(soapBody);372 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);373 when(soapBody.getFault()).thenReturn(soapFault);374 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());375 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);376 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);377 when(soapFault.getFaultDetail()).thenReturn(null);378 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));379 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);380 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);381 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());382 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());383 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());384 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {385 @Override386 public void execute() {387 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())388 .faultString(INTERNAL_SERVER_ERROR)389 .validator(soapFaultValidator)390 .when(new AbstractTestAction() {391 @Override392 public void doExecute(TestContext context) {393 throw new SoapFaultClientException(soapMessage);394 }395 });396 }397 };398 TestCase test = builder.getTestCase();399 Assert.assertEquals(test.getActionCount(), 1);400 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);401 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");402 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));403 Assert.assertEquals(container.getActionCount(), 1);404 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());405 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());406 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);407 Assert.assertEquals(container.getValidator(), soapFaultValidator);408 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),409 any(TestContext.class), any(ValidationContext.class));410 }411 @Test412 public void testAssertSoapFaultBuilderWithActor() {413 reset(applicationContextMock, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);414 when(soapMessage.getSoapBody()).thenReturn(soapBody);415 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);416 when(soapBody.getFault()).thenReturn(soapFault);417 when(soapFault.getFaultActorOrRole()).thenReturn("MyActor");418 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);419 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);420 when(soapFault.getFaultDetail()).thenReturn(null);421 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));422 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);423 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());424 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());425 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());426 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {427 @Override428 public void execute() {429 assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())430 .faultString(INTERNAL_SERVER_ERROR)431 .faultActor("MyActor")432 .when(new AbstractTestAction() {433 @Override434 public void doExecute(TestContext context) {435 throw new SoapFaultClientException(soapMessage);436 }437 });438 }439 };440 TestCase test = builder.getTestCase();441 Assert.assertEquals(test.getActionCount(), 1);442 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);...

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.runner;2import com.consol.citrus.dsl.junit.JUnit4CitrusTestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.message.MessageType;5import com.consol.citrus.testng.CitrusParameters;6import org.testng.annotations.DataProvider;7import org.testng.annotations.Test;8import java.util.Arrays;9import java.util.Collection;10public class AssertSoapFaultTestRunnerTest extends TestNGCitrusTestRunner {11 @DataProvider(name = "testData")12 public Object[][] testData() {13 return new Object[][] {14 new Object[] { new JUnit4CitrusTestRunner() }15 };16 }17 @Test(dataProvider = "testData")18 @CitrusParameters("runner")19 public void testAssertSoapFault(JUnit4CitrusTestRunner runner) {20 runner.variable("faultCode", "Server");21 runner.variable("faultString", "Internal Server Error");22 runner.variable("faultDetail", "Something went wrong");23 runner.soap(builder -> builder.server("soapServer")24 .receive()25 .messageType(MessageType.XML)26 "</ns0:TestRequest>"));27 runner.soap(builder -> builder.server("soapServer")28 .send()29 "<faultstring>${faultString}</faultstring>" +30 "<ns0:Error>${faultDetail}</ns0:Error>" +31 "</SOAP-ENV:Envelope>"));32 runner.soap(builder -> builder.server("soapServer")33 .receive()34 .messageType(MessageType.XML)

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest testClass = new com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest();2testClass.execute();3com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest testClass = new com.consol.citrus.dsl.runner.AssertSoapFaultTestRunnerTest();4testClass.execute();5public void execute() {6 send().soap().fault()7 .faultCode("Client")8 .faultString("Invalid request")9 .faultDetail("<detail>Invalid request</detail>"

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1public void testSoapFault() {2 execute(new AssertSoapFaultTestRunnerTest());3}4public void testSoapFault() {5 execute(new AssertSoapFaultTestRunnerTest());6}7public void testSoapFault() {8 execute(new AssertSoapFaultTestRunnerTest());9}10public void testSoapFault() {11 execute(new AssertSoapFaultTestRunnerTest());12}13public void testSoapFault() {14 execute(new AssertSoapFaultTestRunnerTest());15}16public void testSoapFault() {17 execute(new AssertSoapFaultTestRunnerTest());18}19public void testSoapFault() {20 execute(new AssertSoapFaultTestRunnerTest());21}22public void testSoapFault() {23 execute(new AssertSoapFaultTestRunnerTest());24}25public void testSoapFault() {26 execute(new AssertSoapFaultTestRunnerTest());27}28public void testSoapFault() {29 execute(new AssertSoapFaultTestRunnerTest());30}31public void testSoapFault() {32 execute(new AssertSoapFaultTestRunnerTest());33}34public void testSoapFault() {35 execute(new AssertSoapFaultTestRunnerTest());36}

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