Methods Summary |
---|
public static void | main(java.lang.String[] args)
if (args.length == 0){
TestRunner.run(SchematronTest.class);
} else {
TestRunner.run(makeSuite(args));
}
|
private static junit.framework.TestSuite | makeSuite(java.lang.String[] args)
final TestSuite ts = new TestSuite();
for (int i = 0; i < args.length; i++){
ts.addTest(new SchematronTest(args[i]));
}
return ts;
|
private void | nyi()
fail("Not Yet Implemented");
|
protected void | setUp()
|
protected void | tearDown()
|
public void | testComment()
Schematron s = new Schematron("/schema2.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
String input = "<?xml version='1.0'?><!-- comment --><root id=\"${var}\"><system-property name=\"var\" value=\"value\"/></root>";
SAXSource src = new SAXSource(new VariableResolver(),
new InputSource(new StringReader(input)));
s.analyze(src, r);
assertEquals("This is the id: value", ""+actual);
|
public void | testExternal()
Schematron s = new Schematron("/schema2.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
SAXSource src = new SAXSource(new VariableResolver(),
new InputSource("schema2.xml"));
s.analyze(src, r);
assertEquals("This is the id: value", ""+actual);
|
public void | testExternalWithEntityResolver()
Schematron s = new Schematron("/schema2.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
VariableResolver vr = new VariableResolver();
vr.setEntityResolver(new MyEntityResolver("/schema2.dtd"));
SAXSource src = new SAXSource(vr,
new InputSource("schema2.xml"));
s.analyze(src, r);
assertEquals("This is the id: value", ""+actual);
|
public void | testPipeline()
Schematron s = new Schematron("/schema2.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
String input = "<?xml version='1.0'?><root id=\"${var}\"><system-property name=\"var\" value=\"value\"/></root>";
SAXSource src = new SAXSource(new VariableResolver(),
new InputSource(new StringReader(input)));
s.analyze(src, r);
assertEquals("This is the id: value", ""+actual);
|
public void | testSchematron()
Schematron s = new Schematron("/schema.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
s.analyze(new SAXSource(new InputSource(new StringReader("<top><root id ='foo'/></top>"))), r);
assertEquals("This is the result", ""+actual);
|
public void | testSimpleTransform()
Schematron s = new Schematron("/simple.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
VariableResolver vr = new VariableResolver();
vr.setEntityResolver(new MyEntityResolver("/sun-domain_1_1.dtd"));
SAXSource src = new SAXSource(vr,
new InputSource("domain.xml"));
s.analyze(src, r);
|
public void | testWithEntityResolver()
Schematron s = new Schematron("/schema2.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
String input = "<?xml version='1.0'?><!DOCTYPE domain PUBLIC '-//Sun Microsystems Inc.//DTD Application Server 8.0 Domain//EN' 'http://www.sun.com/software/appserver/dtds/sun-domain_1_1.dtd'><root id=\"${var}\"><system-property name=\"var\" value=\"value\"/></root>";
VariableResolver vr = new VariableResolver();
vr.setEntityResolver(new MyEntityResolver("/schema2.dtd"));
SAXSource src = new SAXSource(vr,
new InputSource(new StringReader(input)));
s.analyze(src, r);
assertEquals("This is the id: value", ""+actual);
|
public void | testWithEntityResolverError()
Schematron s = new Schematron("/schema2.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
String input = "<?xml version='1.0'?><!DOCTYPE root PUBLIC 'DO NOT MATCH' 'http://www.google.com'><root id=\"${var}\"><system-property name=\"var\" value=\"value\"/></root>";
VariableResolver vr = new VariableResolver();
vr.setEntityResolver(new MyEntityResolver("/schema2.dtd"));
SAXSource src = new SAXSource(vr,
new InputSource(new StringReader(input)));
try {
s.analyze(src, r);
fail("Expected a Transformer Exception");
}
catch (TransformerException te){
assertEquals("javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: External parameter entity \"%[dtd];\" has characters after markup.", te.getMessage());
}
|
public void | testWithSAXSourceNoVR()
Schematron s = new Schematron("/domain.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
SAXSource src = new SAXSource(new InputSource("domain.xml.no.dtd"));
s.analyze(src, r);
assertEquals(1540, actual.toString().length());
|
public void | testWithSAXSourceWithVRAndER()
Schematron s = new Schematron("/domain.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
VariableResolver vr = new VariableResolver();
vr.setEntityResolver(new MyEntityResolver("/sun-domain_1_1.dtd"));
SAXSource src = new SAXSource(vr,
new InputSource("domain.xml.no.dtd"));
s.analyze(src, r);
assertEquals(1540, actual.toString().length());
|
public void | testWithSAXSourceWithVRNoER()
Schematron s = new Schematron("/domain.xsl");
StringWriter actual = new StringWriter();
Result r = new StreamResult(actual);
VariableResolver vr = new VariableResolver();
SAXSource src = new SAXSource(vr,
new InputSource(new FileReader("domain.xml.no.dtd")));
s.analyze(src, r);
assertEquals(1540, actual.toString().length());
|