Trying to reproduce SWS-176

This commit is contained in:
Arjen Poutsma
2007-09-21 08:49:39 +00:00
parent b3c9cb7a63
commit ec664693b8
7 changed files with 63 additions and 25 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.xml.validation;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
@@ -25,6 +26,7 @@ import javax.xml.transform.stream.StreamSource;
import junit.framework.TestCase;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.xml.transform.ResourceSource;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
@@ -102,4 +104,21 @@ public abstract class AbstractValidatorFactoryTestCase extends TestCase {
assertEquals("ValidationErrors returned", 3, errors.length);
}
public void testMultipleSchemasValidMessage() throws Exception {
Resource[] schemaResources = new Resource[]{
new ClassPathResource("multipleSchemas1.xsd", AbstractValidatorFactoryTestCase.class),
new ClassPathResource("multipleSchemas2.xsd", AbstractValidatorFactoryTestCase.class)};
validator = createValidator(schemaResources, XmlValidatorFactory.SCHEMA_W3C_XML);
Source document = new ResourceSource(
new ClassPathResource("multipleSchemas1.xml", AbstractValidatorFactoryTestCase.class));
SAXParseException[] errors = validator.validate(document);
assertEquals("ValidationErrors returned", 0, errors.length);
validator = createValidator(schemaResources, XmlValidatorFactory.SCHEMA_W3C_XML);
document = new ResourceSource(
new ClassPathResource("multipleSchemas2.xml", AbstractValidatorFactoryTestCase.class));
errors = validator.validate(document);
assertEquals("ValidationErrors returned", 0, errors.length);
}
}

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<multipleSchemas1 xmlns="http://www.springframework.org/spring-ws/test/multipleSchemas1">abc</multipleSchemas1>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/test/multipleSchemas1"
elementFormDefault="qualified">
<element name="multipleSchemas1">
<simpleType>
<restriction base="string">
<pattern value="[a-c]+"/>
</restriction>
</simpleType>
</element>
</schema>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<multipleSchemas2 xmlns="http://www.springframework.org/spring-ws/test/multipleSchemas2">123</multipleSchemas2>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/test/multipleSchemas2"
elementFormDefault="qualified">
<element name="multipleSchemas2">
<simpleType>
<restriction base="string">
<pattern value="[1-3]+"/>
</restriction>
</simpleType>
</element>
</schema>