@Test public void testDoWithSingleContext() { when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); verifyNoMoreInteractions(contextSourceMock); SingleContextSource.doWithSingleContext(contextSourceMock, new LdapOperationsCallback<Object>() { @Override public Object doWithLdapOperations(LdapOperations operations) { operations.executeReadOnly(new ContextExecutor<Object>() { @Override public Object executeWithContext(DirContext ctx) throws NamingException { Object targetContex = Whitebox.getInternalState(Proxy.getInvocationHandler(ctx), "target"); assertThat(targetContex).isSameAs(dirContextMock); return false; } }); operations.executeReadOnly(new ContextExecutor<Object>() { @Override public Object executeWithContext(DirContext ctx) throws NamingException { Object targetContex = Whitebox.getInternalState(Proxy.getInvocationHandler(ctx), "target"); assertThat(targetContex).isSameAs(dirContextMock); return false; } }); return null; } }); }
public static <T> T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback) { return doWithSingleContext(contextSource, callback, DONT_USE_READ_ONLY, DONT_IGNORE_PARTIAL_RESULT, DONT_IGNORE_NAME_NOT_FOUND); }
SingleContextSource implements ContextSource, DisposableBean { public static <T> T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback) { return doWithSingleContext(contextSource, callback, DONT_USE_READ_ONLY, DONT_IGNORE_PARTIAL_RESULT, DONT_IGNORE_NAME_NOT_FOUND); } }
SingleContextSource implements ContextSource, DisposableBean { public static <T> T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback) { return doWithSingleContext(contextSource, callback, DONT_USE_READ_ONLY, DONT_IGNORE_PARTIAL_RESULT, DONT_IGNORE_NAME_NOT_FOUND); } SingleContextSource(DirContext ctx); }
SingleContextSource implements ContextSource, DisposableBean { public static <T> T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback) { return doWithSingleContext(contextSource, callback, DONT_USE_READ_ONLY, DONT_IGNORE_PARTIAL_RESULT, DONT_IGNORE_NAME_NOT_FOUND); } SingleContextSource(DirContext ctx); DirContext getReadOnlyContext(); DirContext getReadWriteContext(); DirContext getContext(String principal, String credentials); void destroy(); static T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback); static T doWithSingleContext(ContextSource contextSource,
                                            LdapOperationsCallback<T> callback,
                                            boolean useReadOnly,
                                            boolean ignorePartialResultException,
                                            boolean ignoreNameNotFoundException); }
SingleContextSource implements ContextSource, DisposableBean { public static <T> T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback) { return doWithSingleContext(contextSource, callback, DONT_USE_READ_ONLY, DONT_IGNORE_PARTIAL_RESULT, DONT_IGNORE_NAME_NOT_FOUND); } SingleContextSource(DirContext ctx); DirContext getReadOnlyContext(); DirContext getReadWriteContext(); DirContext getContext(String principal, String credentials); void destroy(); static T doWithSingleContext(ContextSource contextSource, LdapOperationsCallback<T> callback); static T doWithSingleContext(ContextSource contextSource,
                                            LdapOperationsCallback<T> callback,
                                            boolean useReadOnly,
                                            boolean ignorePartialResultException,
                                            boolean ignoreNameNotFoundException);  }