@Test
public void testPoolExceptionOnClose() throws Exception {

    doThrow(new Exception("Fake Pool returnObject Exception"))
            .when(keyedObjectPoolMock).returnObject(DirContextType.READ_ONLY, contextMock);
    final DelegatingContext delegatingContext = new DelegatingContext(
            keyedObjectPoolMock, contextMock, DirContextType.READ_ONLY);
    try {
        delegatingContext.close();
        fail("DelegatingContext.close should have thrown a NamingException");
    } catch (NamingException ne) {
        // Expected
    }
}