org.springframework.ldap.core.support.SingleContextSource Java Examples

The following examples show how to use org.springframework.ldap.core.support.SingleContextSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PagedSearchITest.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
@Test
public void testPaged() {
    final SearchControls searchControls = new SearchControls();
    searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);

    // There  should be three pages of three entries, and one final page with one entry
    final PagedResultsDirContextProcessor processor = new PagedResultsDirContextProcessor(3);

    SingleContextSource.doWithSingleContext(contextSource, new LdapOperationsCallback<Object>() {
        @Override
        public Object doWithLdapOperations(LdapOperations operations) {
            List<String> result = operations.search(
                    "ou=People",
                    "(&(objectclass=person))",
                    searchControls,
                    CN_ATTRIBUTES_MAPPER,
                    processor);
            assertThat(result).hasSize(3);

            result = operations.search(
                    "ou=People",
                    "(&(objectclass=person))",
                    searchControls,
                    CN_ATTRIBUTES_MAPPER,
                    processor);
            assertThat(result).hasSize(3);

            result = operations.search(
                    "ou=People",
                    "(&(objectclass=person))",
                    searchControls,
                    CN_ATTRIBUTES_MAPPER,
                    processor);
            assertThat(result).hasSize(3);

            result = operations.search(
                    "ou=People",
                    "(&(objectclass=person))",
                    searchControls,
                    CN_ATTRIBUTES_MAPPER,
                    processor);
            assertThat(result).hasSize(1);

            assertThat(processor.hasMore()).isFalse();
            return null;
        }
    });

}
 
Example #2
Source File: LdapCompensatingTransactionOperationFactory.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
LdapOperations createLdapOperationsInstance(DirContext ctx) {
	return new LdapTemplate(new SingleContextSource(ctx));
}