diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java index 7c766cf704..63141dd85f 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java @@ -42,7 +42,7 @@ public class XmlSchemaValidation implements SchemaValidator" + + "Cm123456789" + + "FOO" + + ""); + + XsdSchemaRepository schemaRepository = new XsdSchemaRepository(); + schemaRepository.setName("schemaRepository"); + + XsdSchemaCollection schemaCollection = new XsdSchemaCollection(); + schemaCollection.setSchemas(List.of("org/citrusframework/validation/SampleMessage.xsd", "org/citrusframework/validation/SampleTypes.xsd")); + schemaCollection.initialize(); + schemaCollection.afterPropertiesSet(); + + schemaRepository.getSchemas().add(schemaCollection); + + context.getReferenceResolver().bind("schemaRepository", schemaRepository); + + validator.validateXMLSchema(message, context, new XmlMessageValidationContext()); + } + + @Test + public void validateSchemaWithSchemaImportAndWildcard() throws ParserConfigurationException, IOException, SAXException { + Message message = new DefaultMessage("" + + "Cm123456789" + + "FOO" + + ""); + + XsdSchemaRepository schemaRepository = new XsdSchemaRepository(); + schemaRepository.setName("schemaRepository"); + + XsdSchemaCollection schemaCollection = new XsdSchemaCollection(); + schemaCollection.setSchemas(List.of("org/citrusframework/validation/Sample*.xsd")); + schemaCollection.initialize(); + schemaCollection.afterPropertiesSet(); + + schemaRepository.getSchemas().add(schemaCollection); + + context.getReferenceResolver().bind("schemaRepository", schemaRepository); + + validator.validateXMLSchema(message, context, new XmlMessageValidationContext()); + } + @Test(expectedExceptions = {ValidationException.class}) public void validateXMLSchemaError() throws SAXException, IOException, ParserConfigurationException { Message message = new DefaultMessage(""