Package org.htmlparser.tags

Examples of org.htmlparser.tags.BodyTag


    }

    public void testBodywithJsp() throws ParserException {
        String body = "<body><%=BodyValue%></body>";
        createParser("<html><head><title>Test 1</title></head>" + body + "</html>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new BodyTag ()));
        parseAndAssertNodeCount(8);
        assertTrue(node[6] instanceof BodyTag);
        // check the body node
        BodyTag bodyTag = (BodyTag) node[6];
        assertStringEquals("Body",body,bodyTag.toHtml());
    }
View Full Code Here


        createParser("<html><head><title>Test 1</title></head>" + body + "</html>");
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new BodyTag (),
                    new TitleTag (),
                }));
        parseAndAssertNodeCount(6);
        assertTrue(node[4] instanceof BodyTag);
        // check the body node
        BodyTag bodyTag = (BodyTag) node[4];
        assertEquals("Body",body,bodyTag.toHtml());
    }
View Full Code Here

    }

    public void testBodyEnding() throws ParserException {
        String body = "<body>before jsp<%=BodyValue%>after jsp";
        createParser("<html>" + body + "</html>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new BodyTag ()));
        parseAndAssertNodeCount(3);
        assertTrue(node[1] instanceof BodyTag);
        // check the body node
        BodyTag bodyTag = (BodyTag) node[1];
        assertEquals("Body",body + "</body>",bodyTag.toHtml());
    }
View Full Code Here

        html = "<html>" + guts + "</html>";
        createParser (html);
        list = parser.extractAllNodesThatMatch (new NodeClassFilter (BodyTag.class));
        assertEquals ("only one element", 1, list.size ());
        assertType ("should be BodyTag", BodyTag.class, list.elementAt (0));
        BodyTag body = (BodyTag)list.elementAt (0);
        assertEquals ("only one child", 1, body.getChildCount ());
        assertSuperType ("should be Text", Text.class, body.getChildren ().elementAt (0));
        assertStringEquals("html", guts, body.toHtml ());
    }
View Full Code Here

        String testHTML1 = sb1.toString();

        createParser(testHTML1,"http://www.google.com/test/index.html");
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a body tag", node[0] instanceof BodyTag);
        BodyTag body = (BodyTag)node[0];
        assertTrue("Node should have one child", 1 == body.getChildCount ());
        assertTrue("Child should be a script tag", body.getChild (0) instanceof ScriptTag);
        // Check the data in the script tag
        ScriptTag scriptTag = (ScriptTag)body.getChild (0);
        String s = scriptTag.getScriptCode();
        assertStringEquals("Expected Script Code",testHTML2,s);
    }
View Full Code Here

        parser = new Parser(url);
        PrototypicalNodeFactory factory = new PrototypicalNodeFactory ();
        // we want to expose the repetitive tags
        factory.unregisterTag (new Html ());
        factory.unregisterTag (new HeadTag ());
        factory.unregisterTag (new BodyTag ());
        factory.unregisterTag (new ParagraphTag ());
        parser.setNodeFactory (factory);
        i = 0;
        nodes = new Node[50];
        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
View Full Code Here

            + "onload=setfocus() text=#000000\nvLink=#551a8b>";
        createParser(body);
        parseAndAssertNodeCount(1);
        // The node should be a body Tag
        assertTrue("Node should be a BodyTag",node[0] instanceof BodyTag);
        BodyTag tag = (BodyTag)node[0];
        String text = tag.toHtml ();
        assertEquals("Contents of the tag",body + "</BODY>",text);
    }
View Full Code Here

        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        assertEquals("Third node has incorrect text","text<>text",stringNode.getText());
    }
View Full Code Here

        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        String actual = stringNode.getText();
        assertEquals("Third node has incorrect text","text\n<>text",actual);
    }
View Full Code Here

        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        String actual = stringNode.getText();
        assertEquals("Third node has incorrect text","text<\n>text",actual);
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.BodyTag

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.