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

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

Source:AssertSoapFaultTest.java Github

copy

Full Screen

...249 });250 251 assertAction.setFaultString("Internal server error");252 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");253 assertAction.getFaultDetails().add("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>");254 255 assertAction.execute(context);256 }257 258 @Test259 public void testAssertSoapFaultDetailVariableSupport() throws Exception {260 AssertSoapFault assertAction = new AssertSoapFault();261 assertAction.setValidator(soapFaultValidator);262 assertAction.setAction(new AbstractTestAction() {263 @Override264 public void doExecute(TestContext context) {265 SoapMessage faultMessage;266 267 faultMessage = messageFactory.createWebServiceMessage();268 269 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 270 "Internal server error", 271 Locale.GERMANY);272 273 try {274 TransformerFactory transformerFactory = TransformerFactory.newInstance();275 Transformer transformer = transformerFactory.newTransformer();276 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());277 } catch (TransformerException e) {278 throw new CitrusRuntimeException(e);279 }280 281 throw new SoapFaultClientException(faultMessage);282 }283 });284 285 context.setVariable("faultReason", "Invalid request");286 287 assertAction.setFaultString("Internal server error");288 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");289 assertAction.getFaultDetails().add("<FaultDetail><Reason>${faultReason}</Reason></FaultDetail>");290 291 assertAction.execute(context);292 }293 294 @Test295 public void testAssertSoapFaultDetailResource() throws Exception {296 AssertSoapFault assertAction = new AssertSoapFault();297 assertAction.setValidator(soapFaultValidator);298 assertAction.setAction(new AbstractTestAction() {299 @Override300 public void doExecute(TestContext context) {301 SoapMessage faultMessage;302 303 faultMessage = messageFactory.createWebServiceMessage();304 305 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 306 "Internal server error", 307 Locale.GERMANY);308 309 try {310 TransformerFactory transformerFactory = TransformerFactory.newInstance();311 Transformer transformer = transformerFactory.newTransformer();312 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());313 } catch (TransformerException e) {314 throw new CitrusRuntimeException(e);315 }316 317 throw new SoapFaultClientException(faultMessage);318 }319 });320 321 assertAction.setFaultString("Internal server error");322 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");323 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail.xml");324 325 assertAction.execute(context);326 }327 328 @Test329 public void testAssertSoapFaultDetailResourceVariableSupport() throws Exception {330 AssertSoapFault assertAction = new AssertSoapFault();331 assertAction.setValidator(soapFaultValidator);332 assertAction.setAction(new AbstractTestAction() {333 @Override334 public void doExecute(TestContext context) {335 SoapMessage faultMessage;336 337 faultMessage = messageFactory.createWebServiceMessage();338 339 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 340 "Internal server error", 341 Locale.GERMANY);342 343 try {344 TransformerFactory transformerFactory = TransformerFactory.newInstance();345 Transformer transformer = transformerFactory.newTransformer();346 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), fault.addFaultDetail().getResult());347 } catch (TransformerException e) {348 throw new CitrusRuntimeException(e);349 }350 351 throw new SoapFaultClientException(faultMessage);352 }353 });354 355 context.setVariable("faultReason", "Invalid request");356 357 assertAction.setFaultString("Internal server error");358 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");359 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail-with-variables.xml");360 361 assertAction.execute(context);362 }363 364 @Test365 public void testAssertMultipleSoapFaultDetails() throws Exception {366 AssertSoapFault assertAction = new AssertSoapFault();367 assertAction.setValidator(soapFaultValidator);368 assertAction.setAction(new AbstractTestAction() {369 @Override370 public void doExecute(TestContext context) {371 SoapMessage faultMessage;372 373 faultMessage = messageFactory.createWebServiceMessage();374 375 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 376 "Internal server error", 377 Locale.GERMANY);378 379 SoapFaultDetail faultDetail = fault.addFaultDetail();380 try {381 TransformerFactory transformerFactory = TransformerFactory.newInstance();382 Transformer transformer = transformerFactory.newTransformer();383 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), faultDetail.getResult());384 transformer.transform(new StringSource("<ErrorDetail><Code>1001</Code></ErrorDetail>"), faultDetail.getResult());385 } catch (TransformerException e) {386 throw new CitrusRuntimeException(e);387 }388 389 throw new SoapFaultClientException(faultMessage);390 }391 });392 393 assertAction.setFaultString("Internal server error");394 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");395 assertAction.getFaultDetails().add("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>");396 assertAction.getFaultDetails().add("<ErrorDetail><Code>1001</Code></ErrorDetail>");397 398 assertAction.execute(context);399 }400 401 @Test402 public void testAssertMultipleSoapFaultDetailsWithResource() throws Exception {403 AssertSoapFault assertAction = new AssertSoapFault();404 assertAction.setValidator(soapFaultValidator);405 assertAction.setAction(new AbstractTestAction() {406 @Override407 public void doExecute(TestContext context) {408 SoapMessage faultMessage;409 410 faultMessage = messageFactory.createWebServiceMessage();411 412 SoapFault fault =((Soap11Body)faultMessage.getSoapBody()).addFault(QNameUtils.parseQNameString("{http://citrusframework.org}ws:TEC-1001"), 413 "Internal server error", 414 Locale.GERMANY);415 416 SoapFaultDetail faultDetail = fault.addFaultDetail();417 try {418 TransformerFactory transformerFactory = TransformerFactory.newInstance();419 Transformer transformer = transformerFactory.newTransformer();420 transformer.transform(new StringSource("<ErrorDetail><Code>1001</Code></ErrorDetail>"), faultDetail.getResult());421 transformer.transform(new StringSource("<FaultDetail><Reason>Invalid request</Reason></FaultDetail>"), faultDetail.getResult());422 } catch (TransformerException e) {423 throw new CitrusRuntimeException(e);424 }425 426 throw new SoapFaultClientException(faultMessage);427 }428 });429 430 assertAction.setFaultString("Internal server error");431 assertAction.setFaultCode("{http://citrusframework.org}ws:TEC-1001");432 assertAction.getFaultDetails().add("<ErrorDetail><Code>1001</Code></ErrorDetail>");433 assertAction.getFaultDetailResourcePaths().add("classpath:com/consol/citrus/ws/actions/test-fault-detail.xml");434 435 assertAction.execute(context);436 }437}...

Full Screen

Full Screen

Source:AssertSoapFaultTestDesignerTest.java Github

copy

Full Screen

...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() {...

Full Screen

Full Screen

Source:AssertSoapFaultParserTest.java Github

copy

Full Screen

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

getFaultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.exceptions.CitrusRuntimeException;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapFault;6import com.consol.citrus.ws.message.SoapFaultDetail;7import com.consol.citrus.ws.message.SoapFaultDetailEntry;8import org.mockito.Mockito;9import org.springframework.ws.soap.SoapFaultDetailElement;10import org.springframework.ws.soap.SoapFaultDetailElementDefinition;11import org.springframework.ws.soap.SoapFaultDetailException;12import org.springframework.ws.soap.SoapFaultDetailText;13import org.springframework.ws.soap.SoapFaultDetailTextDefinition;14import org.springframework.ws.soap.SoapFaultDetailUnknownElement;15import org.springframework.ws.soap.SoapFaultDetailUnknownElementDefinition;16import org.springframework.ws.soap.SoapFaultDetailXml;17import org.springframework.ws.soap.SoapFaultDetailXmlDefinition;18import org.springframework.ws.soap.SoapFaultException;19import org.springframework.ws.soap.SoapFaultReason;20import org.springframework.ws.soap.SoapFaultReasonText;21import org.springframework.ws.soap.SoapFaultReasonTextDefinition;22import org.springframework.ws.soap.SoapFaultVersionMismatchException;23import org.springframework.ws.soap.SoapVersion;24import org.springframework.ws.soap.client.SoapFaultClientException;25import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition;26import org.testng.Assert;27import org.testng.annotations.Test;28import javax.xml.namespace.QName;29import java.util.ArrayList;30import java.util.Arrays;31import java.util.List;32public class AssertSoapFaultTest extends AbstractTestNGUnitTest {33 public void testGetFaultDetails() {34 SoapFaultDetailElementDefinition soapFaultDetailElementDefinition = Mockito.mock(SoapFaultDetailElementDefinition.class);35 SoapFaultDetailTextDefinition soapFaultDetailTextDefinition = Mockito.mock(SoapFaultDetailTextDefinition.class);36 SoapFaultDetailXmlDefinition soapFaultDetailXmlDefinition = Mockito.mock(SoapFaultDetailXmlDefinition.class);37 SoapFaultDetailUnknownElementDefinition soapFaultDetailUnknownElementDefinition = Mockito.mock(SoapFaultDetailUnknownElementDefinition.class);38 SoapFaultReasonTextDefinition soapFaultReasonTextDefinition = Mockito.mock(SoapFaultReasonTextDefinition.class);39 SoapFaultDefinition soapFaultDefinition = Mockito.mock(SoapFaultDefinition.class

Full Screen

Full Screen

getFaultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.exceptions.CitrusRuntimeException;4import com.consol.citrus.testng.AbstractTestNGUnitTest;5import com.consol.citrus.ws.message.SoapFault;6import org.mockito.Mockito;7import org.testng.Assert;8import org.testng.annotations.Test;9import org.w3c.dom.Document;10import org.w3c.dom.Node;11import org.w3c.dom.NodeList;12import javax.xml.namespace.QName;13import javax.xml.soap.SOAPBody;14import java.util.HashMap;15import java.util.Map;16public class AssertSoapFaultTest extends AbstractTestNGUnitTest {17 private AssertSoapFault action;18 private SOAPBody soapBody;19 private TestContext context;20 public void testGetFaultDetails() {21 action = new AssertSoapFault();22 action.setFaultCode("Server");23 action.setFaultString("faultString");24 action.setFaultActor("faultActor");25 action.setFaultDetail("faultDetail");26 soapBody = Mockito.mock(SOAPBody.class);27 context = Mockito.mock(TestContext.class);28 Document faultDetail = Mockito.mock(Document.class);29 Mockito.when(soapBody.getFault()).thenReturn(faultDetail);30 Mockito.when(faultDetail.getElementsByTagName("faultCode")).thenReturn(getNodeList("Server"));31 Mockito.when(faultDetail.getElementsByTagName("faultString")).thenReturn(getNodeList("faultString"));32 Mockito.when(faultDetail.getElementsByTagName("faultActor")).thenReturn(getNodeList("faultActor"));33 Mockito.when(faultDetail.getElementsByTagName("faultDetail")).thenReturn(getNodeList("faultDetail"));34 Map<String, String> faultDetails = action.getFaultDetails(soapBody, context);35 Assert.assertEquals(faultDetails.get("faultCode"), "Server");36 Assert.assertEquals(faultDetails.get("faultString"), "faultString");37 Assert.assertEquals(faultDetails.get("faultActor"), "faultActor");38 Assert.assertEquals(faultDetails.get("faultDetail"), "faultDetail");39 }40 public void testGetFaultDetailsWithEmptyFaultCode() {41 action = new AssertSoapFault();42 action.setFaultCode("");43 action.setFaultString("faultString");44 action.setFaultActor("faultActor");45 action.setFaultDetail("faultDetail");46 soapBody = Mockito.mock(SOAPBody.class);47 context = Mockito.mock(TestContext.class);

Full Screen

Full Screen

getFaultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.Citrus;3import com.consol.citrus.annotations.CitrusTest;4import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;5import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;6import com.consol.citrus.ws.actions.AssertSoapFault;7import org.springframework.http.HttpStatus;8import org.testng.annotations.Test;9public class 3 extends TestNGCitrusTestRunner {10 public void 3() {11 variable("faultCode", "soap:Server");12 variable("faultString", "Internal Server Error");13 variable("faultDetail", "com.consol.citrus.exceptions.CitrusRuntimeException: Error occurred: 'Error!'");14 variable("faultDetailPrefix", "sch");15 http()16 .client("httpClient")17 .send()18 .post()19 .fork(true)20 http()21 .client("httpClient")22 .receive()23 .response(HttpStatus.INTERNAL_SERVER_ERROR)24 soap()25 .client("soapClient")26 .receive()27 .fault()28 .faultCode("${faultCode}")29 .faultString("${faultString}")30 .faultActor("${faultActor}")31 .faultDetail("${faultDetail}")32 .faultDetailNamespace("${faultDetailNamespace}")33 .faultDetailPrefix("${faultDetailPrefix}");34 soap()35 .client("soapClient")36 .receive()37 .fault()38 .faultCode("${faultCode}")39 .faultString("${faultString}")40 .faultActor("${faultActor}")41 .faultDetail("${

Full Screen

Full Screen

getFaultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.testng.AbstractTestNGUnitTest;3import com.consol.citrus.ws.message.SoapFault;4import org.mockito.Mockito;5import org.testng.Assert;6import org.testng.annotations.Test;7public class AssertSoapFaultTest extends AbstractTestNGUnitTest {8 public void testGetFaultDetails() {9 SoapFault fault = Mockito.mock(SoapFault.class);10 Mockito.when(fault.getFaultCode()).thenReturn("FaultCode");11 Mockito.when(fault.getFaultString()).thenReturn("FaultString");12 Mockito.when(fault.getFaultActor()).thenReturn("FaultActor");13 Mockito.when(fault.getFaultDetail()).thenReturn("FaultDetail");14 AssertSoapFault assertSoapFault = new AssertSoapFault();15 assertSoapFault.setFault(fault);16 Assert.assertEquals(assertSoapFault.getFaultDetails(), "FaultCode: FaultString, FaultActor: FaultActor, FaultDetail: FaultDetail");17 }18}

Full Screen

Full Screen

getFaultDetails

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.junit.JUnit4CitrusTestRunner;4import com.consol.citrus.message.MessageType;5import com.consol.citrus.ws.actions.AssertSoapFault;6import com.consol.citrus.ws.message.SoapFault;7import org.junit.Test;8import org.springframework.http.HttpStatus;9import org.springframework.web.client.HttpClientErrorException;10public class AssertSoapFaultTest extends JUnit4CitrusTestRunner {11 public void assertSoapFaultTest() {12 variable("faultString", "Server Error");13 variable("faultCode", "soap:Server");14 variable("faultLanguage", "en-US");15 try {16 soap().client("sayHelloClient")17 .send()18 .soapAction("sayHelloFault")19 fail("Missing SOAP fault because of invalid request");20 } catch (HttpClientErrorException e) {21 AssertSoapFault assertSoapFault = new AssertSoapFault();22 assertSoapFault.setEndpoint("sayHelloClient");23 assertSoapFault.setFaultString("${faultString}");24 assertSoapFault.setFaultCode("${faultCode}");25 assertSoapFault.setFaultDetail("${faultDetail}");26 assertSoapFault.setFaultActor("${faultActor}");27 assertSoapFault.setFaultRole("${faultRole}");28 assertSoapFault.setFaultNode("${faultNode}");29 assertSoapFault.setFaultLanguage("${

Full Screen

Full Screen

getFaultDetails

Using AI Code Generation

copy

Full Screen

1public class 3.java extends AbstractTestNGCitrusTest {2 public void 3() {3 variable("faultCode", "soap:Server");4 variable("faultString", "Internal Server Error");5 variable("faultDetail", "Invalid request");6 soap().client("mySoapClient")7 .send()8 .soapAction("testAction")9 .payload("<testMessage>Hello Citrus!</testMessage>");10 soap().client("mySoapClient")11 .receive()12 .fault()13 .faultCode("${faultCode}")14 .faultString("${faultString}")15 .faultActor("${faultActor}")16 .faultDetail("${faultDetail}");17 }18}19public class 4.java extends AbstractTestNGCitrusTest {20 public void 4() {21 variable("faultCode", "soap:Server");22 variable("faultString", "Internal Server Error");23 variable("faultDetail", "Invalid request");24 soap().client("mySoapClient")25 .send()26 .soapAction("testAction")27 .payload("<testMessage>Hello Citrus!</testMessage>");28 soap().client("mySoapClient")29 .receive()30 .fault()31 .faultCode("${faultCode}")32 .faultString("${faultString}")33 .faultActor("${faultActor}")34 .faultDetail("${faultDetail}");35 }36}37public class 5.java extends AbstractTestNGCitrusTest {38 public void 5() {39 variable("faultCode", "soap:Server");40 variable("faultString", "Internal Server Error");41 variable("faultDetail", "Invalid request");42 soap().client("mySoapClient")43 .send()44 .soapAction("testAction")45 .payload("<testMessage>Hello Citrus!</testMessage>");46 soap().client("mySoapClient")47 .receive()48 .fault()

Full Screen

Full Screen

getFaultDetails

Using AI Code Generation

copy

Full Screen

1public class 3 extends CitrusTestDesigner {2 public void configure() {3 send(builder -> builder.endpoint(new HttpEndpoint.Builder()4 .build())5 "</soapenv:Envelope>"));6 receive(builder -> builder.endpoint(new HttpEndpoint.Builder()7 .build())8 "</soapenv:Envelope>"));9 send(builder -> builder.endpoint(new HttpEndpoint.Builder()10 .build())

Full Screen

Full Screen

getFaultDetails

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.actions.AssertSoapFault;5import org.springframework.http.HttpStatus;6import org.testng.annotations.Test;7public class GetFaultDetails extends TestNGCitrusTestRunner {8 public void getFaultDetails() {9 http(action -> action.client("httpClient")10 .send()11 .post()12 .fork(true)13</soapenv:Envelope>"));14 http(action -> action.client("httpClient")15 .receive()16 .response(HttpStatus.BAD_REQUEST));17 soap(action -> action.client("soapClient")18 .receive()19 .fault()20 .faultString("Division by zero is not allowed!")21 .faultDetailText("Division by zero is not allowed!")22 soap(action -> action.client("soapClient")23 .send()24 .fault()25 .faultString("Division by zero is not allowed!")26 .faultDetailText("Division by zero is not allowed!")27 http(action -> action.client("httpClient

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