/** * Determines whether the Server can be stopped in-process, such as when a Server is embedded in * an application and the ServerLauncher API is being used. * * @return a boolean indicating whether the Server can be stopped in-process (the application's * process with an embedded Server). */ private boolean isStoppable() { return isRunning() && getCache() != null; }
@Test public void canBeMocked() throws IOException { ServerLauncher launcher = mock(ServerLauncher.class); Cache cache = mock(Cache.class); CacheConfig cacheConfig = mock(CacheConfig.class); when(launcher.getCache()).thenReturn(cache); when(launcher.getCacheConfig()).thenReturn(cacheConfig); when(launcher.getId()).thenReturn("ID"); when(launcher.isWaiting(eq(cache))).thenReturn(true); when(launcher.isHelping()).thenReturn(true); launcher.startCacheServer(cache); verify(launcher, times(1)).startCacheServer(cache); assertThat(launcher.getCache()).isSameAs(cache); assertThat(launcher.getCacheConfig()).isSameAs(cacheConfig); assertThat(launcher.getId()).isSameAs("ID"); assertThat(launcher.isWaiting(cache)).isTrue(); assertThat(launcher.isHelping()).isTrue(); }
/** * 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); } } }