How to use getFaultCode method of com.consol.citrus.ws.message.SoapFault class

Best Citrus code snippet using com.consol.citrus.ws.message.SoapFault.getFaultCode

Source:AssertSoapFaultBuilderTest.java Github

copy

Full Screen

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

Full Screen

Full Screen

Source:SendSoapFaultActionTest.java Github

copy

Full Screen

...54 public Object answer(InvocationOnMock invocation) throws Throwable {55 Message sentMessage = (Message)invocation.getArguments()[0];56 Assert.assertTrue(sentMessage instanceof SoapFault);57 SoapFault soapFault = (SoapFault) sentMessage;58 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");59 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");60 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);61 return null;62 }63 }).when(producer).send(any(Message.class), any(TestContext.class));64 when(endpoint.getActor()).thenReturn(null);65 66 sendSoapFaultAction.execute(context);67 }68 69 @Test70 @SuppressWarnings("rawtypes")71 public void testSendSoapFaultWithActor() {72 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();73 sendSoapFaultAction.setEndpoint(endpoint);74 75 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");76 sendSoapFaultAction.setFaultString("Internal server error");77 sendSoapFaultAction.setFaultActor("SERVER");78 79 reset(endpoint, producer, endpointConfiguration);80 when(endpoint.createProducer()).thenReturn(producer);81 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);82 when(endpointConfiguration.getTimeout()).thenReturn(5000L);83 doAnswer(new Answer() {84 @Override85 public Object answer(InvocationOnMock invocation) throws Throwable {86 Message sentMessage = (Message)invocation.getArguments()[0];87 Assert.assertTrue(sentMessage instanceof SoapFault);88 SoapFault soapFault = (SoapFault) sentMessage;89 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");90 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");91 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);92 Assert.assertEquals(soapFault.getFaultActor(), "SERVER");93 return null;94 }95 }).when(producer).send(any(Message.class), any(TestContext.class));96 when(endpoint.getActor()).thenReturn(null);97 98 sendSoapFaultAction.execute(context);99 }100 101 @Test102 @SuppressWarnings("rawtypes")103 public void testSendSoapFaultMissingFaultString() {104 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();105 sendSoapFaultAction.setEndpoint(endpoint);106 107 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");108 109 reset(endpoint, producer, endpointConfiguration);110 when(endpoint.createProducer()).thenReturn(producer);111 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);112 when(endpointConfiguration.getTimeout()).thenReturn(5000L);113 doAnswer(new Answer() {114 @Override115 public Object answer(InvocationOnMock invocation) throws Throwable {116 Message sentMessage = (Message)invocation.getArguments()[0];117 Assert.assertTrue(sentMessage instanceof SoapFault);118 SoapFault soapFault = (SoapFault) sentMessage;119 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");120 Assert.assertNull(soapFault.getFaultString());121 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);122 return null;123 }124 }).when(producer).send(any(Message.class), any(TestContext.class));125 when(endpoint.getActor()).thenReturn(null);126 127 sendSoapFaultAction.execute(context);128 }129 130 @Test131 @SuppressWarnings("rawtypes")132 public void testSendSoapFaultWithVariableSupport() {133 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();134 sendSoapFaultAction.setEndpoint(endpoint);135 136 sendSoapFaultAction.setFaultCode("citrus:concat('{http://citrusframework.org}ws:', ${faultCode})");137 sendSoapFaultAction.setFaultString("${faultString}");138 139 context.setVariable("faultCode", "TEC-1000");140 context.setVariable("faultString", "Internal server error");141 reset(endpoint, producer, endpointConfiguration);142 when(endpoint.createProducer()).thenReturn(producer);143 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);144 when(endpointConfiguration.getTimeout()).thenReturn(5000L);145 doAnswer(new Answer() {146 @Override147 public Object answer(InvocationOnMock invocation) throws Throwable {148 Message sentMessage = (Message)invocation.getArguments()[0];149 Assert.assertTrue(sentMessage instanceof SoapFault);150 SoapFault soapFault = (SoapFault) sentMessage;151 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");152 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");153 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);154 return null;155 }156 }).when(producer).send(any(Message.class), any(TestContext.class));157 when(endpoint.getActor()).thenReturn(null);158 159 sendSoapFaultAction.execute(context);160 }161 162 @Test163 public void testSendSoapFaultMissingFaultCode() {164 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();165 sendSoapFaultAction.setEndpoint(endpoint);...

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;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.SoapFault;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.http.HttpStatus;8import org.springframework.ws.soap.client.SoapFaultClientException;9import org.testng.annotations.Test;10import java.util.HashMap;11import java.util.Map;12import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;13import static com.consol.citrus.actions.EchoAction.Builder.echo;14import static com.consol.citrus.actions.SendMessageAction.Builder.send;15import static com.consol.citrus.dsl.XpathSupport.xpath;16import static com.consol.citrus.validation.xml.XmlMessageValidationContext.Builder.xmlMessage;17public class SoapFaultTest extends TestNGCitrusTestRunner {18 private WebServiceClient weatherClient;19 public void testSoapFault() {20 description("Test to check SOAP fault response");21 variable("faultCode", "soap:Client");22 variable("faultString", "Invalid city");23 variable("city", "unknown");24 variable("country", "unknown");25 variable("faultCode", "soap:Client");26 variable("faultString", "Invalid city");27 variable("city", "unknown");28 variable("country", "unknown");29 send(weatherClient)30 "<ns:City>${city}</ns:City>" +31 "<ns:Country>${country}</ns:Country>" +32 "</ns:getWeather>");33 receive(weatherClient)34 "<ns:City>${city}</ns:City>" +35 "<ns:Country>${country}</ns:Country>" +36 .validationContext(xmlMessage()

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapFault;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.http.HttpStatus;8import org.testng.annotations.Test;9import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;10import static com.consol.citrus.actions.EchoAction.Builder.echo;11import static com.consol.citrus.actions.SendMessageAction.Builder.soap;12import static com.consol.citrus.validation.xml.XmlMessageValidationContext.Builder.xmlMessage;13import static org.hamcrest.CoreMatchers.is;14import static org.hamcrest.CoreMatchers.notNullValue;15public class SoapFaultTest extends TestNGCitrusTestDesigner {16 private WebServiceClient webServiceClient;17 public void soapFaultTest() {18 variable("soapFault", SoapFault.class);19 variable("faultCode", String.class);20 send(soap()21 .client(webServiceClient)22 "<ns0:Text>citrus:concat('Hello ', citrus:randomNumber(3))</ns0:Text>" +23 .soapAction("SayHello")24 .fork(true));25 receive(receiveBuilder -> receiveBuilder.endpoint(webServiceClient)26 .messageType(SoapFault.class)27 .message(new SoapFault(HttpStatus.BAD_REQUEST)28 .faultString("Invalid request message payload!")29 .validationContext(xmlMessage()30 .schemaValidation(false)

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import org.testng.annotations.Test;3import org.testng.Assert;4import org.testng.annotations.Test;5import org.testng.Assert;6import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;7import com.consol.citrus.ws.message.SoapFault;8public class SoapFaultTest extends TestNGCitrusTestDesigner {9 public void soapFaultTest() {10 Assert.assertEquals(soapFault.getFaultCode(), "soap:Server");11 }12}13Method soapFaultTest() should be public14at org.testng.internal.MethodHelper.checkMethodIsPublic(MethodHelper.java:225)15at org.testng.internal.MethodHelper.checkMethod(MethodHelper.java:212)16at org.testng.internal.MethodHelper.findMethods(MethodHelper.java:127)17at org.testng.internal.Configuration.getTestMethods(Configuration.java:1020)18at org.testng.internal.Invoker.getTestMethods(Invoker.java:1462)19at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:635)20at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)21at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)22at org.testng.TestRunner.privateRun(TestRunner.java:756)23at org.testng.TestRunner.run(TestRunner.java:610)24at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)25at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)26at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)27at org.testng.SuiteRunner.run(SuiteRunner.java:289)28at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)29at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)30at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)31at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)32at org.testng.TestNG.runSuites(TestNG.java:1144)33at org.testng.TestNG.run(TestNG.java:1115)34at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:116)35at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)36at org.testng.remote.RemoteTestNG.main(Remote

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.message;2import org.testng.annotations.Test;3import org.testng.Assert;4import org.testng.annotations.Test;5import org.testng.Assert;6import org.springframework.ws.soap.SoapFault;7import org.springframework.ws.soap.SoapFaultDetail;8import org.springframework.ws.soap.SoapFaultDetailElement;9import org.springframework.ws.soap.SoapFaultReason;10import org.springframework.ws.soap.SoapFaultDetail;11import org.springframework.ws.soap.SoapFaultDetailElement;12import org.springframework.ws.soap.SoapFaultReason;13import org.springframework.ws.soap.SoapFaultDetail;14import org.springframework.ws.soap.SoapFaultDetailElement;15import org.springframework.ws.soap.SoapFaultReason;16import org.springframework.ws.soap.SoapFaultDetail;17import org.springframework.ws.soap.SoapFaultDetailElement;18import org.springframework.ws.soap.SoapFaultReason;19import org.springframework.ws.soap.SoapFaultDetail;20import org.springframework.ws.soap.SoapFaultDetailElement;21import org.springframework.ws.soap.SoapFaultReason;22import org.springframework.ws.soap.SoapFaultDetail;23import org.springframework.ws.soap.SoapFaultDetailElement;24import org.springframework.ws.soap.SoapFaultReason;25import javax.xml.namespace.QName;26import java.util.Iterator;27public class SoapFaultTest {28 public void testGetFaultCode() {29 SoapFault soapFault = new SoapFault() {30 public QName getFaultCode() {31 return null;32 }33 public void setFaultCode(QName faultCode) {34 }35 public String getFaultStringOrReason() {36 return null;37 }38 public void setFaultStringOrReason(String faultStringOrReason) {39 }40 public SoapFaultDetail getFaultDetail() {41 return null;42 }43 public SoapFaultReason getFaultReason() {44 return null;45 }46 };47 SoapFault soapFault1 = new SoapFault() {48 public QName getFaultCode() {49 return null;50 }51 public void setFaultCode(QName faultCode) {52 }53 public String getFaultStringOrReason() {54 return null;55 }56 public void setFaultStringOrReason(String faultStringOrReason) {57 }

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1public class 3 {2 public static void main(String[] args) {3 SoapFault fault = new SoapFault();4 fault.setFaultCode("Server");5 System.out.println(fault.getFaultCode());6 }7}8com.consol.citrus.ws.message.SoapFault.getFaultString()9public class 4 {10 public static void main(String[] args) {11 SoapFault fault = new SoapFault();12 fault.setFaultString("Server Error");13 System.out.println(fault.getFaultString());14 }15}16com.consol.citrus.ws.message.SoapFault.getFaultActor()17public class 5 {18 public static void main(String[] args) {19 SoapFault fault = new SoapFault();20 System.out.println(fault.getFaultActor());21 }22}23com.consol.citrus.ws.message.SoapFault.getFaultDetail()24public class 6 {25 public static void main(String[] args) {26 SoapFault fault = new SoapFault();27 fault.setFaultDetail("Server Error");28 System.out.println(fault.getFaultDetail());29 }30}31com.consol.citrus.ws.message.SoapFault.setFaultCode()32public class 7 {33 public static void main(String[] args) {34 SoapFault fault = new SoapFault();35 fault.setFaultCode("Server");36 System.out.println(fault.getFaultCode());37 }38}39com.consol.citrus.ws.message.SoapFault.setFaultString()40public class 8 {

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws;2import org.springframework.context.support.ClassPathXmlApplicationContext;3import org.testng.annotations.Test;4import com.consol.citrus.context.TestContext;5import com.consol.citrus.message.MessageType;6import com.consol.citrus.testng.AbstractTestNGUnitTest;7public class getFaultCodeTest extends AbstractTestNGUnitTest {8 public void testGetFaultCode() {9 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:com/consol/citrus/ws/getFaultCodeTest.xml");10 SoapFault soapFault = new SoapFault();11 soapFault.setFaultString("Sender fault string");12 soapFault.setFaultActor("Sender actor");13 soapFault.setFaultDetail("Sender detail");14 TestContext ctx = new TestContext();15 soapFault.getFaultCode(ctx);16 }17}18package com.consol.citrus.ws;19import org.springframework.context.support.ClassPathXmlApplicationContext;20import org.testng.annotations.Test;21import com.consol.citrus.context.TestContext;22import com.consol.citrus.message.MessageType;23import com.consol.citrus.testng.AbstractTestNGUnitTest;24public class getFaultStringTest extends AbstractTestNGUnitTest {25 public void testGetFaultString() {26 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:com/consol/citrus/ws/getFaultStringTest.xml");27 SoapFault soapFault = new SoapFault();28 soapFault.setFaultString("Sender fault string");29 soapFault.setFaultActor("Sender actor");30 soapFault.setFaultDetail("Sender detail");31 TestContext ctx = new TestContext();32 soapFault.getFaultString(ctx);33 }34}35package com.consol.citrus.ws;36import org.springframework.context.support.ClassPathXmlApplicationContext;37import org.testng.annotations.Test;38import com.consol.citrus.context.TestContext;39import com.consol.cit

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1public class 3 {2public static void main(String[] args) {3SoapFault soapFault = new SoapFault();4soapFault.setFaultCode("soap:Server");5System.out.println(soapFault.getFaultCode());6}7}8public class 4 {9public static void main(String[] args) {10SoapFault soapFault = new SoapFault();11System.out.println(soapFault.getFaultActor());12}13}14public class 5 {15public static void main(String[] args) {16SoapFault soapFault = new SoapFault();17soapFault.setFaultString("Invalid operation");18System.out.println(soapFault.getFaultString());19}20}21public class 6 {22public static void main(String[] args) {23SoapFault soapFault = new SoapFault();24soapFault.setFaultStringOrReason("Invalid operation");25System.out.println(soapFault.getFaultStringOrReason());26}27}28public class 7 {29public static void main(String[] args) {30SoapFault soapFault = new SoapFault();31soapFault.setFaultDetail("Invalid operation");32System.out.println(soapFault.getFaultDetail());33}34}

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.testng.CitrusParameters;5import org.testng.annotations.Test;6public class GetFaultCode extends TestNGCitrusTestDesigner {7 @CitrusParameters({"message"})8 public void getFaultCode(String message) {9 variable("faultCode", "soap:Server");10 echo("Fault code is ${faultCode}");11 }12}13package com.consol.citrus.samples;14import com.consol.citrus.context.TestContext;15import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;16import com.consol.citrus.testng.CitrusParameters;17import org.testng.annotations.Test;18public class GetFaultString extends TestNGCitrusTestDesigner {19 @CitrusParameters({"message"})20 public void getFaultString(String message) {21 variable("faultString", "Server Error");22 echo("Fault string is ${faultString}");23 }24}25package com.consol.citrus.samples;26import com.consol.citrus.context.TestContext;27import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;28import com.consol.citrus.testng.CitrusParameters;29import org.testng.annotations.Test;30public class GetFaultActor extends TestNGCitrusTestDesigner {31 @CitrusParameters({"message"})32 public void getFaultActor(String message) {33 echo("Fault actor is ${faultActor}");34 }35}36package com.consol.citrus.samples;37import com.consol.citrus.context.TestContext;38import

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1public class getFaultCode extends CitrusTestDesigner {2 public void getFaultCode() {3 soap().client("soapClient")4 .send()5 .soapAction("getFaultCode")6 + "<text>citrus:concat('Hello ', 'World!')</text>"7 + "</getFaultCode>");8 soap().client("soapClient")9 .receive()10 .fault()11 }12}13public class getFaultString extends CitrusTestDesigner {14 public void getFaultString() {15 soap().client("soapClient")16 .send()17 .soapAction("getFaultString")18 + "<text>citrus:concat('Hello ', 'World!')</text>"19 + "</getFaultString>");20 soap().client("soapClient")21 .receive()22 .fault()23 .faultString("HelloServiceException: Hello World!");24 }25}26public class getFaultActor extends CitrusTestDesigner {27 public void getFaultActor() {28 soap().client("soapClient")29 .send()30 .soapAction("getFaultActor")31 + "<text>citrus:concat('Hello ', 'World!')</text>"32 + "</getFaultActor>");33 soap().client("soapClient")34 .receive()35 .fault()36 }37}

Full Screen

Full Screen

getFaultCode

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.ws.message.SoapFault;2import com.consol.citrus.message.Message;3import com.consol.citrus.context.TestContext;4import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;5import org.testng.annotations.Test;6import org.testng.annotations.BeforeClass;7import org.testng.annotations.AfterClass;8public class 3 extends TestNGCitrusTestDesigner {9 public void beforeClass() {10 echo("This is a code to use getFaultCode method of com.consol.citrus.ws.message.SoapFault class to get the fault code from the soap fault message");11 }12 public void 3() {13 variable("faultCode", "soap:Client");14 variable("faultString", "soap:Client");15 variable("faultActor", "soap:Client");16 variable("faultDetail", "soap:Client");17 variable("faultCodeNS", "soap:Client");18 variable("faultStringNS", "soap:Client");19 variable("faultActorNS", "soap:Client");20 variable("faultDetailNS", "soap:Client");21 variable("faultCodeNSPrefix", "soap:Client");22 variable("faultStringNSPrefix", "soap:Client");23 variable("faultActorNSPrefix", "soap:Client");24 variable("faultDetailNSPrefix", "soap:Client");25 variable("faultCodeNSURI", "soap:Client");26 variable("faultStringNSURI", "soap:Client");27 variable("faultActorNSURI", "soap:Client");28 variable("faultDetailNSURI", "soap:Client");29 variable("faultCodeNSValue", "soap:Client");30 variable("faultStringNSValue", "soap:Client");31 variable("faultActorNSValue", "soap:Client");32 variable("faultDetailNSValue", "soap:Client");33 variable("faultCodeQName", "soap:Client");34 variable("faultStringQName", "soap:Client");35 variable("faultActorQName", "soap:Client");36 variable("faultDetailQName", "soap:Client");37 variable("faultCodeQNameLocalPart", "soap:Client");38 variable("faultStringQNameLocalPart", "soap:Client");39 variable("faultActorQNameLocalPart", "soap

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.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful