LUCENE-5630: Fix TestAllAnalyzersHaveFactories to correctly check for existence of class and corresponding Map<String,String> ctor

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1589870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2014-04-24 20:33:25 +00:00
parent 317ac65bdd
commit 03dc5ec912
3 changed files with 18 additions and 4 deletions

View File

@ -319,6 +319,14 @@ Bug fixes
concurrently. This error is now handled the same way like in NativeFSLockFactory
by 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)

View File

@ -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());
}
}

View File

@ -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 available
throw 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 available
throw 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 available
throw e;
}
// TODO: For now pass because some factories have not yet a default config that always works