@Test public void testSearchWithCustomPageSize() { sut = new PagedLdapSearchStrategy(2); final List<Person> testPersonList = new ArrayList<Person>(); testPersonList.add(new Person()); testPersonList.add(new Person()); context.checking(new Expectations() { { allowing(ldapTemplateMock).getContextSource(); will(returnValue(ldapContextSourceMock)); allowing(ldapContextSourceMock).getUrls(); will(returnValue(urls)); allowing(ldapContextSourceMock).getBaseLdapPathAsString(); will(returnValue("dc=blah")); oneOf(ldapTemplateMock).search(with(any(String.class)), with(any(String.class)), with(any(SearchControls.class)), with(any(CollectingNameClassPairCallbackHandler.class)), with(any(PagedResultsDirContextProcessor.class))); oneOf(handlerMock).getList(); will(returnValue(testPersonList)); } }); sut.searchLdap(ldapTemplateMock, "cn=groupname", searchControlsMock, handlerMock); context.assertIsSatisfied(); }
@Override public void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter, final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler) { PagedResultsDirContextProcessor pager = new PagedResultsDirContextProcessor(resultsPerPage); if (logger.isTraceEnabled()) { logger.trace("Beginning paged ldap search with " + resultsPerPage + " results per page. Filter: " + inEncodedFilter + " using dc: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getUrls()[0] + " using baseLdapPath: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getBaseLdapPathAsString()); } do { inLdapTemplate.search("", inEncodedFilter, inSearchControls, inHandler, pager); pager = new PagedResultsDirContextProcessor(resultsPerPage, pager.getCookie()); } while (pager.getCookie() != null && pager.getCookie().getCookie() != null && inHandler.getList().size() < inSearchControls.getCountLimit()); if (logger.isTraceEnabled()) { logger.trace("Paged ldap search complete with " + inHandler.getList().size() + " results retrieved"); } }
PagedLdapSearchStrategy implements LdapSearchStrategy { @Override public void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter, final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler) { PagedResultsDirContextProcessor pager = new PagedResultsDirContextProcessor(resultsPerPage); if (logger.isTraceEnabled()) { logger.trace("Beginning paged ldap search with " + resultsPerPage + " results per page. Filter: " + inEncodedFilter + " using dc: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getUrls()[0] + " using baseLdapPath: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getBaseLdapPathAsString()); } do { inLdapTemplate.search("", inEncodedFilter, inSearchControls, inHandler, pager); pager = new PagedResultsDirContextProcessor(resultsPerPage, pager.getCookie()); } while (pager.getCookie() != null && pager.getCookie().getCookie() != null && inHandler.getList().size() < inSearchControls.getCountLimit()); if (logger.isTraceEnabled()) { logger.trace("Paged ldap search complete with " + inHandler.getList().size() + " results retrieved"); } } }
PagedLdapSearchStrategy implements LdapSearchStrategy { @Override public void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter, final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler) { PagedResultsDirContextProcessor pager = new PagedResultsDirContextProcessor(resultsPerPage); if (logger.isTraceEnabled()) { logger.trace("Beginning paged ldap search with " + resultsPerPage + " results per page. Filter: " + inEncodedFilter + " using dc: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getUrls()[0] + " using baseLdapPath: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getBaseLdapPathAsString()); } do { inLdapTemplate.search("", inEncodedFilter, inSearchControls, inHandler, pager); pager = new PagedResultsDirContextProcessor(resultsPerPage, pager.getCookie()); } while (pager.getCookie() != null && pager.getCookie().getCookie() != null && inHandler.getList().size() < inSearchControls.getCountLimit()); if (logger.isTraceEnabled()) { logger.trace("Paged ldap search complete with " + inHandler.getList().size() + " results retrieved"); } } PagedLdapSearchStrategy();  PagedLdapSearchStrategy(final int inPageSize); }
PagedLdapSearchStrategy implements LdapSearchStrategy { @Override public void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter, final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler) { PagedResultsDirContextProcessor pager = new PagedResultsDirContextProcessor(resultsPerPage); if (logger.isTraceEnabled()) { logger.trace("Beginning paged ldap search with " + resultsPerPage + " results per page. Filter: " + inEncodedFilter + " using dc: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getUrls()[0] + " using baseLdapPath: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getBaseLdapPathAsString()); } do { inLdapTemplate.search("", inEncodedFilter, inSearchControls, inHandler, pager); pager = new PagedResultsDirContextProcessor(resultsPerPage, pager.getCookie()); } while (pager.getCookie() != null && pager.getCookie().getCookie() != null && inHandler.getList().size() < inSearchControls.getCountLimit()); if (logger.isTraceEnabled()) { logger.trace("Paged ldap search complete with " + inHandler.getList().size() + " results retrieved"); } } PagedLdapSearchStrategy();  PagedLdapSearchStrategy(final int inPageSize); @Override void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter,
            final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler); }
PagedLdapSearchStrategy implements LdapSearchStrategy { @Override public void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter, final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler) { PagedResultsDirContextProcessor pager = new PagedResultsDirContextProcessor(resultsPerPage); if (logger.isTraceEnabled()) { logger.trace("Beginning paged ldap search with " + resultsPerPage + " results per page. Filter: " + inEncodedFilter + " using dc: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getUrls()[0] + " using baseLdapPath: " + ((LdapContextSource) inLdapTemplate.getContextSource()).getBaseLdapPathAsString()); } do { inLdapTemplate.search("", inEncodedFilter, inSearchControls, inHandler, pager); pager = new PagedResultsDirContextProcessor(resultsPerPage, pager.getCookie()); } while (pager.getCookie() != null && pager.getCookie().getCookie() != null && inHandler.getList().size() < inSearchControls.getCountLimit()); if (logger.isTraceEnabled()) { logger.trace("Paged ldap search complete with " + inHandler.getList().size() + " results retrieved"); } } PagedLdapSearchStrategy();  PagedLdapSearchStrategy(final int inPageSize); @Override void searchLdap(final LdapTemplate inLdapTemplate, final String inEncodedFilter,
            final SearchControls inSearchControls, final CollectingNameClassPairCallbackHandler inHandler);  }