Best Citrus code snippet using com.consol.citrus.ws.validation.SoapFaultDetailValidationContext
Source:AssertSoapFaultParserTest.java
...17import com.consol.citrus.testng.AbstractActionParserTest;18import com.consol.citrus.validation.context.ValidationContext;19import com.consol.citrus.validation.xml.XmlMessageValidationContext;20import com.consol.citrus.ws.actions.AssertSoapFault;21import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;22import org.testng.Assert;23import org.testng.annotations.Test;24/**25 * @author Christoph Deppisch26 */27public class AssertSoapFaultParserTest extends AbstractActionParserTest<AssertSoapFault> {28 @Test29 public void testAssertSoapFaultParser() {30 assertActionCount(7);31 assertActionClassAndName(AssertSoapFault.class, "soap-fault");32 33 // 1st action34 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}...
Source:AssertSoapFaultBuilder.java
...19import com.consol.citrus.exceptions.CitrusRuntimeException;20import com.consol.citrus.util.FileUtils;21import com.consol.citrus.validation.xml.XmlMessageValidationContext;22import com.consol.citrus.ws.actions.AssertSoapFault;23import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;24import com.consol.citrus.ws.validation.SoapFaultValidator;25import org.springframework.context.ApplicationContext;26import org.springframework.core.io.Resource;27import java.io.IOException;28import java.nio.charset.Charset;29/**30 * @author Christoph Deppisch31 * since 2.332 */33public class AssertSoapFaultBuilder extends AbstractExceptionContainerBuilder<AssertSoapFault> {34 private XmlMessageValidationContext validationContext = new XmlMessageValidationContext();35 /**36 * Constructor using action field.37 * @param designer38 * @param action39 */40 public AssertSoapFaultBuilder(TestDesigner designer, AssertSoapFault action) {41 super(designer, action);42 // for now support one single soap fault detail43 SoapFaultDetailValidationContext soapFaultDetailValidationContext = new SoapFaultDetailValidationContext();44 soapFaultDetailValidationContext.addValidationContext(validationContext);45 action.setValidationContext(soapFaultDetailValidationContext);46 }47 /**48 * Default constructor49 * @param designer50 */51 public AssertSoapFaultBuilder(TestDesigner designer) {52 this(designer, new AssertSoapFault());53 }54 /**55 * Default constructor using runner and action container.56 * @param runner57 * @param action58 */59 public AssertSoapFaultBuilder(TestRunner runner, AssertSoapFault action) {60 super(runner, action);61 // for now support one single soap fault detail62 SoapFaultDetailValidationContext soapFaultDetailValidationContext = new SoapFaultDetailValidationContext();63 soapFaultDetailValidationContext.addValidationContext(validationContext);64 action.setValidationContext(soapFaultDetailValidationContext);65 }66 /**67 * Default constructor using test runner.68 * @param runner69 */70 public AssertSoapFaultBuilder(TestRunner runner) {71 this(runner, new AssertSoapFault());72 }73 /**74 * Expect fault code in SOAP fault message.75 * @param code76 * @return...
Source:AssertSoapFaultParser.java
...19import com.consol.citrus.config.xml.DescriptionElementParser;20import com.consol.citrus.util.FileUtils;21import com.consol.citrus.validation.xml.XmlMessageValidationContext;22import com.consol.citrus.ws.actions.AssertSoapFault;23import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;24import org.apache.xerces.util.DOMUtil;25import org.springframework.beans.factory.BeanCreationException;26import org.springframework.beans.factory.config.BeanDefinition;27import org.springframework.beans.factory.support.BeanDefinitionBuilder;28import org.springframework.beans.factory.xml.BeanDefinitionParser;29import org.springframework.beans.factory.xml.ParserContext;30import org.springframework.util.StringUtils;31import org.springframework.util.xml.DomUtils;32import org.w3c.dom.Element;33import java.util.*;34/**35 * Parser for SOAP fault assert action.36 * 37 * @author Christoph Deppisch38 */39public class AssertSoapFaultParser implements BeanDefinitionParser {40 public BeanDefinition parse(Element element, ParserContext parserContext) {41 BeanDefinitionBuilder beanDefinition;42 beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(AssertSoapFault.class);43 DescriptionElementParser.doParse(element, beanDefinition);44 BeanDefinitionParserUtils.setPropertyValue(beanDefinition, element.getAttribute("fault-code"), "faultCode");45 BeanDefinitionParserUtils.setPropertyValue(beanDefinition, element.getAttribute("fault-string"), "faultString");46 BeanDefinitionParserUtils.setPropertyValue(beanDefinition, element.getAttribute("fault-actor"), "faultActor");47 48 List<Element> faultDetails = DomUtils.getChildElementsByTagName(element, "fault-detail");49 SoapFaultDetailValidationContext validationContext = new SoapFaultDetailValidationContext();50 List<String> soapFaultDetails = new ArrayList<String>();51 List<String> soapFaultDetailPaths = new ArrayList<String>();52 for (Element faultDetailElement : faultDetails) {53 if (faultDetailElement.hasAttribute("file")) {54 if (StringUtils.hasText(DomUtils.getTextValue(faultDetailElement).trim())) {55 throw new BeanCreationException("You tried to set fault-detail by file resource attribute and inline text value at the same time! " +56 "Please choose one of them.");57 }58 String charset = faultDetailElement.getAttribute("charset");59 String filePath = faultDetailElement.getAttribute("file");60 soapFaultDetailPaths.add(filePath + (StringUtils.hasText(charset) ? FileUtils.FILE_PATH_CHARSET_PARAMETER + charset : ""));61 } else {62 String faultDetailData = DomUtils.getTextValue(faultDetailElement).trim();63 if (StringUtils.hasText(faultDetailData)) {...
SoapFaultDetailValidationContext
Using AI Code Generation
1package com.consol.citrus.ws;2import com.consol.citrus.testng.AbstractTestNGUnitTest;3import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;4import org.testng.Assert;5import org.testng.annotations.Test;6public class SoapFaultDetailValidationContextTest extends AbstractTestNGUnitTest {7 public void testValidationContext() {8 SoapFaultDetailValidationContext validationContext = new SoapFaultDetailValidationContext();9 validationContext.setValidationContext("test");10 Assert.assertEquals(validationContext.getValidationContext(), "test");11 }12}
SoapFaultDetailValidationContext
Using AI Code Generation
1public class SoapFaultDetailValidationContextTest {2 public void testSoapFaultDetailValidationContext() {3 SoapFaultDetailValidationContext soapFaultDetailValidationContext = new SoapFaultDetailValidationContext();4 soapFaultDetailValidationContext.setIgnoreNamespaces(true);5 soapFaultDetailValidationContext.setIgnoreWhitespace(true);6 soapFaultDetailValidationContext.setIgnoreComments(true);7 soapFaultDetailValidationContext.setIgnoreProcessingInstructions(true);8 soapFaultDetailValidationContext.setIgnoreDTD(true);9 soapFaultDetailValidationContext.setIgnoreAttributeOrder(true);10 soapFaultDetailValidationContext.setIgnoreXPathNamespacePrefixes(true);11 soapFaultDetailValidationContext.setIgnoreXPathNamespaces(true);12 soapFaultDetailValidationContext.setIgnoreXPathComments(true);13 soapFaultDetailValidationContext.setIgnoreXPathWhitespace(true);14 soapFaultDetailValidationContext.setIgnoreXPathProcessingInstructions(true);15 soapFaultDetailValidationContext.setIgnoreXPathDTD(true);16 soapFaultDetailValidationContext.setIgnoreXPathAttributeOrder(true);17 soapFaultDetailValidationContext.setIgnoreXPathNamespacePrefixes(true);18 soapFaultDetailValidationContext.setIgnoreXPathNamespaces(true);19 soapFaultDetailValidationContext.setIgnoreXPathComments(true);20 soapFaultDetailValidationContext.setIgnoreXPathWhitespace(true);21 soapFaultDetailValidationContext.setIgnoreXPathProcessingInstructions(true);22 soapFaultDetailValidationContext.setIgnoreXPathDTD(true);23 soapFaultDetailValidationContext.setIgnoreXPathAttributeOrder(true);24 soapFaultDetailValidationContext.setIgnoreXPathNamespacePrefixes(true);25 soapFaultDetailValidationContext.setIgnoreXPathNamespaces(true);26 soapFaultDetailValidationContext.setIgnoreXPathComments(true);27 soapFaultDetailValidationContext.setIgnoreXPathWhitespace(true);28 soapFaultDetailValidationContext.setIgnoreXPathProcessingInstructions(true);29 soapFaultDetailValidationContext.setIgnoreXPathDTD(true);30 soapFaultDetailValidationContext.setIgnoreXPathAttributeOrder(true);31 soapFaultDetailValidationContext.setIgnoreXPathNamespacePrefixes(true);32 soapFaultDetailValidationContext.setIgnoreXPathNamespaces(true);33 soapFaultDetailValidationContext.setIgnoreXPathComments(true);34 soapFaultDetailValidationContext.setIgnoreXPathWhitespace(true);35 soapFaultDetailValidationContext.setIgnoreXPathProcessingInstructions(true);36 soapFaultDetailValidationContext.setIgnoreXPathDTD(true);37 soapFaultDetailValidationContext.setIgnoreXPathAttributeOrder(true);38 soapFaultDetailValidationContext.setIgnoreXPathNamespacePrefixes(true);39 soapFaultDetailValidationContext.setIgnoreXPathNamespaces(true);
SoapFaultDetailValidationContext
Using AI Code Generation
1public class SoapFaultDetailValidationContextTest {2 private SoapFaultDetailValidationContext validationContext;3 private SoapFaultDetailValidationContext validationContext1;4 private SoapFaultDetailValidationContext validationContext2;5 private SoapFaultDetailValidationContext validationContext3;6 public void setUp() {7 validationContext = new SoapFaultDetailValidationContext();8 validationContext1 = new SoapFaultDetailValidationContext();9 validationContext2 = new SoapFaultDetailValidationContext();10 validationContext3 = new SoapFaultDetailValidationContext();11 }12 public void testValidationContext() {13 validationContext.setPath("/fault/detail");14 validationContext.setXpathExpressions(Collections.singletonMap("myns:detail", "myns:detail"));15 validationContext1.setPath("/fault/detail");16 validationContext1.setXpathExpressions(Collections.singletonMap("myns:detail", "myns:detail"));17 validationContext2.setPath("/fault/detail");18 validationContext2.setXpathExpressions(Collections.singletonMap("myns:detail", "myns:detail"));19 validationContext3.setPath("/fault/detail");20 validationContext3.setXpathExpressions(Collections.singletonMap("myns:detail", "myns:detail"));21 Assert.assertEquals(validationContext, validationContext1);22 Assert.assertEquals(validationContext.hashCode(), validationContext1.hashCode());23 Assert.assertEquals(validationContext, validationContext2);24 Assert.assertEquals(validationContext.hashCode(), validationContext2.hashCode());25 Assert.assertEquals(validationContext, validationContext3);26 Assert.assertEquals(validationContext.hashCode(), validationContext3.hashCode());27 }28}
SoapFaultDetailValidationContext
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.endpoint.CitrusEndpoints;3import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;4import com.consol.citrus.dsl.runner.TestRunner;5import com.consol.citrus.ws.actions.SoapActionBuilder;6import com.consol.citrus.ws.client.WebServiceClient;7import com.consol.citrus.ws.message.SoapFault;8import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;9import org.springframework.context.annotation.Bean;10import org.springframework.context.annotation.Configuration;11import org.springframework.ws.soap.SoapFaultDetail;12public class SoapFaultDetailValidationContextTest extends JUnit4CitrusTestDesigner {13 public WebServiceClient soapClient() {14 return CitrusEndpoints.soap()15 .client()16 .build();17 }18 public void configure() {19 SoapFaultDetailValidationContext validationContext = new SoapFaultDetailValidationContext();20 SoapFault soapFault = new SoapFault();21 soapFault.setValidationContext(validationContext);22 SoapFaultDetail soapFaultDetail = new SoapFaultDetail();23 soapFaultDetail.addFaultDetailElementName("error");24 soapFaultDetail.addFaultDetailElementAttribute("code", "404");25 soapFault.setFaultDetail(soapFaultDetail);26 soapFault.setFaultStringOrReason("Service not found");27 soapFault.setFaultCodeOrSubcode("soap:Client");28 send(soapClient())29 .soap()30 .fault(soapFault);31 }32}
SoapFaultDetailValidationContext
Using AI Code Generation
1package com.consol.citrus.validation.soap;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.ws.actions.SoapActionBuilder;5import com.consol.citrus.ws.validation.SoapFaultDetailValidationContext;6import org.springframework.http.HttpStatus;7import org.springframework.web.bind.annotation.RequestMapping;8import org.springframework.web.bind.annotation.RequestMethod;9import org.springframework.web.bind.annotation.RestController;10import org.testng.annotations.Test;11import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;12import static com.consol.citrus.actions.EchoAction.Builder.echo;13import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQL;14import static com.consol.citrus.actions.SendMessageAction.Builder.withSoapMessage;15import static com.consol.citrus.actions.SoapAction.Builder.soap;16import static com.consol.citrus.container.Assert.Builder.assertException;17import static com.consol.citrus.container.Sequence.Builder.sequential;18import static com.consol.citrus.ws.actions.SoapActionBuilder.soap;19public class SoapFaultDetailValidation_IT extends AbstractSoapIT {20 @CitrusParameters({"soapVersion"})21 public void soapFaultDetailValidation(String soapVersion) {22 SoapActionBuilder soapActionBuilder = soap().client("soapClient")23 .soapAction("getEmployeeRequest")24 .version(soapVersion);25 run(sequential(26 soapActionBuilder.send()27 soapActionBuilder.receive()28 soapActionBuilder.send()
SoapFaultDetailValidationContext
Using AI Code Generation
1public class 3 extends TestNGCitrusTestDesigner {2 public void configure() {3 soap()4 .client("soapClient")5 .send()6 .soapAction("getWeatherRequest")7 "</ns0:getWeather>");8 soap()9 .client("soapClient")10 .receive()11 .fault()12 .faultString("Validation error")13 .detail()14 .validationContext(new SoapFaultDetailValidationContext()15 .xpath("ns0:getWeather/ns0:City", "London")16 .xpath("ns0:getWeather/ns0:City", "Paris")17 .xpath("ns0:getWeather/ns0:City", "Berlin"));18 }19}20public class 4 extends TestNGCitrusTestDesigner {21 public void configure() {22 soap()23 .client("soapClient")24 .send()25 .soapAction("getWeatherRequest")26 "</ns0:getWeather>");27 soap()28 .client("soapClient")29 .receive()30 .fault()31 .faultString("Validation error")32 .detail()33 .validationContext(new SoapFaultDetailValidationContext()34 .xpath("ns0:getWeather/ns0:City", "London")35 .xpath("ns0:getWeather/ns0:City", "Paris")36 .xpath("ns0:getWeather/ns0:City", "Berlin"));37 }38}39public class 5 extends TestNGCitrusTestDesigner {40 public void configure() {41 soap()
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!