SWS-304
This commit is contained in:
@@ -29,6 +29,7 @@ import org.w3c.dom.Document;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.xml.sax.SaxUtils;
|
||||
import org.springframework.xml.validation.XmlValidator;
|
||||
import org.springframework.xml.xsd.AbstractXsdSchemaTestCase;
|
||||
import org.springframework.xml.xsd.XsdSchema;
|
||||
|
||||
@@ -89,4 +90,13 @@ public class CommonsXsdSchemaCollectionTest extends XMLTestCase {
|
||||
assertEquals("Invalid amount of XSDs loaded", 1, schemas.length);
|
||||
}
|
||||
|
||||
public void testCreateValidator() throws Exception {
|
||||
Resource a = new ClassPathResource("A.xsd", AbstractXsdSchemaTestCase.class);
|
||||
collection.setXsds(new Resource[]{a});
|
||||
collection.setInline(true);
|
||||
collection.afterPropertiesSet();
|
||||
|
||||
XmlValidator validator = collection.createValidator();
|
||||
assertNotNull("No XmlValidator returned", validator);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@
|
||||
xmlns:tns="urn:1" elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
<xsd:include schemaLocation="B.xsd"/>
|
||||
<xsd:simpleType name="A">
|
||||
<xsd:restriction base="tns:B"/>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="A">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="tns:B"/>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:schema>
|
||||
@@ -2,9 +2,11 @@
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="urn:2" xmlns:tns="urn:1"
|
||||
attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:1">
|
||||
<xsd:import namespace="urn:2"/>
|
||||
<xsd:simpleType name="A">
|
||||
<xsd:restriction base="tns:B"/>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="A">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="tns:B"/>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="B">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="c" type="tns:C"/>
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.w3c.dom.Document;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.xml.sax.SaxUtils;
|
||||
import org.springframework.xml.validation.XmlValidator;
|
||||
|
||||
public abstract class AbstractXsdSchemaTestCase extends XMLTestCase {
|
||||
|
||||
@@ -84,5 +85,12 @@ public abstract class AbstractXsdSchemaTestCase extends XMLTestCase {
|
||||
assertXMLEqual("Invalid Source returned", expected, result);
|
||||
}
|
||||
|
||||
public void testCreateValidator() throws Exception {
|
||||
Resource resource = new ClassPathResource("single.xsd", AbstractXsdSchemaTestCase.class);
|
||||
XsdSchema single = createSchema(resource);
|
||||
XmlValidator validator = single.createValidator();
|
||||
assertNotNull("No XmlValidator returned", validator);
|
||||
}
|
||||
|
||||
protected abstract XsdSchema createSchema(Resource resource) throws Exception;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user