Best Citrus code snippet using com.consol.citrus.ws.actions.AssertSoapFault.getFaultCode
Source:AssertSoapFaultBuilderTest.java
...65 when(soapMessage.getSoapBody()).thenReturn(soapBody);66 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);67 when(soapBody.getFault()).thenReturn(soapFault);68 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());69 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);70 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);71 when(soapFault.getFaultDetail()).thenReturn(null);72 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);73 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);74 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());75 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());76 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());77 context.setReferenceResolver(referenceResolver);78 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);79 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())80 .faultString(INTERNAL_SERVER_ERROR)81 .when(action(context -> {82 throw new SoapFaultClientException(soapMessage);83 })));84 TestCase test = runner.getTestCase();85 Assert.assertEquals(test.getActionCount(), 1);86 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);87 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");88 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));89 Assert.assertEquals(container.getActionCount(), 1);90 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());91 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());92 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);93 }94 @Test95 public void testAssertSoapFaultExplicitValidatorBuilder() {96 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);97 when(soapMessage.getSoapBody()).thenReturn(soapBody);98 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);99 when(soapBody.getFault()).thenReturn(soapFault);100 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());101 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);102 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);103 when(soapFault.getFaultDetail()).thenReturn(null);104 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);105 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());106 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());107 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());108 context.setReferenceResolver(referenceResolver);109 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);110 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())111 .faultString(INTERNAL_SERVER_ERROR)112 .validator(soapFaultValidator)113 .when(action(context -> {114 throw new SoapFaultClientException(soapMessage);115 })));116 TestCase test = runner.getTestCase();117 Assert.assertEquals(test.getActionCount(), 1);118 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);119 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");120 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));121 Assert.assertEquals(container.getActionCount(), 1);122 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());123 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());124 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);125 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),126 any(TestContext.class), any(SoapFaultValidationContext.class));127 }128 @Test129 public void testAssertSoapFaultWithValidatorNameBuilder() {130 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);131 when(soapMessage.getSoapBody()).thenReturn(soapBody);132 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);133 when(soapBody.getFault()).thenReturn(soapFault);134 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());135 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);136 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);137 when(soapFault.getFaultDetail()).thenReturn(null);138 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);139 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);140 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);141 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());142 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());143 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());144 context.setReferenceResolver(referenceResolver);145 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);146 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())147 .faultString(INTERNAL_SERVER_ERROR)148 .validator(SOAP_FAULT_VALIDATOR)149 .when(action(context -> {150 throw new SoapFaultClientException(soapMessage);151 })));152 TestCase test = runner.getTestCase();153 Assert.assertEquals(test.getActionCount(), 1);154 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);155 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");156 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));157 Assert.assertEquals(container.getActionCount(), 1);158 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());159 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());160 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);161 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),162 any(TestContext.class), any(SoapFaultValidationContext.class));163 }164 @Test165 public void testAssertSoapFaultDefaultValidatorBuilder() {166 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);167 when(soapMessage.getSoapBody()).thenReturn(soapBody);168 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);169 when(soapBody.getFault()).thenReturn(soapFault);170 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());171 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);172 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);173 when(soapFault.getFaultDetail()).thenReturn(null);174 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);175 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);176 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);177 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());178 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());179 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());180 context.setReferenceResolver(referenceResolver);181 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);182 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())183 .faultString(INTERNAL_SERVER_ERROR)184 .when(action(context -> {185 throw new SoapFaultClientException(soapMessage);186 })));187 TestCase test = runner.getTestCase();188 Assert.assertEquals(test.getActionCount(), 1);189 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);190 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");191 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));192 Assert.assertEquals(container.getActionCount(), 1);193 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());194 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());195 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);196 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),197 any(TestContext.class), any(SoapFaultValidationContext.class));198 }199 @Test200 public void testFaultDetail() {201 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);202 when(soapMessage.getSoapBody()).thenReturn(soapBody);203 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);204 when(soapBody.getFault()).thenReturn(soapFault);205 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());206 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);207 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);208 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);209 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());210 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));211 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);212 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);213 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());214 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());215 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());216 context.setReferenceResolver(referenceResolver);217 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);218 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())219 .faultString(INTERNAL_SERVER_ERROR)220 .faultDetail("<ErrorDetail><message>Something went wrong</message></ErrorDetail>")221 .when(action(context -> {222 throw new SoapFaultClientException(soapMessage);223 })));224 TestCase test = runner.getTestCase();225 Assert.assertEquals(test.getActionCount(), 1);226 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);227 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");228 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));229 Assert.assertEquals(container.getActionCount(), 1);230 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());231 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());232 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);233 Assert.assertEquals(container.getFaultDetails().size(), 1L);234 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>Something went wrong</message></ErrorDetail>");235 }236 @Test237 public void testMultipleFaultDetails() {238 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);239 when(soapMessage.getSoapBody()).thenReturn(soapBody);240 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);241 when(soapBody.getFault()).thenReturn(soapFault);242 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());243 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);244 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);245 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);246 when(soapFaultDetail.getDetailEntries()).thenReturn(Arrays.asList(soapFaultDetailElement, soapFaultDetailElement).iterator());247 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><code>1001</code></ErrorDetail>"))248 .thenReturn(new StringSource("<MessageDetail><message>Something went wrong</message></MessageDetail>"));249 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);250 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);251 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());252 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());253 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());254 context.setReferenceResolver(referenceResolver);255 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);256 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())257 .faultString(INTERNAL_SERVER_ERROR)258 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")259 .faultDetail("<MessageDetail><message>Something went wrong</message></MessageDetail>")260 .when(action(context -> {261 throw new SoapFaultClientException(soapMessage);262 })));263 TestCase test = runner.getTestCase();264 Assert.assertEquals(test.getActionCount(), 1);265 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);266 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");267 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));268 Assert.assertEquals(container.getActionCount(), 1);269 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());270 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());271 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);272 Assert.assertEquals(container.getFaultDetails().size(), 2L);273 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");274 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>Something went wrong</message></MessageDetail>");275 }276 @Test277 public void testFaultDetailResource() throws IOException {278 reset(resource, referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);279 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<ErrorDetail><message>Something went wrong</message></ErrorDetail>".getBytes()));280 when(soapMessage.getSoapBody()).thenReturn(soapBody);281 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);282 when(soapBody.getFault()).thenReturn(soapFault);283 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());284 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);285 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);286 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);287 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());288 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));289 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);290 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);291 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());292 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());293 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());294 context.setReferenceResolver(referenceResolver);295 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);296 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())297 .faultString(INTERNAL_SERVER_ERROR)298 .faultDetailResource(resource)299 .when(action(context -> {300 throw new SoapFaultClientException(soapMessage);301 })));302 TestCase test = runner.getTestCase();303 Assert.assertEquals(test.getActionCount(), 1);304 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);305 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");306 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));307 Assert.assertEquals(container.getActionCount(), 1);308 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());309 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());310 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);311 Assert.assertEquals(container.getFaultDetails().size(), 1L);312 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>Something went wrong</message></ErrorDetail>");313 }314 @Test315 public void testFaultDetailResourcePath() {316 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);317 when(soapMessage.getSoapBody()).thenReturn(soapBody);318 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);319 when(soapBody.getFault()).thenReturn(soapFault);320 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());321 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);322 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);323 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);324 when(soapFaultDetail.getDetailEntries()).thenReturn(Collections.singleton(soapFaultDetailElement).iterator());325 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><message>Something went wrong</message></ErrorDetail>"));326 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);327 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);328 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());329 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());330 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());331 context.setReferenceResolver(referenceResolver);332 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);333 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())334 .faultString(INTERNAL_SERVER_ERROR)335 .faultDetailResource("classpath:com/consol/citrus/ws/actions/dsl/soap-fault-detail.xml")336 .when(action(context -> {337 throw new SoapFaultClientException(soapMessage);338 })));339 TestCase test = runner.getTestCase();340 Assert.assertEquals(test.getActionCount(), 1);341 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);342 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");343 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));344 Assert.assertEquals(container.getActionCount(), 1);345 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());346 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());347 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);348 Assert.assertEquals(container.getFaultDetails().size(), 0L);349 Assert.assertEquals(container.getFaultDetailResourcePaths().size(), 1L);350 Assert.assertEquals(container.getFaultDetailResourcePaths().get(0), "classpath:com/consol/citrus/ws/actions/dsl/soap-fault-detail.xml");351 }352 @Test353 public void testMultipleFaultDetailsInlineAndResource() throws IOException {354 reset(resource, referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);355 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<MessageDetail><message>Something went wrong</message></MessageDetail>".getBytes()));356 when(soapMessage.getSoapBody()).thenReturn(soapBody);357 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);358 when(soapBody.getFault()).thenReturn(soapFault);359 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());360 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);361 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);362 when(soapFault.getFaultDetail()).thenReturn(soapFaultDetail);363 when(soapFaultDetail.getDetailEntries()).thenReturn(Arrays.asList(soapFaultDetailElement, soapFaultDetailElement).iterator());364 when(soapFaultDetailElement.getSource()).thenReturn(new StringSource("<ErrorDetail><code>1001</code></ErrorDetail>"))365 .thenReturn(new StringSource("<MessageDetail><message>Something went wrong</message></MessageDetail>"));366 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);367 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);368 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());369 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());370 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());371 context.setReferenceResolver(referenceResolver);372 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);373 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())374 .faultString(INTERNAL_SERVER_ERROR)375 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")376 .faultDetailResource(resource)377 .when(action(context -> {378 throw new SoapFaultClientException(soapMessage);379 })));380 TestCase test = runner.getTestCase();381 Assert.assertEquals(test.getActionCount(), 1);382 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);383 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");384 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));385 Assert.assertEquals(container.getActionCount(), 1);386 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());387 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());388 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);389 Assert.assertEquals(container.getFaultDetails().size(), 2L);390 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");391 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>Something went wrong</message></MessageDetail>");392 }393 @Test394 public void testAssertSoapFaultBuilderWithValidator() {395 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);396 when(soapMessage.getSoapBody()).thenReturn(soapBody);397 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);398 when(soapBody.getFault()).thenReturn(soapFault);399 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());400 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);401 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);402 when(soapFault.getFaultDetail()).thenReturn(null);403 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);404 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(true);405 when(referenceResolver.resolve(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);406 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());407 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());408 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());409 context.setReferenceResolver(referenceResolver);410 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);411 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())412 .faultString(INTERNAL_SERVER_ERROR)413 .validator(soapFaultValidator)414 .when(action(context -> {415 throw new SoapFaultClientException(soapMessage);416 })));417 TestCase test = runner.getTestCase();418 Assert.assertEquals(test.getActionCount(), 1);419 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);420 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");421 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));422 Assert.assertEquals(container.getActionCount(), 1);423 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());424 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());425 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);426 Assert.assertEquals(container.getValidator(), soapFaultValidator);427 verify(soapFaultValidator).validateSoapFault(any(com.consol.citrus.ws.message.SoapFault.class), any(com.consol.citrus.ws.message.SoapFault.class),428 any(TestContext.class), any(SoapFaultValidationContext.class));429 }430 @Test431 public void testAssertSoapFaultBuilderWithActor() {432 reset(referenceResolver, soapMessage, soapFaultValidator, soapBody, soapFault, soapFaultDetail, soapFaultDetailElement);433 when(soapMessage.getSoapBody()).thenReturn(soapBody);434 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);435 when(soapBody.getFault()).thenReturn(soapFault);436 when(soapFault.getFaultActorOrRole()).thenReturn("MyActor");437 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);438 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);439 when(soapFault.getFaultDetail()).thenReturn(null);440 when(referenceResolver.resolve(TestContext.class)).thenReturn(context);441 when(referenceResolver.isResolvable(SOAP_FAULT_VALIDATOR)).thenReturn(false);442 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());443 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());444 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());445 context.setReferenceResolver(referenceResolver);446 DefaultTestCaseRunner runner = new DefaultTestCaseRunner(context);447 runner.run(assertSoapFault().faultCode(SoapFaultDefinition.SERVER.getLocalPart())448 .faultString(INTERNAL_SERVER_ERROR)449 .faultActor("MyActor")450 .when(action(context -> {451 throw new SoapFaultClientException(soapMessage);452 })));453 TestCase test = runner.getTestCase();454 Assert.assertEquals(test.getActionCount(), 1);455 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);456 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");457 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));458 Assert.assertEquals(container.getActionCount(), 1);459 Assert.assertTrue(container.getAction().getClass().isAnonymousClass());460 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());461 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);462 Assert.assertEquals(container.getFaultActor(), "MyActor");463 }464}...
Source:AssertSoapFaultTestRunnerTest.java
...54 when(soapMessage.getSoapBody()).thenReturn(soapBody);55 when(soapMessage.getFaultReason()).thenReturn(INTERNAL_SERVER_ERROR);56 when(soapBody.getFault()).thenReturn(soapFault);57 when(soapFault.getFaultActorOrRole()).thenReturn(SoapFaultDefinition.SERVER.getLocalPart());58 when(soapFault.getFaultCode()).thenReturn(SoapFaultDefinition.SERVER);59 when(soapFault.getFaultStringOrReason()).thenReturn(INTERNAL_SERVER_ERROR);60 when(soapFault.getFaultDetail()).thenReturn(null);61 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));62 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(false);63 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());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);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());449 Assert.assertEquals(container.getFaultCode(), SoapFaultDefinition.SERVER.getLocalPart());450 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);451 Assert.assertEquals(container.getFaultActor(), "MyActor");452 }453}...
Source:AssertSoapFault.java
...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;90 } catch (RuntimeException e) {91 throw new ValidationException("SOAP fault validation failed for asserted exception type - expected: '" + 92 SoapFaultClientException.class + "' but was: '" + e.getClass().getName() + "'", e);93 } catch (Exception e) {94 throw new ValidationException("SOAP fault validation failed for asserted exception type - expected: '" + 95 SoapFaultClientException.class + "' but was: '" + e.getClass().getName() + "'", e);96 }97 98 throw new ValidationException("SOAP fault validation failed! Missing asserted SOAP fault exception");99 }100 /**101 * Constructs the control soap fault holding all expected fault information102 * like faultCode, faultString and faultDetail.103 * 104 * @return the constructed SoapFault instance.105 */106 private SoapFault constructControlFault(TestContext context) {107 SoapFault controlFault= new SoapFault();108 if (StringUtils.hasText(faultActor)) {109 controlFault.faultActor(context.replaceDynamicContentInString(faultActor));110 }111 controlFault.faultCode(context.replaceDynamicContentInString(faultCode));112 controlFault.faultString(context.replaceDynamicContentInString(faultString));113 for (String faultDetail : faultDetails) {114 controlFault.addFaultDetail(context.replaceDynamicContentInString(faultDetail));115 }116 try {117 for (String faultDetailPath : faultDetailResourcePaths) {118 String resourcePath = context.replaceDynamicContentInString(faultDetailPath);119 controlFault.addFaultDetail(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(resourcePath, context), FileUtils.getCharset(resourcePath))));120 }121 } catch (IOException e) {122 throw new CitrusRuntimeException("Failed to create SOAP fault detail from file resource", e);123 }124 return controlFault;125 }126 /**127 * Set the nested test action.128 * @param action the action to set129 */130 public AssertSoapFault setAction(TestAction action) {131 addTestAction(action);132 return this;133 }134 /**135 * Set the fault code.136 * @param faultCode the faultCode to set137 */138 public AssertSoapFault setFaultCode(String faultCode) {139 this.faultCode = faultCode;140 return this;141 }142 /**143 * Set the fault string.144 * @param faultString the faultString to set145 */146 public AssertSoapFault setFaultString(String faultString) {147 this.faultString = faultString;148 return this;149 }150 /**151 * @param validator the validator to set152 */153 public AssertSoapFault setValidator(SoapFaultValidator validator) {154 this.validator = validator;155 return this;156 }157 @Override158 public AssertSoapFault addTestAction(TestAction action) {159 this.action = action;160 super.addTestAction(action);161 return this;162 }163 @Override164 public TestAction getTestAction(int index) {165 if (index == 0) {166 return action;167 } else {168 throw new IndexOutOfBoundsException("Illegal index in action list:" + index);169 }170 }171 @Override172 public AssertSoapFault setActions(List<TestAction> actions) {173 if (actions.size() > 1) {174 throw new CitrusRuntimeException("Invalid number of nested test actions - only one single nested action is allowed");175 }176 action = actions.get(0);177 super.setActions(actions);178 return this;179 }180 /**181 * Gets the action.182 * @return the action183 */184 public TestAction getAction() {185 return action;186 }187 /**188 * Gets the faultString.189 * @return the faultString190 */191 public String getFaultString() {192 return faultString;193 }194 /**195 * Gets the faultCode.196 * @return the faultCode197 */198 public String getFaultCode() {199 return faultCode;200 }201 /**202 * Gets the list of fault details.203 * @return the faultDetails204 */205 public List<String> getFaultDetails() {206 return faultDetails;207 }208 209 /**210 * Sets the faultDetails.211 * @param faultDetails the faultDetails to set212 */...
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.actions.AbstractTestAction;3import com.consol.citrus.context.TestContext;4import com.consol.citrus.exceptions.TestCaseFailedException;5import com.consol.citrus.message.Message;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.validation.context.ValidationContext;8import com.consol.citrus.validation.xml.XmlMessageValidationContext;9import com.consol.citrus.ws.message.SoapFault;10import com.consol.citrus.ws.message.SoapMessage;11import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;12import com.consol.citrus.ws.validation.SoapFaultValidationContext;13import org.slf4j.Logger;14import org.slf4j.LoggerFactory;15import org.springframework.util.Assert;16import org.springframework.util.StringUtils;17import org.springframework.ws.soap.SoapFaultDetail;18import javax.xml.namespace.QName;19import java.util.*;20public class AssertSoapFault extends AbstractTestAction {21 private static Logger log = LoggerFactory.getLogger(AssertSoapFault.class);22 private final String faultCode;23 private final String faultString;24 private final String faultActor;25 private final String faultDetail;26 private final String faultDetailExpression;27 private final String faultDetailNamespace;28 private final SoapFaultDetailValidationContext faultDetailValidationContext;29 private final SoapFaultValidationContext faultValidationContext;30 private final MessageType messageType;31 private final String messageSelector;32 private final String messageReceiver;33 private final ValidationContext validationContext;34 private final List<ValidationContext> faultDetailValidationContexts;35 private final List<ValidationContext> faultValidationContexts;36 private final String messageTypeString;37 private final String messageSelectorString;38 private final String messageReceiverString;39 private final String validationContextString;
getFaultCode
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.endpoint.CitrusEndpoints;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.runner.TestRunners;5import com.consol.citrus.http.client.HttpClient;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.ws.client.WebServiceClient;8import com.consol.citrus.ws.message.SoapMessage;9import org.testng.annotations.Test;10public class AssertSoapFaultSample {11 .soap()12 .client()13 .build();14 .http()15 .client()16 .build();17 public void testAssertSoapFault() {18 TestRunner runner = TestRunners.inline().actions(19 webServiceClient.send()20 .soap()21 .payload("<testRequestMessage><text>Hello Citrus!</text></testRequestMessage>"),22 webServiceClient.receive()23 .soap()24 .payload("<testResponseMessage><text>Hello Citrus!</text></testResponseMessage>"),25 webServiceClient.send()26 .soap()27 .payload("<testRequestMessage><text>Hello Citrus!</text></testRequestMessage>"),28 webServiceClient.receive()29 .soap()30 .payload("<testResponseMessage><text>Hello Citrus!</text></testResponseMessage>"),31 webServiceClient.send()32 .soap()33 .payload("<testRequestMessage><text>Hello Citrus!</text></testRequestMessage>"),34 webServiceClient.receive()35 .soap()36 .fault()37 .faultCode("SOAP-ENV:Client")38 .faultString("Client error")39 .faultDetail("<detail><message>Client error</message></detail>"),40 webServiceClient.send()41 .soap()42 .payload("<testRequestMessage><text>Hello Citrus!</text></testRequestMessage>"),43 webServiceClient.receive()44 .soap()45 .fault()46 .getFaultCode()47 .startsWith("SOAP-ENV:Client"),48 webServiceClient.send()49 .soap()50 .payload("<testRequestMessage><text>Hello Citrus!</text></testRequestMessage>"),51 webServiceClient.receive()52 .soap()
getFaultCode
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTest;4import com.consol.citrus.ws.actions.AssertSoapFault;5import com.consol.citrus.ws.actions.ReceiveSoapMessageAction;6import org.springframework.http.HttpStatus;7import org.springframework.ws.soap.SoapFault;8import org.testng.annotations.Test;9public class AssertSoapFaultTest extends TestNGCitrusTest {10 public void test() {11 TestRunner runner = citrus.createTestRunner();12 runner.echo("AssertSoapFaultTest");13 runner.soap(builder -> builder.client("soapClient")14 .send()15 "</OrderRequest>"));16 runner.soap(builder -> builder.server("soapServer")17 .receive()18 "</OrderResponse>"));19 runner.soap(builder -> builder.client("soapClient")20 .send()21 "</OrderRequest>"));22 runner.soap(builder -> builder.server("soapServer")23 .receive()24 "</OrderResponse>"));25 runner.soap(builder -> builder.client("soapClient")26 .send()27 .payload("<OrderRequest xmlns
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import static org.testng.Assert.assertEquals;3import org.testng.annotations.Test;4import com.consol.citrus.testng.AbstractTestNGUnitTest;5public class GetFaultCodeTest extends AbstractTestNGUnitTest {6public void testGetFaultCode() {7AssertSoapFault assertSoapFault = new AssertSoapFault();8assertSoapFault.setFaultCode("soap:Server");9assertSoapFault.getFaultCode();10assertEquals("soap:Server", assertSoapFault.getFaultCode());11}12}
getFaultCode
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class 3 extends TestNGCitrusTestDesigner {5public void test3() {6http().client("httpClient")7.send()8.post()9.soap()10.header("Content-Type", "text/xml; charset=UTF-8")11.header("SOAPAction", "echoMessage");12http().client("httpClient")13.receive()14.response(HttpStatus.BAD_REQUEST)15.soap()16.header("Content-Type", "text/xml; charset=UTF-8");17assertSoapFault().faultCode("soapenv:Client");18}19}20package com.consol.citrus;21import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;22import org.testng.annotations.Test;23public class 4 extends TestNGCitrusTestDesigner {24public void test4() {25http().client("httpClient")26.send()27.post()28.soap()
getFaultCode
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTest;4import com.consol.citrus.ws.actions.AssertSoapFault;5import com.consol.citrus.ws.actions.ReceiveSoapMessageAction;6import org.springframework.http.HttpStatus;7import org.springframework.ws.soap.SoapFault;8import org.testng.annotations.Test;9public class AssertSoapFaultTest extends TestNGCitrusTest {10 public void test() {11 TestRunner runner = citrus.createTestRunner();12 runner.echo("AssertSoapFaultTest");13 runner.soap(builder -> builder.client("soapClient")14 .send()15 "</OrderRequest>"));16 runner.soap(builder -> builder.server("soapServer")17 .receive()18 "</OrderResponse>"));19 runner.soap(builder -> builder.client("soapClient")20 .send()21 "</OrderRequest>"));22 runner.soap(builder -> builder.server("soapServer")23 .receive()24 "</OrderResponse>"));25 runner.soap(builder -> builder.client("soapClient")26 .send()27 .payload("<OrderRequest xmlns
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import static org.testng.Assert.assertEquals;3import org.testng.annotations.Test;4import com.consol.citrus.testng.AbstractTestNGUnitTest;5public class GetFaultCodeTest extends AbstractTestNGUnitTest {6public void testGetFaultCode() {7AssertSoapFault assertSoapFault = new AssertSoapFault();8assertSoapFault.setFaultCode("soap:Server");9assertSoapFault.getFaultCode();10assertEquals("soap:Server", assertSoapFault.getFaultCode());11}12}
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import org.testng.annotations.Test;3import org.testng.Assert;4import com.consol.citrus.ws.actions.AssertSoapFault;5public class GetFaultCodeTest {6public void getFaultCodeTest() {7AssertSoapFault assertSoapFault = new AssertSoapFault();8assertSoapFault.setFaultCode("Server");9String faultCode = assertSoapFault.getFaultCode();10Assert.assertEquals(faultCode,"Server");11}12}13BUILD SUCCESSFUL (total time: 0 seconds)
getFaultCode
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapMessage;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.http.HttpStatus;8import org.springframework.web.client.HttpClientErrorException;9import org.testng.annotations.Test;10public class 3 extends TestNGCitrusTestRunner {11 private WebServiceClient webServiceClient;12 public void 3() {13 variable("faultcode", "env:FAULTCODE");14 variable("faultstring", "env:FAULTSTRING");15 variable("faultactor", "env:FAULTACTOR");16 variable("detail", "env:DETAIL");17 variable("message", "env:MESSAGE");18 variable("faultcode1", "env:FAULTCODE1");19 variable("faultstring1", "env:FAULTSTRING1");20 variable("faultactor1", "env:FAULTACTOR1");21 variable("detail1", "env:DETAIL1");22 variable("message1", "env:MESSAGE1");23 echo("Sending SOAP request message: ${faultcode} ${faultstring} ${faultactor} ${detail} ${message} ${faultcode1} ${faultstring1} ${faultactor1} ${detail1} ${message1}");24 send(webServiceClient)25 " <xsd:price>${faultcode}</xsd:price>\n" +26 " <xsd:quantity>${faultstring}</xsd:quantity>\n" +
getFaultCode
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class AssertSoapFaultJavaIT extends TestNGCitrusTestDesigner {5 public void assertSoapFaultJavaIT() {6 variable("faultCode", "soap:Server");7 variable("faultString", "Server Error");8 http().client("httpClient")9 .send()10 .post()11 .fork(true)12 "</soapenv:Envelope>");13 http().client("httpClient")14 .receive()15 .response(HttpStatus.INTERNAL_SERVER_ERROR)16 "</soapenv:Envelope>");17 soap().client("soapClient")18 .receive()19 .fault()20 .faultCode("${faultCode}")21 .faultString("${faultString}");22 soap().client("soapClient")23 .send()24 .soapFault()25 .faultCode("${faultCode}")26 .faultString("${faultString}");27 http().client("httpClient")28 .receive()29 .response(HttpStatus.OK)
getFaultCode
Using AI Code Generation
1public class AssertSoapFaultTest {2 public void assertSoapFaultTest() {3 description("AssertSoapFaultTest");4 variable("faultCode", "Sender");5 variable("faultString", "FaultString");6 variable("faultActor", "FaultActor");7 variable("faultDetail", "FaultDetail");8 send("sendRequest");9 receive("receiveResponse");10 assertSoapFault()11 .faultCode("${faultCode}")12 .faultString("${faultString}")13 .faultActor("${faultActor}")14 .faultDetail("${faultDetail}")15 .validate();16 }17}18public class AssertSoapFaultTest {19 public void assertSoapFaultTest() {20 description("AssertSoapFaultTest");21 variable("faultCode", "Sender");22 variable("faultString", "FaultString");23 variable("faultActor", "FaultActor");24 variable("faultDetail", "FaultDetail");25 send("sendRequest");26 receive("receiveResponse");27 assertSoapFault()28 .faultCode("${faultCode}")29 .faultString("${faultString}")30 .faultActor("${faultActor}")31 .faultDetail("${faultDetail}")32 .validate();33 }34}35public class AssertSoapFaultTest {36 public void assertSoapFaultTest() {37 description("AssertSoapFaultTest");38 variable("faultCode", "Sender");39 variable("faultString", "FaultString");40 variable("faultActor", "FaultActor");41 variable("faultDetail", "FaultDetail");42 send("sendRequest");43 receive("receiveResponse");44 assertSoapFault()45 .faultCode("${faultCode}")46 .faultString("${faultString}")47 .faultActor("${faultActor}")48 .faultDetail("${faultDetail}")49 .validate();50 }51}
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!!