@Test public void isServingReturnsTrueWhenCacheHasOneCacheServer() { Cache cache = mock(Cache.class); CacheServer cacheServer = mock(CacheServer.class); when(cache.getCacheServers()).thenReturn(Collections.singletonList(cacheServer)); ServerLauncher launcher = new Builder().build(); assertThat(launcher.isServing(cache)).isTrue(); }
@Test public void isServingReturnsFalseWhenCacheHasZeroCacheServers() { Cache cache = mock(Cache.class); when(cache.getCacheServers()).thenReturn(Collections.emptyList()); ServerLauncher launcher = new Builder().build(); assertThat(launcher.isServing(cache)).isFalse(); }
/** * Causes the calling Thread to block until the GemFire Cache Server/Data Member stops. */ public void waitOnServer() { assert getCache() != null : "The Cache Server must first be started with a call to start!"; if (!isServing(getCache())) { Throwable cause = null; try { while (isWaiting(getCache())) { try { synchronized (this) { wait(500L); } } catch (InterruptedException handled) { // loop back around } } } catch (RuntimeException e) { cause = e; throw e; } finally { failOnStart(cause); } } }