How to use getFaultString method of com.consol.citrus.ws.actions.AssertSoapFault class

Best Citrus code snippet using com.consol.citrus.ws.actions.AssertSoapFault.getFaultString

Source:AssertSoapFaultBuilderTest.java Github

copy

Full Screen

...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}...

Full Screen

Full Screen

Source:AssertSoapFaultTestDesignerTest.java Github

copy

Full Screen

...65 66 Assert.assertEquals(container.getActionCount(), 1);67 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);68 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);69 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);70 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");71 }72 73 @Test74 public void testFaultDetail() {75 reset(applicationContextMock);76 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);77 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);78 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());79 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());80 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());81 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {82 @Override83 public void configure() {84 assertSoapFault()85 .faultCode(SOAP_ENV_SERVER_ERROR)86 .faultString(INTERNAL_SERVER_ERROR)87 .faultDetail("<ErrorDetail><message>FooBar</message></ErrorDetail>")88 .when(echo("${foo}"));89 }90 };91 builder.configure();92 TestCase test = builder.getTestCase();93 Assert.assertEquals(test.getActionCount(), 1);94 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);95 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");96 97 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));98 99 Assert.assertEquals(container.getActionCount(), 1);100 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);101 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);102 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);103 Assert.assertEquals(container.getFaultDetails().size(), 1L);104 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>FooBar</message></ErrorDetail>");105 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");106 }107 108 @Test109 public void testMultipleFaultDetails() {110 reset(applicationContextMock);111 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);112 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);113 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());114 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());115 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());116 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {117 @Override118 public void configure() {119 assertSoapFault()120 .faultCode(SOAP_ENV_SERVER_ERROR)121 .faultString(INTERNAL_SERVER_ERROR)122 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")123 .faultDetail("<MessageDetail><message>FooBar</message></MessageDetail>")124 .when(echo("${foo}"));125 }126 };127 builder.configure();128 TestCase test = builder.getTestCase();129 Assert.assertEquals(test.getActionCount(), 1);130 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);131 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");132 133 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));134 135 Assert.assertEquals(container.getActionCount(), 1);136 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);137 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);138 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);139 Assert.assertEquals(container.getFaultDetails().size(), 2L);140 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");141 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>FooBar</message></MessageDetail>");142 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");143 }144 145 @Test146 public void testFaultDetailResource() throws IOException {147 reset(resource, applicationContextMock);148 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<ErrorDetail><message>FooBar</message></ErrorDetail>".getBytes()));149 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);150 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);151 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());152 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());153 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());154 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {155 @Override156 public void configure() {157 assertSoapFault()158 .faultCode(SOAP_ENV_SERVER_ERROR)159 .faultString(INTERNAL_SERVER_ERROR)160 .faultDetailResource(resource)161 .when(echo("${foo}"));162 }163 };164 builder.configure();165 TestCase test = builder.getTestCase();166 Assert.assertEquals(test.getActionCount(), 1);167 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);168 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");169 170 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));171 172 Assert.assertEquals(container.getActionCount(), 1);173 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);174 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);175 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);176 Assert.assertEquals(container.getFaultDetails().size(), 1L);177 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><message>FooBar</message></ErrorDetail>");178 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");179 }180 @Test181 public void testFaultDetailResourcePath() {182 reset(applicationContextMock);183 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);184 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);185 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());186 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());187 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());188 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {189 @Override190 public void configure() {191 assertSoapFault()192 .faultCode(SOAP_ENV_SERVER_ERROR)193 .faultString(INTERNAL_SERVER_ERROR)194 .faultDetailResource("com/consol/citrus/soap/fault.xml")195 .when(echo("${foo}"));196 }197 };198 builder.configure();199 TestCase test = builder.getTestCase();200 Assert.assertEquals(test.getActionCount(), 1);201 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);202 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");203 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));204 Assert.assertEquals(container.getActionCount(), 1);205 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);206 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);207 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);208 Assert.assertEquals(container.getFaultDetails().size(), 0L);209 Assert.assertEquals(container.getFaultDetailResourcePaths().size(), 1L);210 Assert.assertEquals(container.getFaultDetailResourcePaths().get(0), "com/consol/citrus/soap/fault.xml");211 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");212 }213 214 @Test215 public void testMultipleFaultDetailsInlineAndResource() throws IOException {216 reset(resource, applicationContextMock);217 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<MessageDetail><message>FooBar</message></MessageDetail>".getBytes()));218 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);219 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);220 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());221 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());222 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());223 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {224 @Override225 public void configure() {226 assertSoapFault()227 .faultCode(SOAP_ENV_SERVER_ERROR)228 .faultString(INTERNAL_SERVER_ERROR)229 .faultDetail("<ErrorDetail><code>1001</code></ErrorDetail>")230 .faultDetailResource(resource)231 .when(echo("${foo}"));232 }233 };234 builder.configure();235 TestCase test = builder.getTestCase();236 Assert.assertEquals(test.getActionCount(), 1);237 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);238 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");239 240 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));241 242 Assert.assertEquals(container.getActionCount(), 1);243 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);244 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);245 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);246 Assert.assertEquals(container.getFaultDetails().size(), 2L);247 Assert.assertEquals(container.getFaultDetails().get(0), "<ErrorDetail><code>1001</code></ErrorDetail>");248 Assert.assertEquals(container.getFaultDetails().get(1), "<MessageDetail><message>FooBar</message></MessageDetail>");249 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");250 }251 252 @Test253 public void testAssertSoapFaultBuilderWithValidator() {254 reset(applicationContextMock);255 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);256 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);257 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());258 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());259 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());260 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {261 @Override262 public void configure() {263 assertSoapFault()264 .faultCode(SOAP_ENV_SERVER_ERROR)265 .faultString(INTERNAL_SERVER_ERROR)266 .validator(soapFaultValidator)267 .when(echo("${foo}"));268 }269 };270 builder.configure();271 TestCase test = builder.getTestCase();272 Assert.assertEquals(test.getActionCount(), 1);273 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);274 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");275 276 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));277 278 Assert.assertEquals(container.getActionCount(), 1);279 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);280 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);281 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);282 Assert.assertEquals(container.getValidator(), soapFaultValidator);283 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");284 }285 286 @Test287 public void testAssertSoapFaultBuilderWithActor() {288 reset(applicationContextMock);289 when(applicationContextMock.containsBean(SOAP_FAULT_VALIDATOR)).thenReturn(true);290 when(applicationContextMock.getBean(SOAP_FAULT_VALIDATOR, SoapFaultValidator.class)).thenReturn(soapFaultValidator);291 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());292 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());293 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());294 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {295 @Override296 public void configure() {297 assertSoapFault()298 .faultCode(SOAP_ENV_SERVER_ERROR)299 .faultString(INTERNAL_SERVER_ERROR)300 .faultActor("MyActor")301 .when(echo("${foo}"));302 }303 };304 builder.configure();305 TestCase test = builder.getTestCase();306 Assert.assertEquals(test.getActionCount(), 1);307 Assert.assertEquals(test.getActions().get(0).getClass(), AssertSoapFault.class);308 Assert.assertEquals(test.getActions().get(0).getName(), "soap-fault");309 310 AssertSoapFault container = (AssertSoapFault)(test.getTestAction(0));311 312 Assert.assertEquals(container.getActionCount(), 1);313 Assert.assertEquals(container.getAction().getClass(), EchoAction.class);314 Assert.assertEquals(container.getFaultCode(), SOAP_ENV_SERVER_ERROR);315 Assert.assertEquals(container.getFaultString(), INTERNAL_SERVER_ERROR);316 Assert.assertEquals(container.getFaultActor(), "MyActor");317 Assert.assertEquals(((EchoAction)(container.getAction())).getMessage(), "${foo}");318 }319}...

