Skip to content

Apache Lucene open-source search software

LUCENE-3726: additional tests

Robert Muirbef6e3664d1e
diff --git a/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TestKuromojiAnalyzer.java b/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TestKuromojiAnalyzer.java
index 3f0361d7d24..4e6928d374d 100644
--- a/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TestKuromojiAnalyzer.java
+++ b/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TestKuromojiAnalyzer.java
@@ -42,6 +42,15 @@ public class TestKuromojiAnalyzer extends BaseTokenStreamTestCase {
);
}
+ /**
+ * Test that search mode is enabled and working by default
+ */
+ public void testDecomposition() throws IOException {
+ assertAnalyzesTo(new KuromojiAnalyzer(TEST_VERSION_CURRENT), "シニアソフトウェアエンジニア",
+ new String[] { "シニア", "ソフトウェア", "エンジニア" }
+ );
+ }
+
/**
* blast random strings against the analyzer
*/
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestKuromojiTokenizerFactory.java b/solr/core/src/test/org/apache/solr/analysis/TestKuromojiTokenizerFactory.java
index a3c4c3e59df..5ebce6113da 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestKuromojiTokenizerFactory.java
+++ b/solr/core/src/test/org/apache/solr/analysis/TestKuromojiTokenizerFactory.java
@@ -41,6 +41,34 @@ public class TestKuromojiTokenizerFactory extends BaseTokenTestCase {
);
}
+ /**
+ * Test that search mode is enabled and working by default
+ */
+ public void testDefaults() throws IOException {
+ KuromojiTokenizerFactory factory = new KuromojiTokenizerFactory();
+ factory.init(DEFAULT_VERSION_PARAM);
+ factory.inform(new SolrResourceLoader(null, null));
+ TokenStream ts = factory.create(new StringReader("シニアソフトウェアエンジニア"));
+ assertTokenStreamContents(ts,
+ new String[] { "シニア", "ソフトウェア", "エンジニア" }
+ );
+ }
+
+ /**
+ * Test mode parameter: specifying normal mode
+ */
+ public void testMode() throws IOException {
+ KuromojiTokenizerFactory factory = new KuromojiTokenizerFactory();
+ Map<String,String> args = new HashMap<String,String>();
+ args.put("mode", "normal");
+ factory.init(args);
+ factory.inform(new SolrResourceLoader(null, null));
+ TokenStream ts = factory.create(new StringReader("シニアソフトウェアエンジニア"));
+ assertTokenStreamContents(ts,
+ new String[] { "シニアソフトウェアエンジニア" }
+ );
+ }
+
public void testUserDict() throws IOException {
String userDict =
"# Custom segmentation for long entries\n" +