@Test public void testModifyAttributesWithDirContextOperationsNotInitializedInUpdateMode() throws Exception { when(dirContextOperationsMock.getDn()).thenReturn(null); LdapTemplate tested = new LdapTemplate() { public void modifyAttributes(Name dn, ModificationItem[] mods) { fail("The call to the base modifyAttributes should not have occured."); } }; try { tested.modifyAttributes(dirContextOperationsMock); fail("IllegalStateException expected"); } catch (IllegalStateException expected) { assertThat(true).isTrue(); } }
@Override public void modifyAttributes(final Name dn, final ModificationItem[] mods) { executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.modifyAttributes(dn, mods); return null; } }); }
LdapTemplate implements LdapOperations, InitializingBean { @Override public void modifyAttributes(final Name dn, final ModificationItem[] mods) { executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.modifyAttributes(dn, mods); return null; } }); } }
LdapTemplate implements LdapOperations, InitializingBean { @Override public void modifyAttributes(final Name dn, final ModificationItem[] mods) { executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.modifyAttributes(dn, mods); return null; } }); } LdapTemplate();  LdapTemplate(ContextSource contextSource); }
LdapTemplate implements LdapOperations, InitializingBean { @Override public void modifyAttributes(final Name dn, final ModificationItem[] mods) { executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.modifyAttributes(dn, mods); return null; } }); } LdapTemplate();  LdapTemplate(ContextSource contextSource); void setContextSource(ContextSource contextSource); @Override ObjectDirectoryMapper getObjectDirectoryMapper(); void setObjectDirectoryMapper(ObjectDirectoryMapper odm); ContextSource getContextSource(); void setIgnoreNameNotFoundException(boolean ignore); void setIgnorePartialResultException(boolean ignore); void setIgnoreSizeLimitExceededException(boolean ignore); void setDefaultSearchScope(int defaultSearchScope); void setDefaultTimeLimit(int defaultTimeLimit); void setDefaultCountLimit(int defaultCountLimit); @Override void search(Name base, String filter, int searchScope, boolean returningObjFlag,
			NameClassPairCallbackHandler handler); @Override void search(String base, String filter, int searchScope, boolean returningObjFlag,
			NameClassPairCallbackHandler handler); @Override void search(final Name base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler); @Override void search(final String base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler); @Override void search(final Name base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler, DirContextProcessor processor); @Override void search(final String base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler, DirContextProcessor processor); @Override void search(SearchExecutor se, NameClassPairCallbackHandler handler, DirContextProcessor processor); @Override void search(SearchExecutor se, NameClassPairCallbackHandler handler); @Override void search(Name base, String filter, NameClassPairCallbackHandler handler); @Override void search(String base, String filter, NameClassPairCallbackHandler handler); @Override List<T> search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper); @Override List<T> search(Name base, String filter, int searchScope, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, AttributesMapper<T> mapper); @Override List<T> search(Name base, String filter, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, AttributesMapper<T> mapper); @Override List<T> search(Name base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, int searchScope, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, SearchControls controls, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, SearchControls controls, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper,
			DirContextProcessor processor); @Override List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper,
			DirContextProcessor processor); @Override List<T> search(String base, String filter, SearchControls controls, ContextMapper<T> mapper,
			DirContextProcessor processor); @Override List<T> search(Name base, String filter, SearchControls controls, ContextMapper<T> mapper,
			DirContextProcessor processor); @Override void list(final String base, NameClassPairCallbackHandler handler); @Override void list(final Name base, NameClassPairCallbackHandler handler); @Override List<T> list(String base, NameClassPairMapper<T> mapper); @Override List<T> list(Name base, NameClassPairMapper<T> mapper); @Override List<String> list(final Name base); @Override List<String> list(final String base); @Override void listBindings(final String base, NameClassPairCallbackHandler handler); @Override void listBindings(final Name base, NameClassPairCallbackHandler handler); @Override List<T> listBindings(String base, NameClassPairMapper<T> mapper); @Override List<T> listBindings(Name base, NameClassPairMapper<T> mapper); @Override List<String> listBindings(final String base); @Override List<String> listBindings(final Name base); @Override List<T> listBindings(String base, ContextMapper<T> mapper); @Override List<T> listBindings(Name base, ContextMapper<T> mapper); @Override T executeReadOnly(ContextExecutor<T> ce); @Override T executeReadWrite(ContextExecutor<T> ce); @Override Object lookup(final Name dn); @Override Object lookup(final String dn); @Override T lookup(final Name dn, final AttributesMapper<T> mapper); @Override T lookup(final String dn, final AttributesMapper<T> mapper); @Override T lookup(final Name dn, final ContextMapper<T> mapper); @Override T lookup(final String dn, final ContextMapper<T> mapper); @Override T lookup(final Name dn, final String[] attributes, final AttributesMapper<T> mapper); @Override T lookup(final String dn, final String[] attributes, final AttributesMapper<T> mapper); @Override T lookup(final Name dn, final String[] attributes, final ContextMapper<T> mapper); @Override T lookup(final String dn, final String[] attributes, final ContextMapper<T> mapper); @Override void modifyAttributes(final Name dn, final ModificationItem[] mods); @Override void modifyAttributes(final String dn, final ModificationItem[] mods); @Override void bind(final Name dn, final Object obj, final Attributes attributes); @Override void bind(final String dn, final Object obj, final Attributes attributes); @Override void unbind(final Name dn); @Override void unbind(final String dn); @Override void unbind(final Name dn, boolean recursive); @Override void unbind(final String dn, boolean recursive); @Override void rebind(final Name dn, final Object obj, final Attributes attributes); @Override void rebind(final String dn, final Object obj, final Attributes attributes); @Override void rename(final Name oldDn, final Name newDn); @Override void rename(final String oldDn, final String newDn); @Override void afterPropertiesSet(); @Override DirContextOperations lookupContext(Name dn); @Override DirContextOperations lookupContext(String dn); @Override void modifyAttributes(DirContextOperations ctx); @Override void bind(DirContextOperations ctx); @Override void rebind(DirContextOperations ctx); @Override boolean authenticate(Name base, String filter, String password); @Override boolean authenticate(String base, String filter, String password); @Override boolean authenticate(String base, String filter, String password,
			AuthenticatedLdapEntryContextCallback callback); @Override boolean authenticate(Name base, String filter, String password,
			final AuthenticatedLdapEntryContextCallback callback); @Override boolean authenticate(String base, String filter, String password,
			AuthenticationErrorCallback errorCallback); @Override boolean authenticate(Name base, String filter, String password,
			final AuthenticationErrorCallback errorCallback); @Override boolean authenticate(String base, String filter, String password,
			final AuthenticatedLdapEntryContextCallback callback, final AuthenticationErrorCallback errorCallback); @Override boolean authenticate(Name base, String filter, String password,
			final AuthenticatedLdapEntryContextCallback callback, final AuthenticationErrorCallback errorCallback); @Override T authenticate(LdapQuery query, String password, AuthenticatedLdapEntryContextMapper<T> mapper); @Override void authenticate(LdapQuery query, String password); @Override T searchForObject(Name base, String filter, ContextMapper<T> mapper); @Override T searchForObject(String base, String filter, ContextMapper<T> mapper); @Override T searchForObject(Name base, String filter, SearchControls searchControls, ContextMapper<T> mapper); @Override T searchForObject(String base, String filter, SearchControls searchControls, ContextMapper<T> mapper); @Override void search(LdapQuery query, NameClassPairCallbackHandler callbackHandler); @Override List<T> search(LdapQuery query, ContextMapper<T> mapper); @Override List<T> search(LdapQuery query, AttributesMapper<T> mapper); @Override DirContextOperations searchForContext(LdapQuery query); @Override T searchForObject(LdapQuery query, ContextMapper<T> mapper); @Override T findByDn(Name dn, final Class<T> clazz); @Override void create(Object entry); @Override void update(Object entry); @Override void delete(Object entry); @Override List<T> findAll(Name base, SearchControls searchControls, final Class<T> clazz); @Override List<T> findAll(Class<T> clazz); @Override List<T> find(Name base, Filter filter, SearchControls searchControls, final Class<T> clazz); @Override List<T> find(LdapQuery query, Class<T> clazz); @Override T findOne(LdapQuery query, Class<T> clazz); }
