Package org.jdom.input

Examples of org.jdom.input.SAXHandler


       * @throws SAXException   any SAX exception, possibly wrapping
       *                        another exception.
       */
      public SAXHandler getContentHandler()         throws SAXException {
         try {
            SAXHandler handler = this.createContentHandler();
            this.configureContentHandler(handler);

            return (handler);
         }
         catch (Exception ex1) {
View Full Code Here


    private void executeProcessResponseTestCommand(String inputText,
                                    ProcessResponseTestCommand comm)
            throws Exception {
        HTTPRequestOperationProcess process = (HTTPRequestOperationProcess)
                createTestableProcess();
        SAXHandler handler = new SAXHandler();
        XMLProcess consumer = XMLHelpers.createSAXHandlerProcess(handler);

        WebDriverAccessor accessor = createWebDriverAccessor(
                new WebDriverRequestImpl(), new WebDriverResponseImpl());
        XMLPipelineContext context = process.getPipelineContext();
View Full Code Here

    public void testProcessResponseConfigDefinesResponseContainsPipelineMarkup()
            throws Throwable {

        HTTPRequestOperationProcess process = (HTTPRequestOperationProcess)
                createTestableProcess();
        SAXHandler handler = new SAXHandler();
        XMLProcess consumer = XMLHelpers.createSAXHandlerProcess(handler);

        WebDriverAccessor accessor = createWebDriverAccessor(
                new WebDriverRequestImpl(), new WebDriverResponseImpl());
        XMLPipelineContext context = process.getPipelineContext();
View Full Code Here

     */
    public void testGZIPResponse() throws Exception {
        HTTPRequestOperationProcess process =
                (HTTPRequestOperationProcess) createTestableProcess();

        SAXHandler handler = new SAXHandler();
        XMLProcess consumer = XMLHelpers.createSAXHandlerProcess(handler);
        process.setNextProcess(consumer);

        final String input =
                "<html>" +
                "<head>" +
                    "<title>The title<title>" +
                "</head>" +
                "<h2>A Heading<h2>" +
                "<p>A paragraph<br>Link " +
                    "<a href=nothing1.html>Nothing 1 " +
                        "<a href=nested>nested anchor</a>" +
                        "<p>an anchored p" +
                    "</a>" +
                "</html>";

        // Create a compressed gzip response stream.
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(out);
        gzip.write(input.getBytes());
        gzip.flush();
        gzip.close();
        InputStream responseStream = new ByteArrayInputStream(out.toByteArray());
        process.processResponse(null, responseStream, 200, "text/html", "gzip");

        assertEquals("Next process should match",
                consumer, process.getNextProcess().getNextProcess());

        XMLOutputter outputter = new XMLOutputter();
        outputter.setTrimAllWhite(true);
        outputter.setNewlines(false);
        outputter.setLineSeparator("");
        final String expected =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<html>" +
                "<head>" +
                    "<meta name=\"generator\" content=\"HTML Tidy, see www.w3.org\" />" +
                    "<title>The title</title>" +
                    "<title />" +
                "</head>" +
                "<body>" +
                    "<h2>A Heading</h2>" +
                        "<p>A paragraph<br />\nLink " +
                            "<a href=\"nothing1.html\">Nothing 1 nested anchor</a>" +
                        "</p>" +
                        "<p>an anchored p</p>" +
                "</body>" +
            "</html>";
        String actual = outputter.outputString(handler.getDocument());
        assertEquals("Response read should match original input\n",
                     expected, actual);
    }
View Full Code Here

    }

    private static Element getElement(XMLReader reader, InputSource input)
            throws SAXException, IOException {

        SAXHandler sax2dom = new SAXHandler();
        //SAX2DOM sax2dom = new SAX2DOM();

        reader.setContentHandler(sax2dom);
        reader.setDTDHandler(sax2dom);
        reader.setProperty("http://xml.org/sax/properties/lexical-handler",
                sax2dom);
        reader.setProperty("http://xml.org/sax/properties/declaration-handler",
                sax2dom);
        reader.parse(input);

        Document document = sax2dom.getDocument();
        return document.getRootElement();
    }
View Full Code Here

        RequestOperationProcess process =
                (RequestOperationProcess) createTestableProcess();

        XMLPipelineContext context = process.getPipelineContext();

        SAXHandler saxHandler = new SAXHandler();

        XMLProcess next = XMLHelpers.createSAXHandlerProcess(saxHandler);

        process.setNextProcess(next);

        // Setup the operation and message.
        WSDLOperation operation = new WSDLOperation();
        Message message = new Message();
        WSDriverTestHelpers.setupAmazonOperationMessage(operation,
                message, "Douglas Adams");

        context.setProperty(Operation.class, operation, false);
        context.setProperty(Message.class, message, false);

        process.stopProcess();

        Document document = saxHandler.getDocument();

        String documentString = new XMLOutputter("  ", true).
                outputString(document);       

        assertTrue(documentString.
View Full Code Here

            throws Exception {
        InputSource inputSource = new InputSource(getInputReader(input));
        Document expectedDoc = new SAXBuilder().
                build(getExpectedReader(expected));

        SAXHandler handler = new SAXHandler();
        XMLProcess consumer = XMLHelpers.createSAXHandlerProcess(handler);

        ContextAnnotatingProcess cap = new ContextAnnotatingProcess();
        initializeProcess(cap);
        cap.setNextProcess(consumer);

        ContextManagerProcess cmp = new ContextManagerProcess();
        cmp.setPipeline(cap.getPipeline());
        cmp.setNextProcess(cap);

        XMLReader reader = XMLReaderFactory.createXMLReader(false);
        reader.setContentHandler(cmp);

        reader.parse(inputSource);

        DOMOutputter domOutputter = new DOMOutputter();
        XMLAssert.assertXMLEqual(domOutputter.output(expectedDoc),
                domOutputter.output(handler.getDocument()));
    }
View Full Code Here

     * @throws Exception if an error occurs
     */
    public void testTracker() throws Exception {
        // create a JDOM document from the textXML file
        XMLReader reader = XMLReaderFactory.createXMLReader();
        SAXHandler handler = new SAXHandler();
        reader.setContentHandler(handler);
        InputStream is = new ByteArrayInputStream(testXML.getBytes());
        reader.parse(new InputSource(is));
        Document document = handler.getDocument();

        // create an XPathTracker
        XPathTracker tracker = new XPathTracker(document.getRootElement());

        // create a SAXOutputter
View Full Code Here

    continue;
      }
      // Handle path expression
      if (jdomRes == null) {
    try {
        SAXHandler hdlr = new SAXHandler ();
        seb.emit (hdlr);
        jdomRes = hdlr.getDocument();
    } catch (SAXException e) {
        String msg = "Problem converting SAX to JDOM: "
      + e.getMessage ();
        logger.error (msg, e);
        throw new CannotExecuteException (msg);
View Full Code Here

                (sp, "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                 "http://www.w3.org/2001/XMLSchema", eh);
            maybeSetProperty
                (sp, "http://java.sun.com/xml/jaxp/properties/schemaSource",
                 schemaUris(), eh);
            SAXHandler sh = new SAXHandler ();
            XMLFilter filter = new XmlnsUrisPatcher ();
            filter.setParent(sp.getXMLReader());
            filter.setContentHandler(sh);
            filter.setDTDHandler(sh);
            filter.setEntityResolver(sh);
            filter.setErrorHandler(eh);
            // build Document
            filter.parse(toParse);
            doc = sh.getDocument();
            Element root = doc.getRootElement();
            if (root == null || !root.getName().equals ("Package")
          || !root.getNamespaceURI().equals (XPDLUtil.XPDL_NS)) {
          eh.add (new PrioritizedMessage
            (PrioritizedMessage.Priority.ERROR,
View Full Code Here

TOP

Related Classes of org.jdom.input.SAXHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.