### Question:
CacheManagerImpl extends CacheManager { static void eventuallyThrowException(List<Throwable> suppressedExceptions) { if (suppressedExceptions.isEmpty()) { return; } Throwable error = null; for (Throwable t : suppressedExceptions) { if (t instanceof Error) { error = t; break; } if (t instanceof ExecutionException && t.getCause() instanceof Error) { error = t.getCause(); break; } } String text = "Exception(s) during shutdown"; if (suppressedExceptions.size() > 1) { text = " (" + (suppressedExceptions.size() - 1) + " more suppressed exceptions)"; } if (error != null) { throw new CacheInternalError(text, error); } throw new CacheException(text, suppressedExceptions.get(0)); } CacheManagerImpl(Cache2kCoreProviderImpl provider, ClassLoader cl, String name,
                          boolean defaultManager); static Iterable<CacheLifeCycleListener> getCacheLifeCycleListeners(); void sendCreatedEvent(Cache c, final Cache2kConfiguration configuration); static void checkName(String s); String newCache(InternalCache c, String requestedName); void cacheDestroyed(Cache c); @Override boolean isDefaultManager(); @Override String getName(); @Override Iterable<Cache> getActiveCaches(); @Override Iterable<String> getConfiguredCacheNames(); @SuppressWarnings("unchecked") @Override Cache<K, V> getCache(String name); @Override Cache<K, V> createCache(final Cache2kConfiguration<K, V> cfg); @Override void clear(); @Override void close(); @Override Properties getProperties(); @Override ClassLoader getClassLoader(); String getVersion(); Cache2kCoreProviderImpl getProvider(); @Override boolean isClosed(); Object getLockObject(); String toString(); static final Cache2kCoreProvider PROVIDER; }### Answer:
@Test public void eventuallyThrowException_empty() { List<Throwable> li = new ArrayList<Throwable>(); CacheManagerImpl.eventuallyThrowException(li); }
@Test(expected = CacheException.class) public void eventuallyThrowException_normalException() { List<Throwable> li = new ArrayList<Throwable>(); li.add(new IllegalArgumentException()); CacheManagerImpl.eventuallyThrowException(li); fail("exception expected"); }
@Test(expected = CacheInternalError.class) public void eventuallyThrowException_error() { List<Throwable> li = new ArrayList<Throwable>(); li.add(new LinkageError()); CacheManagerImpl.eventuallyThrowException(li); fail("exception expected"); }
@Test(expected = CacheInternalError.class) public void eventuallyThrowException_ExecutionExceptionWithEWrror() { List<Throwable> li = new ArrayList<Throwable>(); li.add(new ExecutionException(new LinkageError())); CacheManagerImpl.eventuallyThrowException(li); fail("exception expected"); }
@Test(expected = CacheInternalError.class) public void eventuallyThrowException_ExceptionAndError() { List<Throwable> li = new ArrayList<Throwable>(); li.add(new IllegalArgumentException()); li.add(new LinkageError()); CacheManagerImpl.eventuallyThrowException(li); fail("exception expected"); }