[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/tagTests AppletTagTest.java,1.30,1.31 FormTagTe
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests In directory sc8-pr-cvs1:/tmp/cvs-serv10542/tests/tagTests Modified Files: AppletTagTest.java FormTagTest.java JspTagTest.java ScriptTagTest.java TagTest.java Log Message: Partition Attribute into a base class and PageAttribute class for the Lexer. Fixed the AppletTag.setAppletParams in a cheesy manner. Clear out the released NodeList entry on remove(). Dropped the HTMLTagParserTest tests, because they really weren't relevant any more. Index: AppletTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/AppletTagTest.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** AppletTagTest.java 6 Oct 2003 01:43:28 -0000 1.30 --- AppletTagTest.java 18 Oct 2003 20:50:37 -0000 1.31 *************** *** 170,179 **** // Check the data in the applet tag String expectedRawString = ! "<APPLET CODE=MyOtherClass.class ARCHIVE=htmlparser.jar CODEBASE=htmlparser.sourceforge.net>\n"+ "<PARAM VALUE=\"One\" NAME=\"First\">"+ - "<PARAM VALUE=\"Two\" NAME=\"Second\">"+ "<PARAM VALUE=\"3\" NAME=\"Third\">"+ "</APPLET>"; ! assertStringEquals("toHTML()",expectedRawString,appletTag.toHtml()); } } --- 170,180 ---- // Check the data in the applet tag String expectedRawString = ! "<APPLET CODE=Myclass.class ARCHIVE=test.jar CODEBASE=www.kizna.com>\n"+ ! "<PARAM VALUE=\"Two\" NAME=\"Second\">"+ // note these are out of orer because of the hashtable "<PARAM VALUE=\"One\" NAME=\"First\">"+ "<PARAM VALUE=\"3\" NAME=\"Third\">"+ "</APPLET>"; ! String actual = appletTag.toHtml(); ! assertStringEquals("toHTML()",expectedRawString,actual); } } Index: FormTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/FormTagTest.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** FormTagTest.java 13 Oct 2003 21:48:14 -0000 1.34 --- FormTagTest.java 18 Oct 2003 20:50:37 -0000 1.35 *************** *** 57,61 **** String expected = FormScannerTest.FORM_HTML.substring (0, FormScannerTest.FORM_HTML.indexOf ("\"do_login.php\"")) ! + "http://www.yahoo.com/yahoo/do_not_login.jsp" + FormScannerTest.FORM_HTML.substring (FormScannerTest.FORM_HTML.indexOf ("\"do_login.php\"") + 14); assertStringEquals("Raw String",expected,formTag.toHtml()); --- 57,61 ---- String expected = FormScannerTest.FORM_HTML.substring (0, FormScannerTest.FORM_HTML.indexOf ("\"do_login.php\"")) ! + "\"http://www.yahoo.com/yahoo/do_not_login.jsp\"" + FormScannerTest.FORM_HTML.substring (FormScannerTest.FORM_HTML.indexOf ("\"do_login.php\"") + 14); assertStringEquals("Raw String",expected,formTag.toHtml()); Index: JspTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/JspTagTest.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** JspTagTest.java 13 Oct 2003 21:48:14 -0000 1.33 --- JspTagTest.java 18 Oct 2003 20:50:37 -0000 1.34 *************** *** 62,69 **** public void testJspTag() throws ParserException { ! createParser( ! "<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>\n"+ ! "<jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"/>\n"+ ! "<%\n"+ " org.apache.struts.util.BeanUtils.populate(transfer, request);\n"+ " if(request.getParameter(\"marker\") == null)\n"+ --- 62,68 ---- public void testJspTag() throws ParserException { ! String contents = "jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"/"; ! String jsp = "<" + contents + ">"; ! String contents2 = "%\n"+ " org.apache.struts.util.BeanUtils.populate(transfer, request);\n"+ " if(request.getParameter(\"marker\") == null)\n"+ *************** *** 73,78 **** " else \n"+ " if(transfer.validate(request))\n"+ ! " %><jsp:forward page=\"transferConfirm.jsp\"/><%\n"+ ! "%>\n"); Parser.setLineSeparator("\r\n"); // Register the Jsp Scanner --- 72,81 ---- " else \n"+ " if(transfer.validate(request))\n"+ ! " %"; ! createParser( ! "<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>\n"+ ! jsp + "\n" + ! "<" + contents2 + ">\n<jsp:forward page=\"transferConfirm.jsp\"/><%\n"+ ! "%>"); Parser.setLineSeparator("\r\n"); // Register the Jsp Scanner *************** *** 87,105 **** assertTrue("Node 3 should be a normal Tag",node[2] instanceof Tag); Tag htag = (Tag)node[2]; ! assertStringEquals("Contents of the tag","jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"",htag.getText()); ! assertStringEquals("html","<JSP:USEBEAN ID=\"transfer\" SCOPE=\"session\" CLASS=\"com.bank.PageBean\"/>",htag.toHtml()); // The third node should be an JspTag assertTrue("Node 5 should be an JspTag",node[4] instanceof JspTag); JspTag tag2 = (JspTag)node[4]; ! String expected = "\r\n"+ ! " org.apache.struts.util.BeanUtils.populate(transfer, request);\r\n"+ ! " if(request.getParameter(\"marker\") == null)\r\n"+ ! " // initialize a pseudo-property\r\n"+ ! " transfer.set(\"days\", java.util.Arrays.asList(\r\n"+ ! " new String[] {\"1\", \"2\", \"3\", \"4\", \"31\"}));\r\n"+ ! " else \r\n"+ ! " if(transfer.validate(request))\r\n"+ ! " "; ! assertEquals("Contents of the tag",expected,tag2.getText()); } --- 90,99 ---- assertTrue("Node 3 should be a normal Tag",node[2] instanceof Tag); Tag htag = (Tag)node[2]; ! assertStringEquals("Contents of the tag",contents,htag.getText()); ! assertStringEquals("html",jsp,htag.toHtml()); // The third node should be an JspTag assertTrue("Node 5 should be an JspTag",node[4] instanceof JspTag); JspTag tag2 = (JspTag)node[4]; ! assertEquals("Contents of the tag",contents2,tag2.getText()); } Index: ScriptTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/ScriptTagTest.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** ScriptTagTest.java 6 Oct 2003 01:43:28 -0000 1.32 --- ScriptTagTest.java 18 Oct 2003 20:50:37 -0000 1.33 *************** *** 53,76 **** } ! public void testCreation() { ! fail ("not implemented"); ! // StringNode stringNode = ! // new StringNode(new StringBuffer("Script Code"),0,0); ! // NodeList childVector = new NodeList(); ! // childVector.add(stringNode); ! // ScriptTag scriptTag = ! // new ScriptTag( ! // new TagData(0,10,"Tag Contents","tagline"), ! // new CompositeTagData(null,null,childVector) ! // ); ! // ! // assertNotNull("Script Tag object creation",scriptTag); ! // assertEquals("Script Tag Begin",0,scriptTag.elementBegin()); ! // assertEquals("Script Tag End",10,scriptTag.elementEnd()); ! // assertEquals("Script Tag Contents","Tag Contents",scriptTag.getText()); ! // assertEquals("Script Tag Code","Script Code",scriptTag.getScriptCode()); ! // assertEquals("Script Tag Line","tagline",scriptTag.getTagLine()); } - public void testToHTML() throws ParserException { --- 53,69 ---- } ! public void testCreation() throws ParserException ! { ! String testHtml = "<SCRIPT>Script Code</SCRIPT>"; ! createParser(testHtml,"http://localhost/index.html"); ! // Register the script scanner ! parser.addScanner(new ScriptScanner("-s")); ! parseAndAssertNodeCount(1); ! assertTrue("Node should be a script tag",node[0] instanceof ScriptTag); ! ScriptTag scriptTag = (ScriptTag)node[0]; ! assertEquals("Script Tag Begin",0,scriptTag.elementBegin()); ! assertEquals("Script Tag End",28,scriptTag.elementEnd()); ! assertEquals("Script Tag Code","Script Code",scriptTag.getScriptCode()); } public void testToHTML() throws ParserException { Index: TagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/TagTest.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** TagTest.java 13 Oct 2003 21:48:14 -0000 1.47 --- TagTest.java 18 Oct 2003 20:50:37 -0000 1.48 *************** *** 588,615 **** assertStringEquals("Expected HTML",expectedHTML,htmlTag.toHtml()); } - public void testIgnoreState() throws ParserException { - fail ("not implemented"); - // String testHTML = "<A \n"+ - // "HREF=\"/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html\">20020702 Report 1</A>"; - // createParser(testHTML); - // Node node = Tag.find(parser.getReader(),testHTML,0); - // assertTrue("Node should be a tag",node instanceof Tag); - // Tag tag = (Tag)node; - // String href = tag.getAttribute("HREF"); - // assertStringEquals("Resolved Link","/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html",href); ! } ! public void testExtractWord() { ! fail ("not implemented"); ! // String line = "Abc DEF GHHI"; ! // assertEquals("Word expected","ABC",Tag.extractWord(line)); ! // String line2= "%\n "; ! // assertEquals("Word expected for line 2","%",Tag.extractWord(line2)); ! // String line3 = "%\n%>"; ! // assertEquals("Word expected for line 3","%",Tag.extractWord(line3)); ! // String line4 = "%=abc%>"; ! // assertEquals("Word expected for line 4","%",Tag.extractWord(line4)); ! // String line5 = "OPTION"; ! // assertEquals("Word expected for line 5","OPTION",Tag.extractWord(line5)); } --- 588,603 ---- assertStringEquals("Expected HTML",expectedHTML,htmlTag.toHtml()); } ! public void testIgnoreState() throws ParserException ! { ! String testHTML = "<A \n"+ ! "HREF=\"/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html\">20020702 Report 1</A>"; ! createParser(testHTML); ! parser.registerScanners (); ! parseAndAssertNodeCount(1); ! assertTrue("Node should be a tag",node[0] instanceof Tag); ! Tag tag = (Tag)node[0]; ! String href = tag.getAttribute("HREF"); ! assertStringEquals("Resolved Link","/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html",href); } |