How to use afterPropertiesSet method of com.consol.citrus.xml.XsdSchemaRepository class

Best Citrus code snippet using com.consol.citrus.xml.XsdSchemaRepository.afterPropertiesSet

Source:DomXmlMessageValidatorTest.java Github

copy

Full Screen

...52 53 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();54 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");55 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);56 schema.afterPropertiesSet();57 58 schemaRepository.getSchemas().add(schema);59 60 validator.addSchemaRepository(schemaRepository);61 62 validator.validateXMLSchema(message, new XmlMessageValidationContext());63 }64 @Test65 public void validateXMLSchemaNested() throws Exception {66 Message message = new DefaultMessage("<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +67 "<SOAP-ENV:Header/>" +68 "<SOAP-ENV:Body>" +69 "<message xmlns=\"http://citrusframework.org/test\">"70 + "<correlationId>Kx1R123456789</correlationId>"71 + "<bookingId>Bx1G987654321</bookingId>"72 + "<test>Hello TestFramework</test>"73 + "</message>" +74 "</SOAP-ENV:Body>" +75 "</SOAP-ENV:Envelope>");76 DomXmlMessageValidator validator = new DomXmlMessageValidator();77 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();78 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");79 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);80 schema.afterPropertiesSet();81 schemaRepository.getSchemas().add(schema);82 schemaRepository.getLocations().add("schemas/soap-1.1.xsd");83 schemaRepository.afterPropertiesSet();84 validator.addSchemaRepository(schemaRepository);85 validator.validateXMLSchema(message, new XmlMessageValidationContext());86 }87 @Test88 public void validateXMLSchemaNestedWithNamespaceInRoot() throws Exception {89 Message message = new DefaultMessage("<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns=\"http://citrusframework.org/test\">" +90 "<SOAP-ENV:Header/>" +91 "<SOAP-ENV:Body>" +92 "<message>"93 + "<correlationId>Kx1R123456789</correlationId>"94 + "<bookingId>Bx1G987654321</bookingId>"95 + "<test>Hello TestFramework</test>"96 + "</message>" +97 "</SOAP-ENV:Body>" +98 "</SOAP-ENV:Envelope>");99 DomXmlMessageValidator validator = new DomXmlMessageValidator();100 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();101 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");102 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);103 schema.afterPropertiesSet();104 schemaRepository.getSchemas().add(schema);105 schemaRepository.getLocations().add("schemas/soap-1.1.xsd");106 schemaRepository.afterPropertiesSet();107 validator.addSchemaRepository(schemaRepository);108 validator.validateXMLSchema(message, new XmlMessageValidationContext());109 }110 @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*Invalid content was found starting with element '\\{\"http://citrusframework.org/test\":wrong\\}'.*")111 public void validateXMLSchemaNestedError() throws Exception {112 Message message = new DefaultMessage("<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +113 "<SOAP-ENV:Header/>" +114 "<SOAP-ENV:Body>" +115 "<message xmlns=\"http://citrusframework.org/test\">"116 + "<correlationId>Kx1R123456789</correlationId>"117 + "<wrong>Bx1G987654321</wrong>"118 + "<test>Hello TestFramework</test>"119 + "</message>" +120 "</SOAP-ENV:Body>" +121 "</SOAP-ENV:Envelope>");122 DomXmlMessageValidator validator = new DomXmlMessageValidator();123 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();124 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");125 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);126 schema.afterPropertiesSet();127 schemaRepository.getSchemas().add(schema);128 schemaRepository.getLocations().add("schemas/soap-1.1.xsd");129 schemaRepository.afterPropertiesSet();130 validator.addSchemaRepository(schemaRepository);131 validator.validateXMLSchema(message, new XmlMessageValidationContext());132 }133 @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*Invalid content was found starting with element '\\{\"http://citrusframework.org/test\":wrong\\}'.*")134 public void validateXMLSchemaNestedWithNamespaceInRootError() throws Exception {135 Message message = new DefaultMessage("<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns=\"http://citrusframework.org/test\">" +136 "<SOAP-ENV:Header/>" +137 "<SOAP-ENV:Body>" +138 "<message>"139 + "<correlationId>Kx1R123456789</correlationId>"140 + "<wrong>Bx1G987654321</wrong>"141 + "<test>Hello TestFramework</test>"142 + "</message>" +143 "</SOAP-ENV:Body>" +144 "</SOAP-ENV:Envelope>");145 DomXmlMessageValidator validator = new DomXmlMessageValidator();146 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();147 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");148 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);149 schema.afterPropertiesSet();150 schemaRepository.getSchemas().add(schema);151 schemaRepository.getLocations().add("schemas/soap-1.1.xsd");152 schemaRepository.afterPropertiesSet();153 validator.addSchemaRepository(schemaRepository);154 validator.validateXMLSchema(message, new XmlMessageValidationContext());155 }156 157 @Test158 public void validateWithExplicitXMLSchema() throws SAXException, IOException, ParserConfigurationException {159 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"160 + "<correlationId>Kx1R123456789</correlationId>"161 + "<bookingId>Bx1G987654321</bookingId>"162 + "<test>Hello TestFramework</test>"163 + "</message>");164 165 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();166 validationContext.setSchema("testSchema2"); // defined as bean in application context167 validator.validateXMLSchema(message, validationContext);168 }169 170 @Test171 public void validateWithExplicitSpringSchemaRepository() throws SAXException, IOException, ParserConfigurationException {172 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"173 + "<correlationId>Kx1R123456789</correlationId>"174 + "<bookingId>Bx1G987654321</bookingId>"175 + "<test>Hello TestFramework</test>"176 + "</message>");177 178 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();179 validationContext.setSchemaRepository("testSchemaRepository1"); // defined as bean in application context180 validator.validateXMLSchema(message, validationContext);181 }182 183 @Test184 public void validateWithExplicitCitrusSchemaRepository() throws SAXException, IOException, ParserConfigurationException {185 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"186 + "<correlationId>Kx1R123456789</correlationId>"187 + "<bookingId>Bx1G987654321</bookingId>"188 + "<test>Hello TestFramework</test>"189 + "</message>");190 XmlMessageValidationContext validationContext = new XmlMessageValidationContext();191 validationContext.setSchemaRepository("testSchemaRepository2"); // defined as bean in application context192 validator.validateXMLSchema(message, validationContext);193 }194 @Test195 public void validateWithDefaultSchemaRepository() throws SAXException, IOException, ParserConfigurationException {196 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"197 + "<correlationId>Kx1R123456789</correlationId>"198 + "<bookingId>Bx1G987654321</bookingId>"199 + "<test>Hello TestFramework</test>"200 + "</message>");201 202 validator.validateXMLSchema(message, new XmlMessageValidationContext());203 }204 205 @Test206 public void validateNoDefaultSchemaRepository() throws SAXException, IOException, ParserConfigurationException {207 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"208 + "<correlationId>Kx1R123456789</correlationId>"209 + "<bookingId>Bx1G987654321</bookingId>"210 + "<test>Hello TestFramework</test>"211 + "</message>");212 213 DomXmlMessageValidator validator = new DomXmlMessageValidator();214 215 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();216 schemaRepository.setBeanName("schemaRepository1");217 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");218 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);219 schema.afterPropertiesSet();220 221 schemaRepository.getSchemas().add(schema);222 223 validator.addSchemaRepository(schemaRepository);224 225 XsdSchemaRepository schemaRepository2 = new XsdSchemaRepository();226 schemaRepository2.setBeanName("schemaRepository2");227 Resource schemaResource2 = new ClassPathResource("com/consol/citrus/validation/sample.xsd");228 SimpleXsdSchema schema2 = new SimpleXsdSchema(schemaResource2);229 schema2.afterPropertiesSet();230 schemaRepository2.getSchemas().add(schema2);231 validator.addSchemaRepository(schemaRepository2);232 233 validator.validateXMLSchema(message, new XmlMessageValidationContext());234 message = new DefaultMessage("<message xmlns='http://citrusframework.org/sample'>"235 + "<correlationId>Kx1R123456789</correlationId>"236 + "<bookingId>Bx1G987654321</bookingId>"237 + "<test>Hello TestFramework</test>"238 + "</message>");239 validator.validateXMLSchema(message, new XmlMessageValidationContext());240 }241 @Test242 public void validateNoMatchingSchemaRepository() throws SAXException, IOException, ParserConfigurationException {243 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/special'>"244 + "<correlationId>Kx1R123456789</correlationId>"245 + "<bookingId>Bx1G987654321</bookingId>"246 + "<test>Hello TestFramework</test>"247 + "</message>");248 DomXmlMessageValidator validator = new DomXmlMessageValidator();249 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();250 schemaRepository.setBeanName("schemaRepository1");251 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");252 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);253 schema.afterPropertiesSet();254 schemaRepository.getSchemas().add(schema);255 validator.addSchemaRepository(schemaRepository);256 XsdSchemaRepository schemaRepository2 = new XsdSchemaRepository();257 schemaRepository2.setBeanName("schemaRepository2");258 Resource schemaResource2 = new ClassPathResource("com/consol/citrus/validation/sample.xsd");259 SimpleXsdSchema schema2 = new SimpleXsdSchema(schemaResource2);260 schema2.afterPropertiesSet();261 schemaRepository2.getSchemas().add(schema2);262 validator.addSchemaRepository(schemaRepository2);263 try {264 validator.validateXMLSchema(message, new XmlMessageValidationContext());265 Assert.fail("Missing exception due to no matching schema repository error");266 } catch (CitrusRuntimeException e) {267 Assert.assertTrue(e.getMessage().startsWith("Failed to find proper schema repository"), e.getMessage());268 }269 }270 @Test271 public void validateNoMatchingSchema() throws SAXException, IOException, ParserConfigurationException {272 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/special'>"273 + "<correlationId>Kx1R123456789</correlationId>"274 + "<bookingId>Bx1G987654321</bookingId>"275 + "<test>Hello TestFramework</test>"276 + "</message>");277 DomXmlMessageValidator validator = new DomXmlMessageValidator();278 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();279 schemaRepository.setBeanName("schemaRepository");280 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");281 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);282 schema.afterPropertiesSet();283 Resource schemaResource2 = new ClassPathResource("com/consol/citrus/validation/sample.xsd");284 SimpleXsdSchema schema2 = new SimpleXsdSchema(schemaResource2);285 schema2.afterPropertiesSet();286 schemaRepository.getSchemas().add(schema);287 schemaRepository.getSchemas().add(schema2);288 validator.addSchemaRepository(schemaRepository);289 try {290 validator.validateXMLSchema(message, new XmlMessageValidationContext());291 Assert.fail("Missing exception due to no matching schema repository error");292 } catch (CitrusRuntimeException e) {293 Assert.assertTrue(e.getMessage().startsWith("Unable to find proper XML schema definition"), e.getMessage());294 }295 }296 @Test297 public void validateNoSchemaRepositoryAtAll() throws SAXException, IOException, ParserConfigurationException {298 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"299 + "<correlationId>Kx1R123456789</correlationId>"300 + "<bookingId>Bx1G987654321</bookingId>"301 + "<test>Hello TestFramework</test>"302 + "</message>");303 DomXmlMessageValidator validator = new DomXmlMessageValidator();304 validator.validateXMLSchema(message, new XmlMessageValidationContext());305 }306 307 @Test(expectedExceptions = {ValidationException.class})308 public void validateXMLSchemaError() throws SAXException, IOException, ParserConfigurationException {309 Message message = new DefaultMessage("<message xmlns='http://citrusframework.org/test'>"310 + "<correlationId>Kx1R123456789</correlationId>"311 + "<bookingId>Bx1G987654321</bookingId>"312 + "<test>Hello TestFramework</test>"313 + "<wrongElement>totally wrong</wrongElement>"314 + "</message>");315 316 DomXmlMessageValidator validator = new DomXmlMessageValidator();317 318 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();319 Resource schemaResource = new ClassPathResource("com/consol/citrus/validation/test.xsd");320 SimpleXsdSchema schema = new SimpleXsdSchema(schemaResource);321 schema.afterPropertiesSet();322 323 schemaRepository.getSchemas().add(schema);324 325 validator.addSchemaRepository(schemaRepository);326 327 validator.validateXMLSchema(message, new XmlMessageValidationContext());328 }329 330 @Test331 public void testExpectDefaultNamespace() {332 Message message = new DefaultMessage("<root xmlns='http://citrusframework.org/test'>"333 + "<element attributeA='attribute-value' attributeB='attribute-value'>"334 + "<sub-element attribute='A'>text-value</sub-element>"335 + "</element>" ...

