org.apache.geode.cache30

## Class ClientServerTestCase

- java.lang.Object
- - org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase
  - - org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase
    - - org.apache.geode.cache30.ClientServerTestCase

- All Implemented Interfaces:
    java.io.Serializable, org.apache.geode.test.dunit.cache.internal.CacheTestFixture, org.apache.geode.test.dunit.internal.DistributedTestFixture

      public abstract class ClientServerTestCase
      extends org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase

  Provides helper methods for testing clients and servers. This test case was created by refactoring methods from ConnectionPoolDUnitTest into this class.
  Since:
    GemFire 4.2.1
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ClientServerTestCase.CacheServerCacheLoader`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `AUTO_LOAD_BALANCE`
    `static java.lang.String` | `BridgeServerKey`
    `static java.lang.String` | `NON_EXISTENT_KEY`

    - ### Fields inherited from class org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase

      `cache`

    - ### Fields inherited from class org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase

      `system, testNameForDistributedTestCase`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientServerTestCase()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup)`
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, int pingInterval, int idleTimeout, boolean threadLocalCnxs, int lifetimeTimeout)`
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, int pingInterval, int idleTimeout, boolean threadLocalCnxs, int lifetimeTimeout, int statisticInterval)`
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int port1, int port2, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup)`
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int port1, int port2, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, int pingInterval)`
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int port1, int port2, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, int pingInterval, int idleTimeout, boolean threadLocalCnxs)`
    `static Pool` | `configureConnectionPool(AttributesFactory factory, java.lang.String host, int port1, int port2, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, int pingInterval, int idleTimeout, boolean threadLocalCnxs, int lifetimeTimeout)`
    `static Pool` | `configureConnectionPoolWithName(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, java.lang.String poolName)`
    `static Pool` | `configureConnectionPoolWithName(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, java.lang.String poolName, int pingInterval, int idleTimeout, boolean threadLocalCnxs, int lifetimeTimeout, int statisticInterval)`
    `static Pool` | `configureConnectionPoolWithNameAndFactory(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, java.lang.String poolName, PoolFactory pf)`
    `static Pool` | `configureConnectionPoolWithNameAndFactory(AttributesFactory factory, java.lang.String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, java.lang.String serverGroup, java.lang.String poolName, PoolFactory pf, int pingInterval, int idleTimeout, boolean threadLocalCnxs, int lifetimeTimeout, int statisticInterval)` this method creates a client connection pool and configures it.
    `static java.lang.String` | `createBridgeClientConnection(java.lang.String host, int[] ports)`
    `void` | `createBridgeServer(org.apache.geode.test.dunit.VM vm, java.lang.String rName, int port)` Create a server that has a value for every key queried and a unique key/value in the specified Region that uniquely identifies each instance.
    `static int[]` | `createUniquePorts(int numToCreate)`
    `protected int` | `getMaxThreads()` Defaults to 0 which means no selector in server.
    `protected static DistributedMember` | `getMemberId()`
    `protected RegionAttributes` | `getRegionAttributes()` Returns region attributes for a `LOCAL` region
    `void` | `postSetUp()`
    `protected void` | `postSetUpClientServerTestCase()`
    `void` | `preTearDownCacheTestCase()`
    `protected void` | `preTearDownClientServerTestCase()`
    `int` | `startBridgeServer(int port)` Starts a bridge server on the given port
    `void` | `stopBridgeServers(Cache cache)` Stops the bridge server that serves up the given cache.

    - ### Methods inherited from class org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase

      `addExceptionTag1, basicGetCache, beginCacheXml, closeAllCache, closeCache, createExpiryRootRegion, createLonerCache, createRegion, createRegion, createRootRegion, createRootRegion, finishCacheXml, finishCacheXml, getCache, getCache, getCache, getCache, getCache, getClientCache, getClientCache, getDiskDir, getDiskDirs, getGemfireCache, getRootRegion, getRootRegion, hasCache, postTearDownCacheTestCase, preTearDown, removeExceptionTag1`

    - ### Methods inherited from class org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase

      `basicGetSystem, cleanDiskDirs, cleanupAllVms, deleteBACKUPDiskStoreFile, destroyRegions, disconnectAllFromDS, disconnectFromDS, getBlackboard, getDistributedSystemProperties, getLonerSystem, getName, getSystem, getSystem, getSystemStatic, getTestClass, getTestMethodName, getUniqueName, initializeBlackboard, initializeDistributedTestCase, isConnectedToDS, nullSystem, postTearDown, postTearDownAssertions, preSetUp, preTearDownAssertions, setSystem, setUpDistributedTestCase, tearDownDistributedTestCase`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.geode.test.dunit.internal.DistributedTestFixture

      `getDistributedSystemProperties, getName, postTearDown, postTearDownAssertions, preSetUp, preTearDownAssertions`

- - ### Field Detail

    - #### NON_EXISTENT_KEY

          public static java.lang.String NON_EXISTENT_KEY

    - #### AUTO_LOAD_BALANCE

          public static boolean AUTO_LOAD_BALANCE

    - #### BridgeServerKey

          public static final java.lang.String BridgeServerKey

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ClientServerTestCase

          public ClientServerTestCase()

  - ### Method Detail

    - #### postSetUp

          public final void postSetUp()
                               throws java.lang.Exception

      Specified by:
        `postSetUp` in interface `org.apache.geode.test.dunit.internal.DistributedTestFixture`
      Overrides:
        `postSetUp` in class `org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase`
      Throws:
        `java.lang.Exception`

    - #### postSetUpClientServerTestCase

          protected void postSetUpClientServerTestCase()
                                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### preTearDownCacheTestCase

          public final void preTearDownCacheTestCase()
                                              throws java.lang.Exception

      Specified by:
        `preTearDownCacheTestCase` in interface `org.apache.geode.test.dunit.cache.internal.CacheTestFixture`
      Overrides:
        `preTearDownCacheTestCase` in class `org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase`
      Throws:
        `java.lang.Exception`

    - #### preTearDownClientServerTestCase

          protected void preTearDownClientServerTestCase()
                                                  throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### startBridgeServer

          public int startBridgeServer(int port)
                                throws java.io.IOException

      Starts a bridge server on the given port
      Throws:
        `java.io.IOException`
      Since:
        GemFire 4.0

    - #### getMaxThreads

          protected int getMaxThreads()

      Defaults to 0 which means no selector in server. Subclasses can override setting this to a value > 0 to enable selector.

    - #### stopBridgeServers

          public void stopBridgeServers(Cache cache)

      Stops the bridge server that serves up the given cache.
      Since:
        GemFire 4.0

    - #### getRegionAttributes

          protected RegionAttributes getRegionAttributes()

      Returns region attributes for a `LOCAL` region

    - #### createBridgeClientConnection

          public static java.lang.String createBridgeClientConnection(java.lang.String host,
                                                                      int[] ports)

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int port1,
                                                     int port2,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup,
                                                     int pingInterval,
                                                     int idleTimeout,
                                                     boolean threadLocalCnxs,
                                                     int lifetimeTimeout)

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int port1,
                                                     int port2,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup,
                                                     int pingInterval,
                                                     int idleTimeout,
                                                     boolean threadLocalCnxs)

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int port1,
                                                     int port2,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup,
                                                     int pingInterval)

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int port1,
                                                     int port2,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup)

    - #### configureConnectionPoolWithName

          public static Pool configureConnectionPoolWithName(AttributesFactory factory,
                                                             java.lang.String host,
                                                             int[] ports,
                                                             boolean establish,
                                                             int redundancy,
                                                             int connectionsPerServer,
                                                             java.lang.String serverGroup,
                                                             java.lang.String poolName)

    - #### configureConnectionPoolWithName

          public static Pool configureConnectionPoolWithName(AttributesFactory factory,
                                                             java.lang.String host,
                                                             int[] ports,
                                                             boolean establish,
                                                             int redundancy,
                                                             int connectionsPerServer,
                                                             java.lang.String serverGroup,
                                                             java.lang.String poolName,
                                                             int pingInterval,
                                                             int idleTimeout,
                                                             boolean threadLocalCnxs,
                                                             int lifetimeTimeout,
                                                             int statisticInterval)

    - #### configureConnectionPoolWithNameAndFactory

          public static Pool configureConnectionPoolWithNameAndFactory(AttributesFactory factory,
                                                                       java.lang.String host,
                                                                       int[] ports,
                                                                       boolean establish,
                                                                       int redundancy,
                                                                       int connectionsPerServer,
                                                                       java.lang.String serverGroup,
                                                                       java.lang.String poolName,
                                                                       PoolFactory pf)

    - #### configureConnectionPoolWithNameAndFactory

          public static Pool configureConnectionPoolWithNameAndFactory(AttributesFactory factory,
                                                                       java.lang.String host,
                                                                       int[] ports,
                                                                       boolean establish,
                                                                       int redundancy,
                                                                       int connectionsPerServer,
                                                                       java.lang.String serverGroup,
                                                                       java.lang.String poolName,
                                                                       PoolFactory pf,
                                                                       int pingInterval,
                                                                       int idleTimeout,
                                                                       boolean threadLocalCnxs,
                                                                       int lifetimeTimeout,
                                                                       int statisticInterval)

      this method creates a client connection pool and configures it. If the ports array is not empty it is used to configure the client pool. Otherwise the pool is configured to use the dunit locator.

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int[] ports,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup)

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int[] ports,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup,
                                                     int pingInterval,
                                                     int idleTimeout,
                                                     boolean threadLocalCnxs,
                                                     int lifetimeTimeout)

    - #### configureConnectionPool

          public static Pool configureConnectionPool(AttributesFactory factory,
                                                     java.lang.String host,
                                                     int[] ports,
                                                     boolean establish,
                                                     int redundancy,
                                                     int connectionsPerServer,
                                                     java.lang.String serverGroup,
                                                     int pingInterval,
                                                     int idleTimeout,
                                                     boolean threadLocalCnxs,
                                                     int lifetimeTimeout,
                                                     int statisticInterval)

    - #### getMemberId

          protected static DistributedMember getMemberId()

    - #### createBridgeServer

          public void createBridgeServer(org.apache.geode.test.dunit.VM vm,
                                         java.lang.String rName,
                                         int port)

      Create a server that has a value for every key queried and a unique key/value in the specified Region that uniquely identifies each instance.
      Parameters:
        `vm` - the VM on which to create the server
        `rName` - the name of the Region to create on the server
        `port` - the TCP port on which the server should listen

    - #### createUniquePorts

          public static int[] createUniquePorts(int numToCreate)