Search in sources :

Example 1 with NonBlockingStringWriter

use of com.helger.commons.io.stream.NonBlockingStringWriter in project ph-css by phax.

the class CSSWriterFuncTest method testRead30Write21.

@Test
public void testRead30Write21() throws IOException {
    for (final File aFile : new FileSystemRecursiveIterator(new File("src/test/resources/testfiles/css30/good/artificial")).withFilter(IFileFilter.filenameEndsWith(".css"))) {
        final String sKey = aFile.getAbsolutePath();
        try {
            // read and interpret CSS 3.0
            final CascadingStyleSheet aCSS = CSSReader.readFromFile(aFile, StandardCharsets.UTF_8, ECSSVersion.CSS30);
            assertNotNull(sKey, aCSS);
            // write to CSS 2.1
            final NonBlockingStringWriter aSW = new NonBlockingStringWriter();
            new CSSWriter(ECSSVersion.CSS21).writeCSS(aCSS, aSW);
            // This should throw an error
            fail(sKey + " should have thrown an exception but got: " + aSW.getAsString());
        } catch (final IllegalStateException ex) {
        }
    }
}
Also used : CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) FileSystemRecursiveIterator(com.helger.commons.io.file.FileSystemRecursiveIterator) File(java.io.File) NonBlockingStringWriter(com.helger.commons.io.stream.NonBlockingStringWriter) Test(org.junit.Test)

Aggregations

FileSystemRecursiveIterator (com.helger.commons.io.file.FileSystemRecursiveIterator)1 NonBlockingStringWriter (com.helger.commons.io.stream.NonBlockingStringWriter)1 CascadingStyleSheet (com.helger.css.decl.CascadingStyleSheet)1 File (java.io.File)1 Test (org.junit.Test)1