Full Screen

Full Screen

Source:XsdSchemaRepositoryTest.java Github

copy

Full Screen

...28 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();29 30 schemaRepository.getLocations().add("classpath:com/consol/citrus/schema/citrus-config.xsd");31 32 schemaRepository.afterPropertiesSet();33 34 Assert.assertEquals(schemaRepository.getSchemas().size(), 1);35 Assert.assertEquals(schemaRepository.getSchemas().get(0).getClass(), SimpleXsdSchema.class);36 }37 38 @Test(expectedExceptions = { IllegalArgumentException.class })39 public void testUnknownLocation() throws Exception {40 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();41 42 schemaRepository.getLocations().add("classpath:com/consol/citrus/unknown/unknown.xsd");43 44 schemaRepository.afterPropertiesSet();45 }46 47 @Test48 public void testResourceLocationPattern() throws Exception {49 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();50 51 schemaRepository.getLocations().add("classpath:com/consol/citrus/schema/*.xsd");52 53 schemaRepository.afterPropertiesSet();54 55 Assert.assertEquals(schemaRepository.getSchemas().size(), 4);56 Assert.assertEquals(schemaRepository.getSchemas().get(0).getClass(), SimpleXsdSchema.class);57 Assert.assertEquals(schemaRepository.getSchemas().get(1).getClass(), SimpleXsdSchema.class);58 Assert.assertEquals(schemaRepository.getSchemas().get(2).getClass(), SimpleXsdSchema.class);59 Assert.assertEquals(schemaRepository.getSchemas().get(3).getClass(), SimpleXsdSchema.class);60 }61 62 @Test63 public void testResourceLocationPatternNothingFound() throws Exception {64 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();65 66 schemaRepository.getLocations().add("classpath:com/consol/citrus/*.xsd");67 68 schemaRepository.afterPropertiesSet();69 70 Assert.assertEquals(schemaRepository.getSchemas().size(), 0);71 }72 73 @Test74 public void testResourceLocationPatternWithExclusion() throws Exception {75 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();76 schemaRepository.getLocations().add("classpath:com/consol/citrus/validation/*");77 78 schemaRepository.afterPropertiesSet();79 80 Assert.assertEquals(schemaRepository.getSchemas().size(), 15);81 schemaRepository = new XsdSchemaRepository();82 schemaRepository.getLocations().add("classpath:com/consol/citrus/validation/*.xsd");83 schemaRepository.afterPropertiesSet();84 Assert.assertEquals(schemaRepository.getSchemas().size(), 6);85 Assert.assertEquals(schemaRepository.getSchemas().get(0).getClass(), SimpleXsdSchema.class);86 Assert.assertEquals(schemaRepository.getSchemas().get(1).getClass(), SimpleXsdSchema.class);87 Assert.assertEquals(schemaRepository.getSchemas().get(2).getClass(), SimpleXsdSchema.class);88 schemaRepository = new XsdSchemaRepository();89 schemaRepository.getLocations().add("classpath:com/consol/citrus/validation/*.wsdl");90 schemaRepository.afterPropertiesSet();91 Assert.assertEquals(schemaRepository.getSchemas().size(), 9);92 Assert.assertEquals(schemaRepository.getSchemas().get(0).getClass(), WsdlXsdSchema.class);93 Assert.assertEquals(schemaRepository.getSchemas().get(1).getClass(), WsdlXsdSchema.class);94 Assert.assertEquals(schemaRepository.getSchemas().get(2).getClass(), WsdlXsdSchema.class);95 Assert.assertEquals(schemaRepository.getSchemas().get(3).getClass(), WsdlXsdSchema.class);96 Assert.assertEquals(schemaRepository.getSchemas().get(4).getClass(), WsdlXsdSchema.class);97 Assert.assertEquals(schemaRepository.getSchemas().get(5).getClass(), WsdlXsdSchema.class);98 Assert.assertEquals(schemaRepository.getSchemas().get(6).getClass(), WsdlXsdSchema.class);99 Assert.assertEquals(schemaRepository.getSchemas().get(7).getClass(), WsdlXsdSchema.class);100 Assert.assertEquals(schemaRepository.getSchemas().get(8).getClass(), WsdlXsdSchema.class);101 }102 103 @Test104 public void testWsdlResourceLocation() throws Exception {105 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();106 107 schemaRepository.getLocations().add("classpath:com/consol/citrus/xml/BookStore.wsdl");108 109 schemaRepository.afterPropertiesSet();110 111 Assert.assertEquals(schemaRepository.getSchemas().size(), 1);112 Assert.assertEquals(schemaRepository.getSchemas().get(0).getClass(), WsdlXsdSchema.class);113 }114 @Test115 public void testDefaultCitrusSchemas() throws Exception {116 XsdSchemaRepository schemaRepository = new XsdSchemaRepository();117 schemaRepository.addCitrusSchema("citrus-unknown-config");118 Assert.assertEquals(schemaRepository.getSchemas().size(), 0);119 schemaRepository.addCitrusSchema("citrus-config");120 Assert.assertEquals(schemaRepository.getSchemas().size(), 1);121 Assert.assertEquals(schemaRepository.getSchemas().get(0).getClass(), SimpleXsdSchema.class);122 }123}...

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1import org.springframework.core.io.ClassPathResource;2import org.springframework.core.io.Resource;3import org.springframework.core.io.ResourceLoader;4import org.springframework.util.Assert;5import org.springframework.util.ResourceUtils;6import org.springframework.xml.xsd.SimpleXsdSchema;7import org.springframework.xml.xsd.XsdSchema;8import org.springframework.xml.xsd.XsdSchemaCollection;9import org.springframework.xml.xsd.XsdSchemaCollectionFactoryBean;10import org.springframework.xml.xsd.XsdSchemaFactoryBean;11import org.springframework.xml.xsd.XsdSchemaRepository;12import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;13import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollectionFactoryBean;14import org.springframework.xml.xsd.support.DefaultSchemaNameProvider;15import org.springframework.xml.xsd.support.SchemaNameProvider;16import org.springframework.xml.xsd.support.SimpleSchemaNameProvider;17import org.springframework.xml.xsd.support.XsdSchemaCollectionFactoryBeanUtils;18import org.springframework.xml.xsd.support.XsdSchemaFactoryBeanUtils;19import org.springframework.xml.xsd.support.XsdSchemaUtils;20import org.xml.sax.InputSource;21import org.xml.sax.SAXException;22import org.xml.sax.SAXParseException;23import org.xml.sax.helpers.DefaultHandler;24import org.xml.sax.helpers.LocatorImpl;25import org.xml.sax.helpers.XMLReaderFactory;26import org.xml.sax.helpers.XMLReaderFactory;27import org.xml.sax.XMLReader;28import org.xml.sax.SAXException;29import org.xml.sax.SAXParseException;30import org.xml.sax.helpers.DefaultHandler;31import org.xml.sax.helpers.LocatorImpl;32import org.xml.sax.helpers.XMLReaderFactory;33import org.springframework.xml.xsd.XsdSchema;34import org.springframework.xml.xsd.XsdSchemaCollection;35import org.springframework.xml.xsd.XsdSchemaCollectionFactoryBean;36import org.springframework.xml.xsd.XsdSchemaFactoryBean;37import org.springframework.xml.xsd.XsdSchemaRepository;38import org.springframework.xml.xsd.SimpleXsdSchema;39import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;40import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollectionFactoryBean;41import org.springframework.xml.xsd.support.DefaultSchemaNameProvider;42import org.springframework.xml.xsd.support.SchemaNameProvider;43import org.springframework.xml.xsd.support.SimpleSchemaNameProvider;44import org.springframework.xml.xsd.support.XsdSchemaCollectionFactoryBeanUtils;45import org.springframework.xml.xsd.support.XsdSchemaFactoryBeanUtils;46import org.springframework.xml.xsd.support.XsdSchemaUtils;47import org.xml.sax.InputSource

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.xml.XsdSchemaRepository;2import java.util.HashMap;3import java.util.Map;4import org.springframework.core.io.ClassPathResource;5public class Test {6 public static void main(String[] args) {7 XsdSchemaRepository xsdSchemaRepository = new XsdSchemaRepository();8 Map<String, String> schemaMap = new HashMap<String, String>();9 xsdSchemaRepository.setSchemas(schemaMap);10 xsdSchemaRepository.setBasePath(new ClassPathResource("/com/consol/citrus/schema/"));11 xsdSchemaRepository.afterPropertiesSet();12 }13}14import com.consol.citrus.xml.XsdSchemaRepository;15import java.util.HashMap;16import java.util.Map;17import org.springframework.core.io.ClassPathResource;18public class Test {19 public static void main(String[] args) {20 XsdSchemaRepository xsdSchemaRepository = new XsdSchemaRepository();21 Map<String, String> schemaMap = new HashMap<String, String>();22 xsdSchemaRepository.setSchemas(schemaMap);23 xsdSchemaRepository.setBasePath(new ClassPathResource("/com/consol/citrus/schema/"));24 xsdSchemaRepository.afterPropertiesSet();25 }26}27import com.consol.citrus.xml.XsdSchemaRepository;28import java.util.HashMap;29import java.util.Map;30import org.springframework.core.io.ClassPathResource;31public class Test {32 public static void main(String[] args

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.xml;2import java.io.File;3import java.io.IOException;4import javax.xml.transform.Source;5import javax.xml.transform.dom.DOMSource;6import org.springframework.beans.factory.InitializingBean;7import org.springframework.core.io.Resource;8import org.springframework.util.Assert;9import org.springframework.util.StringUtils;10import org.springframework.xml.validation.XmlValidator;11import org.springframework.xml.validation.XmlValidatorFactory;12import org.w3c.dom.Document;13import org.xml.sax.SAXException;14import com.consol.citrus.exceptions.CitrusRuntimeException;15import com.consol.citrus.util.FileUtils;16public class XsdSchemaRepository implements SchemaRepository, InitializingBean {17 private XmlValidatorFactory xmlValidatorFactory;18 private final SchemaRepository schemaRepository = new DefaultSchemaRepository();19 public XsdSchemaRepository() {20 }21 public XsdSchemaRepository(XmlValidatorFactory xmlValidatorFactory) {22 this.xmlValidatorFactory = xmlValidatorFactory;23 }24 public void setXmlValidatorFactory(XmlValidatorFactory xmlValidatorFactory) {25 this.xmlValidatorFactory = xmlValidatorFactory;26 }27 public void afterPropertiesSet() throws Exception {28 Assert.notNull(xmlValidatorFactory, "XML validator factory is not initialized");29 Assert.notNull(schemaRepository, "Schema repository is not initialized");30 }31 public void addSchema(Resource resource) {32 try {33 Document document = FileUtils.readXmlFile(resource.getInputStream());34 XmlValidator xmlValidator = xmlValidatorFactory.createValidator(new DOMSource(document));35 schemaRepository.addSchema(xmlValidator);36 } catch (IOException e) {37 throw new CitrusRuntimeException("Failed to read XML schema resource", e);38 } catch (SAXException

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.xml;2import java.io.File;3import java.io.IOException;4import java.util.Collection;5import org.springframework.beans.factory.InitializingBean;6import org.springframework.core.io.Resource;7import org.springframework.core.io.support.PathMatchingResourcePatternResolver;8import org.springframework.core.io.support.ResourcePatternResolver;9import org.springframework.util.Assert;10import org.springframework.util.StringUtils;11import org.springframework.xml.xsd.SimpleXsdSchema;12import org.springframework.xml.xsd.XsdSchema;13import org.springframework.xml.xsd.XsdSchemaCollection;14import org.springframework.xml.xsd.XsdSchemaCollectionFactoryBean;15import org.springframework.xml.xsd.XsdSchemaFactory;16import org.springframework.xml.xsd.XsdSchemaFactoryBean;17import org.springframework.xml.xsd.XsdSchemaSource;18import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;19import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollectionFactoryBean;20import org.springframework.xml.xsd.support.DefaultSchemaNameProvider;21import org.springframework.xml.xsd.support.SchemaNameProvider;22import org.springframework.xml.xsd.support.XsdSchemaUtils;23import org.xml.sax.InputSource;24import org.xml.sax.SAXException;25import com.consol.citrus.exceptions.CitrusRuntimeException;26public class XsdSchemaRepository implements SchemaRepository, InitializingBean {27private ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();28private XsdSchemaCollection schemaCollection;29private SchemaNameProvider schemaNameProvider = new DefaultSchemaNameProvider();30private String schemaLocation;31public void setSchemaLocation(String schemaLocation) {32this.schemaLocation = schemaLocation;33}34public void setSchemaNameProvider(SchemaNameProvider schemaNameProvider) {35this.schemaNameProvider = schemaNameProvider;36}37public void setSchemaCollection(XsdSchemaCollection schemaCollection) {38this.schemaCollection = schemaCollection;39}40 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()41public void afterPropertiesSet() throws Exception {42if (

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.xml;2import org.springframework.core.io.ClassPathResource;3import org.springframework.core.io.Resource;4public class XsdSchemaRepository extends AbstractSchemaRepository {5 private Resource schemaLocation;6 public void afterPropertiesSet() throws Exception {7 super.afterPropertiesSet();8 if (schemaLocation == null) {9 throw new IllegalArgumentException("Schema location is not set");10 }11 setSchemaRepository(new ClassPathResource(schemaLocation.getFilename(), XsdSchemaRepository.class));12 }13 public Resource getSchemaLocation() {14 return schemaLocation;15 }16 public void setSchemaLocation(Resource schemaLocation) {17 this.schemaLocation = schemaLocation;18 }19}20package com.consol.citrus.xml;21import org.springframework.core.io.ClassPathResource;22import org.springframework.core.io.Resource;23public class XsdSchemaRepository extends AbstractSchemaRepository {24 private Resource schemaLocation;25 public void afterPropertiesSet() throws Exception {26 super.afterPropertiesSet();27 if (schemaLocation == null) {28 throw new IllegalArgumentException("Schema location is not set");29 }30 setSchemaRepository(new ClassPathResource(schemaLocation.getFilename(), XsdSchemaRepository.class));31 }32 public Resource getSchemaLocation() {33 return schemaLocation;34 }35 public void setSchemaLocation(Resource schemaLocation) {36 this.schemaLocation = schemaLocation;37 }38}39package com.consol.citrus.xml;40import org.springframework.core.io.ClassPathResource;41import org.springframework.core.io.Resource;

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1package org.springframework.beans.factory.xml;2import org.springframework.beans.BeansException;3import org.springframework.beans.factory.BeanFactory;4import org.springframework.beans.factory.BeanFactoryAware;5import org.springframework.beans.factory.BeanInitializationException;6import org.springframework.beans.factory.InitializingBean;7import org.springframework.core.io.Resource;8import org.springframework.util.Assert;9import org.springframework.util.StringUtils;10import org.springframework.xml.xsd.SimpleXsdSchema;11import org.springframework.xml.xsd.XsdSchema;12import org.springframework.xml.xsd.XsdSchemaCollection;13import org.springframework.xml.xsd.support.DefaultSchemaReader;14import org.springframework.xml.xsd.support.SchemaReader;15import org.springframework.xml.xsd.support.SchemaReaderContext;16import org.springframework.xml.xsd.support.SchemaReaderContextAware;17import org.xml.sax.InputSource;18import javax.xml.transform.Source;19import javax.xml.transform.stream.StreamSource;20import java.io.IOException;21import java.util.*;22 * <p>Can be used as a {@link BeanFactory} to resolve schema locations. This is useful for23 * {@link org.springframework.xml.x

Full Screen

Full Screen

afterPropertiesSet

Using AI Code Generation

copy

Full Screen

1import java.io.File;2import java.util.ArrayList;3import java.util.List;4import java.util.Map;5import org.springframework.beans.factory.InitializingBean;6import org.springframework.core.io.Resource;7import org.springframework.util.Assert;8import org.springframework.util.CollectionUtils;9import org.springframework.util.StringUtils;10import org.xml.sax.SAXException;11import com.consol.citrus.exceptions.CitrusRuntimeException;12import com.consol.citrus.util.FileUtils;13public class XsdSchemaRepository implements InitializingBean {14 private List<Resource> xsdResources = new ArrayList<Resource>();15 private List<Resource> xsdSchemaLocations = new ArrayList<Resource>();16 private Map<String, Resource> xsdSchemaLocationMap;17 private final XmlSchemaRepository schemaRepository = new XmlSchemaRepository();18 public void setXsdResources(List<Resource> xsdResources) {19 this.xsdResources = xsdResources;20 }21 public void setXsdSchemaLocations(List<Resource> xsdSchemaLocations) {22 this.xsdSchemaLocations = xsdSchemaLocations;23 }24 public void setXsdSchemaLocationMap(Map<String, Resource> xsdSchemaLocationMap) {25 this.xsdSchemaLocationMap = xsdSchemaLocationMap;26 }

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