You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2017/06/14 02:02:41 UTC

[05/35] lucene-solr:jira/SOLR-10834: LUCENE-7866: Apply changes also to cloned test (TODO: fix this!)

LUCENE-7866: Apply changes also to cloned test (TODO: fix this!)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d7808ebc
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d7808ebc
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d7808ebc

Branch: refs/heads/jira/SOLR-10834
Commit: d7808ebc6029a51c6f80e6700ca53f7c9a6523f0
Parents: f43f89e
Author: Uwe Schindler <us...@apache.org>
Authored: Sun Jun 11 14:25:03 2017 +0200
Committer: Uwe Schindler <us...@apache.org>
Committed: Sun Jun 11 14:25:03 2017 +0200

----------------------------------------------------------------------
 .../lucene/analysis/ja/TestFactories.java       | 46 +++++++++++++-------
 1 file changed, 31 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d7808ebc/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestFactories.java
----------------------------------------------------------------------
diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestFactories.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestFactories.java
index bae8ffc..0a467a7 100644
--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestFactories.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestFactories.java
@@ -21,13 +21,17 @@ import java.io.IOException;
 import java.io.Reader;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.MockTokenizer;
 import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.miscellaneous.DelimitedTermFrequencyTokenFilterFactory;
 import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
 import org.apache.lucene.analysis.util.CharFilterFactory;
 import org.apache.lucene.analysis.util.MultiTermAwareComponent;
@@ -46,6 +50,12 @@ import org.apache.lucene.util.Version;
 
 // TODO: fix this to use CustomAnalyzer instead of its own FactoryAnalyzer
 public class TestFactories extends BaseTokenStreamTestCase {
+  
+  /** Factories that are excluded from testing it with random data */
+  private static final Set<Class<? extends AbstractAnalysisFactory>> EXCLUDE_FACTORIES_RANDOM_DATA = new HashSet<>(Arrays.asList(
+      DelimitedTermFrequencyTokenFilterFactory.class
+  ));
+  
   public void test() throws IOException {
     for (String tokenizer : TokenizerFactory.availableTokenizers()) {
       doTestTokenizer(tokenizer);
@@ -74,11 +84,13 @@ public class TestFactories extends BaseTokenStreamTestCase {
         assertFalse(mtc instanceof CharFilterFactory);
       }
       
-      // beast it just a little, it shouldnt throw exceptions:
-      // (it should have thrown them in initialize)
-      Analyzer a = new FactoryAnalyzer(factory, null, null);
-      checkRandomData(random(), a, 20, 20, false, false);
-      a.close();
+      if (!EXCLUDE_FACTORIES_RANDOM_DATA.contains(factory.getClass())) {
+        // beast it just a little, it shouldnt throw exceptions:
+        // (it should have thrown them in initialize)
+        Analyzer a = new FactoryAnalyzer(factory, null, null);
+        checkRandomData(random(), a, 20, 20, false, false);
+        a.close();
+      }
     }
   }
   
@@ -96,11 +108,13 @@ public class TestFactories extends BaseTokenStreamTestCase {
         assertTrue(mtc instanceof TokenFilterFactory);
       }
       
-      // beast it just a little, it shouldnt throw exceptions:
-      // (it should have thrown them in initialize)
-      Analyzer a = new FactoryAnalyzer(assertingTokenizer, factory, null);
-      checkRandomData(random(), a, 20, 20, false, false);
-      a.close();
+      if (!EXCLUDE_FACTORIES_RANDOM_DATA.contains(factory.getClass())) {
+        // beast it just a little, it shouldnt throw exceptions:
+        // (it should have thrown them in initialize)
+        Analyzer a = new FactoryAnalyzer(assertingTokenizer, factory, null);
+        checkRandomData(random(), a, 20, 20, false, false);
+        a.close();
+      }
     }
   }
   
@@ -118,11 +132,13 @@ public class TestFactories extends BaseTokenStreamTestCase {
         assertTrue(mtc instanceof CharFilterFactory);
       }
       
-      // beast it just a little, it shouldnt throw exceptions:
-      // (it should have thrown them in initialize)
-      Analyzer a = new FactoryAnalyzer(assertingTokenizer, null, factory);
-      checkRandomData(random(), a, 20, 20, false, false);
-      a.close();
+      if (!EXCLUDE_FACTORIES_RANDOM_DATA.contains(factory.getClass())) {
+        // beast it just a little, it shouldnt throw exceptions:
+        // (it should have thrown them in initialize)
+        Analyzer a = new FactoryAnalyzer(assertingTokenizer, null, factory);
+        checkRandomData(random(), a, 20, 20, false, false);
+        a.close();
+      }
     }
   }