@Test
public void testReuse() throws Exception {
Directory dir = newDirectory();
// test that IWC cannot be reused across two IWs
IndexWriterConfig conf = newIndexWriterConfig(null);
new RandomIndexWriter(random(),dir,conf).close();
// this should fail
try {
assertNotNull(new RandomIndexWriter(random(),conf));
fail("should have hit AlreadySetException");
} catch (AlreadySetException e) {
// expected
}
dir.close();
}
项目:elasticsearch_my
文件:IndexModuleTests.java
public void testForceCustomQueryCache() throws IOException {
Settings indexSettings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(),createTempDir().toString())
.put(IndexMetaData.SETTING_VERSION_CREATED,Version.CURRENT).build();
IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings("foo",indexSettings),new AnalysisRegistry(environment,emptyMap(),emptyMap()));
module.forceQueryCacheProvider((a,b) -> new CustomQueryCache());
expectThrows(AlreadySetException.class,() -> module.forceQueryCacheProvider((a,b) -> new CustomQueryCache()));
IndexService indexService = newIndexService(module);
assertTrue(indexService.cache().query() instanceof CustomQueryCache);
indexService.close("simon says",false);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。