protected void setUp() throws Exception {

    super.setUp();
    for (final String configuration : CACHEONIX_CONFIGURATIONS) {
      final Cacheonix manager =
          Cacheonix.getInstance(TestUtils.getTestFile(configuration).toString());
      cacheonixList.add(manager);
    }

    // Let the cluster form
    Thread.sleep(1000L);
  }
  public void setUp() throws Exception {

    super.setUp();

    final ConfigurationReader configurationReader = new ConfigurationReader();
    final String configurationPath =
        TestUtils.getTestFile("cacheonix-config-DataSourceConfigurationTest.xml")
            .getCanonicalPath();
    final CacheonixConfiguration configuration =
        configurationReader.readConfiguration(configurationPath);
    local = configuration.getLocal();
  }
  /**
   * Tests that server configuration auto-creates a cache member.
   *
   * @throws Exception if an unexpected error occurred.
   */
  public void testServerCreatesCache() throws Exception {

    // Startup caches
    final List<Cacheonix> cacheManagerList = new ArrayList<Cacheonix>(5);
    try {
      for (int i = 0; i < NODE_COUNT; i++) {

        final String configurationPath = TestUtils.getTestFile(NODE_CONFIGURATIONS[i]).toString();
        cacheManagerList.add(Cacheonix.getInstance(configurationPath));
      }

      // Wait for cluster to stabilize
      //noinspection ControlFlowStatementWithoutBraces
      if (LOG.isDebugEnabled())
        LOG.debug("======= Begin waiting for a cache processor to create ======= "); // NOPMD

      final Timeout timeoutForOwnersToArrive = new Timeout(10000L).reset();
      while (!timeoutForOwnersToArrive.isExpired()
          && cacheManagerList.get(0).getCache(DISTRIBUTED_CACHE_NAME).getKeyOwners().size()
              != NODE_COUNT) {

        Thread.sleep(100L);
      }

      //noinspection ControlFlowStatementWithoutBraces
      if (LOG.isDebugEnabled())
        LOG.debug("======= End waiting for a cache processor to create ======= "); // NOPMD

      // Assert key owners size - should be number of configs though
      // the server configuration does not define the named node.
      assertEquals(
          NODE_COUNT,
          cacheManagerList.get(0).getCache(DISTRIBUTED_CACHE_NAME).getKeyOwners().size());
    } catch (final Exception e) {

      LOG.error(e, e);
      throw e;
    } finally {

      // Shutdown caches
      for (final Cacheonix cacheonix : cacheManagerList) {

        cacheonix.shutdown(ShutdownMode.GRACEFUL_SHUTDOWN, true);
      }
      cacheManagerList.clear();
    }
  }