@@ -48,127 +48,26 @@ This file is part of the iText (R) project.
4848import com .itextpdf .styledxmlparser .css .parse .CssStyleSheetParser ;
4949import com .itextpdf .test .ExtendedITextTest ;
5050import com .itextpdf .test .annotations .type .UnitTest ;
51-
52- import java .io .FileInputStream ;
53- import java .io .IOException ;
54-
5551import org .junit .Assert ;
56- import org .junit .BeforeClass ;
5752import org .junit .Test ;
5853import org .junit .experimental .categories .Category ;
5954
55+ import java .io .FileInputStream ;
56+ import java .io .IOException ;
57+
6058@ Category (UnitTest .class )
6159public class CssStyleSheetParserTest extends ExtendedITextTest {
6260
6361 private static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/css/CssStyleSheetParserTest/" ;
6462 private static final String DEFAULT_CSS_PATH = "com/itextpdf/html2pdf/default.css" ;
6563
66- @ BeforeClass
67- public static void beforeClass () {
68- }
69-
7064 @ Test
7165 public void testDefaultCss () throws IOException {
7266 String cmpFile = sourceFolder + "cmp_default.css" ;
7367 CssStyleSheet styleSheet = CssStyleSheetParser .parse (ResourceUtil .getResourceStream (DEFAULT_CSS_PATH ));
7468 Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
7569 }
7670
77- @ Test
78- public void test01 () throws IOException {
79- String cssFile = sourceFolder + "css01.css" ;
80- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
81- Assert .assertEquals (getCssFileContents (cssFile ), styleSheet .toString ());
82- }
83-
84- @ Test
85- public void test02 () throws IOException {
86- String cssFile = sourceFolder + "css02.css" ;
87- String cmpFile = sourceFolder + "cmp_css02.css" ;
88- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
89- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
90- }
91-
92- @ Test
93- public void test03 () throws IOException {
94- String cssFile = sourceFolder + "css03.css" ;
95- String cmpFile = sourceFolder + "cmp_css03.css" ;
96- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
97- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
98- }
99-
100- @ Test
101- public void test04 () throws IOException {
102- String cssFile = sourceFolder + "css04.css" ;
103- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
104- Assert .assertEquals ("" , styleSheet .toString ());
105- }
106-
107- @ Test
108- public void test05 () throws IOException {
109- String cssFile = sourceFolder + "css05.css" ;
110- String cmpFile = sourceFolder + "cmp_css05.css" ;
111- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
112- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
113- }
114-
115- @ Test
116- public void test06 () throws IOException {
117- String cssFile = sourceFolder + "css06.css" ;
118- String cmpFile = sourceFolder + "cmp_css06.css" ;
119- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
120- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
121- }
122-
123- @ Test
124- public void test07 () throws IOException {
125- String cssFile = sourceFolder + "css07.css" ;
126- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
127- Assert .assertEquals (getCssFileContents (cssFile ), styleSheet .toString ());
128- }
129-
130- @ Test
131- public void test08 () throws IOException {
132- String cssFile = sourceFolder + "css08.css" ;
133- String cmpFile = sourceFolder + "cmp_css08.css" ;
134- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
135- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
136- }
137-
138- @ Test
139- public void test09 () throws IOException {
140- String cssFile = sourceFolder + "css09.css" ;
141- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
142- Assert .assertEquals (getCssFileContents (cssFile ), styleSheet .toString ());
143- }
144-
145- @ Test
146- public void test10 () throws IOException {
147- String cssFile = sourceFolder + "css10.css" ;
148- String cmpFile = sourceFolder + "cmp_css10.css" ;
149- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
150- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
151- }
152-
153- @ Test
154- public void test11 () throws IOException {
155- // TODO in this test declarations of the page at-rule with compound selector are duplicated.
156- // See CssPageRule#addBodyCssDeclarations() method for the reason and possible solution if this becomes important.
157-
158- String cssFile = sourceFolder + "css11.css" ;
159- String cmpFile = sourceFolder + "cmp_css11.css" ;
160- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
161- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
162- }
163-
164- @ Test
165- public void test12 () throws IOException {
166- String cssFile = sourceFolder + "css12.css" ;
167- String cmpFile = sourceFolder + "cmp_css12.css" ;
168- CssStyleSheet styleSheet = CssStyleSheetParser .parse (new FileInputStream (cssFile ));
169- Assert .assertEquals (getCssFileContents (cmpFile ), styleSheet .toString ());
170- }
171-
17271 private String getCssFileContents (String filePath ) throws IOException {
17372 byte [] bytes = StreamUtil .inputStreamToArray (new FileInputStream (filePath ));
17473 String content = new String (bytes );
0 commit comments