Best Citrus code snippet using com.consol.citrus.container.SequenceBeforeTest.doExecute
Source:AssertSoapFaultTestRunnerTest.java
...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);443 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");444 445 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));446 447 Assert.assertEquals(container.getActionCount(), 1);448 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());...
Source:EndpointConfig.java
...86 @Bean87 public BeforeTest beforeTest(KafkaEndpoint fruitEvents) {88 return new SequenceBeforeTest() {89 @Override90 public void doExecute(TestContext context) {91 purgeEndpoints()92 .endpoint(fruitEvents)93 .build()94 .execute(context);95 }96 };97 }98}...
Source:SequenceBeforeTest.java
...28public class SequenceBeforeTest extends AbstractTestBoundaryActionContainer {29 /** Logger */30 private static Logger log = LoggerFactory.getLogger(SequenceBeforeTest.class);31 @Override32 public void doExecute(TestContext context) {33 if (CollectionUtils.isEmpty(actions)) {34 return;35 }36 log.info("Entering before test block");37 if (log.isDebugEnabled()) {38 log.debug("Executing " + actions.size() + " actions before test");39 log.debug("");40 }41 for (TestAction action: actions) {42 action.execute(context);43 }44 }45}...
doExecute
Using AI Code Generation
1package com.consol.citrus.container;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTest;4import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;5import com.consol.citrus.ws.client.WebServiceClient;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.beans.factory.annotation.Qualifier;8import org.testng.annotations.Test;9public class SequenceBeforeTest extends TestNGCitrusTest {10 @Qualifier("emptySequence")11 private EmptySequence emptySequence;12 @Qualifier("emptySequence2")13 private EmptySequence emptySequence2;14 @Qualifier("emptySequence3")15 private EmptySequence emptySequence3;16 @Qualifier("emptySequence4")17 private EmptySequence emptySequence4;18 @Qualifier("emptySequence5")19 private EmptySequence emptySequence5;20 @Qualifier("emptySequence6")21 private EmptySequence emptySequence6;22 @Qualifier("emptySequence7")23 private EmptySequence emptySequence7;24 @Qualifier("emptySequence8")25 private EmptySequence emptySequence8;26 @Qualifier("emptySequence9")27 private EmptySequence emptySequence9;28 @Qualifier("emptySequence10")29 private EmptySequence emptySequence10;30 @Qualifier("emptySequence11")31 private EmptySequence emptySequence11;32 @Qualifier("emptySequence12")33 private EmptySequence emptySequence12;34 @Qualifier("emptySequence13")35 private EmptySequence emptySequence13;36 @Qualifier("emptySequence14")37 private EmptySequence emptySequence14;38 @Qualifier("emptySequence15")39 private EmptySequence emptySequence15;40 @Qualifier("emptySequence16")41 private EmptySequence emptySequence16;42 @Qualifier("emptySequence17")43 private EmptySequence emptySequence17;44 @Qualifier("emptySequence18")45 private EmptySequence emptySequence18;46 @Qualifier("emptySequence19")47 private EmptySequence emptySequence19;48 @Qualifier("emptySequence20")49 private EmptySequence emptySequence20;
doExecute
Using AI Code Generation
1package com.consol.citrus.dsl.testng;2import com.consol.citrus.Citrus;3import com.consol.citrus.annotations.CitrusXmlTest;4import com.consol.citrus.testng.AbstractTestNGCitrusTest;5import org.testng.annotations.Test;6public class SequenceBeforeTest extends AbstractTestNGCitrusTest {7 @CitrusXmlTest(name = "SequenceBeforeTest")8 public void SequenceBeforeTest() {}9}10package com.consol.citrus.dsl.testng;11import com.consol.citrus.Citrus;12import com.consol.citrus.annotations.CitrusXmlTest;13import com.consol.citrus.testng.AbstractTestNGCitrusTest;14import org.testng.annotations.Test;15public class SequenceBeforeTest extends AbstractTestNGCitrusTest {16 @CitrusXmlTest(name = "SequenceBeforeTest")17 public void SequenceBeforeTest() {}18}
doExecute
Using AI Code Generation
1package com.consol.citrus.container;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class SequenceBeforeTest extends TestNGCitrusTestDesigner {5public void testSequenceBefore() {6doExecute(new SequenceBeforeTest() {7public void execute() {8}9});
doExecute
Using AI Code Generation
1public class BeforeTest extends TestNGCitrusTestDesigner {2 public void beforeTest() {3 beforeTest(new SequenceBeforeTest() {4 public void doExecute() {5 echo("Before Test");6 }7 });8 echo("Test");9 }10}11public class AfterTest extends TestNGCitrusTestDesigner {12 public void afterTest() {13 echo("Test");14 afterTest(new SequenceAfterTest() {15 public void doExecute() {16 echo("After Test");17 }18 });19 }20}21public class BeforeSuite extends TestNGCitrusTestDesigner {22 public void beforeSuite() {23 beforeSuite(new SequenceBeforeSuite() {24 public void doExecute() {25 echo("Before Suite");26 }27 });28 echo("Test");29 }30}31public class AfterSuite extends TestNGCitrusTestDesigner {32 public void afterSuite() {33 echo("Test");34 afterSuite(new SequenceAfterSuite() {35 public void doExecute() {36 echo("After Suite");37 }38 });39 }40}41public class BeforeGroups extends TestNGCitrusTestDesigner {42 public void beforeGroups() {43 beforeGroups(new SequenceBeforeGroups() {44 public void doExecute() {45 echo("Before Groups");46 }47 });48 echo("Test");49 }50}51public class AfterGroups extends TestNGCitrusTestDesigner {52 public void afterGroups() {53 echo("Test");54 afterGroups(new SequenceAfterGroups() {55 public void doExecute() {56 echo("After Groups");57 }58 });
doExecute
Using AI Code Generation
1package com.consol.citrus.testng;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.spring.TestNGCitrusSpringSupport;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.context.annotation.Bean;6import org.springframework.context.annotation.Configuration;7import org.springframework.context.annotation.Import;8import org.testng.annotations.Test;9import com.consol.citrus.container.SequenceBeforeTest;10import com.consol.citrus.dsl.builder.BuilderSupport;11import com.consol.citrus.dsl.builder.HttpActionBuilder;12import com.consol.citrus.dsl.builder.HttpClientActionBuilder;13import com.consol.citrus.http.client.HttpClient;14import com.consol.citrus.message.MessageType;15public class SequenceBeforeTestIT extends TestNGCitrusSpringSupport {16 private HttpClient httpClient;17 public void sequenceBeforeTest() {18 doExecute(new SequenceBeforeTest.Builder()19 .actions(new BuilderSupport<HttpActionBuilder>() {20 public void configure(HttpActionBuilder builder) {21 builder.client(httpClient)22 .send()23 .get("/test");24 }25 }, new BuilderSupport<HttpClientActionBuilder>() {26 public void configure(HttpClientActionBuilder builder) {27 builder.client(httpClient)28 .receive()29 .response(HttpStatus.OK)30 .messageType(MessageType.PLAINTEXT);31 }32 })33 .build());34 doExecute(new SequenceBeforeTest.Builder()35 .actions(new BuilderSupport<HttpActionBuilder>() {36 public void configure(HttpActionBuilder builder) {37 builder.client(httpClient)38 .send()39 .get("/test");40 }41 }, new BuilderSupport<HttpClientActionBuilder>() {42 public void configure(HttpClientActionBuilder builder) {43 builder.client(httpClient)44 .receive()45 .response(HttpStatus.OK)46 .messageType(MessageType.PLAINTEXT);47 }48 })49 .build());50 }51 @Import(DefaultTestConfig.class)52 public static class Config {53 public HttpClient httpClient() {54 return CitrusEndpoints.http()55 .client()56 .build();57 }58 }59}
doExecute
Using AI Code Generation
1package com.consol.citrus.container;2import com.consol.citrus.dsl.builder.BuilderSupport;3import com.consol.citrus.dsl.builder.ExecuteBeforeTestBuilder;4public class SequenceBeforeTest extends AbstractActionContainer {5 private final ExecuteBeforeTestBuilder executeBeforeTestBuilder;6 public SequenceBeforeTest(BuilderSupport<ExecuteBeforeTestBuilder> builder) {7 super("sequence-before-test");8 this.executeBeforeTestBuilder = builder.build();9 }10 public void doExecute(TestContext context) {11 executeBeforeTestBuilder.execute(context);12 }13}14package com.consol.citrus.container;15import com.consol.citrus.dsl.builder.BuilderSupport;16import com.consol.citrus.dsl.builder.ExecuteAfterTestBuilder;17public class SequenceAfterTest extends AbstractActionContainer {18 private final ExecuteAfterTestBuilder executeAfterTestBuilder;19 public SequenceAfterTest(BuilderSupport<ExecuteAfterTestBuilder> builder) {20 super("sequence-after-test");21 this.executeAfterTestBuilder = builder.build();22 }23 public void doExecute(TestContext context) {24 executeAfterTestBuilder.execute(context);25 }26}27package com.consol.citrus.container;28import com.consol.citrus.dsl.builder.BuilderSupport;29import com.consol.citrus.dsl.builder.ExecuteBeforeSuiteBuilder;30public class SequenceBeforeSuite extends AbstractActionContainer {31 private final ExecuteBeforeSuiteBuilder executeBeforeSuiteBuilder;32 public SequenceBeforeSuite(BuilderSupport<ExecuteBeforeSuiteBuilder> builder) {33 super("sequence-before-suite");34 this.executeBeforeSuiteBuilder = builder.build();35 }36 public void doExecute(TestContext context) {37 executeBeforeSuiteBuilder.execute(context);38 }39}40package com.consol.citrus.container;41import com.consol.citrus.dsl.builder.BuilderSupport;42import com.consol.cit
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!!