[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/nodeDecoratorTests NonBreakingSpaceConvertingNo
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests In directory sc8-pr-cvs1:/tmp/cvs-serv2842/src/org/htmlparser/tests/nodeDecoratorTests Modified Files: DecodingNodeTest.java EscapeCharacterRemovingNodeTest.java AllTests.java Added Files: NonBreakingSpaceConvertingNodeTest.java Log Message: added non breaking space converting decorator --- NEW FILE: NonBreakingSpaceConvertingNodeTest.java --- // HTMLParser Library v1_4_20030622 - 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 // // This test class produced by Joshua Kerievsky package org.htmlparser.tests.nodeDecoratorTests; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.NodeIterator; import org.htmlparser.util.ParserException; public class NonBreakingSpaceConvertingNodeTest extends ParserTestCase { public NonBreakingSpaceConvertingNodeTest(String name) { super(name); } private String parseToObtainDecodedResult(String STRING_TO_DECODE) throws ParserException { StringBuffer decodedContent = new StringBuffer(); createParser(STRING_TO_DECODE); parser.setNonBreakSpaceConversion(true); NodeIterator nodes = parser.elements(); while (nodes.hasMoreNodes()) decodedContent.append(nodes.nextNode().toPlainTextString()); return decodedContent.toString(); } 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", DECODED_WITH_NON_BREAKING_SPACE, 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", DECODED_WITH_NON_BREAKING_SPACE, parseToObtainDecodedResult(ENCODED_WITH_NON_BREAKING_SPACE)); } } Index: DecodingNodeTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/DecodingNodeTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DecodingNodeTest.java 25 Jun 2003 03:56:20 -0000 1.1 --- DecodingNodeTest.java 25 Jun 2003 05:03:08 -0000 1.2 *************** *** 110,113 **** --- 110,127 ---- } + 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", + DECODED_WITH_NON_BREAKING_SPACE, + 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.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EscapeCharacterRemovingNodeTest.java 25 Jun 2003 03:56:20 -0000 1.1 --- EscapeCharacterRemovingNodeTest.java 25 Jun 2003 05:03:08 -0000 1.2 *************** *** 36,40 **** public class EscapeCharacterRemovingNodeTest extends ParserTestCase { - public EscapeCharacterRemovingNodeTest(String name) { super(name); --- 36,39 ---- Index: AllTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/nodeDecoratorTests/AllTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AllTests.java 25 Jun 2003 03:56:20 -0000 1.1 --- AllTests.java 25 Jun 2003 05:03:08 -0000 1.2 *************** *** 41,44 **** --- 41,45 ---- suite.addTestSuite(DecodingNodeTest.class); suite.addTestSuite(EscapeCharacterRemovingNodeTest.class); + suite.addTestSuite(NonBreakingSpaceConvertingNodeTest.class); return suite; } |