2323import java .net .URLConnection ;
2424import java .nio .charset .StandardCharsets ;
2525
26- import org .dom4j .DocumentException ;
2726import org .dom4j .io .SAXReader ;
28- import org .dom4j .io .XPP3Reader ;
2927import org .junit .jupiter .api .BeforeAll ;
3028import org .junit .jupiter .api .Test ;
3129import org .w3c .dom .DocumentType ;
3230import org .w3c .dom .Node ;
3331import org .w3c .dom .NodeList ;
3432import org .xml .sax .InputSource ;
35- import org .xml .sax .SAXException ;
3633
3734import io .sf .carte .doc .style .css .CSSDocument ;
3835import io .sf .carte .doc .style .css .om .DOMCSSStyleSheetFactoryTest ;
@@ -46,7 +43,7 @@ public class XHTMLDocumentFactoryTest {
4643 public static void setUpBeforeClass () throws Exception {
4744 Reader re = DOMCSSStyleSheetFactoryTest .sampleHTMLReader ();
4845 InputSource isrc = new InputSource (re );
49- xhtmlDoc = parseXML (isrc );
46+ xhtmlDoc = TestUtil . parseXML (isrc );
5047 re .close ();
5148 }
5249
@@ -154,29 +151,4 @@ public void testEntities2() throws Exception {
154151 assertEquals ("ítem" , ent0 .getNodeValue ());
155152 }
156153
157- public static XHTMLDocument parseXML (InputSource is ) throws DocumentException , SAXException {
158- TestDocumentFactory factory = new TestDocumentFactory ();
159- factory .getStyleSheetFactory ().setDefaultHTMLUserAgentSheet ();
160- SAXReader reader = new SAXReader (factory );
161- reader .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , true );
162- reader .setEntityResolver (new DefaultEntityResolver ());
163- XHTMLDocument document = (XHTMLDocument ) reader .read (is );
164- return document ;
165- }
166-
167- public static XHTMLDocument parseXPP3 (Reader re ) throws Exception {
168- TestDocumentFactory factory = new TestDocumentFactory ();
169- XPP3Reader reader = new XPP3Reader (factory );
170- XHTMLDocument document = (XHTMLDocument ) reader .read (re );
171- return document ;
172- }
173-
174- public static XHTMLDocument sampleXHTML () throws DocumentException , SAXException , IOException {
175- Reader re = DOMCSSStyleSheetFactoryTest .sampleHTMLReader ();
176- InputSource isrc = new InputSource (re );
177- XHTMLDocument xhtmlDoc = parseXML (isrc );
178- re .close ();
179- return xhtmlDoc ;
180- }
181-
182154}
0 commit comments