[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/nodeDecoratorTests AllTests.java,1.9,1.10 Decod
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests In directory sc8-pr-cvs1:/tmp/cvs-serv24483/src/org/htmlparser/tests/nodeDecoratorTests Modified Files: AllTests.java DecodingNodeTest.java EscapeCharacterRemovingNodeTest.java NonBreakingSpaceConvertingNodeTest.java 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/nodeDecoratorTests/AllTests.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AllTests.java 8 Sep 2003 02:26:30 -0000 1.9 --- AllTests.java 10 Sep 2003 03:38:24 -0000 1.10 *************** *** 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 { public AllTests(String name) { --- 31,35 ---- import junit.framework.TestSuite; ! public class AllTests extends junit.framework.TestCase { public AllTests(String name) { *************** *** 42,46 **** suite.addTestSuite(EscapeCharacterRemovingNodeTest.class); suite.addTestSuite(NonBreakingSpaceConvertingNodeTest.class); ! return suite; } --- 42,46 ---- suite.addTestSuite(EscapeCharacterRemovingNodeTest.class); suite.addTestSuite(NonBreakingSpaceConvertingNodeTest.class); ! return suite; } Index: DecodingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/DecodingNodeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DecodingNodeTest.java 8 Sep 2003 02:26:30 -0000 1.10 --- DecodingNodeTest.java 10 Sep 2003 03:38:24 -0000 1.11 *************** *** 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,56 **** stringNodeFactory.setNodeDecoding(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); --- 48,56 ---- stringNodeFactory.setNodeDecoding(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); *************** *** 60,64 **** String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop"; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop"; --- 60,64 ---- String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop"; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop"; *************** *** 73,80 **** String ENCODED_DIVISION_SIGN = "÷ is the division sign."; ! String DECODED_DIVISION_SIGN = "÷ is the division sign."; ! assertEquals( "numeric reference for division sign", --- 73,80 ---- String ENCODED_DIVISION_SIGN = "÷ is the division sign."; ! String DECODED_DIVISION_SIGN = "÷ is the division sign."; ! assertEquals( "numeric reference for division sign", *************** *** 82,96 **** parseToObtainDecodedResult(ENCODED_DIVISION_SIGN)); } ! ! public void testReferencesInString () throws Exception { String ENCODED_REFERENCE_IN_STRING = "Thus, the character entity reference ÷ is a more convenient" + " form than ÷ for obtaining the division sign (÷)"; ! String DECODED_REFERENCE_IN_STRING = "Thus, the character entity reference ÷ is a more convenient" + " form than ÷ for obtaining the division sign (÷)"; ! assertEquals ( "character references within a string", --- 82,96 ---- parseToObtainDecodedResult(ENCODED_DIVISION_SIGN)); } ! ! public void testReferencesInString () throws Exception { String ENCODED_REFERENCE_IN_STRING = "Thus, the character entity reference ÷ is a more convenient" + " form than ÷ for obtaining the division sign (÷)"; ! String DECODED_REFERENCE_IN_STRING = "Thus, the character entity reference ÷ is a more convenient" + " form than ÷ for obtaining the division sign (÷)"; ! assertEquals ( "character references within a string", *************** *** 100,110 **** public void testBogusCharacterEntityReference() throws Exception { ! ! String ENCODED_BOGUS_CHARACTER_ENTITY = "The character entity reference &divode; is bogus"; ! String DECODED_BOGUS_CHARACTER_ENTITY = "The character entity reference &divode; is bogus"; ! assertEquals ( "bogus character entity reference", --- 100,110 ---- public void testBogusCharacterEntityReference() throws Exception { ! ! String ENCODED_BOGUS_CHARACTER_ENTITY = "The character entity reference &divode; is bogus"; ! String DECODED_BOGUS_CHARACTER_ENTITY = "The character entity reference &divode; is bogus"; ! assertEquals ( "bogus character entity reference", *************** *** 112,124 **** parseToObtainDecodedResult(ENCODED_BOGUS_CHARACTER_ENTITY)); } ! public void testDecodingNonBreakingSpaceDoesNotOccur() throws Exception { ! ! String ENCODED_WITH_NON_BREAKING_SPACE = "Here is string with \u00a0."; ! String DECODED_WITH_NON_BREAKING_SPACE = "Here is string with \u00a0."; ! assertEquals ( "bogus character entity reference", --- 112,124 ---- parseToObtainDecodedResult(ENCODED_BOGUS_CHARACTER_ENTITY)); } ! public void testDecodingNonBreakingSpaceDoesNotOccur() throws Exception { ! ! String ENCODED_WITH_NON_BREAKING_SPACE = "Here is string with \u00a0."; ! String DECODED_WITH_NON_BREAKING_SPACE = "Here is string with \u00a0."; ! assertEquals ( "bogus character entity reference", *************** *** 126,131 **** parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } ! ! } --- 126,131 ---- parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } ! ! } Index: EscapeCharacterRemovingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/EscapeCharacterRemovingNodeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EscapeCharacterRemovingNodeTest.java 8 Sep 2003 02:26:30 -0000 1.10 --- EscapeCharacterRemovingNodeTest.java 10 Sep 2003 03:38:24 -0000 1.11 *************** *** 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,57 **** stringNodeFactory.setEscapeCharacterRemoval(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); --- 48,57 ---- stringNodeFactory.setEscapeCharacterRemoval(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); *************** *** 61,65 **** String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop\tCreated by Industrial Logic, Inc."; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring WorkshopCreated by Industrial Logic, Inc."; --- 61,65 ---- String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop\tCreated by Industrial Logic, Inc."; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring WorkshopCreated by Industrial Logic, Inc."; *************** *** 70,78 **** parseToObtainDecodedResult(ENCODED_WORKSHOP_TITLE)); } ! public void testCarriageReturn() throws Exception { String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop\nCreated by Industrial Logic, Inc.\n"; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring WorkshopCreated by Industrial Logic, Inc."; --- 70,78 ---- parseToObtainDecodedResult(ENCODED_WORKSHOP_TITLE)); } ! public void testCarriageReturn() throws Exception { String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop\nCreated by Industrial Logic, Inc.\n"; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring WorkshopCreated by Industrial Logic, Inc."; *************** *** 82,106 **** DECODED_WORKSHOP_TITLE, parseToObtainDecodedResult(ENCODED_WORKSHOP_TITLE)); ! } ! public void testWithDecodingNodeDecorator() throws Exception { String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop\nCreated by Industrial Logic, Inc.\n"; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring WorkshopCreated by Industrial Logic, Inc."; StringBuffer decodedContent = new StringBuffer(); ! StringNodeFactory stringNodeFactory = new StringNodeFactory(); stringNodeFactory.setNodeDecoding(true); stringNodeFactory.setEscapeCharacterRemoval(true); ! createParser(ENCODED_WORKSHOP_TITLE); parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); assertEquals( --- 82,106 ---- DECODED_WORKSHOP_TITLE, parseToObtainDecodedResult(ENCODED_WORKSHOP_TITLE)); ! } ! public void testWithDecodingNodeDecorator() throws Exception { String ENCODED_WORKSHOP_TITLE = "The Testing & Refactoring Workshop\nCreated by Industrial Logic, Inc.\n"; ! String DECODED_WORKSHOP_TITLE = "The Testing & Refactoring WorkshopCreated by Industrial Logic, Inc."; StringBuffer decodedContent = new StringBuffer(); ! StringNodeFactory stringNodeFactory = new StringNodeFactory(); stringNodeFactory.setNodeDecoding(true); stringNodeFactory.setEscapeCharacterRemoval(true); ! createParser(ENCODED_WORKSHOP_TITLE); parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); assertEquals( *************** *** 108,112 **** DECODED_WORKSHOP_TITLE, decodedContent.toString()); ! } } --- 108,112 ---- DECODED_WORKSHOP_TITLE, decodedContent.toString()); ! } } Index: NonBreakingSpaceConvertingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/NonBreakingSpaceConvertingNodeTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NonBreakingSpaceConvertingNodeTest.java 8 Sep 2003 02:26:30 -0000 1.9 --- NonBreakingSpaceConvertingNodeTest.java 10 Sep 2003 03:38:24 -0000 1.10 *************** *** 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 *************** *** 44,57 **** throws ParserException { StringBuffer decodedContent = new StringBuffer(); ! StringNodeFactory stringNodeFactory = new StringNodeFactory(); stringNodeFactory.setNonBreakSpaceConversion(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); --- 44,57 ---- throws ParserException { StringBuffer decodedContent = new StringBuffer(); ! StringNodeFactory stringNodeFactory = new StringNodeFactory(); stringNodeFactory.setNonBreakSpaceConversion(true); createParser(STRING_TO_DECODE); ! parser.setStringNodeFactory(stringNodeFactory); NodeIterator nodes = parser.elements(); ! ! while (nodes.hasMoreNodes()) ! decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); *************** *** 59,68 **** public void testOneNonBreakingSpace() throws Exception { ! String ENCODED_WITH_NON_BREAKING_SPACE = "Here is string with \u00a0 inside of it."; ! String DECODED_WITH_NON_BREAKING_SPACE = "Here is string with inside of it."; ! assertEquals ( "\u00a0 was converted to a space correctly", --- 59,68 ---- public void testOneNonBreakingSpace() throws Exception { ! String ENCODED_WITH_NON_BREAKING_SPACE = "Here is string with \u00a0 inside of it."; ! String DECODED_WITH_NON_BREAKING_SPACE = "Here is string with inside of it."; ! assertEquals ( "\u00a0 was converted to a space correctly", *************** *** 70,81 **** parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } ! public void testMultipleNonBreakingSpace() throws Exception { ! String ENCODED_WITH_NON_BREAKING_SPACE = "\u00a0Here is string with \u00a0 inside of it\u00a0."; ! String DECODED_WITH_NON_BREAKING_SPACE = " Here is string with inside of it ."; ! assertEquals ( "\u00a0 was converted to a space correctly", --- 70,81 ---- parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } ! public void testMultipleNonBreakingSpace() throws Exception { ! String ENCODED_WITH_NON_BREAKING_SPACE = "\u00a0Here is string with \u00a0 inside of it\u00a0."; ! String DECODED_WITH_NON_BREAKING_SPACE = " Here is string with inside of it ."; ! assertEquals ( "\u00a0 was converted to a space correctly", *************** *** 83,86 **** parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } ! } --- 83,86 ---- parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } ! } |