CssStyleSheetParser { public static CssStyleSheet parse(InputStream stream, String baseUrl) throws IOException { CssParserStateController controller = new CssParserStateController(baseUrl); Reader br = PortUtil.wrapInBufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); char[] buffer = new char[8192]; int length; while ((length = br.read(buffer, 0, buffer.length)) > 0) { for(int i = 0 ; i < length; i++) { controller.process(buffer[i]); } } return controller.getParsingResult(); } private  CssStyleSheetParser(); static CssStyleSheet parse(InputStream stream, String baseUrl); static CssStyleSheet parse(InputStream stream); static CssStyleSheet parse(String data, String baseUrl); static CssStyleSheet parse(String data);  }
@Test public void test01() throws IOException { String cssFile = sourceFolder + "css01.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); }
@Test public void test02() throws IOException { String cssFile = sourceFolder + "css02.css"; String cmpFile = sourceFolder + "cmp_css02.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test03() throws IOException { String cssFile = sourceFolder + "css03.css"; String cmpFile = sourceFolder + "cmp_css03.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test04() throws IOException { String cssFile = sourceFolder + "css04.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals("", styleSheet.toString()); }
@Test public void test05() throws IOException { String cssFile = sourceFolder + "css05.css"; String cmpFile = sourceFolder + "cmp_css05.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test06() throws IOException { String cssFile = sourceFolder + "css06.css"; String cmpFile = sourceFolder + "cmp_css06.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test07() throws IOException { String cssFile = sourceFolder + "css07.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); }
@Test public void test08() throws IOException { String cssFile = sourceFolder + "css08.css"; String cmpFile = sourceFolder + "cmp_css08.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test09() throws IOException { String cssFile = sourceFolder + "css09.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); }
@Test public void test10() throws IOException { String cssFile = sourceFolder + "css10.css"; String cmpFile = sourceFolder + "cmp_css10.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test11() throws IOException { String cssFile = sourceFolder + "css11.css"; String cmpFile = sourceFolder + "cmp_css11.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }
@Test public void test12() throws IOException { String cssFile = sourceFolder + "css12.css"; String cmpFile = sourceFolder + "cmp_css12.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(new FileInputStream(cssFile)); Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); }