Package org.htmlparser.tags

Examples of org.htmlparser.tags.JspTag


    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

    // Register the Jsp Scanner
    parser.addScanner(new JspScanner("-j"));
    parseAndAssertNodeCount(5);
    // The first node should be an HTMLJspTag
    assertTrue("Node 1 should be an HTMLJspTag", node[0] instanceof JspTag);
    JspTag tag = (JspTag) node[0];
    assertStringEquals("Contents of the tag", "@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" ", tag
        .getText());

    // The second node should be a normal tag
    assertTrue("Node 2 should be an Tag", node[1] instanceof Tag);
    Tag htag = (Tag) node[1];
    assertStringEquals("Contents of the tag",
        "jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"", htag.getText());
    assertStringEquals("html", "<JSP:USEBEAN ID=\"transfer\" SCOPE=\"session\" CLASS=\"com.bank.PageBean\"/>", htag
        .toHtml());
    // The third node should be an HTMLJspTag
    assertTrue("Node 3 should be an HTMLJspTag", node[2] instanceof JspTag);
    JspTag tag2 = (JspTag) node[2];
    String expected = "\r\n" + "    org.apache.struts.util.BeanUtils.populate(transfer, request);\r\n"
        + "    if(request.getParameter(\"marker\") == null)\r\n"
        + "        // initialize a pseudo-property\r\n"
        + "        transfer.set(\"days\", java.util.Arrays.asList(\r\n"
        + "            new String[] {\"1\", \"2\", \"3\", \"4\", \"31\"}));\r\n" + "    else \r\n"
        + "        if(transfer.validate(request))\r\n" + "            ";
    assertEquals("Contents of the tag", expected, tag2.getText());

  }
View Full Code Here

    // Register the Jsp Scanner
    parser.addScanner(new JspScanner("-j"));
    parseAndAssertNodeCount(5);
    // The first node should be an HTMLJspTag
    assertTrue("Node 1 should be an HTMLJspTag", 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());

    // The third node should be an HTMLJspTag
    assertTrue("Node 2 should be an HTMLJspTag", node[2] instanceof JspTag);
    JspTag tag2 = (JspTag) node[2];
    String expected = "<%\r\n" + "    org.apache.struts.util.BeanUtils.populate(transfer, request);\r\n"
        + "    if(request.getParameter(\"marker\") == null)\r\n"
        + "        // initialize a pseudo-property\r\n"
        + "        transfer.set(\"days\", java.util.Arrays.asList(\r\n"
        + "            new String[] {\"1\", \"2\", \"3\", \"4\", \"31\"}));\r\n" + "    else \r\n"
        + "        if(transfer.validate(request))\r\n" + "            %>";
    assertEquals("Raw String of the second JSP tag", expected, tag2.toHtml());
    assertTrue("Node 4 should be an HTMLJspTag", node[4] instanceof JspTag);
    JspTag tag4 = (JspTag) node[4];
    expected = "<%\r\n" + "%>";
    assertEquals("Raw String of the fourth JSP tag", expected, tag4.toHtml());

  }
View Full Code Here

    // Register the jsp scanner
    parser.addScanner(new JspScanner("-j"));
    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

    // Register the Jsp Scanner
    parser.addScanner(new JspScanner("-j"));
    parseAndAssertNodeCount(4);
    // The first node should be an HTMLJspTag
    assertTrue("Third should be an HTMLJspTag", node[2] instanceof JspTag);
    JspTag tag = (JspTag) node[2];
    assertEquals("tag contents", "=object", tag.getText());
  }
View Full Code Here

  }

  protected Tag createTag(TagData tagData, Tag tag, String url) throws ParserException {
    String tagContents = tagData.getTagContents();
    tagData.setTagContents(tagContents.substring(1, tagContents.length() - 1));
    return new JspTag(tagData);
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.JspTag

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.