@Test
public void testRestore() throws IOException {

  double compressionRatioSum = 0;
  int calcuTimes = 0;
  if (new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
    fail();
  }
  int compressionRatio = 10;
  for(int i = 0; i < 100 ; i+= compressionRatio){
    this.compressionRatio.updateRatio(compressionRatio);
    if (new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
      fail();
    }
    calcuTimes++;
    compressionRatioSum += compressionRatio;
    if (!new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
      fail();
    }
    assertEquals(0, Double
        .compare(compressionRatioSum / calcuTimes, this.compressionRatio.getRatio()));
  }
  this.compressionRatio.restore();
  assertEquals(10, this.compressionRatio.getCalcTimes());
  assertEquals(0, Double
      .compare(compressionRatioSum / calcuTimes, this.compressionRatio.getRatio()));
}