KickJava   Java API By Example, From Geeks To Geeks.

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


1 // HTMLParser Library $Name: v1_5_20050313 $ - A java-based parser for HTML
2
// http://sourceforge.org/projects/htmlparser
3
// Copyright (C) 2004 Somik Raha
4
//
5
// Revision Control Information
6
//
7
// $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/TextareaTagTest.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/01/02 16:24:57 $
10
// $Revision: 1.38 $
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.tags.TextareaTag;
30 import org.htmlparser.tests.ParserTestCase;
31 import org.htmlparser.util.ParserException;
32
33 public class TextareaTagTest extends ParserTestCase
34 {
35     static
36     {
37         System.setProperty ("org.htmlparser.tests.tagTests.TextareaTagTest", "TextareaTagTest");
38     }
39
40     private String JavaDoc area1 = "<TEXTAREA name=\"Remarks\" >The intervention by the UN proved beneficial</TEXTAREA>";
41     private String JavaDoc area2 = "<TEXTAREA>The capture of the Somali warloard was elusive</TEXTAREA>";
42     private String JavaDoc area3 = "<TEXTAREA></TEXTAREA>";
43     private String JavaDoc area4 = "<TEXTAREA name=\"Remarks\">The death threats of the organization\n" +
44                             "refused to intimidate the soldiers</TEXTAREA>";
45     private String JavaDoc area5 = "<TEXTAREA name=\"Remarks\">The death threats of the LTTE\n" +
46                             "refused to intimidate the Tamilians\n</TEXTAREA>";
47
48     private String JavaDoc testHTML = area1 + area2 + area3 + area4 + area5;
49
50     private String JavaDoc html = "<TEXTAREA name=\"Remarks\">The intervention by the UN proved beneficial</TEXTAREA>" +
51                           "<TEXTAREA>The capture of the Somali warloard was elusive</TEXTAREA>" +
52                           "<TEXTAREA></TEXTAREA>" +
53                           "<TEXTAREA name=\"Remarks\">The death threats of the organization\n" +
54                           "refused to intimidate the soldiers</TEXTAREA>" +
55                           "<TEXTAREA name=\"Remarks\">The death threats of the LTTE\n" +
56                           "refused to intimidate the Tamilians\n</TEXTAREA>";
57
58     public TextareaTagTest(String JavaDoc name)
59     {
60         super(name);
61     }
62
63     public void setUp() throws Exception JavaDoc
64     {
65         super.setUp();
66         createParser(testHTML);
67         parseAndAssertNodeCount(5);
68     }
69
70     public void testToHTML() throws ParserException
71     {
72         assertTrue("Node 1 should be Textarea Tag",node[0] instanceof TextareaTag);
73         assertTrue("Node 2 should be Textarea Tag",node[1] instanceof TextareaTag);
74         assertTrue("Node 3 should be Textarea Tag",node[2] instanceof TextareaTag);
75         assertTrue("Node 4 should be Textarea Tag",node[3] instanceof TextareaTag);
76         assertTrue("Node 5 should be Textarea Tag",node[4] instanceof TextareaTag);
77         TextareaTag textareaTag;
78         textareaTag = (TextareaTag) node[0];
79         assertStringEquals("HTML String 1",area1,textareaTag.toHtml());
80         textareaTag = (TextareaTag) node[1];
81         assertStringEquals("HTML String 2",area2,textareaTag.toHtml());
82         textareaTag = (TextareaTag) node[2];
83         assertStringEquals("HTML String 3",area3,textareaTag.toHtml());
84         textareaTag = (TextareaTag) node[3];
85         assertStringEquals("HTML String 4",area4,textareaTag.toHtml());
86         textareaTag = (TextareaTag) node[4];
87         assertStringEquals("HTML String 5",area5,textareaTag.toHtml());
88
89     }
90
91     public void testScan() throws ParserException
92     {
93         createParser(html);
94         parseAndAssertNodeCount(5);
95
96         // check the Textarea node
97
for(int j=0;j<nodeCount;j++)
98             assertTrue(node[j] instanceof TextareaTag);
99     }
100 }
101
Popular Tags