use of com.helger.commons.io.resource.IReadableResource in project ph-css by phax.
the class Issue22Test method testIssue.
@Test
public void testIssue() {
// Multiple errors contained
final IReadableResource aRes = new ClassPathResource("testfiles/css30/good/issue22.css");
assertTrue(aRes.exists());
final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, new CSSReaderSettings().setFallbackCharset(StandardCharsets.UTF_8).setCustomErrorHandler(new LoggingCSSParseErrorHandler()));
assertNotNull(aCSS);
if (false)
System.out.println(new CSSWriter(ECSSVersion.CSS30).getCSSAsString(aCSS));
}
use of com.helger.commons.io.resource.IReadableResource in project ph-css by phax.
the class Issue26Test method testIssue.
@Test
public void testIssue() {
final IReadableResource aRes = new ClassPathResource("testfiles/css30/bad_but_browsercompliant/issue26.css");
assertTrue(aRes.exists());
final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, new CSSReaderSettings().setFallbackCharset(StandardCharsets.UTF_8).setBrowserCompliantMode(true).setCustomErrorHandler(new LoggingCSSParseErrorHandler()));
assertNotNull(aCSS);
if (false)
System.out.println(new CSSWriter().getCSSAsString(aCSS));
}
use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.
the class SchematronValidatorTest method testSchematron.
@Test
public void testSchematron() {
// Check all documents
for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles()) {
final IMicroDocument aDoc = SchematronHelper.getWithResolvedSchematronIncludes(aRes);
final boolean bIsValid = SchematronValidator.isValidSchematron(aDoc);
assertTrue(aRes.getPath(), bIsValid);
}
}
use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.
the class SchematronResourcePure method createBoundSchema.
@Nonnull
protected IPSBoundSchema createBoundSchema() {
final IReadableResource aResource = getResource();
final IPSErrorHandler aErrorHandler = getErrorHandler();
final PSBoundSchemaCacheKey aCacheKey = new PSBoundSchemaCacheKey(aResource, getPhase(), aErrorHandler, getVariableResolver(), getFunctionResolver(), getEntityResolver());
if (aResource instanceof AbstractMemoryReadableResource || !isUseCache()) {
// No need to cache anything for memory resources
try {
return aCacheKey.createBoundSchema();
} catch (final SchematronException ex) {
// Convert to runtime exception
throw new IllegalStateException("Failed to bind Schematron", ex);
}
}
// happens
return PSBoundSchemaCache.getInstance().getFromCache(aCacheKey);
}
use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.
the class PSReaderTest method testReadAll.
@Test
public void testReadAll() throws Exception {
for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles()) {
final PSReader aReader = new PSReader(aRes);
// Parse the schema
final PSSchema aSchema1 = aReader.readSchema();
assertNotNull(aSchema1);
final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler();
assertTrue(aRes.getPath(), aSchema1.isValid(aLogger));
assertTrue(aLogger.isEmpty());
// Convert back to XML
final IMicroElement e1 = aSchema1.getAsMicroElement();
final String sXML1 = MicroWriter.getNodeAsString(e1);
// Re-read the created XML and re-create it
final PSSchema aSchema2 = aReader.readSchemaFromXML(e1);
final IMicroElement e2 = aSchema2.getAsMicroElement();
final String sXML2 = MicroWriter.getNodeAsString(e2);
// Originally created XML and re-created-written XML must match
assertEquals(sXML1, sXML2);
}
}
Aggregations