Search in sources :

Example 46 with Builder

use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.

the class ServerLauncherTest method testSetAndGetMaxThreads.

@Test
public void testSetAndGetMaxThreads() {
    Builder builder = new Builder();
    assertNull(builder.getMaxThreads());
    assertSame(builder, builder.setMaxThreads(16));
    assertEquals(16, builder.getMaxThreads().intValue());
    assertSame(builder, builder.setMaxThreads(null));
    assertNull(builder.getMaxThreads());
}
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 47 with Builder

use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.

the class ServerLauncherTest method testParseMemberName.

@Test
public void testParseMemberName() {
    Builder builder = new Builder();
    assertNull(builder.getMemberName());
    builder.parseMemberName((String[]) null);
    assertNull(builder.getMemberName());
    // empty String array
    builder.parseMemberName();
    assertNull(builder.getMemberName());
    builder.parseMemberName(Command.START.getName(), "--opt", "-o");
    assertNull(builder.getMemberName());
    builder.parseMemberName("memberOne");
    assertEquals("memberOne", builder.getMemberName());
}
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 48 with Builder

use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.

the class ServerLauncherTest method testSetServerBindAddressToLocalHost.

@Test
public void testSetServerBindAddressToLocalHost() throws Exception {
    String host = InetAddress.getLocalHost().getHostName();
    new Builder().setServerBindAddress(host);
}
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 49 with Builder

use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.

the class ServerLauncherTest method testStartCacheServer.

@Test
public void testStartCacheServer() throws IOException {
    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getCacheServers();
            will(returnValue(Collections.emptyList()));
            oneOf(mockCache).addCacheServer();
            will(returnValue(mockCacheServer));
            oneOf(mockCacheServer).setBindAddress(with(aNull(String.class)));
            oneOf(mockCacheServer).setPort(with(equal(11235)));
            oneOf(mockCacheServer).start();
        }
    });
    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setServerBindAddress(null).setServerPort(11235).setDisableDefaultServer(false).build();
    assertNotNull(serverLauncher);
    assertEquals("serverOne", serverLauncher.getMemberName());
    assertFalse(serverLauncher.isDisableDefaultServer());
    serverLauncher.startCacheServer(mockCache);
}
Also used : Expectations(org.jmock.Expectations) Builder(org.apache.geode.distributed.ServerLauncher.Builder) CacheServer(org.apache.geode.cache.server.CacheServer) 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 50 with Builder

use of org.apache.geode.distributed.ServerLauncher.Builder in project geode by apache.

the class ServerLauncherTest method testIsWaiting.

@Test
public void testIsWaiting() {
    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(true));
        }
    });
    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
    assertNotNull(serverLauncher);
    assertEquals("serverOne", serverLauncher.getMemberName());
    serverLauncher.running.set(true);
    assertTrue(serverLauncher.isRunning());
    assertTrue(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)

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