@Test
public void testSelfPopulatingCacheUpdates() throws Exception {

  UpdatingCacheEntryFactory cacheEntryFactory = createMock(UpdatingCacheEntryFactory.class);
  StringBuilder value = new StringBuilder("b");
  expect(cacheEntryFactory.createEntry("a")).andReturn(value);
  cacheEntryFactory.updateEntryValue("a", value);
  expectLastCall().andAnswer(new IAnswer<Object>() {
    @Override
    public Object answer() throws Throwable {
      String key = (String) getCurrentArguments()[0];
      StringBuilder value = (StringBuilder) getCurrentArguments()[1];
      System.out.println("key = " + key + ", value = " + value);
      value.append("c");
      return null;
    }
  });
  replay(cacheEntryFactory);
  // Need to set this due what seems like a bug in Ehcache 2.10.0, setting
  // it on the second cache instance results in a assertion error.
  // Since this is not out production use case, setting it here as well.
  net.sf.ehcache.config.Configuration managerConfig = new net.sf.ehcache.config.Configuration();
  managerConfig.setMaxBytesLocalHeap("10%");
  CacheManager manager = CacheManager.create(managerConfig);
  Cache cache = new Cache("test", 0, false, false, 10000, 10000);
  UpdatingSelfPopulatingCache testCache = new UpdatingSelfPopulatingCache(cache, cacheEntryFactory);
  manager.addCache(testCache);
  Assert.assertEquals("b", testCache.get("a").getObjectValue().toString());
  Assert.assertEquals("bc", testCache.get("a").getObjectValue().toString());
  verify(cacheEntryFactory);
}