KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > htmlparser > tests > scannersTests > FrameScannerTest


1 // $Header: /home/cvs/jakarta-jmeter/src/htmlparser/org/htmlparser/tests/scannersTests/FrameScannerTest.java,v 1.2 2004/02/11 02:16:58 woolfel Exp $
2
/*
3  * ====================================================================
4  * Copyright 2002-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */

19
20 // The developers of JMeter and Apache are greatful to the developers
21
// of HTMLParser for giving Apache Software Foundation a non-exclusive
22
// license. The performance benefits of HTMLParser are clear and the
23
// users of JMeter will benefit from the hard work the HTMLParser
24
// team. For detailed information about HTMLParser, the project is
25
// hosted on sourceforge at http://htmlparser.sourceforge.net/.
26
//
27
// HTMLParser was originally created by Somik Raha in 2000. Since then
28
// a healthy community of users has formed and helped refine the
29
// design so that it is able to tackle the difficult task of parsing
30
// dirty HTML. Derrick Oswald is the current lead developer and was kind
31
// enough to assist JMeter.
32

33 package org.htmlparser.tests.scannersTests;
34
35 import org.htmlparser.scanners.FrameScanner;
36 import org.htmlparser.tags.FrameTag;
37 import org.htmlparser.tests.ParserTestCase;
38 import org.htmlparser.util.ParserException;
39
40 public class FrameScannerTest extends ParserTestCase
41 {
42
43     public FrameScannerTest(String JavaDoc name)
44     {
45         super(name);
46     }
47
48     public void testScan() throws ParserException
49     {
50         createParser(
51             "<frameset rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">\n"
52                 + "<frame name=\"topFrame\" noresize SRC=\"demo_bc_top.html\" scrolling=\"NO\" frameborder=\"NO\">\n"
53                 + "<frame name=\"mainFrame\" SRC=\"http://www.kizna.com/web_e/\" scrolling=\"AUTO\">\n"
54                 + "</frameset>",
55             "http://www.google.com/test/index.html");
56
57         parser.addScanner(new FrameScanner(""));
58
59         parseAndAssertNodeCount(4);
60
61         assertTrue("Node 1 should be Frame Tag", node[1] instanceof FrameTag);
62         assertTrue("Node 2 should be Frame Tag", node[2] instanceof FrameTag);
63
64         FrameTag frameTag1 = (FrameTag) node[1];
65         FrameTag frameTag2 = (FrameTag) node[2];
66         assertEquals(
67             "Frame 1 Locn",
68             "http://www.google.com/test/demo_bc_top.html",
69             frameTag1.getFrameLocation());
70         assertEquals("Frame 1 Name", "topFrame", frameTag1.getFrameName());
71         assertEquals(
72             "Frame 2 Locn",
73             "http://www.kizna.com/web_e/",
74             frameTag2.getFrameLocation());
75         assertEquals("Frame 2 Name", "mainFrame", frameTag2.getFrameName());
76         assertEquals(
77             "Frame 1 Scrolling",
78             "NO",
79             frameTag1.getAttribute("scrolling"));
80         assertEquals(
81             "Frame 1 Border",
82             "NO",
83             frameTag1.getAttribute("frameborder"));
84     }
85 }
86
Popular Tags