Package org.htmlparser.tags

Examples of org.htmlparser.tags.Tag


        newLine);
  }

  public void testInsertEndTagBeforeTag() throws ParserException {
    String currentLine = "<a href=s/7509><b>Yahoo! Movies</b></a>";
    Tag tag = new Tag(new TagData(0, 14, "a href=s/7509", currentLine));
    LinkScanner linkScanner = new LinkScanner();
    String newLine = linkScanner.insertEndTagBeforeNode(tag, currentLine);
    assertEquals("Expected insertion", "</A><a href=s/7509><b>Yahoo! Movies</b></a>", newLine);
  }
View Full Code Here


    // Register the image scanner
    parser.addScanner(new LinkScanner("-l"));

    parseAndAssertNodeCount(3);
    assertTrue("Node 0 should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Tag Contents", "a", tag.getText());
    assertTrue("Node 1 should be a string node", node[1] instanceof StringNode);
    StringNode stringNode = (StringNode) node[1];
    assertEquals("StringNode Contents", "Revision", stringNode.getText());
    assertTrue("Node 2 should be a string node", node[2] instanceof EndTag);
    EndTag endTag = (EndTag) node[2];
View Full Code Here

    assertEquals("Image Height", "60", imageTag.getAttribute("HEIGHT"));
    assertEquals("Image Width", "468", imageTag.getAttribute("WIDTH"));
    assertEquals("Image Border", "0", imageTag.getAttribute("BORDER"));
    assertEquals("Image Alt", "See Signs in Theaters 8-2 - Starring Mel Gibson", imageTag.getAttribute("ALT"));
    assertTrue("Second contained node should be Tag", containedNodes[1] instanceof Tag);
    Tag tag1 = (Tag) containedNodes[1];
    assertEquals("Tag Contents", "font face=\"verdana,arial,helvetica\" SIZE=\"1\"", tag1.getText());
    assertTrue("Third contained node should be Tag", containedNodes[2] instanceof Tag);
    Tag tag2 = (Tag) containedNodes[2];
    assertEquals("Tag Contents", "b", tag2.getText());
    assertTrue("Fourth contained node should be HTMLEndTag", containedNodes[3] instanceof EndTag);
    EndTag endTag1 = (EndTag) containedNodes[3];
    assertEquals("Fourth Tag contents", "b", endTag1.getText());
    assertTrue("Fifth contained node should be HTMLEndTag", containedNodes[4] instanceof EndTag);
    EndTag endTag2 = (EndTag) containedNodes[4];
View Full Code Here

    parser.addScanner(new FormScanner(parser));
    parseAndAssertNodeCount(1);
    assertTrue("Node 0 should be Form Tag", node[0] instanceof FormTag);
    FormTag formTag = (FormTag) node[0];

    Tag tag = formTag.searchByName("passwd");
    assertNotNull("Should have found the password node", tag);
    assertType("tag found", InputTag.class, tag);
  }
View Full Code Here

  }

  public void testTagExtraction() {
    String testHTML = "<AREA \n coords=0,0,52,52 href=\"http://www.yahoo.com/r/c1\" shape=RECT>";
    createParser(testHTML);
    Tag tag = Tag.find(parser.getReader(), testHTML, 0);
    assertNotNull(tag);
  }
View Full Code Here

    assertEquals("A tag found", 1, visitor.getTagCount(3));
    assertEquals("BODY end tag found", 1, visitor.getEndTagCount(1));
  }

  public void assertTagNameShouldBe(String message, Node node, String expectedTagName) {
    Tag tag = (Tag) node;
    assertStringEquals(message, expectedTagName, tag.getTagName());
  }
View Full Code Here

    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"
View Full Code Here

    assertEquals("custom tag starting loc", 0, customTag.elementBegin());
    assertEquals("custom tag ending loc", 23, customTag.elementEnd());

    Node child = customTag.childAt(0);
    assertType("child", Tag.class, child);
    Tag tag = (Tag) child;
    assertStringEquals("child html", "<HELLO>", child.toHtml());
  }
View Full Code Here

  /**
   * This is the reproduction of a bug which causes a null pointer exception
   */
  public void testExtractImageLocnInvertedCommasBug() throws ParserException {
    Tag tag = new Tag(
        new TagData(
            0,
            0,
            "img width=638 height=53 border=0 usemap=\"#m\" src=http://us.a1.yimg.com/us.yimg.com/i/ww/m5v5.gif alt=Yahoo",
            ""));
View Full Code Here

  public HTMLTagParserTest(String name) {
    super(name);
  }

  public void testCorrectTag() {
    Tag tag = new Tag(new TagData(0, 20,
        "font face=\"Arial,\"helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",
        "<font face=\"Arial,\"helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\">"));
    tagParser.correctTag(tag);
    assertStringEquals("Corrected Tag",
        "font face=\"Arial,helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"", tag.getText());
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.Tag

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.