[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests AllTests.java,1.49,1.50 AssertXmlEqualsTest.jav
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-09-10 03:39:08
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests In directory sc8-pr-cvs1:/tmp/cvs-serv24483/src/org/htmlparser/tests Modified Files: AllTests.java AssertXmlEqualsTest.java BadTagIdentifier.java FunctionalTests.java InstanceofPerformanceTest.java LineNumberAssignedByNodeReaderTest.java ParserTest.java ParserTestCase.java PerformanceTest.java package.html Log Message: Add style checking target to ant build script: ant checkstyle It uses a jar from http://checkstyle.sourceforge.net which is dropped in the lib directory. The rules are in the file htmlparser_checks.xml in the src directory. Added lexerapplications package with Tabby as the first app. It performs whitespace manipulation on source files to follow the style rules. This reduced the number of style violations to roughly 14,000. There are a few issues with the style checker that need to be resolved before it should be taken too seriously. For example: It thinks all method arguments should be final, even if they are modified by the code (which the compiler frowns on). It complains about long lines, even when there is no possibility of wrapping the line, i.e. a URL in a comment that's more than 80 characters long. It considers all naked integers as 'magic numbers', even when they are obvious, i.e. the 4 corners of a box. It complains about whitespace following braces, even in array initializers, i.e. X[][] = { {a, b} { } } But it points out some really interesting things, even if you don't agree with the style guidelines, so it's worth a look. Index: AllTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/AllTests.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** AllTests.java 8 Sep 2003 02:26:30 -0000 1.49 --- AllTests.java 10 Sep 2003 03:38:23 -0000 1.50 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 31,35 **** import junit.framework.TestSuite; ! public class AllTests extends junit.framework.TestCase { --- 31,35 ---- import junit.framework.TestSuite; ! public class AllTests extends junit.framework.TestCase { *************** *** 115,119 **** suite.addTest(LineNumberAssignedByNodeReaderTest.suite()); return suite; ! } } --- 115,119 ---- suite.addTest(LineNumberAssignedByNodeReaderTest.suite()); return suite; ! } } Index: AssertXmlEqualsTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/AssertXmlEqualsTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AssertXmlEqualsTest.java 8 Sep 2003 02:26:30 -0000 1.11 --- AssertXmlEqualsTest.java 10 Sep 2003 03:38:23 -0000 1.12 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 37,49 **** super(name); } ! public void testNestedTagWithText() throws Exception { assertXmlEquals("nested with text","<hello> <hi>My name is Nothing</hi></hello>","<hello><hi>My name is Nothing</hi> </hello>"); } ! public void testThreeTagsDifferent() throws Exception { assertXmlEquals("two tags different","<someTag></someTag><someOtherTag>","<someTag/><someOtherTag>"); } ! public void testOneTag() throws Exception { assertXmlEquals("one tag","<someTag>","<someTag>"); --- 37,49 ---- super(name); } ! public void testNestedTagWithText() throws Exception { assertXmlEquals("nested with text","<hello> <hi>My name is Nothing</hi></hello>","<hello><hi>My name is Nothing</hi> </hello>"); } ! public void testThreeTagsDifferent() throws Exception { assertXmlEquals("two tags different","<someTag></someTag><someOtherTag>","<someTag/><someOtherTag>"); } ! public void testOneTag() throws Exception { assertXmlEquals("one tag","<someTag>","<someTag>"); *************** *** 57,77 **** assertXmlEquals("two tags different","<someTag></someTag>","<someTag/>"); } ! public void testTwoTagsDifferent2() throws Exception { assertXmlEquals("two tags different","<someTag/>","<someTag></someTag>"); } ! public void testTwoTagsWithSameAttributes() throws Exception { assertXmlEquals("attributes","<tag name=\"John\" age=\"22\" sex=\"M\"/>","<tag sex=\"M\" name=\"John\" age=\"22\"/>"); } ! public void testTagWithText() throws Exception { assertXmlEquals("text","<hello> My name is Nothing</hello>","<hello>My name is Nothing </hello>"); } ! public void testStringWithLineBreaks() throws Exception { assertXmlEquals("string with line breaks","testing & refactoring","testing &\nrefactoring"); } ! public static TestSuite suite() { TestSuite suite = new TestSuite("XML Tests"); --- 57,77 ---- assertXmlEquals("two tags different","<someTag></someTag>","<someTag/>"); } ! public void testTwoTagsDifferent2() throws Exception { assertXmlEquals("two tags different","<someTag/>","<someTag></someTag>"); } ! public void testTwoTagsWithSameAttributes() throws Exception { assertXmlEquals("attributes","<tag name=\"John\" age=\"22\" sex=\"M\"/>","<tag sex=\"M\" name=\"John\" age=\"22\"/>"); } ! public void testTagWithText() throws Exception { assertXmlEquals("text","<hello> My name is Nothing</hello>","<hello>My name is Nothing </hello>"); } ! public void testStringWithLineBreaks() throws Exception { assertXmlEquals("string with line breaks","testing & refactoring","testing &\nrefactoring"); } ! public static TestSuite suite() { TestSuite suite = new TestSuite("XML Tests"); Index: BadTagIdentifier.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/BadTagIdentifier.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** BadTagIdentifier.java 8 Sep 2003 02:26:30 -0000 1.11 --- BadTagIdentifier.java 10 Sep 2003 03:38:23 -0000 1.12 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 38,53 **** } ! public static void main(String[] args) throws Exception { ! BadTagIdentifier badTags = new BadTagIdentifier(); badTags.identify("http://www.amazon.com"); } ! ! private void identify(String url) throws Exception{ ! String [] tagsBeingChecked = {"TABLE","DIV","SPAN"}; ! Parser parser = new Parser(url); --- 38,53 ---- } ! public static void main(String[] args) throws Exception { ! BadTagIdentifier badTags = new BadTagIdentifier(); badTags.identify("http://www.amazon.com"); } ! ! private void identify(String url) throws Exception{ ! String [] tagsBeingChecked = {"TABLE","DIV","SPAN"}; ! Parser parser = new Parser(url); *************** *** 63,67 **** tagFinder.getEndTagCount(i)); } ! } } --- 63,67 ---- tagFinder.getEndTagCount(i)); } ! } } Index: FunctionalTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/FunctionalTests.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** FunctionalTests.java 8 Sep 2003 02:26:30 -0000 1.42 --- FunctionalTests.java 10 Sep 2003 03:38:23 -0000 1.43 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 56,60 **** /** * Based on a suspected bug report by Annette Doyle, ! * to check if the no of image tags are correctly * identified by the parser */ --- 56,60 ---- /** * Based on a suspected bug report by Annette Doyle, ! * to check if the no of image tags are correctly * identified by the parser */ *************** *** 65,74 **** try { int parserImgTagCount = countImageTagsWithHTMLParser(); ! assertEquals("Image Tag Count",imgTagCount,parserImgTagCount); } catch (ParserException e) { throw new ParserException("Error thrown in call to countImageTagsWithHTMLParser()",e); } ! } --- 65,74 ---- try { int parserImgTagCount = countImageTagsWithHTMLParser(); ! assertEquals("Image Tag Count",imgTagCount,parserImgTagCount); } catch (ParserException e) { throw new ParserException("Error thrown in call to countImageTagsWithHTMLParser()",e); } ! } *************** *** 79,83 **** InputStream is = url.openStream(); BufferedReader reader; ! reader = new BufferedReader(new InputStreamReader(is)); imgTagCount = countImageTagsWithoutHTMLParser(reader); is.close(); --- 79,83 ---- InputStream is = url.openStream(); BufferedReader reader; ! reader = new BufferedReader(new InputStreamReader(is)); imgTagCount = countImageTagsWithoutHTMLParser(reader); is.close(); *************** *** 100,105 **** node = (Node)e.nextNode(); if (node instanceof ImageTag) { ! parserImgTagCount++; ! } } return parserImgTagCount; --- 100,105 ---- node = (Node)e.nextNode(); if (node instanceof ImageTag) { ! parserImgTagCount++; ! } } return parserImgTagCount; Index: InstanceofPerformanceTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/InstanceofPerformanceTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** InstanceofPerformanceTest.java 8 Sep 2003 02:26:30 -0000 1.13 --- InstanceofPerformanceTest.java 10 Sep 2003 03:38:23 -0000 1.14 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 56,60 **** } } ! public void doInstanceofTest(long [] time,int index, long numTimes) { System.out.println("doInstanceofTest("+index+")"); --- 56,60 ---- } } ! public void doInstanceofTest(long [] time,int index, long numTimes) { System.out.println("doInstanceofTest("+index+")"); *************** *** 62,66 **** for (long i=0;i<numTimes;i++) { for (Enumeration e = formChildren.elements();e.hasMoreElements();) { ! Node node = (Node)e.nextElement(); } } --- 62,66 ---- for (long i=0;i<numTimes;i++) { for (Enumeration e = formChildren.elements();e.hasMoreElements();) { ! Node node = (Node)e.nextElement(); } } *************** *** 68,72 **** time[index] = end-start; } ! public void doGetTypeTest(long [] time,int index, long numTimes) { System.out.println("doGetTypeTest("+index+")"); --- 68,72 ---- time[index] = end-start; } ! public void doGetTypeTest(long [] time,int index, long numTimes) { System.out.println("doGetTypeTest("+index+")"); *************** *** 83,95 **** public void perform() { int numTimes = 30; ! long time1[] = new long[numTimes], time2[] = new long[numTimes]; ! for (int i=0;i<numTimes;i++) doInstanceofTest(time1,i,i*10000); ! for (int i=0;i<numTimes;i++) doGetTypeTest(time2,i,i*10000); ! print(time1,time2); } --- 83,95 ---- public void perform() { int numTimes = 30; ! long time1[] = new long[numTimes], time2[] = new long[numTimes]; ! for (int i=0;i<numTimes;i++) doInstanceofTest(time1,i,i*10000); ! for (int i=0;i<numTimes;i++) doGetTypeTest(time2,i,i*10000); ! print(time1,time2); } *************** *** 101,105 **** } public static void main(String [] args) throws Exception { ! InstanceofPerformanceTest test = new InstanceofPerformanceTest(); test.setUp(); --- 101,105 ---- } public static void main(String [] args) throws Exception { ! InstanceofPerformanceTest test = new InstanceofPerformanceTest(); test.setUp(); Index: LineNumberAssignedByNodeReaderTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/LineNumberAssignedByNodeReaderTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** LineNumberAssignedByNodeReaderTest.java 8 Sep 2003 02:26:30 -0000 1.20 --- LineNumberAssignedByNodeReaderTest.java 10 Sep 2003 03:38:23 -0000 1.21 *************** *** 1,27 **** // HTMLParser Library v1_4_20030907 - A java-based parser for HTML // Copyright (C) Dec 31, 2000 Somik Raha ! // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. ! // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! // // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 1,27 ---- // HTMLParser Library v1_4_20030907 - A java-based parser for HTML // Copyright (C) Dec 31, 2000 Somik Raha ! // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. ! // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! // // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 49,59 **** super(name); } ! /** * Test to ensure that the <code>Tag</code> being created by the * <code>CompositeTagScanner</code> has the correct startLine and endLine ! * information in the <code>TagData</code> it is constructed with. * @throws ParserException if there is a problem parsing the test data ! */ public void testLineNumbers() throws ParserException { testLineNumber("<Custom/>", 1, 0, 1, 1); --- 49,59 ---- super(name); } ! /** * Test to ensure that the <code>Tag</code> being created by the * <code>CompositeTagScanner</code> has the correct startLine and endLine ! * information in the <code>TagData</code> it is constructed with. * @throws ParserException if there is a problem parsing the test data ! */ public void testLineNumbers() throws ParserException { testLineNumber("<Custom/>", 1, 0, 1, 1); *************** *** 93,97 **** ); } ! /** * Helper method to ensure that the <code>Tag</code> being created by the --- 93,97 ---- ); } ! /** * Helper method to ensure that the <code>Tag</code> being created by the *************** *** 100,108 **** * @param xml String containing HTML or XML to parse, containing a Custom tag * @param numNodes int number of expected nodes returned by parser ! * @param useNode int index of the node to test (should be of type CustomTag) * @param startLine int the expected start line number of the tag * @param endLine int the expected end line number of the tag * @throws ParserException if there is an exception during parsing ! */ private void testLineNumber(String xml, int numNodes, int useNode, int expectedStartLine, int expectedEndLine) throws ParserException { createParser(xml); --- 100,108 ---- * @param xml String containing HTML or XML to parse, containing a Custom tag * @param numNodes int number of expected nodes returned by parser ! * @param useNode int index of the node to test (should be of type CustomTag) * @param startLine int the expected start line number of the tag * @param endLine int the expected end line number of the tag * @throws ParserException if there is an exception during parsing ! */ private void testLineNumber(String xml, int numNodes, int useNode, int expectedStartLine, int expectedEndLine) throws ParserException { createParser(xml); *************** *** 113,117 **** assertEquals("start line", expectedStartLine, tag.tagData.getStartLine()); assertEquals("end line", expectedEndLine, tag.tagData.getEndLine()); ! } --- 113,117 ---- assertEquals("start line", expectedStartLine, tag.tagData.getStartLine()); assertEquals("end line", expectedEndLine, tag.tagData.getEndLine()); ! } Index: ParserTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/ParserTest.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ParserTest.java 8 Sep 2003 02:26:30 -0000 1.40 --- ParserTest.java 10 Sep 2003 03:38:23 -0000 1.41 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 106,111 **** } assertEquals("There should be "+cnt+" nodes identified (second call to parser.elements())",cnt,i); ! } ! /** * Test the Parser(URLConnection) constructor. --- 106,111 ---- } assertEquals("There should be "+cnt+" nodes identified (second call to parser.elements())",cnt,i); ! } ! /** * Test the Parser(URLConnection) constructor. *************** *** 115,135 **** * <form NAME="SearchQuick" method="POST" action="cp_search_response-e.asp" * onSubmit="return runSubmit();"> ! * * <!-- begin test hidden field code --> * <input TYPE="Hidden" NAME="app_language" value="english"> ! * * <input TYPE="Hidden" NAME="app_response_start_row_number" value="1"> * <input TYPE="Hidden" NAME="app_response_rows_max" value="9"> ! * * <input TYPE="Hidden" NAME="app_source" value="quick"> * <input TYPE="Hidden" NAME="query_source" value="q"> ! * * <input TYPE="Hidden" NAME="name" value> * <input TYPE="Hidden" NAME="postal_code" value> * <input TYPE="Hidden" NAME="directory_area_name" value> ! * * <input TYPE="Hidden" NAME="delivery_mode" value> * <input TYPE="Hidden" NAME="Suffix" value> ! * * <input TYPE="Hidden" NAME="street_direction" value> * <input TYPE="Hidden" NAME="installation_type" value> --- 115,135 ---- * <form NAME="SearchQuick" method="POST" action="cp_search_response-e.asp" * onSubmit="return runSubmit();"> ! * * <!-- begin test hidden field code --> * <input TYPE="Hidden" NAME="app_language" value="english"> ! * * <input TYPE="Hidden" NAME="app_response_start_row_number" value="1"> * <input TYPE="Hidden" NAME="app_response_rows_max" value="9"> ! * * <input TYPE="Hidden" NAME="app_source" value="quick"> * <input TYPE="Hidden" NAME="query_source" value="q"> ! * * <input TYPE="Hidden" NAME="name" value> * <input TYPE="Hidden" NAME="postal_code" value> * <input TYPE="Hidden" NAME="directory_area_name" value> ! * * <input TYPE="Hidden" NAME="delivery_mode" value> * <input TYPE="Hidden" NAME="Suffix" value> ! * * <input TYPE="Hidden" NAME="street_direction" value> * <input TYPE="Hidden" NAME="installation_type" value> *************** *** 137,147 **** * <input TYPE="Hidden" NAME="installation_name" value> * <input TYPE="Hidden" NAME="unit_number" value> ! * * <input TYPE="Hidden" NAME="app_state" value="production"> * <!-- end test hidden field code --> ! * * <p> * <table border="0" cellpadding="0" width="90%" cellspacing="0"> ! * * <tr> * <td class="tbltitle"> Street Number: </td> --- 137,147 ---- * <input TYPE="Hidden" NAME="installation_name" value> * <input TYPE="Hidden" NAME="unit_number" value> ! * * <input TYPE="Hidden" NAME="app_state" value="production"> * <!-- end test hidden field code --> ! * * <p> * <table border="0" cellpadding="0" width="90%" cellspacing="0"> ! * * <tr> * <td class="tbltitle"> Street Number: </td> *************** *** 150,154 **** * </tr> * <tr> ! * * <td> * <input type="text" name="street_number" size="10" maxlength="10"> --- 150,154 ---- * </tr> * <tr> ! * * <td> * <input type="text" name="street_number" size="10" maxlength="10"> *************** *** 160,164 **** * <td><input type="text" name="test" size="10" maxlength="30"></td> * </tr> ! * * </table> * <p> --- 160,164 ---- * <td><input type="text" name="test" size="10" maxlength="30"></td> * </tr> ! * * </table> * <p> *************** *** 171,175 **** * Province: * </td> ! * * </tr> * <tr> --- 171,175 ---- * Province: * </td> ! * * </tr> * <tr> *************** *** 180,184 **** * <select size="1" name="prov"> * <option selected value="NULL">Select</option><option value="AB">AB - Alberta</option><option value="BC">BC - British Columbia</option><option value="MB">MB - Manitoba</option><option value="NB">NB - New Brunswick</option><option value="NL">NL - Newfoundland and Labrador</option><option value="NS">NS - Nova Scotia</option><option value="NT">NT - Northwest Territories</option><option value="NU">NU - Nunavut</option><option value="ON">ON - Ontario</option><option value="PE">PE - Prince Edward Island</option><option value="QC">QC - Quebec</option><option value="SK">SK - Saskatchewan</option><option value="YT">YT - Yukon</option> ! * * </select> * </td> --- 180,184 ---- * <select size="1" name="prov"> * <option selected value="NULL">Select</option><option value="AB">AB - Alberta</option><option value="BC">BC - British Columbia</option><option value="MB">MB - Manitoba</option><option value="NB">NB - New Brunswick</option><option value="NL">NL - Newfoundland and Labrador</option><option value="NS">NS - Nova Scotia</option><option value="NT">NT - Northwest Territories</option><option value="NU">NU - Nunavut</option><option value="ON">ON - Ontario</option><option value="PE">PE - Prince Edward Island</option><option value="QC">QC - Quebec</option><option value="SK">SK - Saskatchewan</option><option value="YT">YT - Yukon</option> ! * * </select> * </td> *************** *** 308,312 **** } assertTrue("POST operation failed.", pass); ! } /** --- 308,312 ---- } assertTrue("POST operation failed.", pass); ! } /** *************** *** 322,326 **** int i; NodeIterator enumeration; ! path = System.getProperty ("user.dir"); if (!path.endsWith (File.separator)) --- 322,326 ---- int i; NodeIterator enumeration; ! path = System.getProperty ("user.dir"); if (!path.endsWith (File.separator)) *************** *** 390,394 **** Parser parser; NodeIterator enumeration; ! try { --- 390,394 ---- Parser parser; NodeIterator enumeration; ! try { *************** *** 415,419 **** int i; Node[] nodes; ! parser = new Parser(url); i = 0; --- 415,419 ---- int i; Node[] nodes; ! parser = new Parser(url); i = 0; *************** *** 437,441 **** Parser parser; String url = "http://htmlparser.sourceforge.net/test/DoublequotedCharset.html"; ! parser = new Parser(url); for (NodeIterator e = parser.elements();e.hasMoreNodes();) --- 437,441 ---- Parser parser; String url = "http://htmlparser.sourceforge.net/test/DoublequotedCharset.html"; ! parser = new Parser(url); for (NodeIterator e = parser.elements();e.hasMoreNodes();) *************** *** 457,461 **** Parser parser; String url = "http://htmlparser.sourceforge.net/test/SinglequotedCharset.html"; ! parser = new Parser(url); for (NodeIterator e = parser.elements();e.hasMoreNodes();) --- 457,461 ---- Parser parser; String url = "http://htmlparser.sourceforge.net/test/SinglequotedCharset.html"; ! parser = new Parser(url); for (NodeIterator e = parser.elements();e.hasMoreNodes();) *************** *** 543,554 **** } catch (ParserException e) { ! } } ! public void testURLWithSpaces() throws ParserException{ Parser parser; String url = "http://htmlparser.sourceforge.net/test/This is a Test Page.html"; ! parser = new Parser(url); Node node [] = new AbstractNode[30]; --- 543,554 ---- } catch (ParserException e) { ! } } ! public void testURLWithSpaces() throws ParserException{ Parser parser; String url = "http://htmlparser.sourceforge.net/test/This is a Test Page.html"; ! parser = new Parser(url); Node node [] = new AbstractNode[30]; *************** *** 557,561 **** node[i] = e.nextNode(); i++; ! } assertEquals("Expected nodes",12,i); --- 557,561 ---- node[i] = e.nextNode(); i++; ! } assertEquals("Expected nodes",12,i); *************** *** 611,615 **** "</script></font>\n"+ "<p><font size=-2>©2002 Google</font><font size=-2> - Searching 3,083,324,652 web pages</font></center></body></html>\n" ! ); parser.registerScanners(); NodeList collectionList = new NodeList(); --- 611,615 ---- "</script></font>\n"+ "<p><font size=-2>©2002 Google</font><font size=-2> - Searching 3,083,324,652 web pages</font></center></body></html>\n" ! ); parser.registerScanners(); NodeList collectionList = new NodeList(); *************** *** 667,671 **** "</tr></table></div>\n"+ "</body>\n"+ ! "</html>"); parser.registerScanners(); NodeList collectionList = new NodeList(); --- 667,671 ---- "</tr></table></div>\n"+ "</body>\n"+ ! "</html>"); parser.registerScanners(); NodeList collectionList = new NodeList(); *************** *** 688,692 **** ); parser.registerScanners(); ! parser.removeScanner(new FormScanner("",parser)); Map scanners = parser.getScanners(); TagScanner scanner = (TagScanner)scanners.get("FORM"); --- 688,692 ---- ); parser.registerScanners(); ! parser.removeScanner(new FormScanner("",parser)); Map scanners = parser.getScanners(); TagScanner scanner = (TagScanner)scanners.get("FORM"); *************** *** 714,718 **** } } ! /** * See bug #729368 Embedded quote and split tag --- 714,718 ---- } } ! /** * See bug #729368 Embedded quote and split tag Index: ParserTestCase.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/ParserTestCase.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ParserTestCase.java 8 Sep 2003 02:26:30 -0000 1.26 --- ParserTestCase.java 10 Sep 2003 03:38:23 -0000 1.27 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 49,53 **** public class ParserTestCase extends TestCase { ! static boolean mCaseInsensitiveComparisons = true; protected Parser parser; --- 49,53 ---- public class ParserTestCase extends TestCase { ! static boolean mCaseInsensitiveComparisons = true; protected Parser parser; *************** *** 55,59 **** protected int nodeCount; protected NodeReader reader; ! public ParserTestCase(String name) { super(name); --- 55,59 ---- protected int nodeCount; protected NodeReader reader; ! public ParserTestCase(String name) { super(name); *************** *** 97,102 **** node = new AbstractNode[numNodes]; } ! ! public void assertStringEquals(String message, String expected, String actual) { String mismatchInfo = ""; --- 97,102 ---- node = new AbstractNode[numNodes]; } ! ! public void assertStringEquals(String message, String expected, String actual) { String mismatchInfo = ""; *************** *** 114,124 **** mismatchInfo += ("\nPosition : " + i + " , Code = " + (int) expected.charAt(i)); } ! } ! for (int i = 0; i < expected.length(); i++) { if ( ! (expected.length() != actual.length() && ( ! i >= (expected.length()-1 ) || i >= (actual.length()-1 ) ) --- 114,124 ---- mismatchInfo += ("\nPosition : " + i + " , Code = " + (int) expected.charAt(i)); } ! } ! for (int i = 0; i < expected.length(); i++) { if ( ! (expected.length() != actual.length() && ( ! i >= (expected.length()-1 ) || i >= (actual.length()-1 ) ) *************** *** 129,162 **** StringBuffer errorMsg = new StringBuffer(); errorMsg.append( ! message +mismatchInfo + " \nMismatch of strings at char posn " + i + ! " \n\nString Expected upto mismatch = " + ! expected.substring(0, i) + ! " \n\nString Actual upto mismatch = " + actual.substring(0, i) ); ! if (i<expected.length()) errorMsg.append( ! " \n\nString Expected MISMATCH CHARACTER = "+ expected.charAt(i) + ", code = " + (int) expected.charAt(i) ! ); if (i<actual.length()) errorMsg.append( ! " \n\nString Actual MISMATCH CHARACTER = " + ! actual.charAt(i) + ", code = " + (int) actual.charAt(i) ! ); ! errorMsg.append( ! " \n\n**** COMPLETE STRING EXPECTED ****\n" + ! expected + " \n\n**** COMPLETE STRING ACTUAL***\n" + actual ); fail(errorMsg.toString()); } ! } ! } public void parseNodes() throws ParserException{ --- 129,162 ---- StringBuffer errorMsg = new StringBuffer(); errorMsg.append( ! message +mismatchInfo + " \nMismatch of strings at char posn " + i + ! " \n\nString Expected upto mismatch = " + ! expected.substring(0, i) + ! " \n\nString Actual upto mismatch = " + actual.substring(0, i) ); ! if (i<expected.length()) errorMsg.append( ! " \n\nString Expected MISMATCH CHARACTER = "+ expected.charAt(i) + ", code = " + (int) expected.charAt(i) ! ); if (i<actual.length()) errorMsg.append( ! " \n\nString Actual MISMATCH CHARACTER = " + ! actual.charAt(i) + ", code = " + (int) actual.charAt(i) ! ); ! errorMsg.append( ! " \n\n**** COMPLETE STRING EXPECTED ****\n" + ! expected + " \n\n**** COMPLETE STRING ACTUAL***\n" + actual ); fail(errorMsg.toString()); } ! } ! } public void parseNodes() throws ParserException{ *************** *** 165,169 **** { node[nodeCount++] = e.nextNode(); ! } } --- 165,169 ---- { node[nodeCount++] = e.nextNode(); ! } } *************** *** 185,189 **** String expectedNodeName = expected.getClass().getName(); String actualNodeName = actual.getClass().getName(); ! displayMessage = "The types did not match: Expected "+ expectedNodeName+" \nbut was "+ --- 185,189 ---- String expectedNodeName = expected.getClass().getName(); String actualNodeName = actual.getClass().getName(); ! displayMessage = "The types did not match: Expected "+ expectedNodeName+" \nbut was "+ *************** *** 192,200 **** assertStringEquals(displayMessage, expectedNodeName, actualNodeName); } ! public void assertTagEquals(String displayMessage, Node expected, Node actual) { if (expected instanceof Tag) { Tag expectedTag = (Tag)expected; ! Tag actualTag = (Tag)actual; assertTagNameMatches(displayMessage, expectedTag, actualTag); assertAttributesMatch(displayMessage, expectedTag, actualTag); --- 192,200 ---- assertStringEquals(displayMessage, expectedNodeName, actualNodeName); } ! public void assertTagEquals(String displayMessage, Node expected, Node actual) { if (expected instanceof Tag) { Tag expectedTag = (Tag)expected; ! Tag actualTag = (Tag)actual; assertTagNameMatches(displayMessage, expectedTag, actualTag); assertAttributesMatch(displayMessage, expectedTag, actualTag); *************** *** 211,234 **** assertStringEquals(displayMessage, expectedTagName, actualTagName); } ! public void assertXmlEquals(String displayMessage, String expected, String actual) throws Exception { expected = removeEscapeCharacters(expected); actual = removeEscapeCharacters(actual); ! Parser expectedParser = Parser.createParser(expected); Parser resultParser = Parser.createParser(actual); ! NodeIterator expectedIterator = expectedParser.elements(); NodeIterator actualIterator = resultParser.elements(); displayMessage = createGenericFailureMessage(displayMessage, expected, actual); ! Node nextExpectedNode = null, nextActualNode = null; do { nextExpectedNode = getNextNodeUsing(expectedIterator); nextActualNode = getNextNodeUsing(actualIterator); ! assertStringValueMatches( ! displayMessage, ! nextExpectedNode, nextActualNode ); --- 211,234 ---- assertStringEquals(displayMessage, expectedTagName, actualTagName); } ! public void assertXmlEquals(String displayMessage, String expected, String actual) throws Exception { expected = removeEscapeCharacters(expected); actual = removeEscapeCharacters(actual); ! Parser expectedParser = Parser.createParser(expected); Parser resultParser = Parser.createParser(actual); ! NodeIterator expectedIterator = expectedParser.elements(); NodeIterator actualIterator = resultParser.elements(); displayMessage = createGenericFailureMessage(displayMessage, expected, actual); ! Node nextExpectedNode = null, nextActualNode = null; do { nextExpectedNode = getNextNodeUsing(expectedIterator); nextActualNode = getNextNodeUsing(actualIterator); ! assertStringValueMatches( ! displayMessage, ! nextExpectedNode, nextActualNode ); *************** *** 258,269 **** private void assertStringValueMatches( String displayMessage, Node expectedNode,Node actualNode) { ! String expected = expectedNode.toPlainTextString().trim(); String actual = actualNode.toPlainTextString().trim(); expected = expected.replace('\n', ' '); actual = actual.replace('\n',' '); ! displayMessage = "String value mismatch\nEXPECTED:"+expected+"\nACTUAL:"+actual+displayMessage; assertStringEquals(displayMessage,expected,actual); ! } --- 258,269 ---- private void assertStringValueMatches( String displayMessage, Node expectedNode,Node actualNode) { ! String expected = expectedNode.toPlainTextString().trim(); String actual = actualNode.toPlainTextString().trim(); expected = expected.replace('\n', ' '); actual = actual.replace('\n',' '); ! displayMessage = "String value mismatch\nEXPECTED:"+expected+"\nACTUAL:"+actual+displayMessage; assertStringEquals(displayMessage,expected,actual); ! } *************** *** 278,282 **** } while (actualIterator.hasMoreNodes()); ! displayMessage = "Actual had more data than expected\n"+extraTags+displayMessage; fail(displayMessage); --- 278,282 ---- } while (actualIterator.hasMoreNodes()); ! displayMessage = "Actual had more data than expected\n"+extraTags+displayMessage; fail(displayMessage); *************** *** 298,302 **** String currLine = parser.getReader().getCurrentLine(); int pos = parser.getReader().getLastReadPosition(); ! currLine = currLine.substring(0,pos+1)+ "</"+tag.getTagName()+">"+ --- 298,302 ---- String currLine = parser.getReader().getCurrentLine(); int pos = parser.getReader().getLastReadPosition(); ! currLine = currLine.substring(0,pos+1)+ "</"+tag.getTagName()+">"+ *************** *** 306,310 **** } } ! --- 306,310 ---- } } ! *************** *** 318,322 **** } } ! private void assertActualTagHasNoExtraAttributes(String displayMessage, Tag expectedTag, Tag actualTag) { Iterator i = actualTag.getAttributes().keySet().iterator(); --- 318,322 ---- } } ! private void assertActualTagHasNoExtraAttributes(String displayMessage, Tag expectedTag, Tag actualTag) { Iterator i = actualTag.getAttributes().keySet().iterator(); *************** *** 324,328 **** String key = (String)i.next(); if (key=="/") continue; ! String expectedValue = expectedTag.getAttribute(key); String actualValue = --- 324,328 ---- String key = (String)i.next(); if (key=="/") continue; ! String expectedValue = expectedTag.getAttribute(key); String actualValue = *************** *** 334,345 **** continue; } ! if (expectedValue==null) fail( "\nActual tag had extra key: "+key+displayMessage ); ! } } ! private void assertAllExpectedTagAttributesFoundInActualTag( String displayMessage, --- 334,345 ---- continue; } ! if (expectedValue==null) fail( "\nActual tag had extra key: "+key+displayMessage ); ! } } ! private void assertAllExpectedTagAttributesFoundInActualTag( String displayMessage, *************** *** 350,354 **** String key = (String)i.next(); if (key=="/") continue; ! String expectedValue = expectedTag.getAttribute(key); String actualValue = --- 350,354 ---- String key = (String)i.next(); if (key=="/") continue; ! String expectedValue = expectedTag.getAttribute(key); String actualValue = *************** *** 360,364 **** continue; } ! assertStringEquals( "\nvalue for key "+key+" in tag "+expectedTag.getTagName()+" expected="+expectedValue+" but was "+actualValue+ --- 360,364 ---- continue; } ! assertStringEquals( "\nvalue for key "+key+" in tag "+expectedTag.getTagName()+" expected="+expectedValue+" but was "+actualValue+ *************** *** 380,385 **** public void assertType( ! String message, ! Class expectedType, Object object) { String expectedTypeName = expectedType.getName(); --- 380,385 ---- public void assertType( ! String message, ! Class expectedType, Object object) { String expectedTypeName = expectedType.getName(); *************** *** 392,396 **** actualTypeName+"\n and is :"+((Node)object).toHtml() ); ! } } --- 392,396 ---- actualTypeName+"\n and is :"+((Node)object).toHtml() ); ! } } *************** *** 417,420 **** fail(failMsg.toString()); } ! } } --- 417,420 ---- fail(failMsg.toString()); } ! } } Index: PerformanceTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/PerformanceTest.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** PerformanceTest.java 8 Sep 2003 02:26:30 -0000 1.40 --- PerformanceTest.java 10 Sep 2003 03:38:23 -0000 1.41 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 48,52 **** public PerformanceTest(String file, int numTimes) { this.file = file; ! this.numTimes = numTimes; } --- 48,52 ---- public PerformanceTest(String file, int numTimes) { this.file = file; ! this.numTimes = numTimes; } *************** *** 57,61 **** System.out.println("***************************************"); System.out.println("* Test Without Scanners Registered *"); ! System.out.println("***************************************"); for (int i=0;i<=numTimes;i++) { // Create the parser object --- 57,61 ---- System.out.println("***************************************"); System.out.println("* Test Without Scanners Registered *"); ! System.out.println("***************************************"); for (int i=0;i<=numTimes;i++) { // Create the parser object *************** *** 85,89 **** System.out.println("***************************************"); System.out.println("* Test With Scanners Registered *"); ! System.out.println("***************************************"); for (int i=0;i<=numTimes;i++) { // Create the parser object --- 85,89 ---- System.out.println("***************************************"); System.out.println("* Test With Scanners Registered *"); ! System.out.println("***************************************"); for (int i=0;i<=numTimes;i++) { // Create the parser object *************** *** 107,111 **** System.out.println("***************************************"); } ! public static void main(String[] args) { if (args.length<2) { --- 107,111 ---- System.out.println("***************************************"); } ! public static void main(String[] args) { if (args.length<2) { Index: package.html =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/package.html,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** package.html 8 Sep 2003 02:26:30 -0000 1.13 --- package.html 10 Sep 2003 03:38:23 -0000 1.14 *************** *** 18,22 **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software --- 18,22 ---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software *************** *** 25,37 **** For any questions or suggestions, you can write to me at : Email :so...@in... ! ! Postal Address : Somik Raha Extreme Programmer & Coach Industrial Logic Corporation ! 2583 Cedar Street, Berkeley, CA 94708, USA Website : http://www.industriallogic.com ! --> </head> --- 25,37 ---- For any questions or suggestions, you can write to me at : Email :so...@in... ! ! Postal Address : Somik Raha Extreme Programmer & Coach Industrial Logic Corporation ! 2583 Cedar Street, Berkeley, CA 94708, USA Website : http://www.industriallogic.com ! --> </head> |