Przeglądaj źródła

add kuromoji integration tests

Robert Muir 10 lat temu
rodzic
commit
f412c5a6ed

+ 2 - 1
plugins/analysis-kuromoji/pom.xml

@@ -16,7 +16,8 @@
     <description>The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.</description>
 
     <properties>
-        <!-- You can add any specific project property here -->
+        <tests.rest.suite>analysis_kuromoji</tests.rest.suite>
+        <tests.rest.load_packaged>false</tests.rest.load_packaged>
     </properties>
 
     <dependencies>

+ 39 - 0
plugins/analysis-kuromoji/rest-api-spec/test/analysis_kuromoji/10_basic.yaml

@@ -0,0 +1,39 @@
+# Integration tests for ICU analysis components
+#
+"Tokenizer":
+    - do:
+        indices.analyze:
+          text:         関西国際空港
+          tokenizer:    kuromoji_tokenizer
+    - length: { tokens: 4 }
+    - match:  { tokens.0.token: 関西 }
+    - match:  { tokens.1.token: 関西国際空港 }
+    - match:  { tokens.2.token: 国際 }
+    - match:  { tokens.3.token: 空港 }
+---
+"Baseform filter":
+    - do:
+        indices.analyze:
+          text:         飲み
+          tokenizer:    kuromoji_tokenizer
+          filters:      kuromoji_baseform
+    - length: { tokens: 1 }
+    - match:  { tokens.0.token: 飲む }
+---
+"Reading filter":
+    - do:
+        indices.analyze:
+          text:         寿司
+          tokenizer:    kuromoji_tokenizer
+          filters:      kuromoji_readingform
+    - length: { tokens: 1 }
+    - match:  { tokens.0.token: sushi }
+---
+"Stemming filter":
+    - do:
+        indices.analyze:
+          text:         サーバー
+          tokenizer:    kuromoji_tokenizer
+          filters:      kuromoji_stemmer
+    - length: { tokens: 1 }
+    - match:  { tokens.0.token: サーバ }

+ 41 - 0
plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/AnalysisKuromojiRestIT.java

@@ -0,0 +1,41 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch 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.
+ */
+
+package org.elasticsearch.index.analysis;
+
+import com.carrotsearch.randomizedtesting.annotations.Name;
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
+import org.elasticsearch.test.rest.RestTestCandidate;
+import org.elasticsearch.test.rest.parser.RestTestParseException;
+
+import java.io.IOException;
+
+public class AnalysisKuromojiRestIT extends ElasticsearchRestTestCase {
+
+    public AnalysisKuromojiRestIT(@Name("yaml") RestTestCandidate testCandidate) {
+        super(testCandidate);
+    }
+
+    @ParametersFactory
+    public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
+        return ElasticsearchRestTestCase.createParameters(0, 1);
+    }
+}
+