Search in sources :

Example 21 with Builder

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());
}
Also used : Builder(org.apache.geode.distributed.ServerLauncher.Builder) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 22 with Builder

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();
}
Also used : Expectations(org.jmock.Expectations) Builder(org.apache.geode.distributed.ServerLauncher.Builder) Cache(org.apache.geode.cache.Cache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 23 with Builder

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());
}
Also used : Builder(org.apache.geode.distributed.ServerLauncher.Builder) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 24 with Builder

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));
}
Also used : Expectations(org.jmock.Expectations) Builder(org.apache.geode.distributed.ServerLauncher.Builder) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) Cache(org.apache.geode.cache.Cache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 25 with Builder

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());
}
Also used : Builder(org.apache.geode.distributed.ServerLauncher.Builder) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Aggregations

Builder (org.apache.geode.distributed.ServerLauncher.Builder)56 Test (org.junit.Test)56 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)31 UnitTest (org.apache.geode.test.junit.categories.UnitTest)29 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)27 File (java.io.File)18 Cache (org.apache.geode.cache.Cache)14 Expectations (org.jmock.Expectations)12 ServerState (org.apache.geode.distributed.ServerLauncher.ServerState)11 ArrayList (java.util.ArrayList)4 CacheServer (org.apache.geode.cache.server.CacheServer)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)3 FileNotFoundException (java.io.FileNotFoundException)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 BindException (java.net.BindException)2 Properties (java.util.Properties)2 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)2 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)2 ProcessStreamReader (org.apache.geode.internal.process.ProcessStreamReader)2