Apache Lucene open-source search software
LUCENE-5630: Fix TestAllAnalyzersHaveFactories to correctly check for existence of class and corresponding Map<String,String> ctor
Uwe Schindler03dc5ec9125a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 8fa7c830cc5..415293f4713 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -319,6 +319,14 @@ Bug fixesconcurrently. This error is now handled the same way like in NativeFSLockFactoryby returning false. (Uwe Schindler, Robert Muir, Dawid Weiss)+* LUCENE-5630: Add missing META-INF entry for UpperCaseFilterFactory.+ (Robert Muir)++Tests++* LUCENE-5630: Fix TestAllAnalyzersHaveFactories to correctly check for existence+ of class and corresponding Map<String,String> ctor. (Uwe Schindler, Robert Muir)+Test Framework* LUCENE-5592: Incorrectly reported uncloseable files. (Dawid Weiss)diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.javaindex 4b2abad4c29..4df3e086edc 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java@@ -120,7 +120,7 @@ final class AnalysisSPILoader<S extends AbstractAnalysisFactory> {return service;} else {throw new IllegalArgumentException("A SPI class of type "+clazz.getName()+" with name '"+name+"' does not exist. "+- "You need to add the corresponding JAR file supporting this SPI to your classpath."++ "You need to add the corresponding JAR file supporting this SPI to your classpath. "+"The current classpath supports the following names: "+availableServices());}}diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.javaindex 720e3ca1847..1590fb2cd84 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java@@ -125,6 +125,7 @@ public class TestAllAnalyzersHaveFactories extends LuceneTestCase {String clazzName = c.getSimpleName();assertTrue(clazzName.endsWith("Tokenizer"));String simpleName = clazzName.substring(0, clazzName.length() - 9);+ assertNotNull(TokenizerFactory.lookupClass(simpleName));TokenizerFactory instance = null;try {instance = TokenizerFactory.forName(simpleName, args);@@ -134,7 +135,8 @@ public class TestAllAnalyzersHaveFactories extends LuceneTestCase {}assertSame(c, instance.create().getClass());} catch (IllegalArgumentException e) {- if (!e.getMessage().contains("SPI") || e.getMessage().contains("does not exist")) {+ if (e.getCause() instanceof NoSuchMethodException) {+ // there is no corresponding ctor availablethrow e;}// TODO: For now pass because some factories have not yet a default config that always works@@ -143,6 +145,7 @@ public class TestAllAnalyzersHaveFactories extends LuceneTestCase {String clazzName = c.getSimpleName();assertTrue(clazzName.endsWith("Filter"));String simpleName = clazzName.substring(0, clazzName.length() - (clazzName.endsWith("TokenFilter") ? 11 : 6));+ assertNotNull(TokenFilterFactory.lookupClass(simpleName));TokenFilterFactory instance = null;try {instance = TokenFilterFactory.forName(simpleName, args);@@ -156,7 +159,8 @@ public class TestAllAnalyzersHaveFactories extends LuceneTestCase {assertSame(c, createdClazz);}} catch (IllegalArgumentException e) {- if (!e.getMessage().contains("SPI") || e.getMessage().contains("does not exist")) {+ if (e.getCause() instanceof NoSuchMethodException) {+ // there is no corresponding ctor availablethrow e;}// TODO: For now pass because some factories have not yet a default config that always works@@ -165,6 +169,7 @@ public class TestAllAnalyzersHaveFactories extends LuceneTestCase {String clazzName = c.getSimpleName();assertTrue(clazzName.endsWith("CharFilter"));String simpleName = clazzName.substring(0, clazzName.length() - 10);+ assertNotNull(CharFilterFactory.lookupClass(simpleName));CharFilterFactory instance = null;try {instance = CharFilterFactory.forName(simpleName, args);@@ -178,7 +183,8 @@ public class TestAllAnalyzersHaveFactories extends LuceneTestCase {assertSame(c, createdClazz);}} catch (IllegalArgumentException e) {- if (!e.getMessage().contains("SPI") || e.getMessage().contains("does not exist")) {+ if (e.getCause() instanceof NoSuchMethodException) {+ // there is no corresponding ctor availablethrow e;}// TODO: For now pass because some factories have not yet a default config that always works