Java 类org.apache.lucene.util.SetOnce.AlreadySetException 实例源码

项目:search    文件:TestIndexWriterConfig.java   
@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(), dir, 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(), emptyMap(), 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);
}
项目:search    文件:TestSetOnce.java   
@Test(expected=AlreadySetException.class)
public void testSetOnce() throws Exception {
  SetOnce<Integer> set = new SetOnce<>();
  set.set(new Integer(5));
  assertEquals(5, set.get().intValue());
  set.set(new Integer(7));
}
项目:NYBC    文件:TestSetOnce.java   
@Test(expected=AlreadySetException.class)
public void testSetOnce() throws Exception {
  SetOnce<Integer> set = new SetOnce<Integer>();
  set.set(new Integer(5));
  assertEquals(5, set.get().intValue());
  set.set(new Integer(7));
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestSetOnce.java   
@Test(expected=AlreadySetException.class)
public void testSetOnce() throws Exception {
  SetOnce<Integer> set = new SetOnce<Integer>();
  set.set(new Integer(5));
  assertEquals(5, set.get().intValue());
  set.set(new Integer(7));
}
项目:search    文件:TestSetOnce.java   
@Test(expected=AlreadySetException.class)
public void testSettingCtor() throws Exception {
  SetOnce<Integer> set = new SetOnce<>(new Integer(5));
  assertEquals(5, set.get().intValue());
  set.set(new Integer(7));
}
项目:NYBC    文件:TestSetOnce.java   
@Test(expected=AlreadySetException.class)
public void testSettingCtor() throws Exception {
  SetOnce<Integer> set = new SetOnce<Integer>(new Integer(5));
  assertEquals(5, set.get().intValue());
  set.set(new Integer(7));
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestSetOnce.java   
@Test(expected=AlreadySetException.class)
public void testSettingCtor() throws Exception {
  SetOnce<Integer> set = new SetOnce<Integer>(new Integer(5));
  assertEquals(5, set.get().intValue());
  set.set(new Integer(7));
}