Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26191/tests
Modified Files:
FunctionalTests.java ParserTest.java
Log Message:
Fix bug #883664 toUpperCase on tag names and attributes depends on locale
Added locale information to all relevant toUpperCase() calls, with an English locale
for tag names and attribute names, or developers choice of locale for methods that
do uppercase conversion as part of their algorithms.
Index: FunctionalTests.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/FunctionalTests.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** FunctionalTests.java 14 Jan 2004 02:53:47 -0000 1.54
--- FunctionalTests.java 25 Jan 2004 21:33:12 -0000 1.55
***************
*** 29,32 ****
--- 29,33 ----
import java.io.BufferedReader;
import java.io.IOException;
+ import java.util.Locale;
import junit.framework.TestSuite;
***************
*** 105,109 ****
if (line!=null) {
// Check the line for image tags
! String newline = line.toUpperCase();
int fromIndex = -1;
do {
--- 106,110 ----
if (line!=null) {
// Check the line for image tags
! String newline = line.toUpperCase (Locale.ENGLISH);
int fromIndex = -1;
do {
Index: ParserTest.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/ParserTest.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** ParserTest.java 24 Jan 2004 17:15:43 -0000 1.55
--- ParserTest.java 25 Jan 2004 21:33:12 -0000 1.56
***************
*** 36,39 ****
--- 36,40 ----
import java.net.URL;
import java.net.URLConnection;
+ import java.util.Locale;
import org.htmlparser.AbstractNode;
***************
*** 845,848 ****
--- 846,850 ----
}
}
+
/**
* Test reproducing a java.lang.StackOverflowError.
***************
*** 859,861 ****
--- 861,886 ----
assertTrue ("bad toString()", -1 != output.indexOf (guts));
}
+
+ /**
+ * See bug #883664 toUpperCase on tag names and attributes depends on locale
+ */
+ public void testDifferentLocale () throws Exception
+ {
+ String html;
+ Locale original;
+
+ html = "<title>This is supposedly Turkish.</title>";
+ original = Locale.getDefault ();
+ try
+ {
+ Locale.setDefault (new Locale ("tr")); // turkish
+ createParser (html);
+ parseAndAssertNodeCount (1);
+ assertStringEquals ("html", html, node[0].toHtml ());
+ }
+ finally
+ {
+ Locale.setDefault (original);
+ }
+ }
}
|