public void test_saveDataAndReturnData() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather();

    // WHEN
    Weather weatherReturned =
        dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, "weather.xml");

    // THEN
    assertTrue(weatherReturned.getCurren_weather().contains(TEST_TEMP));
  }
  public void test_loadDataFromCache_not_expired() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather();
    final String FILE_NAME = "toto";
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);

    // WHEN
    Weather weatherReturned =
        dataPersistenceManager.loadDataFromCache(FILE_NAME, DurationInMillis.ONE_SECOND);

    // THEN
    assertTrue(weatherReturned.getCurren_weather().contains(TEST_TEMP));
  }
  public void test_saveDataAndReturnData_async() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather();

    // WHEN
    dataPersistenceManager.setAsyncSaveEnabled(true);
    Weather weatherReturned =
        dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, "weather.xml");

    // THEN
    ((SimpleSerializerObjectPersister<?>) dataPersistenceManager)
        .awaitForSaveAsyncTermination(500, TimeUnit.MILLISECONDS);
    assertTrue(weatherReturned.getCurren_weather().contains(TEST_TEMP));
  }
  public void test_loadDataFromCache_expired() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather();
    final String FILE_NAME = "toto";
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    File cachedFile =
        ((SimpleSerializerObjectPersister<?>) dataPersistenceManager).getCacheFile(FILE_NAME);
    cachedFile.setLastModified(System.currentTimeMillis() - 5 * DurationInMillis.ONE_SECOND);

    // WHEN
    Weather weatherReturned =
        dataPersistenceManager.loadDataFromCache(FILE_NAME, DurationInMillis.ONE_SECOND);

    // THEN
    assertNull(weatherReturned);
  }