LUCENE-4194: more encoding fixes.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1357636 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dawid Weiss 2012-07-05 14:41:03 +00:00
parent 1713e0bcc5
commit 8a0e3198ca
3 changed files with 7 additions and 3 deletions

View File

@ -19,9 +19,12 @@ package org.apache.lucene.benchmark.byTask;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader; import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.lucene.benchmark.byTask.feeds.AbstractQueryMaker; import org.apache.lucene.benchmark.byTask.feeds.AbstractQueryMaker;
@ -113,7 +116,7 @@ public class TestPerfTasksParse extends LuceneTestCase {
public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().endsWith(".alg"); } public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().endsWith(".alg"); }
})) { })) {
try { try {
Config config = new Config(new FileReader(algFile)); Config config = new Config(new InputStreamReader(new FileInputStream(algFile), "UTF-8"));
String contentSource = config.get("content.source", null); String contentSource = config.get("content.source", null);
if (contentSource != null) { Class.forName(contentSource); } if (contentSource != null) { Class.forName(contentSource); }
config.set("work.dir", new File(TEMP_DIR,"work").getAbsolutePath()); config.set("work.dir", new File(TEMP_DIR,"work").getAbsolutePath());

View File

@ -1371,7 +1371,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// now an ugly built of XML parsing to test the snippet is encoded OK // now an ugly built of XML parsing to test the snippet is encoded OK
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder(); DocumentBuilder db = dbf.newDocumentBuilder();
org.w3c.dom.Document doc = db.parse(new ByteArrayInputStream(xhtml.getBytes())); org.w3c.dom.Document doc = db.parse(new ByteArrayInputStream(xhtml.getBytes("UTF-8")));
Element root = doc.getDocumentElement(); Element root = doc.getDocumentElement();
NodeList nodes = root.getElementsByTagName("body"); NodeList nodes = root.getElementsByTagName("body");
Element body = (Element) nodes.item(0); Element body = (Element) nodes.item(0);

View File

@ -61,7 +61,8 @@ public class TestParser extends LuceneTestCase {
//initialize the parser //initialize the parser
builder = new CorePlusExtensionsParser("contents", analyzer); builder = new CorePlusExtensionsParser("contents", analyzer);
BufferedReader d = new BufferedReader(new InputStreamReader(TestParser.class.getResourceAsStream("reuters21578.txt"))); BufferedReader d = new BufferedReader(new InputStreamReader(
TestParser.class.getResourceAsStream("reuters21578.txt"), "US-ASCII"));
dir = newDirectory(); dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(Version.LUCENE_40, analyzer)); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(Version.LUCENE_40, analyzer));
String line = d.readLine(); String line = d.readLine();