use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.
the class ServerLauncherTest method testSetAndGetMessageTimeToLive.
@Test
public void testSetAndGetMessageTimeToLive() {
Builder builder = new Builder();
assertNull(builder.getMessageTimeToLive());
assertSame(builder, builder.setMessageTimeToLive(30000));
assertEquals(30000, builder.getMessageTimeToLive().intValue());
assertSame(builder, builder.setMessageTimeToLive(null));
assertNull(builder.getMessageTimeToLive());
}
use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.
the class ServerLauncherTest method reconnectedCacheIsDiscovered.
@Test
public void reconnectedCacheIsDiscovered() throws Exception {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final Cache mockReconnectedCache = mockContext.mock(Cache.class, "ReconnectedCache");
mockContext.checking(new Expectations() {
{
exactly(2).of(mockCache).isReconnecting();
will(returnValue(Boolean.FALSE));
oneOf(mockCache).getCacheServers();
will(returnValue(Collections.emptyList()));
oneOf(mockCache).isReconnecting();
will(returnValue(Boolean.TRUE));
oneOf(mockCache).getReconnectedCache();
will(returnValue(mockReconnectedCache));
oneOf(mockReconnectedCache).close();
}
});
final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setCache(mockCache).build();
assertNotNull(serverLauncher);
serverLauncher.waitOnServer();
}
use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.
the class ServerLauncherTest method testSetAndGetServerBindAddress.
@Test
public void testSetAndGetServerBindAddress() throws Exception {
Builder builder = new Builder();
assertNull(builder.getServerBindAddress());
assertSame(builder, builder.setServerBindAddress(null));
assertNull(builder.getServerBindAddress());
assertSame(builder, builder.setServerBindAddress(""));
assertNull(builder.getServerBindAddress());
assertSame(builder, builder.setServerBindAddress(" "));
assertNull(builder.getServerBindAddress());
assertSame(builder, builder.setServerBindAddress(InetAddress.getLocalHost().getCanonicalHostName()));
assertEquals(InetAddress.getLocalHost(), builder.getServerBindAddress());
}
use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.
the class ServerLauncherTest method testIsWaitingWhenNotConnected.
@Test
public void testIsWaitingWhenNotConnected() {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getDistributedSystem();
will(returnValue(mockDistributedSystem));
oneOf(mockDistributedSystem).isConnected();
will(returnValue(false));
oneOf(mockCache).isReconnecting();
will(returnValue(Boolean.FALSE));
}
});
final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
assertNotNull(serverLauncher);
assertEquals("serverOne", serverLauncher.getMemberName());
serverLauncher.running.set(true);
assertTrue(serverLauncher.isRunning());
assertFalse(serverLauncher.isWaiting(mockCache));
}
use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.
the class ServerLauncherTest method testParseCommand.
@Test
public void testParseCommand() {
Builder builder = new Builder();
assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
builder.parseCommand((String[]) null);
assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
// empty String array
builder.parseCommand();
assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
builder.parseCommand(Command.START.getName());
assertEquals(Command.START, builder.getCommand());
builder.parseCommand("Status");
assertEquals(Command.STATUS, builder.getCommand());
builder.parseCommand("sToP");
assertEquals(Command.STOP, builder.getCommand());
builder.parseCommand("--opt", "START", "-o", Command.STATUS.getName());
assertEquals(Command.START, builder.getCommand());
builder.setCommand(null);
builder.parseCommand("badCommandName", "--start", "stat");
assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
}
Aggregations