Apache Lucene open-source search software
LUCENE-4044: get all lucene tests passing
Robert Muire7ff3048ce00
diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/StringMockResourceLoader.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/StringMockResourceLoader.javanew file mode 100644index 00000000000..1a5d98d8073--- /dev/null+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/StringMockResourceLoader.java@@ -0,0 +1,53 @@+package org.apache.lucene.analysis.ja;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.ByteArrayInputStream;+import java.io.IOException;+import java.io.InputStream;+import java.util.Arrays;+import java.util.List;++import org.apache.lucene.analysis.util.ResourceLoader;++/** Fake resource loader for tests: works if you want to fake reading a single file */+class StringMockResourceLoader implements ResourceLoader {+ String text;++ public StringMockResourceLoader(String text) {+ this.text = text;+ }++ public List<String> getLines(String resource) throws IOException {+ return Arrays.asList(text.split("\n"));+ }++ // TODO: do this subpackages thing... wtf is that?+ public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {+ try {+ Class<? extends T> clazz = Class.forName(cname).asSubclass(expectedType);+ return clazz.newInstance();+ } catch (Exception e) {+ throw new RuntimeException(e);+ }+ }++ public InputStream openResource(String resource) throws IOException {+ return new ByteArrayInputStream(text.getBytes("UTF-8"));+ }+}diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.javaindex c678e798daa..0fd28edf32c 100644--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.java+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.java@@ -24,7 +24,6 @@ import java.util.Map;import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.TokenStream;-import org.apache.solr.core.SolrResourceLoader;/*** Simple tests for {@link JapaneseBaseFormFilterFactory}@@ -35,7 +34,7 @@ public class TestJapaneseBaseFormFilterFactory extends BaseTokenStreamTestCase {tokenizerFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);Map<String, String> args = Collections.emptyMap();tokenizerFactory.init(args);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));TokenStream ts = tokenizerFactory.create(new StringReader("それはまだ実験段階にあります"));JapaneseBaseFormFilterFactory factory = new JapaneseBaseFormFilterFactory();ts = factory.create(ts);diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.javaindex 6a572921c1a..8975337f3ec 100644--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.java+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.java@@ -21,7 +21,6 @@ import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.CharFilter;import org.apache.lucene.analysis.MockTokenizer;import org.apache.lucene.analysis.TokenStream;-import org.apache.solr.core.SolrResourceLoader;import java.io.IOException;import java.io.StringReader;@@ -30,7 +29,7 @@ import java.util.HashMap;import java.util.Map;/**- * Simple tests for {@link org.apache.solr.analysis.JapaneseIterationMarkCharFilterFactory}+ * Simple tests for {@link JapaneseIterationMarkCharFilterFactory}*/public class TestJapaneseIterationMarkCharFilterFactory extends BaseTokenStreamTestCase {@@ -46,7 +45,7 @@ public class TestJapaneseIterationMarkCharFilterFactory extends BaseTokenStreamTJapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();Map<String, String> tokenizerArgs = Collections.emptyMap();tokenizerFactory.init(tokenizerArgs);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));JapaneseIterationMarkCharFilterFactory filterFactory = new JapaneseIterationMarkCharFilterFactory();Map<String, String> filterArgs = Collections.emptyMap();@@ -63,7 +62,7 @@ public class TestJapaneseIterationMarkCharFilterFactory extends BaseTokenStreamTJapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();Map<String, String> tokenizerArgs = Collections.emptyMap();tokenizerFactory.init(tokenizerArgs);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));JapaneseIterationMarkCharFilterFactory filterFactory = new JapaneseIterationMarkCharFilterFactory();Map<String, String> filterArgs = new HashMap<String, String>();@@ -82,7 +81,7 @@ public class TestJapaneseIterationMarkCharFilterFactory extends BaseTokenStreamTJapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();Map<String, String> tokenizerArgs = Collections.emptyMap();tokenizerFactory.init(tokenizerArgs);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));JapaneseIterationMarkCharFilterFactory filterFactory = new JapaneseIterationMarkCharFilterFactory();Map<String, String> filterArgs = new HashMap<String, String>();diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.javaindex 9352c875b30..b3fa8dc6941 100644--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.java+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.java@@ -19,7 +19,6 @@ package org.apache.lucene.analysis.ja;import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.TokenStream;-import org.apache.solr.core.SolrResourceLoader;import java.io.IOException;import java.io.StringReader;@@ -34,7 +33,7 @@ public class TestJapaneseKatakanaStemFilterFactory extends BaseTokenStreamTestCaJapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();Map<String, String> tokenizerArgs = Collections.emptyMap();tokenizerFactory.init(tokenizerArgs);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));TokenStream tokenStream = tokenizerFactory.create(new StringReader("明後日パーティーに行く予定がある。図書館で資料をコピーしました。"));diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.javaindex 3f2cd1f7c88..fdfc9015900 100644--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.java+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.java@@ -25,7 +25,6 @@ import java.util.Map;import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.TokenStream;-import org.apache.solr.core.SolrResourceLoader;/*** Simple tests for {@link JapanesePartOfSpeechStopFilterFactory}@@ -40,14 +39,14 @@ public class TestJapanesePartOfSpeechStopFilterFactory extends BaseTokenStreamTetokenizerFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);Map<String, String> tokenizerArgs = Collections.emptyMap();tokenizerFactory.init(tokenizerArgs);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));TokenStream ts = tokenizerFactory.create(new StringReader("私は制限スピードを超える。"));JapanesePartOfSpeechStopFilterFactory factory = new JapanesePartOfSpeechStopFilterFactory();Map<String,String> args = new HashMap<String,String>();args.put("tags", "stoptags.txt");factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);factory.init(args);- factory.inform(new StringMockSolrResourceLoader(tags));+ factory.inform(new StringMockResourceLoader(tags));ts = factory.create(ts);assertTokenStreamContents(ts,new String[] { "私", "は", "制限", "スピード", "を" }diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.javaindex 5f568f00628..52dc275ea13 100644--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.java+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.java@@ -19,7 +19,6 @@ package org.apache.lucene.analysis.ja;import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.TokenStream;-import org.apache.solr.core.SolrResourceLoader;import java.io.IOException;import java.io.StringReader;@@ -34,7 +33,7 @@ public class TestJapaneseReadingFormFilterFactory extends BaseTokenStreamTestCasJapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();Map<String, String> args = Collections.emptyMap();tokenizerFactory.init(args);- tokenizerFactory.inform(new SolrResourceLoader(null, null));+ tokenizerFactory.inform(new StringMockResourceLoader(""));TokenStream tokenStream = tokenizerFactory.create(new StringReader("先ほどベルリンから来ました。"));JapaneseReadingFormFilterFactory filterFactory = new JapaneseReadingFormFilterFactory();assertTokenStreamContents(filterFactory.create(tokenStream),diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.javaindex 7bbc719c269..3b26dca4146 100644--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.java+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.java@@ -25,7 +25,6 @@ import java.util.Map;import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.TokenStream;-import org.apache.solr.core.SolrResourceLoader;/*** Simple tests for {@link JapaneseTokenizerFactory}@@ -36,7 +35,7 @@ public class TestJapaneseTokenizerFactory extends BaseTokenStreamTestCase {factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);Map<String, String> args = Collections.emptyMap();factory.init(args);- factory.inform(new SolrResourceLoader(null, null));+ factory.inform(new StringMockResourceLoader(""));TokenStream ts = factory.create(new StringReader("これは本ではない"));assertTokenStreamContents(ts,new String[] { "これ", "は", "本", "で", "は", "ない" },@@ -53,7 +52,7 @@ public class TestJapaneseTokenizerFactory extends BaseTokenStreamTestCase {factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);Map<String, String> args = Collections.emptyMap();factory.init(args);- factory.inform(new SolrResourceLoader(null, null));+ factory.inform(new StringMockResourceLoader(""));TokenStream ts = factory.create(new StringReader("シニアソフトウェアエンジニア"));assertTokenStreamContents(ts,new String[] { "シニア", "シニアソフトウェアエンジニア", "ソフトウェア", "エンジニア" }@@ -68,7 +67,7 @@ public class TestJapaneseTokenizerFactory extends BaseTokenStreamTestCase {Map<String,String> args = new HashMap<String,String>();args.put("mode", "normal");factory.init(args);- factory.inform(new SolrResourceLoader(null, null));+ factory.inform(new StringMockResourceLoader(""));TokenStream ts = factory.create(new StringReader("シニアソフトウェアエンジニア"));assertTokenStreamContents(ts,new String[] { "シニアソフトウェアエンジニア" }@@ -89,7 +88,7 @@ public class TestJapaneseTokenizerFactory extends BaseTokenStreamTestCase {Map<String,String> args = new HashMap<String,String>();args.put("userDictionary", "userdict.txt");factory.init(args);- factory.inform(new StringMockSolrResourceLoader(userDict));+ factory.inform(new StringMockResourceLoader(userDict));TokenStream ts = factory.create(new StringReader("関西国際空港に行った"));assertTokenStreamContents(ts,new String[] { "関西", "国際", "空港", "に", "行っ", "た" }@@ -104,7 +103,7 @@ public class TestJapaneseTokenizerFactory extends BaseTokenStreamTestCase {Map<String,String> args = new HashMap<String,String>();args.put("discardPunctuation", "false");factory.init(args);- factory.inform(new SolrResourceLoader(null, null));+ factory.inform(new StringMockResourceLoader(""));TokenStream ts = factory.create(new StringReader("今ノルウェーにいますが、来週の頭日本に戻ります。楽しみにしています!お寿司が食べたいな。。。"));