private <T> T executeWithContext(ContextExecutor<T> ce, DirContext ctx) { try { return ce.executeWithContext(ctx); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); } finally { closeContext(ctx); } }
private <T> T executeWithContext(ContextExecutor<T> ce, DirContext ctx) { try { return ce.executeWithContext(ctx); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); } finally { closeContext(ctx); } }
private <T> T executeWithContext(ContextExecutor<T> ce, DirContext ctx) { try { return ce.executeWithContext(ctx); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); } finally { closeContext(ctx); } }
private <T> T executeWithContext(ContextExecutor<T> ce, DirContext ctx) { try { return ce.executeWithContext(ctx); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); } finally { closeContext(ctx); } }
@Test public void testExecuteReadOnly() throws Exception { expectGetReadOnlyContext(); Object object = new Object(); when(contextExecutorMock.executeWithContext(dirContextMock)).thenReturn(object); Object result = tested.executeReadOnly(contextExecutorMock); verify(dirContextMock).close(); assertThat(result).isSameAs(object); }
@Test public void testExecuteReadWrite() throws Exception { expectGetReadWriteContext(); Object object = new Object(); when(contextExecutorMock.executeWithContext(dirContextMock)).thenReturn(object); Object result = tested.executeReadWrite(contextExecutorMock); verify(dirContextMock).close(); assertThat(result).isSameAs(object); }
ce.executeWithContext(ctx); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e);
@Test public void testExecuteReadOnly_NamingException() throws Exception { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); when(contextExecutorMock.executeWithContext(dirContextMock)).thenThrow(ne); try { tested.executeReadOnly(contextExecutorMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } verify(dirContextMock).close(); }
@Test public void testExecuteReadWrite_NamingException() throws Exception { expectGetReadWriteContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); when(contextExecutorMock.executeWithContext(dirContextMock)).thenThrow(ne); try { tested.executeReadWrite(contextExecutorMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } verify(dirContextMock).close(); }