@Test(expected = Error.class)
@SuppressWarnings("unchecked")
public void errorShouldBeReThrow() throws Exception {

  ConcurrentMap<TemplateSource, Future<Pair<TemplateSource, Template>>> cache = createMock(
      ConcurrentHashMap.class);
  TemplateSource source = new URLTemplateSource("/template.hbs", getClass().getResource(
      "/template.hbs"));
  Future<Pair<TemplateSource, Template>> future = createMock(Future.class);
  // 1st try interrupt thread
  expect(cache.get(source)).andReturn(future);
  expect(future.get()).andThrow(new Error());
  // 2nd success
  Template template = createMock(Template.class);
  Pair<TemplateSource, Template> pair = createMock(Pair.class);
  expect(pair.getLeft()).andReturn(source);
  expect(pair.getValue()).andReturn(template);
  expect(cache.get(source)).andReturn(future);
  expect(future.get()).andReturn(pair).times(2);
  Parser parser = createMock(Parser.class);
  replay(parser, template, cache, future, pair);
  // 1st call, parse must be call it
  assertEquals(template, new HighConcurrencyTemplateCache(cache).get(source, parser));
  verify(parser, template, cache, future, pair);
}