Best Citrus code snippet using com.consol.citrus.ws.actions.AssertSoapFault.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:AssertSoapFaultTest.java
...47 AssertSoapFault assertAction = new AssertSoapFault();48 assertAction.setValidator(soapFaultValidator);49 assertAction.setAction(new AbstractTestAction() {50 @Override51 public void doExecute(TestContext context) {52 SoapMessage faultMessage;53 54 faultMessage = messageFactory.createWebServiceMessage();55 56 Soap11Fault fault = ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 57 "Internal server error", 58 Locale.GERMANY);59 60 fault.setFaultActorOrRole("SERVER");61 62 throw new SoapFaultClientException(faultMessage);63 }64 });65 66 assertAction.setFaultString("Internal server error");67 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");68 assertAction.setFaultActor("SERVER");69 70 assertAction.execute(context);71 }72 73 @Test74 public void testAssertSoapFaultWithValidationMatchers() throws Exception {75 AssertSoapFault assertAction = new AssertSoapFault();76 assertAction.setValidator(soapFaultValidator);77 assertAction.setAction(new AbstractTestAction() {78 @Override79 public void doExecute(TestContext context) {80 SoapMessage faultMessage;81 82 faultMessage = messageFactory.createWebServiceMessage();83 84 Soap11Fault fault = ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 85 "Internal server error", 86 Locale.GERMANY);87 88 fault.setFaultActorOrRole("SERVER");89 90 throw new SoapFaultClientException(faultMessage);91 }92 });93 94 assertAction.setFaultString("@equalsIgnoreCase('internal server error')@");95 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");96 assertAction.setFaultActor("@equalsIgnoreCase('server')@");97 98 assertAction.execute(context);99 }100 101 @Test102 public void testNoPrefix() throws Exception {103 AssertSoapFault assertAction = new AssertSoapFault();104 assertAction.setValidator(soapFaultValidator);105 assertAction.setAction(new AbstractTestAction() {106 @Override107 public void doExecute(TestContext context) {108 SoapMessage faultMessage;109 110 faultMessage = messageFactory.createWebServiceMessage();111 112 ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}TEC-1001"), 113 "Internal server error", 114 Locale.GERMANY);115 116 throw new SoapFaultClientException(faultMessage);117 }118 });119 120 assertAction.setFaultString("Internal server error");121 assertAction.setFaultCode("{http://citrusframework.org}TEC-1001");122 123 assertAction.execute(context);124 }125 126 @Test127 public void testWrongFaultCode() throws Exception {128 AssertSoapFault assertAction = new AssertSoapFault();129 assertAction.setValidator(soapFaultValidator);130 assertAction.setAction(new AbstractTestAction() {131 @Override132 public void doExecute(TestContext context) {133 SoapMessage faultMessage;134 135 faultMessage = messageFactory.createWebServiceMessage();136 137 ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-2002"), 138 "Internal server error", 139 Locale.GERMANY);140 141 throw new SoapFaultClientException(faultMessage);142 }143 });144 145 assertAction.setFaultString("Internal server error");146 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");147 148 try {149 assertAction.execute(context);150 } catch(IllegalArgumentException e) {151 Assert.assertEquals(e.getMessage(), "SOAP fault validation failed! Fault code does not match - expected: '{http://citrusframework.org}TEC-1001' but was: '{http://citrusframework.org}TEC-2002'");152 return;153 }154 155 Assert.fail("Missing validation exception");156 }157 158 @Test159 public void testWrongFaultActor() throws Exception {160 AssertSoapFault assertAction = new AssertSoapFault();161 assertAction.setValidator(soapFaultValidator);162 assertAction.setAction(new AbstractTestAction() {163 @Override164 public void doExecute(TestContext context) {165 SoapMessage faultMessage;166 faultMessage = messageFactory.createWebServiceMessage();167 168 Soap11Fault fault = ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 169 "Internal server error", 170 Locale.GERMANY);171 172 fault.setFaultActorOrRole("CLIENT");173 174 throw new SoapFaultClientException(faultMessage);175 }176 });177 178 assertAction.setFaultString("Internal server error");179 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");180 assertAction.setFaultActor("SERVER");181 182 try {183 assertAction.execute(context);184 } catch(IllegalArgumentException e) {185 Assert.assertEquals(e.getMessage(), "SOAP fault validation failed! Fault actor does not match - expected: 'SERVER' but was: 'CLIENT'");186 return;187 }188 189 Assert.fail("Missing validation exception");190 }191 192 @Test193 public void testWrongFaultString() throws Exception {194 AssertSoapFault assertAction = new AssertSoapFault();195 assertAction.setValidator(soapFaultValidator);196 assertAction.setAction(new AbstractTestAction() {197 @Override198 public void doExecute(TestContext context) {199 SoapMessage faultMessage;200 201 faultMessage = messageFactory.createWebServiceMessage();202 203 ((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 204 "Internal server error", 205 Locale.GERMANY);206 207 throw new SoapFaultClientException(faultMessage);208 }209 });210 211 assertAction.setFaultString("Invalid request");212 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");213 214 try {215 assertAction.execute(context);216 } catch(ValidationException e) {217 Assert.assertEquals(e.getMessage(), "SOAP fault validation failed! Fault string does not match - expected: 'Invalid request' but was: 'Internal server error'");218 return;219 }220 221 Assert.fail("Missing validation exception");222 }223 224 @Test225 public void testAssertSoapFaultDetail() throws Exception {226 AssertSoapFault assertAction = new AssertSoapFault();227 assertAction.setValidator(soapFaultValidator);228 assertAction.setAction(new AbstractTestAction() {229 @Override230 public void doExecute(TestContext context) {231 SoapMessage faultMessage;232 233 faultMessage = messageFactory.createWebServiceMessage();234 235 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 236 "Internal server error", 237 Locale.GERMANY);238 239 try {240 TransformerFactory transformerFactory = TransformerFactory.newInstance();241 Transformer transformer = transformerFactory.newTransformer();242 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());243 } catch (TransformerException e) {244 throw new CitrusRuntimeException(e);245 }246 247 throw new SoapFaultClientException(faultMessage);248 }249 });250 251 assertAction.setFaultString("Internal server error");252 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");253 assertAction.getFaultDetails().add("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>");254 255 assertAction.execute(context);256 }257 258 @Test259 public void testAssertSoapFaultDetailVariableSupport() throws Exception {260 AssertSoapFault assertAction = new AssertSoapFault();261 assertAction.setValidator(soapFaultValidator);262 assertAction.setAction(new AbstractTestAction() {263 @Override264 public void doExecute(TestContext context) {265 SoapMessage faultMessage;266 267 faultMessage = messageFactory.createWebServiceMessage();268 269 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 270 "Internal server error", 271 Locale.GERMANY);272 273 try {274 TransformerFactory transformerFactory = TransformerFactory.newInstance();275 Transformer transformer = transformerFactory.newTransformer();276 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());277 } catch (TransformerException e) {278 throw new CitrusRuntimeException(e);279 }280 281 throw new SoapFaultClientException(faultMessage);282 }283 });284 285 context.setVariable("faultReason", "Invalid request");286 287 assertAction.setFaultString("Internal server error");288 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");289 assertAction.getFaultDetails().add("<FaultDetail><Reason>${faultReason}</Reason></FaultDetail>");290 291 assertAction.execute(context);292 }293 294 @Test295 public void testAssertSoapFaultDetailResource() throws Exception {296 AssertSoapFault assertAction = new AssertSoapFault();297 assertAction.setValidator(soapFaultValidator);298 assertAction.setAction(new AbstractTestAction() {299 @Override300 public void doExecute(TestContext context) {301 SoapMessage faultMessage;302 303 faultMessage = messageFactory.createWebServiceMessage();304 305 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 306 "Internal server error", 307 Locale.GERMANY);308 309 try {310 TransformerFactory transformerFactory = TransformerFactory.newInstance();311 Transformer transformer = transformerFactory.newTransformer();312 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());313 } catch (TransformerException e) {314 throw new CitrusRuntimeException(e);315 }316 317 throw new SoapFaultClientException(faultMessage);318 }319 });320 321 assertAction.setFaultString("Internal server error");322 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");323 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail.xml");324 325 assertAction.execute(context);326 }327 328 @Test329 public void testAssertSoapFaultDetailResourceVariableSupport() throws Exception {330 AssertSoapFault assertAction = new AssertSoapFault();331 assertAction.setValidator(soapFaultValidator);332 assertAction.setAction(new AbstractTestAction() {333 @Override334 public void doExecute(TestContext context) {335 SoapMessage faultMessage;336 337 faultMessage = messageFactory.createWebServiceMessage();338 339 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 340 "Internal server error", 341 Locale.GERMANY);342 343 try {344 TransformerFactory transformerFactory = TransformerFactory.newInstance();345 Transformer transformer = transformerFactory.newTransformer();346 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());347 } catch (TransformerException e) {348 throw new CitrusRuntimeException(e);349 }350 351 throw new SoapFaultClientException(faultMessage);352 }353 });354 355 context.setVariable("faultReason", "Invalid request");356 357 assertAction.setFaultString("Internal server error");358 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");359 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail-with-variables.xml");360 361 assertAction.execute(context);362 }363 364 @Test365 public void testAssertMultipleSoapFaultDetails() throws Exception {366 AssertSoapFault assertAction = new AssertSoapFault();367 assertAction.setValidator(soapFaultValidator);368 assertAction.setAction(new AbstractTestAction() {369 @Override370 public void doExecute(TestContext context) {371 SoapMessage faultMessage;372 373 faultMessage = messageFactory.createWebServiceMessage();374 375 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 376 "Internal server error", 377 Locale.GERMANY);378 379 SoapFaultDetail faultDetail = fault.addFaultDetail();380 try {381 TransformerFactory transformerFactory = TransformerFactory.newInstance();382 Transformer transformer = transformerFactory.newTransformer();383 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), faultDetail.getResult());384 transformer.transform(new StringSource("<ErrorDetail><Code>1001</Code></ErrorDetail>"), faultDetail.getResult());385 } catch (TransformerException e) {386 throw new CitrusRuntimeException(e);387 }388 389 throw new SoapFaultClientException(faultMessage);390 }391 });392 393 assertAction.setFaultString("Internal server error");394 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");395 assertAction.getFaultDetails().add("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>");396 assertAction.getFaultDetails().add("<ErrorDetail><Code>1001</Code></ErrorDetail>");397 398 assertAction.execute(context);399 }400 401 @Test402 public void testAssertMultipleSoapFaultDetailsWithResource() throws Exception {403 AssertSoapFault assertAction = new AssertSoapFault();404 assertAction.setValidator(soapFaultValidator);405 assertAction.setAction(new AbstractTestAction() {406 @Override407 public void doExecute(TestContext context) {408 SoapMessage faultMessage;409 410 faultMessage = messageFactory.createWebServiceMessage();411 412 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 413 "Internal server error", 414 Locale.GERMANY);415 416 SoapFaultDetail faultDetail = fault.addFaultDetail();417 try {418 TransformerFactory transformerFactory = TransformerFactory.newInstance();419 Transformer transformer = transformerFactory.newTransformer();420 transformer.transform(new StringSource("<ErrorDetail><Code>1001</Code></ErrorDetail>"), faultDetail.getResult());421 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), faultDetail.getResult());...
Source:AssertSoapFault.java
...71 public AssertSoapFault() {72 setName("soap-fault");73 }74 @Override75 public void doExecute(TestContext context) {76 log.debug("Asserting SOAP fault ...");77 try {78 action.execute(context);79 } catch (SoapFaultClientException soapFaultException) {80 log.debug("Validating SOAP fault ...");81 82 SoapFault controlFault = constructControlFault(context);83 84 validator.validateSoapFault(SoapFault.from(soapFaultException.getSoapFault()), controlFault, context, validationContext);85 86 log.debug("Asserted SOAP fault as expected: " + soapFaultException.getFaultCode() + ": " + soapFaultException.getFaultStringOrReason());87 log.info("Assert SOAP fault validation successful");88 89 return;...
doExecute
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.exceptions.CitrusRuntimeException;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4import com.consol.citrus.ws.message.SoapFault;5import com.consol.citrus.ws.message.SoapFaultDefinition;6import com.consol.citrus.ws.message.SoapFaultDefinitionBuilder;7import org.easymock.EasyMock;8import org.springframework.ws.soap.SoapFaultDetail;9import org.springframework.ws.soap.SoapFaultDetailElement;10import org.springframework.ws.soap.SoapFaultDetailException;11import org.springframework.ws.soap.SoapMessage;12import org.springframework.ws.soap.SoapMessageFactory;13import org.testng.Assert;14import org.testng.annotations.BeforeMethod;15import org.testng.annotations.Test;16import javax.xml.namespace.QName;17import javax.xml.transform.Source;18public class AssertSoapFaultTest extends AbstractTestNGUnitTest {19 private SoapMessageFactory messageFactory = EasyMock.createMock(SoapMessageFactory.class);20 private SoapFaultDefinitionBuilder faultDefinitionBuilder = EasyMock.createMock(SoapFaultDefinitionBuilder.class);21 private SoapFaultDefinition faultDefinition = EasyMock.createMock(SoapFaultDefinition.class);22 private SoapFault soapFault = EasyMock.createMock(SoapFault.class);23 private SoapMessage soapMessage = EasyMock.createMock(SoapMessage.class);24 private SoapFaultDetailException soapFaultDetailException = EasyMock.createMock(SoapFaultDetailException.class);25 private SoapFaultDetail soapFaultDetail = EasyMock.createMock(SoapFaultDetail.class);26 private SoapFaultDetailElement soapFaultDetailElement = EasyMock.createMock(SoapFaultDetailElement.class);27 private Source source = EasyMock.createMock(Source.class);28 private AssertSoapFault assertSoapFault = new AssertSoapFault();29 public void resetMocks() {30 EasyMock.reset(messageFactory, faultDefinitionBuilder, faultDefinition, soapFault, soapMessage, soapFaultDetailException, soapFaultDetail, soapFaultDetailElement, source);31 }32 public void testAssertSoapFault() throws Exception {33 assertSoapFault.setSoapFaultDefinitionBuilder(faultDefinitionBuilder);34 assertSoapFault.setFaultString("faultString");35 assertSoapFault.setFaultCode("faultCode");36 assertSoapFault.setFaultActor("faultActor");37 assertSoapFault.setFaultDetail("faultDetail");
doExecute
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.TestAction;3import com.consol.citrus.actions.AbstractTestAction;4import com.consol.citrus.context.TestContext;5import com.consol.citrus.exceptions.CitrusRuntimeException;6import com.consol.citrus.ws.message.SoapFault;7import com.consol.citrus.ws.message.SoapFaultDefinition;8import com.consol.citrus.ws.message.SoapFaultDefinitionBuilder;9import org.slf4j.Logger;10import org.slf4j.LoggerFactory;11import org.springframework.util.StringUtils;12import org.springframework.ws.soap.SoapFaultDetail;13import org.springframework.ws.soap.SoapFaultDetailElement;14import org.springframework.ws.soap.SoapMessage;15import org.springframework.ws.soap.SoapVersion;16import org.springframework.ws.soap.server.SoapFaultMappingExceptionResolver;17import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionExceptionResolver;18import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionSource;19import org.springframework.xml.namespace.QNameUtils;20import javax.xml.namespace.QName;21import javax.xml.soap.SOAPConstants;22import java.util.Map;23import java.util.Map.Entry;24import java.util.Optional;25public class AssertSoapFault extends AbstractTestAction {26 private static Logger log = LoggerFactory.getLogger(AssertSoapFault.class);27 private SoapFaultDefinition soapFaultDefinition;28 private SoapFaultDefinitionSource soapFaultDefinitionSource;29 private SoapFaultMappingExceptionResolver soapFaultMappingExceptionResolver;30 private SoapFaultDefinitionExceptionResolver soapFaultDefinitionExceptionResolver;31 private String faultCode;32 private String faultString;33 private String faultActor;34 private String faultDetail;35 private String faultDetailName;36 private String faultDetailNamespace;37 private Map<String, String> faultDetailElements;38 private String faultDetailElementName;
doExecute
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.ws.actions.AssertSoapFault;4import org.testng.annotations.Test;5public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {6public void AssertSoapFaultTest() {7 http().client("httpClient")8 .send()9 .post()10 .soap()11 "</soapenv:Envelope>");12 AssertSoapFault assertSoapFault = new AssertSoapFault();13 doExecute(assertSoapFault);14}15}16package com.consol.citrus;17import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;18import com.consol.citrus.ws.actions.AssertSoapFault;19import org.testng.annotations.Test;20public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {21public void AssertSoapFaultTest() {
doExecute
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import com.consol.citrus.ws.actions.AssertSoapFault;4import org.testng.annotations.Test;5public class AssertSoapFaultTest extends TestNGCitrusTestRunner {6 public void test() {7 variable("faultCode", "soap:Server");8 variable("faultString", "Server Error");9 variable("faultDetail", "Internal Server Error");10 http().client("httpClient")11 .send()12 .post()13 .fork(true)14 "</ns0:HelloWorldRequest>");15 http().client("httpClient")16 .receive()17 .response(HttpStatus.BAD_REQUEST)18 .contentType("text/xml;charset=UTF-8")19 "<faultcode>${faultCode}</faultcode>" +20 "<faultstring>${faultString}</faultstring>" +21 "<ns0:Message>${faultDetail}</ns0:Message>" +22 "</SOAP-ENV:Envelope>");23 doExecute(new AssertSoapFault(this) {24 public void doExecute() {25 faultCode("${faultCode}");26 faultString("${faultString}");27 faultDetail("${faultDetail}");28 }29 });30 }31}32package com.consol.citrus.samples;33import com.consol.citrus.dsl
doExecute
Using AI Code Generation
1public class 3 extends AbstractTestBehavior {2 public 3() {3 setName("3");4 }5 public void execute(JavaTestRunner runner) {6 runner.run(new AssertSoapFault.Builder()7 .faultString("Client Error")8 .build());9 }10}11public class 4 extends AbstractTestBehavior {12 public 4() {13 setName("4");14 }15 public void execute(JavaTestRunner runner) {16 runner.run(new AssertSoapFault.Builder()17 .faultString("Client Error")18 .build());19 }20}21public class 5 extends AbstractTestBehavior {22 public 5() {23 setName("5");24 }25 public void execute(JavaTestRunner runner) {26 runner.run(new AssertSoapFault.Builder()27 .faultString("Client Error")28 .build());29 }30}
doExecute
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import org.springframework.http.HttpStatus;5import org.testng.annotations.Test;6import static com.consol.citrus.actions.EchoAction.Builder.echo;7import static com.consol.citrus.actions.SendMessageAction.Builder.soap;8import static com.consol.citrus.container.Parallel.Builder.parallel;9import static com.consol.citrus.container.Sequence.Builder.sequential;10import static com.consol.citrus.dsl.actions.DelegatingTestAction.Builder.delegate;11import static com.consol.citrus.dsl.actions.PurgeEndpointAction.Builder.purge;12import static com.consol.citrus.dsl.actions.ReceiveMessageAction.Builder.receive;13import static com.consol.citrus.dsl.actions.SendSoapFaultAction.Builder.soapFault;14import static com.consol.citrus.dsl.actions.SleepAction.Builder.sleep;15import static com.consol.citrus.dsl.actions.StopTimeAction.Builder.stopTime;16import static com.consol.citrus.dsl.actions.StartTimeAction.Builder.startTime;17import static com.consol.citrus.dsl.actions.CreateVariablesAction.Builder.createVariable;18import static com.consol.citrus.dsl.actions.ExecutePLSQLAction.Builder.executePLSQL;19import static com.consol.citrus.dsl.actions.ExecuteSQLAction.Builder.executeSQL;20import static com.consol.citrus.dsl.actions.ExecuteSQLQueryAction.Builder.executeSQLQuery;21import static com.consol.citrus.dsl.actions.ExecuteSQLUpdateAction.Builder.executeSQLUpdate;22import static com.consol.citrus.dsl.actions.ExecutePLSQLAction.Builder.executePLSQL;23import static com.consol.citrus.dsl.actions.ExecutePLSQLQueryAction.Builder.executePLSQLQuery;24import static com.consol.citrus.dsl.actions.ExecutePLSQLUpdateAction.Builder.executePLSQLUpdate;25import static com.consol.citrus.dsl.actions.PurgeJmsQueuesAction.Builder.purgeQueues;26import static com.consol.citrus.dsl.actions.PurgeJmsTopicsAction.Builder.purgeTopics;27import static com.consol.citrus.dsl.actions.PurgeMailAction.Builder.purgeMail;28import static com.consol.citrus.dsl.actions.PurgeMongoDbCollectionAction.Builder.purgeMongoDbCollection;29import static com.consol.citrus.dsl.actions.PurgeRedisAction.Builder.p
doExecute
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import org.testng.annotations.Test;4public class AssertSoapFaultJavaITest extends TestNGCitrusTestRunner {5 public void assertSoapFaultJavaITest() {6 variable("faultCode", "soap:Server");7 variable("faultString", "Server Error");8 variable("faultDetail", "Server Error");9 variable("faultDetailElement", "ServerFault");10 variable("faultDetailElementValue", "Server Error");11 send("webServiceClient")12 "</soapenv:Envelope>");13 receive("webServiceServer")14 " <faultcode>${faultCode}</faultcode>\n"
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!!