use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class SchematronResourceSCHCacheTest method testInvalidSchematron.
@Test
public void testInvalidSchematron() {
assertFalse(new SchematronResourceSCH(new ClassPathResource("test-sch/invalid01.sch")).isValidSchematron());
assertFalse(new SchematronResourceSCH(new ClassPathResource("test-sch/this.file.does.not.exists")).isValidSchematron());
assertFalse(new SchematronResourceSCH(new FileSystemResource("src/test/resources/test-sch/invalid01.sch")).isValidSchematron());
assertFalse(new SchematronResourceSCH(new FileSystemResource("src/test/resources/test-sch/this.file.does.not.exists")).isValidSchematron());
}
use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class SchematronResourceSCHCacheTest method testValidSynchronous.
@Test
public void testValidSynchronous() throws Exception {
// Ensure that the Schematron is cached
SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON);
final long nStart = System.nanoTime();
for (int i = 0; i < RUNS; ++i) {
final ISchematronResource aSV = SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON);
final Document aDoc = aSV.applySchematronValidation(new ClassPathResource(VALID_XMLINSTANCE));
assertNotNull(aDoc);
if (false)
s_aLogger.info(XMLWriter.getNodeAsString(aDoc));
}
final long nEnd = System.nanoTime();
s_aLogger.info("Sync Total: " + ((nEnd - nStart) / 1000) + " microsecs btw. " + ((nEnd - nStart) / 1000 / RUNS) + " microsecs/run");
}
use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class SchematronHelperTest method testReadNull.
@Test
public void testReadNull() {
try {
// null-Schematron not allowed
SchematronHelper.applySchematron(null, new ClassPathResource(VALID_XMLINSTANCE));
fail();
} catch (final NullPointerException ex) {
/* expected */
}
try {
// null-XML not allowed
SchematronHelper.applySchematron(SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON), (IReadableResource) null);
fail();
} catch (final NullPointerException ex) {
/* expected */
}
try {
// null-XML not allowed
SchematronHelper.applySchematron(SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON), (Source) null);
fail();
} catch (final NullPointerException ex) {
/* expected */
}
}
use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class SchematronHelperTest method testReadValidSchematronInvalidXML.
@Test
public void testReadValidSchematronInvalidXML() {
final SchematronOutputType aSO = SchematronHelper.applySchematron(SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON), new ClassPathResource(VALID_XMLINSTANCE + ".does.not.exist"));
assertNull("Invalid XML", aSO);
}
use of com.helger.commons.io.resource.ClassPathResource in project ph-schematron by phax.
the class SchematronHelperTest method testReadInvalidSchematronInvalidXML.
@Test
public void testReadInvalidSchematronInvalidXML() {
final SchematronOutputType aSO = SchematronHelper.applySchematron(SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON + ".does.not.exist"), new ClassPathResource(VALID_XMLINSTANCE + ".does.not.exist"));
assertNull("Invalid Schematron and XML", aSO);
}
Aggregations