KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > htmlparser > tests > tagTests > BulletTagTest


1 // HTMLParser Library $Name: v1_5_20050313 $ - A java-based parser for HTML
2
// http://sourceforge.org/projects/htmlparser
3
// Copyright (C) 2003 Derrick Oswald
4
//
5
// Revision Control Information
6
//
7
// $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/BulletTagTest.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/01/14 02:53:47 $
10
// $Revision: 1.2 $
11
//
12
// This library is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU Lesser General Public
14
// License as published by the Free Software Foundation; either
15
// version 2.1 of the License, or (at your option) any later version.
16
//
17
// This library is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
// Lesser General Public License for more details.
21
//
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
//
26

27 package org.htmlparser.tests.tagTests;
28
29 import org.htmlparser.tests.ParserTestCase;
30 import org.htmlparser.tags.Bullet;
31 import org.htmlparser.util.NodeIterator;
32 import org.htmlparser.util.ParserException;
33
34 public class BulletTagTest extends ParserTestCase
35 {
36     static
37     {
38         System.setProperty ("org.htmlparser.tests.tagTests.BulletTagTest", "BulletTagTest");
39     }
40
41     public BulletTagTest (String JavaDoc name)
42     {
43         super(name);
44     }
45     
46     public void testBulletFound() throws Exception JavaDoc {
47         createParser(
48             "<LI><A HREF=\"collapseHierarchy.html\">Collapse Hierarchy</A>\n"+
49             "</LI>"
50         );
51         parseAndAssertNodeCount(1);
52         assertType("should be a bullet",Bullet.class,node[0]);
53     }
54
55
56     public void testOutOfMemoryBug() throws ParserException {
57         createParser(
58             "<html>" +
59             "<head>" +
60             "<title>Foo</title>" +
61             "</head>" +
62             "<body>" +
63             " <ul>" +
64             " <li>" +
65             " <a HREF=\"http://foo.com/c.html\">bibliographies on:" +
66             " <ul>" +
67             " <li>chironomidae</li>" +
68             " </ul>" +
69             " </a>" +
70             " </li>" +
71             " </ul>" +
72             "" +
73             "</body>" +
74             "</html>"
75         );
76         for (NodeIterator i = parser.elements();i.hasMoreNodes();)
77             i.nextNode();
78     }
79
80     public void testNonEndedBullets() throws ParserException {
81         createParser(
82             "<li>forest practices legislation penalties for non-compliance\n"+
83             " (Kwan) <A HREF=\"/hansard/37th3rd/h21107a.htm#4384\">4384-5</A>\n"+
84             "<li>passenger rail service\n"+
85             " (MacPhail) <A HREF=\"/hansard/37th3rd/h21021p.htm#3904\">3904</A>\n"+
86             "<li>referendum on principles for treaty negotiations\n"+
87             " (MacPhail) <A HREF=\"/hansard/37th3rd/h20313p.htm#1894\">1894</A>\n"+
88             "<li>transportation infrastructure projects\n"+
89             " (MacPhail) <A HREF=\"/hansard/37th3rd/h21022a.htm#3945\">3945-7</A>\n"+
90             "<li>tuition fee freeze"
91         );
92         parseAndAssertNodeCount(5);
93         for (int i=0;i<nodeCount;i++) {
94             assertType("node "+i,Bullet.class,node[i]);
95         }
96     }
97 }
98
Popular Tags