Example #1
0
  /** Returns a set of tests to run for varied log configurations. */
  protected Object[] testsFor(Class<? extends LogTest> testClass) throws Throwable {
    List<Object> tests = new ArrayList<>();
    for (int i = 1; i < 10; i++) {
      LogTest test = testClass.newInstance();
      test.entriesPerSegment = i;
      test.entryPadding = i / 3;
      tests.add(test);
    }

    return tests.toArray(new Object[tests.size()]);
  }
  // Loads the parameters from file if the file has changed.
  // Returns the parameters or null if the file does not exist.
  private static <T extends ConfProvider> T loadParameters(
      Path path, Class<T> clazz, T existingInstance) throws Exception {
    T params = existingInstance != null ? existingInstance : (T) clazz.newInstance();

    if (params.hasChanged()) {
      log.trace("Loading {} from {}", clazz.getSimpleName(), path);

      params.load(path.toString());
    }

    return params;
  }