@Test
  public void shouldFailIfHAModeIsSetAndTheDbTuningFileHasNotBeenSpecified() throws IOException {
    File serverPropertyFile = ServerTestUtils.createTempPropertyFile();
    ServerTestUtils.writePropertyToFile(Configurator.DB_MODE_KEY, "ha", serverPropertyFile);

    assertRuleFail(serverPropertyFile);

    serverPropertyFile.delete();
  }
  @Test
  public void shouldFailIfHAModeIsSetAndTheDbTuningFileHasBeenSpecifiedButDoesNotExist()
      throws IOException {
    File serverPropertyFile = ServerTestUtils.createTempPropertyFile();
    File dbTuningFile = ServerTestUtils.createTempPropertyFile();
    ServerTestUtils.writePropertyToFile(
        Configurator.DB_TUNING_PROPERTY_FILE_KEY,
        dbTuningFile.getAbsolutePath(),
        serverPropertyFile);
    ServerTestUtils.writePropertyToFile(Configurator.DB_MODE_KEY, "ha", serverPropertyFile);

    assertRuleFail(serverPropertyFile);

    serverPropertyFile.delete();
    dbTuningFile.delete();
  }
  @Test
  public void shouldPassIfHAModeIsSetAndTheDbTuningFileHasBeenSpecifiedAndExists()
      throws IOException {
    File serverPropertyFile = ServerTestUtils.createTempPropertyFile();
    File dbTuningFile = ServerTestUtils.createTempPropertyFile();
    ServerTestUtils.writePropertyToFile(
        Configurator.DB_TUNING_PROPERTY_FILE_KEY,
        dbTuningFile.getAbsolutePath(),
        serverPropertyFile);
    ServerTestUtils.writePropertyToFile(Configurator.DB_MODE_KEY, "ha", serverPropertyFile);
    ServerTestUtils.writePropertyToFile(HaSettings.server_id.name(), "1", dbTuningFile);

    assertRulePass(serverPropertyFile);

    serverPropertyFile.delete();
    dbTuningFile.delete();
  }
  @Test
  public void shouldPassIfHAModeIsSetAndTheDbTuningFileHasBeenSpecifiedAndExistsWithOldConfig()
      throws IOException {
    File serverPropertyFile = ServerTestUtils.createTempPropertyFile();
    File dbTuningFile = ServerTestUtils.createTempPropertyFile();
    ServerTestUtils.writePropertyToFile(
        Configurator.DB_TUNING_PROPERTY_FILE_KEY,
        dbTuningFile.getAbsolutePath(),
        serverPropertyFile);
    ServerTestUtils.writePropertyToFile(Configurator.DB_MODE_KEY, "ha", serverPropertyFile);
    ServerTestUtils.writePropertyToFile(CONFIG_KEY_OLD_SERVER_ID, "1", dbTuningFile);
    ServerTestUtils.writePropertyToFile(
        CONFIG_KEY_OLD_COORDINATORS, "localhost:0000", dbTuningFile);

    assertRulePass(serverPropertyFile);

    serverPropertyFile.delete();
    dbTuningFile.delete();
  }
 @Test
 public void shouldFailIfInvalidModeSpecified() throws Exception {
   File serverPropertyFile = ServerTestUtils.createTempPropertyFile();
   ServerTestUtils.writePropertyToFile(Configurator.DB_MODE_KEY, "faulty", serverPropertyFile);
   assertRuleFail(serverPropertyFile);
 }
 @Test
 public void shouldPassIfHaModeNotSpecified() throws Exception {
   File serverPropertyFile = ServerTestUtils.createTempPropertyFile();
   ServerTestUtils.writePropertyToFile("touch", "me", serverPropertyFile);
   assertRulePass(serverPropertyFile);
 }