You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2006/07/17 19:57:39 UTC
svn commit: r422772 -
/incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java
Author: yonik
Date: Mon Jul 17 10:57:38 2006
New Revision: 422772
URL: http://svn.apache.org/viewvc?rev=422772&view=rev
Log:
TestXMLEscaping.java: SOLR-33
Added:
incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java (with props)
Added: incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java?rev=422772&view=auto
==============================================================================
--- incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java (added)
+++ incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java Mon Jul 17 10:57:38 2006
@@ -0,0 +1,51 @@
+package org.apache.solr.util;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Random;
+import java.util.BitSet;
+
+/** Test (some of the) character escaping functions of the XML class
+ * $Id$
+ */
+
+public class TestXMLEscaping extends TestCase {
+ private void doSimpleTest(String input,String expectedOutput) throws IOException {
+ final StringWriter sw = new StringWriter();
+ XML.escapeCharData(input, sw);
+ final String result = sw.toString();
+ assertEquals("Escaped output matches '" + expectedOutput + "'",result,expectedOutput);
+ }
+
+ public void testNoEscape() throws IOException {
+ doSimpleTest("Bonnie","Bonnie");
+ }
+
+ public void testAmpAscii() throws IOException {
+ doSimpleTest("Bonnie & Clyde","Bonnie & Clyde");
+ }
+
+ public void testAmpAndTagAscii() throws IOException {
+ doSimpleTest("Bonnie & Cl<em>y</em>de","Bonnie & Cl<em>y</em>de");
+ }
+
+ public void testAmpWithAccents() throws IOException {
+ // 00e9 is unicode eacute
+ doSimpleTest("Les \u00e9v\u00e9nements chez Bonnie & Clyde","Les \u00e9v\u00e9nements chez Bonnie & Clyde");
+ }
+
+ public void testAmpDotWithAccents() throws IOException {
+ // 00e9 is unicode eacute
+ doSimpleTest("Les \u00e9v\u00e9nements chez Bonnie & Clyde.","Les \u00e9v\u00e9nements chez Bonnie & Clyde.");
+ }
+
+ public void testAmpAndTagWithAccents() throws IOException {
+ // 00e9 is unicode eacute
+ doSimpleTest("Les \u00e9v\u00e9nements <chez/> Bonnie & Clyde","Les \u00e9v\u00e9nements <chez/> Bonnie & Clyde");
+ }
+}
+
+
+
Propchange: incubator/solr/trunk/src/test/org/apache/solr/util/TestXMLEscaping.java
------------------------------------------------------------------------------
svn:eol-style = native