Full Screen

Full Screen

Source:AssertSoapFaultParserTest.java Github

copy

Full Screen

...34 AssertSoapFault action = getNextTestActionFromTest();35 Assert.assertNotNull(action.getAction());36 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("soapFaultValidator"));37 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1001");38 Assert.assertNull(action.getFaultString());39 Assert.assertEquals(action.getFaultDetails().size(), 0L);40 Assert.assertNull(action.getValidationContext());41 42 // 2nd action43 action = getNextTestActionFromTest();44 Assert.assertNotNull(action.getAction());45 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("soapFaultValidator"));46 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1002");47 Assert.assertEquals(action.getFaultString(), "FaultString");48 Assert.assertEquals(action.getFaultDetails().size(), 0L);49 Assert.assertNull(action.getValidationContext());50 51 // 3rd action52 action = getNextTestActionFromTest();53 Assert.assertNotNull(action.getAction());54 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("soapFaultValidator"));55 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1003");56 Assert.assertEquals(action.getFaultString(), "FaultString");57 Assert.assertEquals(action.getFaultActor(), "FaultActor");58 Assert.assertEquals(action.getFaultDetails().size(), 1L);59 Assert.assertEquals(action.getFaultDetails().get(0), "FaultDetail");60 Assert.assertEquals(((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().size(), 1L);61 62 // 4th action63 action = getNextTestActionFromTest();64 Assert.assertNotNull(action.getAction());65 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("customSoapFaultValidator"));66 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1004");67 Assert.assertEquals(action.getFaultString(), "FaultString");68 Assert.assertEquals(action.getFaultDetails().size(), 0L);69 Assert.assertEquals(action.getFaultDetailResourcePaths().size(), 1L);70 Assert.assertEquals(action.getFaultDetailResourcePaths().get(0), "classpath:com/consol/citrus/ws/actions/test-fault-detail.xml");71 Assert.assertEquals(((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().size(), 1L);72 73 // 5th action74 action = getNextTestActionFromTest();75 Assert.assertNotNull(action.getAction());76 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("soapFaultValidator"));77 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1003");78 Assert.assertEquals(action.getFaultString(), "FaultString");79 Assert.assertEquals(action.getFaultActor(), "FaultActor");80 Assert.assertEquals(action.getFaultDetails().size(), 1L);81 Assert.assertEquals(action.getFaultDetails().get(0), "FaultDetail");82 83 Assert.assertEquals(((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().size(), 1L);84 85 ValidationContext xmlValidationContext = ((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().get(0);86 Assert.assertTrue(xmlValidationContext instanceof XmlMessageValidationContext);87 Assert.assertTrue(((XmlMessageValidationContext)xmlValidationContext).isSchemaValidationEnabled());88 Assert.assertEquals(((XmlMessageValidationContext)xmlValidationContext).getSchemaRepository(), "fooSchemaRepository");89 Assert.assertNull(((XmlMessageValidationContext)xmlValidationContext).getSchema());90 91 // 6th action92 action = getNextTestActionFromTest();93 Assert.assertNotNull(action.getAction());94 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("soapFaultValidator"));95 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1003");96 Assert.assertEquals(action.getFaultString(), "FaultString");97 Assert.assertEquals(action.getFaultActor(), "FaultActor");98 Assert.assertEquals(action.getFaultDetails().size(), 1L);99 Assert.assertEquals(action.getFaultDetails().get(0), "FaultDetail");100 Assert.assertEquals(((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().size(), 1L);101 102 xmlValidationContext = ((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().get(0);103 Assert.assertTrue(xmlValidationContext instanceof XmlMessageValidationContext);104 Assert.assertTrue(((XmlMessageValidationContext)xmlValidationContext).isSchemaValidationEnabled());105 Assert.assertNull(((XmlMessageValidationContext)xmlValidationContext).getSchemaRepository());106 Assert.assertEquals(((XmlMessageValidationContext)xmlValidationContext).getSchema(), "fooSchema");107 108 // 7th action109 action = getNextTestActionFromTest();110 Assert.assertNotNull(action.getAction());111 Assert.assertEquals(action.getValidator(), beanDefinitionContext.getBean("soapFaultValidator"));112 Assert.assertEquals(action.getFaultCode(), "{http://www.citrusframework.org/faults}FAULT-1003");113 Assert.assertEquals(action.getFaultString(), "FaultString");114 Assert.assertEquals(action.getFaultActor(), "FaultActor");115 Assert.assertEquals(action.getFaultDetails().size(), 1L);116 Assert.assertEquals(action.getFaultDetails().get(0), "FaultDetail");117 Assert.assertEquals(((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().size(), 1L);118 119 xmlValidationContext = ((SoapFaultDetailValidationContext)action.getValidationContext()).getValidationContexts().get(0);120 Assert.assertTrue(xmlValidationContext instanceof XmlMessageValidationContext);121 Assert.assertFalse(((XmlMessageValidationContext)xmlValidationContext).isSchemaValidationEnabled());122 Assert.assertNull(((XmlMessageValidationContext)xmlValidationContext).getSchemaRepository());123 Assert.assertNull(((XmlMessageValidationContext)xmlValidationContext).getSchema());124 }125}...

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import org.springframework.http.HttpStatus;5import org.springframework.web.bind.annotation.GetMapping;6import org.springframework.web.bind.annotation.RequestMapping;7import org.springframework.web.bind.annotation.RestController;8@RequestMapping("/api")9public class SampleController extends TestNGCitrusTestDesigner {10 @GetMapping(value = "/echo")11 public void echo() {12 http().client("httpClient")13 .send()14 .get("/api/echo");15 http().client("httpClient")16 .receive()17 .response(HttpStatus.OK)18 .messageType(MessageType.XML)19 soap().client("soapClient")20 .send()21 .soapAction("echo")22 "</ns1:echo>");23 soap().client("soapClient")24 .receive()25 "</ns1:echoResponse>");26 soap().client("soapClient")27 .send()28 "</ns1:echo>");29 soap().client("soapClient")30 .receive()31 .fault("Server");32 soap().client("soapClient")33 .send()34 "</ns1:echo>");35 soap().client("soapClient")36 .receive()37 .fault("Server")38 .getFaultString();39 }40}41package com.consol.citrus.samples;42import com.consol.c

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {5 public void configure() {6 variable("faultString", "Something went wrong");7 soap().client("soapClient")8 .send()9 .soapFault()10 .faultString("${faultString}");11 soap().client("soapClient")12 .receive()13 .fault()14 .getFaultString()15 .validate("${faultString}");16 }17}18package com.consol.citrus.samples;19import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;20import org.testng.annotations.Test;21public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {22 public void configure() {23 soap().client("soapClient")24 .send()25 .soapFault()26 .faultString("Something went wrong");27 soap().client("soapClient")28 .receive()29 .fault()30 .getFaultString()31 .validate("Something went wrong");32 }33}34package com.consol.citrus.samples;35import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;36import org.testng.annotations.Test;37public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {38 public void configure() {39 variable("faultString", "Something went wrong");40 soap().client("soapClient")41 .send()42 .soapFault()43 .faultString("${faultString}");44 soap().client("soapClient")45 .receive()46 .fault()47 .getFaultString()48 .validate("Something went wrong");49 }50}

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.demo;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.springframework.http.HttpStatus;4import org.testng.annotations.Test;5public class AssertSoapFaultTest extends TestNGCitrusTestDesigner {6 public void testAssertSoapFault() {7 variable("faultString", "Server Error");8 http().client("httpClient")9 .send()10 .get("/soap")11 .accept("application/soap+xml");12 http().client("httpClient")13 .receive()14 .response(HttpStatus.INTERNAL_SERVER_ERROR);15 soap().client("soapClient")16 .send()17 .soapAction("getGreeting")18 "</getGreeting>");19 soap().client("soapClient")20 .receive()21 .fault()22 .faultString("${faultString}");23 soap().client("soapClient")24 .receive()25 .fault()26 .faultString("Server Error");27 soap().client("soapClient")28 .receive()29 .fault()30 .faultString("Server Error")31 soap().client("soapClient")32 .receive()33 .fault()34 .faultString("Server Error")35 "</faultDetail>");36 soap().client("soapClient")37 .receive()38 .fault()39 .faultString("Server Error")

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.springframework.ws.soap.SoapFault;4import org.testng.annotations.Test;5public class AssertSoapFaultJavaIT extends TestNGCitrusTestDesigner {6 public void assertSoapFaultJavaIT() {7 variable("faultCode", "Server");8 variable("faultString", "Internal Server Error");9 variable("faultDetail", "Error occurred while processing request");10 http().client("httpClient")11 .send()12 .post()13 .fork(true)14 "</soap:Envelope>");15 http().client("httpClient")16 .receive()17 .response(HttpStatus.BAD_REQUEST)18 "<faultcode>${faultCode}</faultcode>" +19 "<faultstring>${faultString}</faultstring>" +20 "<faultactor>${faultActor}</faultactor>" +21 "<detail>${faultDetail}</detail>" +22 .validateScript(new AssertSoapFault() {23 public void validateSoapFault(SoapFault soapFault) {24 assertEquals(soapFault.getFaultCode(), getFaultCode());25 assertEquals(soapFault.getFaultString(), getFaultString());26 assertEquals(soapFault.getFaultActor(), getFaultActor());27 assertEquals(soapFault.getFaultDetail().getTextContent(), getFaultDetail());28 }29 });30 http().client("httpClient")31 .receive()32 .response(HttpStatus.OK)

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class JavaTest extends TestNGCitrusTestDesigner {5public void JavaTest() {6 send("soapClient")7 "</soapenv:Envelope>");8 receive("soapClient")9 "</soapenv:Envelope>");10 send("soapClient")

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1public class 3.java {2 public static void main(String[] args) {3 AssertSoapFault assertSoapFault0 = new AssertSoapFault();4 assertSoapFault0.setFaultString("faultString");5 assertSoapFault0.setFaultString("faultString");6 }7}

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.design.TestDesigner;3import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;4import com.consol.citrus.ws.actions.AssertSoapFault;5import com.consol.citrus.ws.message.SoapFault;6import org.springframework.core.io.ClassPathResource;7import org.testng.annotations.Test;8public class AssertSoapFaultJavaITest extends TestDesignerBeforeSuiteSupport {9 public void assertSoapFaultJavaITest() {10 variable("operationName", "sayHello");11 variable("faultCode", "SOAP-ENV:Server");12 variable("faultString", "Internal Server Error");13 variable("faultDetail", "<faultDetail>Internal Server Error</faultDetail>");14 variable("errorMessage", "Internal Server Error");15 http(httpActionBuilder -> httpActionBuilder16 .client("httpClient")17 .send()18 .post()19 .payload(new ClassPathResource("templates/soap_fault_request.xml")));20 http(httpActionBuilder -> httpActionBuilder21 .client("httpClient")22 .receive()23 .response()24 .messageType("SOAP")25 .validateScript(new ClassPathResource("com/consol/citrus/ws/assertions/soap_fault_validator.groovy")));26 soap(soapActionBuilder -> soapActionBuilder27 .client("soapClient")28 .send()29 .soapAction("sayHello")30 soap(soapActionBuilder -> soapActionBuilder31 .client("soapClient")32 .receive()33 .fault()34 .faultCode("${faultCode}")35 .faultString("${faultString}")36 .faultActor("${faultActor}")37 .faultDetail("${faultDetail}")38 .validateScript(new ClassPathResource("com/consol/citrus/ws/assertions/soap_fault_validator.groovy")));39 soap(soapActionBuilder -> soapActionBuilder40 .client("soapClient")41 .receive()42 .fault()43 .faultCode("${faultCode}")44 .faultString("${faultString}")45 .faultActor("${faultActor}")

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.mycompany.tests;2import java.util.ArrayList;3import java.util.List;4import org.springframework.context.annotation.Bean;5import org.springframework.context.annotation.Configuration;6import org.springframework.context.annotation.Import;7import org.springframework.context.annotation.PropertySource;8import com.consol.citrus.dsl.builder.BuilderSupport;9import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder;10import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpServerResponseActionBuilderSupport;11import com.consol.citrus.dsl.builder.HttpServerResponseBuilder.HttpResponseResourceBuilder;12import com.consol.citrus.dsl.builder.SendBuilder;13import com.consol.citrus.dsl.design.TestDesigner;14import com.consol.citrus.dsl.runner.TestRunner;15import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;16import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;17import com.consol.citrus.http.client.HttpClient;18import com.consol.citrus.http.server.HttpServer;19import com.consol.citrus.message.MessageType;20import com.consol.citrus.testng.CitrusParameters;21import com.consol.citrus.ws.actions.AssertSoapFault;22import com.consol.citrus.ws.actions.SoapFaultAction;23import com.mycompany.tests.TestConfig;24public class SoapFaultTest extends TestNGCitrusTestRunner {25 public HttpClient soapClient() {26 return CitrusEndpoints.soap()27 .client()28 .build();29 }30 public HttpServer soapServer() {31 return CitrusEndpoints.soap()32 .server()33 .port(8080)34 .autoStart(true)35 .build();36 }37 public void soapFaultTest() {38 description("Tests a SOAP fault response from the SOAP service");39 http(action -> action.client(soapClient())40 .send()41 .post()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful