fix tests
This commit is contained in:
parent
a5e5a5025b
commit
cc131eb328
|
@ -185,7 +185,7 @@ public class IndexModule extends AbstractModule {
|
|||
throw new IllegalArgumentException("provider must not be null");
|
||||
}
|
||||
if (queryCaches.containsKey(name)) {
|
||||
throw new IllegalArgumentException("provider for name [" + name + "] is already registered");
|
||||
throw new IllegalArgumentException("Can't register the same [query_cache] more than once for [" + name + "]");
|
||||
}
|
||||
queryCaches.put(name, provider);
|
||||
}
|
||||
|
|
|
@ -204,15 +204,24 @@ public class IndexModuleTests extends ModuleTestCase {
|
|||
IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer);
|
||||
try {
|
||||
module.registerQueryCache("index", IndexQueryCache::new);
|
||||
fail("only once");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals(e.getMessage(), "Can't register the same [query_cache] more than once for [index]");
|
||||
}
|
||||
|
||||
try {
|
||||
module.registerQueryCache("none", (settings, x) -> new NoneQueryCache(settings));
|
||||
fail("only once");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals(e.getMessage(), "Can't register the same [query_cache] more than once for [none]");
|
||||
}
|
||||
|
||||
try {
|
||||
module.registerQueryCache("index", null);
|
||||
fail("must not be null");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals(e.getMessage(), "provider must not be null");
|
||||
}
|
||||
}
|
||||
|
||||
public void testRegisterCustomQueryCache() {
|
||||
|
@ -223,6 +232,7 @@ public class IndexModuleTests extends ModuleTestCase {
|
|||
module.registerQueryCache("custom", (a, b) -> new CustomQueryCache());
|
||||
try {
|
||||
module.registerQueryCache("custom", (a, b) -> new CustomQueryCache());
|
||||
fail("only once");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals(e.getMessage(), "Can't register the same [query_cache] more than once for [custom]");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue