1 27 package org.htmlparser.tests.tagTests; 28 29 import org.htmlparser.PrototypicalNodeFactory; 30 import org.htmlparser.Tag; 31 import org.htmlparser.tags.FrameSetTag; 32 import org.htmlparser.tags.FrameTag; 33 import org.htmlparser.tests.ParserTestCase; 34 import org.htmlparser.util.ParserException; 35 36 public class FrameSetTagTest extends ParserTestCase { 37 38 static 39 { 40 System.setProperty ("org.htmlparser.tests.tagTests.FrameSetTagTest", "FrameSetTagTest"); 41 } 42 43 public FrameSetTagTest(String name) { 44 super(name); 45 } 46 47 public void testToHTML() throws ParserException{ 48 String html = "<frameset rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">\n"+ 49 "<frame name=\"topFrame\" noresize SRC=\"demo_bc_top.html\" scrolling=\"NO\" frameborder=\"NO\">\n"+ 50 "<frame name=\"mainFrame\" SRC=\"http://www.kizna.com/web_e/\" scrolling=\"AUTO\">\n"+ 51 "</frameset>"; 52 createParser(html); 53 parseAndAssertNodeCount(1); 54 assertTrue("Node 0 should be a FrameSetTag",node[0] instanceof FrameSetTag); 55 FrameSetTag frameSetTag = (FrameSetTag)node[0]; 56 assertStringEquals("HTML Contents", html, frameSetTag.toHtml()); 57 } 58 59 public void testScan() throws ParserException { 60 createParser( 61 "<frameset rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">\n"+ 62 "<frame name=\"topFrame\" noresize SRC=\"demo_bc_top.html\" scrolling=\"NO\" frameborder=\"NO\">\n"+ 63 "<frame name=\"mainFrame\" SRC=\"http://www.kizna.com/web_e/\" scrolling=\"AUTO\">\n"+ 64 "</frameset>","http://www.google.com/test/index.html"); 65 66 parser.setNodeFactory ( 67 new PrototypicalNodeFactory ( 68 new Tag[] 69 { 70 new FrameSetTag (), 71 new FrameTag (), 72 })); 73 parseAndAssertNodeCount(1); 74 assertTrue("Node 0 should be End Tag",node[0] instanceof FrameSetTag); 75 FrameSetTag frameSetTag = (FrameSetTag)node[0]; 76 assertEquals("Rows","115,*",frameSetTag.getAttribute("rows")); 78 assertEquals("FrameBorder","NO",frameSetTag.getAttribute("FrameBorder")); 79 assertEquals("FrameSpacing","0",frameSetTag.getAttribute("FrameSpacing")); 80 assertEquals("Border","0",frameSetTag.getAttribute("Border")); 81 FrameTag topFrame = frameSetTag.getFrame("topFrame"); 83 FrameTag mainFrame = frameSetTag.getFrame("mainFrame"); 84 assertNotNull("Top Frame should not be null",topFrame); 85 assertNotNull("Main Frame should not be null",mainFrame); 86 assertEquals("Top Frame Name","topFrame",topFrame.getFrameName()); 87 assertEquals("Top Frame Location","http://www.google.com/test/demo_bc_top.html",topFrame.getFrameLocation()); 88 assertEquals("Main Frame Name","mainFrame",mainFrame.getFrameName()); 89 assertEquals("Main Frame Location","http://www.kizna.com/web_e/",mainFrame.getFrameLocation()); 90 assertEquals("Scrolling in Main Frame","AUTO",mainFrame.getAttribute("Scrolling")); 91 } 92 } 93 94
| Popular Tags
|