### Question:
ResourcesHolder { public <T extends SortedResource> void put(Class<T> clazz, T resource) { logger.info("put {}:{}", clazz.getSimpleName(), resource); SortedResource previousResource = resources.putInstance(clazz, resource); if (previousResource != null) { throwAlreadyHeldResourceException(clazz, previousResource); } } ResourcesHolder(); void remove(Class<? extends SortedResource> clazz); void put(Class<T> clazz, T resource); T get(Class<T> clazz); void close(); static final String RESOURCES; }### Answer:
@Test(expected=IllegalStateException.class) public void putShouldCloseOverriddenResource() { TestResource resourceOverridden = new TestResource(); TestResource resource = new TestResource(); testee.put(TestResource.class, resourceOverridden); try { testee.put(TestResource.class, resource); } catch (Exception e) { assertThat(resourceOverridden.isClosed).isTrue(); throw e; } }