LdapTemplate implements LdapOperations, InitializingBean { @Override public void modifyAttributes(final Name dn, final ModificationItem[] mods) { executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.modifyAttributes(dn, mods); return null; } }); } LdapTemplate();  LdapTemplate(ContextSource contextSource); void setContextSource(ContextSource contextSource); @Override ObjectDirectoryMapper getObjectDirectoryMapper(); void setObjectDirectoryMapper(ObjectDirectoryMapper odm); ContextSource getContextSource(); void setIgnoreNameNotFoundException(boolean ignore); void setIgnorePartialResultException(boolean ignore); void setIgnoreSizeLimitExceededException(boolean ignore); void setDefaultSearchScope(int defaultSearchScope); void setDefaultTimeLimit(int defaultTimeLimit); void setDefaultCountLimit(int defaultCountLimit); @Override void search(Name base, String filter, int searchScope, boolean returningObjFlag,
			NameClassPairCallbackHandler handler); @Override void search(String base, String filter, int searchScope, boolean returningObjFlag,
			NameClassPairCallbackHandler handler); @Override void search(final Name base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler); @Override void search(final String base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler); @Override void search(final Name base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler, DirContextProcessor processor); @Override void search(final String base, final String filter, final SearchControls controls,
			NameClassPairCallbackHandler handler, DirContextProcessor processor); @Override void search(SearchExecutor se, NameClassPairCallbackHandler handler, DirContextProcessor processor); @Override void search(SearchExecutor se, NameClassPairCallbackHandler handler); @Override void search(Name base, String filter, NameClassPairCallbackHandler handler); @Override void search(String base, String filter, NameClassPairCallbackHandler handler); @Override List<T> search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper); @Override List<T> search(Name base, String filter, int searchScope, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, AttributesMapper<T> mapper); @Override List<T> search(Name base, String filter, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, AttributesMapper<T> mapper); @Override List<T> search(Name base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, int searchScope, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, int searchScope, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, ContextMapper<T> mapper); @Override List<T> search(String base, String filter, SearchControls controls, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, SearchControls controls, ContextMapper<T> mapper); @Override List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper); @Override List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper,
			DirContextProcessor processor); @Override List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper,
			DirContextProcessor processor); @Override List<T> search(String base, String filter, SearchControls controls, ContextMapper<T> mapper,
			DirContextProcessor processor); @Override List<T> search(Name base, String filter, SearchControls controls, ContextMapper<T> mapper,
			DirContextProcessor processor); @Override void list(final String base, NameClassPairCallbackHandler handler); @Override void list(final Name base, NameClassPairCallbackHandler handler); @Override List<T> list(String base, NameClassPairMapper<T> mapper); @Override List<T> list(Name base, NameClassPairMapper<T> mapper); @Override List<String> list(final Name base); @Override List<String> list(final String base); @Override void listBindings(final String base, NameClassPairCallbackHandler handler); @Override void listBindings(final Name base, NameClassPairCallbackHandler handler); @Override List<T> listBindings(String base, NameClassPairMapper<T> mapper); @Override List<T> listBindings(Name base, NameClassPairMapper<T> mapper); @Override List<String> listBindings(final String base); @Override List<String> listBindings(final Name base); @Override List<T> listBindings(String base, ContextMapper<T> mapper); @Override List<T> listBindings(Name base, ContextMapper<T> mapper); @Override T executeReadOnly(ContextExecutor<T> ce); @Override T executeReadWrite(ContextExecutor<T> ce); @Override Object lookup(final Name dn); @Override Object lookup(final String dn); @Override T lookup(final Name dn, final AttributesMapper<T> mapper); @Override T lookup(final String dn, final AttributesMapper<T> mapper); @Override T lookup(final Name dn, final ContextMapper<T> mapper); @Override T lookup(final String dn, final ContextMapper<T> mapper); @Override T lookup(final Name dn, final String[] attributes, final AttributesMapper<T> mapper); @Override T lookup(final String dn, final String[] attributes, final AttributesMapper<T> mapper); @Override T lookup(final Name dn, final String[] attributes, final ContextMapper<T> mapper); @Override T lookup(final String dn, final String[] attributes, final ContextMapper<T> mapper); @Override void modifyAttributes(final Name dn, final ModificationItem[] mods); @Override void modifyAttributes(final String dn, final ModificationItem[] mods); @Override void bind(final Name dn, final Object obj, final Attributes attributes); @Override void bind(final String dn, final Object obj, final Attributes attributes); @Override void unbind(final Name dn); @Override void unbind(final String dn); @Override void unbind(final Name dn, boolean recursive); @Override void unbind(final String dn, boolean recursive); @Override void rebind(final Name dn, final Object obj, final Attributes attributes); @Override void rebind(final String dn, final Object obj, final Attributes attributes); @Override void rename(final Name oldDn, final Name newDn); @Override void rename(final String oldDn, final String newDn); @Override void afterPropertiesSet(); @Override DirContextOperations lookupContext(Name dn); @Override DirContextOperations lookupContext(String dn); @Override void modifyAttributes(DirContextOperations ctx); @Override void bind(DirContextOperations ctx); @Override void rebind(DirContextOperations ctx); @Override boolean authenticate(Name base, String filter, String password); @Override boolean authenticate(String base, String filter, String password); @Override boolean authenticate(String base, String filter, String password,
			AuthenticatedLdapEntryContextCallback callback); @Override boolean authenticate(Name base, String filter, String password,
			final AuthenticatedLdapEntryContextCallback callback); @Override boolean authenticate(String base, String filter, String password,
			AuthenticationErrorCallback errorCallback); @Override boolean authenticate(Name base, String filter, String password,
			final AuthenticationErrorCallback errorCallback); @Override boolean authenticate(String base, String filter, String password,
			final AuthenticatedLdapEntryContextCallback callback, final AuthenticationErrorCallback errorCallback); @Override boolean authenticate(Name base, String filter, String password,
			final AuthenticatedLdapEntryContextCallback callback, final AuthenticationErrorCallback errorCallback); @Override T authenticate(LdapQuery query, String password, AuthenticatedLdapEntryContextMapper<T> mapper); @Override void authenticate(LdapQuery query, String password); @Override T searchForObject(Name base, String filter, ContextMapper<T> mapper); @Override T searchForObject(String base, String filter, ContextMapper<T> mapper); @Override T searchForObject(Name base, String filter, SearchControls searchControls, ContextMapper<T> mapper); @Override T searchForObject(String base, String filter, SearchControls searchControls, ContextMapper<T> mapper); @Override void search(LdapQuery query, NameClassPairCallbackHandler callbackHandler); @Override List<T> search(LdapQuery query, ContextMapper<T> mapper); @Override List<T> search(LdapQuery query, AttributesMapper<T> mapper); @Override DirContextOperations searchForContext(LdapQuery query); @Override T searchForObject(LdapQuery query, ContextMapper<T> mapper); @Override T findByDn(Name dn, final Class<T> clazz); @Override void create(Object entry); @Override void update(Object entry); @Override void delete(Object entry); @Override List<T> findAll(Name base, SearchControls searchControls, final Class<T> clazz); @Override List<T> findAll(Class<T> clazz); @Override List<T> find(Name base, Filter filter, SearchControls searchControls, final Class<T> clazz); @Override List<T> find(LdapQuery query, Class<T> clazz); @Override T findOne(LdapQuery query, Class<T> clazz);  }