Package org.htmlparser

Examples of org.htmlparser.PrototypicalNodeFactory


     * Based on a bug report submitted by Cedric Rosa, if the last line contains a single character,
     * Text does not return the string node correctly.
     */
    public void testLastLineWithOneChar() throws ParserException {
        createParser("a");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("First node should be Text",node[0] instanceof Text);
        Text stringNode = (Text)node[0];
        assertEquals("First String node contents","a",stringNode.getText());
    }
View Full Code Here


    }

    public void testStringWithEmptyLine() throws ParserException {
        String text = "a\n\nb";
        createParser(text);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("First node should be Text",node[0] instanceof Text);
        Text stringNode = (Text)node[0];
        assertStringEquals("First String node contents",text,stringNode.getText());
    }
View Full Code Here

    }

    public void testStringWithLineBreaks() throws Exception {
        String text = "Testing &\nRefactoring";
        createParser(text);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("first node",Text.class,node[0]);
        Text stringNode = (Text)node[0];
        assertStringEquals("text",text,stringNode.toPlainTextString());
    }
View Full Code Here

    public void testScan() throws Exception {
        createParser(
            HTML_WITH_SPAN
        );
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[] {
                    new TableColumn (),
                    new Span (),
                }));
        parseAndAssertNodeCount(1);
View Full Code Here

        createParser(
            "<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>\n"+
            jsp + "\n" +
            "<" + contents2 + ">\n<jsp:forward page=\"transferConfirm.jsp\"/><%\n"+
            "%>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(8);
        // The first node should be a JspTag
        assertTrue("Node 1 should be a JspTag",node[0] instanceof JspTag);
        JspTag tag = (JspTag)node[0];
        assertStringEquals("Contents of the tag","%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %",tag.getText());
View Full Code Here

            "<jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"/>\n"+
            "<%" +
            guts
            + "%><jsp:forward page=\"transferConfirm.jsp\"/><%\n"+
            "%>\n");
        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(8);
        // The first node should be a JspTag
        assertTrue("Node 1 should be a JspTag",node[0] instanceof JspTag);
        JspTag tag = (JspTag)node[0];
        assertEquals("Raw String of the first JSP tag","<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>",tag.toHtml());
View Full Code Here

    public void testSpecialCharacters() throws ParserException {
        StringBuffer sb1 = new StringBuffer();
        sb1.append("<% for (i=0;i<j;i++);%>");
        createParser(sb1.toString());
        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(1);
        //assertTrue("Node should be a jsp tag",node[1] instanceof HTMLJspTag);
        JspTag jspTag = (JspTag)node[0];
        assertEquals("jsp toHTML()","<% for (i=0;i<j;i++);%>",jspTag.toHtml());
    }
View Full Code Here

    }

    private void testJspTagsInAttributes(String html) throws ParserException
    {
        createParser (html);
        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        if (JSP_TESTS_ENABLED)
        {
            parseAndAssertNodeCount (7);

            assertTrue ("Should be a Jsp tag but was " + node[1].getClass().getName(), node[1] instanceof JspTag);
View Full Code Here

        createParser(
        "<h1>\n"+
        "This is a <%=object%>\n"+
        "</h1>");

        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(5);
        // The first node should be an JspTag
        assertTrue("Third should be an JspTag",node[2] instanceof JspTag);
        JspTag tag = (JspTag)node[2];
        assertEquals("tag contents","%=object%",tag.getText());
View Full Code Here

                "return value.substring(indexs+9,indexe-2);\n" +
                "}\n" +
                "return value;\n" +
                "}\n" +
                "%>");
            parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
            parseAndAssertNodeCount(1);
        }
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.PrototypicalNodeFactory

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.