KickJava   Java API By Example, From Geeks To Geeks.

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


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/SpanTagTest.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/07/02 00:49:31 $
10
// $Revision: 1.3 $
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.Node;
30 import org.htmlparser.PrototypicalNodeFactory;
31 import org.htmlparser.Tag;
32 import org.htmlparser.tags.Span;
33 import org.htmlparser.tags.TableColumn;
34 import org.htmlparser.tests.ParserTestCase;
35
36 public class SpanTagTest extends ParserTestCase
37 {
38     static
39     {
40         System.setProperty ("org.htmlparser.tests.tagTests.SpanTagTest", "SpanTagTest");
41     }
42
43     private static final String JavaDoc HTML_WITH_SPAN =
44         "<TD BORDER=\"0.0\" VALIGN=\"Top\" COLSPAN=\"4\" WIDTH=\"33.33%\">" +
45         " <DIV>" +
46         " <SPAN>Flavor: small(90 to 120 minutes)<BR /></SPAN>" +
47         " <SPAN>The short version of our Refactoring Challenge gives participants a general feel for the smells in the code base and includes time for participants to find and implement important refactorings.&#013;<BR /></SPAN>" +
48         " </DIV>" +
49         "</TD>";
50
51     public SpanTagTest (String JavaDoc name)
52     {
53         super(name);
54     }
55     
56     public void testScan() throws Exception JavaDoc {
57         createParser(
58             HTML_WITH_SPAN
59         );
60         parser.setNodeFactory (
61             new PrototypicalNodeFactory (
62                 new Tag[] {
63                     new TableColumn (),
64                     new Span (),
65                 }));
66         parseAndAssertNodeCount(1);
67         assertType("node",TableColumn.class,node[0]);
68         TableColumn col = (TableColumn)node[0];
69         Node spans [] = col.searchFor(Span.class, true).toNodeArray();
70         assertEquals("number of spans found",2,spans.length);
71         assertStringEquals(
72             "span 1",
73             "Flavor: small(90 to 120 minutes)",
74             spans[0].toPlainTextString()
75         );
76         assertStringEquals(
77             "span 2",
78             "The short version of our Refactoring Challenge gives participants a general feel for the smells in the code base and includes time for participants to find and implement important refactorings.&#013;",
79             spans[1].toPlainTextString()
80         );
81
82     }
83 }
84
Popular Tags