diff --git a/core/src/main/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecorator.java b/core/src/main/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecorator.java index 7c03db83..095420b6 100644 --- a/core/src/main/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecorator.java +++ b/core/src/main/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecorator.java @@ -68,11 +68,11 @@ public class DefaultValuesAuthenticationSourceDecorator implements Authenticatio * defaultPassword otherwise. */ public String getCredentials() { - if (StringUtils.hasText(target.getPrincipal())) { - return target.getCredentials(); + if (StringUtils.hasText(this.target.getPrincipal())) { + return this.target.getCredentials(); } else { - return defaultPassword; + return this.defaultPassword; } } @@ -83,12 +83,12 @@ public class DefaultValuesAuthenticationSourceDecorator implements Authenticatio * otherwise. */ public String getPrincipal() { - String principal = target.getPrincipal(); + String principal = this.target.getPrincipal(); if (StringUtils.hasText(principal)) { return principal; } else { - return defaultUser; + return this.defaultUser; } } @@ -123,15 +123,15 @@ public class DefaultValuesAuthenticationSourceDecorator implements Authenticatio * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ public void afterPropertiesSet() throws Exception { - if (target == null) { + if (this.target == null) { throw new IllegalArgumentException("Property 'target' must be set.'"); } - if (defaultUser == null) { + if (this.defaultUser == null) { throw new IllegalArgumentException("Property 'defaultUser' must be set.'"); } - if (defaultPassword == null) { + if (this.defaultPassword == null) { throw new IllegalArgumentException("Property 'defaultPassword' must be set.'"); } } diff --git a/core/src/main/java/org/springframework/ldap/control/AbstractFallbackRequestAndResponseControlDirContextProcessor.java b/core/src/main/java/org/springframework/ldap/control/AbstractFallbackRequestAndResponseControlDirContextProcessor.java index 6d2bc1ac..0524e36a 100644 --- a/core/src/main/java/org/springframework/ldap/control/AbstractFallbackRequestAndResponseControlDirContextProcessor.java +++ b/core/src/main/java/org/springframework/ldap/control/AbstractFallbackRequestAndResponseControlDirContextProcessor.java @@ -101,20 +101,20 @@ public abstract class AbstractFallbackRequestAndResponseControlDirContextProcess protected String fallbackResponseControl; protected void loadControlClasses() { - Assert.notNull(defaultRequestControl, "defaultRequestControl must not be null"); - Assert.notNull(defaultResponseControl, "defaultResponseControl must not be null"); - Assert.notNull(fallbackRequestControl, "fallbackRequestControl must not be null"); - Assert.notNull(fallbackResponseControl, "fallbackReponseControl must not be null"); + Assert.notNull(this.defaultRequestControl, "defaultRequestControl must not be null"); + Assert.notNull(this.defaultResponseControl, "defaultResponseControl must not be null"); + Assert.notNull(this.fallbackRequestControl, "fallbackRequestControl must not be null"); + Assert.notNull(this.fallbackResponseControl, "fallbackReponseControl must not be null"); try { - requestControlClass = Class.forName(defaultRequestControl); - responseControlClass = Class.forName(defaultResponseControl); + this.requestControlClass = Class.forName(this.defaultRequestControl); + this.responseControlClass = Class.forName(this.defaultResponseControl); } catch (ClassNotFoundException e) { - log.debug("Default control classes not found - falling back to LdapBP classes", e); + this.log.debug("Default control classes not found - falling back to LdapBP classes", e); try { - requestControlClass = Class.forName(fallbackRequestControl); - responseControlClass = Class.forName(fallbackResponseControl); + this.requestControlClass = Class.forName(this.fallbackRequestControl); + this.responseControlClass = Class.forName(this.fallbackResponseControl); } catch (ClassNotFoundException e1) { throw new UncategorizedLdapException( @@ -155,7 +155,7 @@ public abstract class AbstractFallbackRequestAndResponseControlDirContextProcess * @return Control to be used by the DirContextProcessor */ public Control createRequestControl(Class[] paramTypes, Object[] params) { - Constructor constructor = ClassUtils.getConstructorIfAvailable(requestControlClass, paramTypes); + Constructor constructor = ClassUtils.getConstructorIfAvailable(this.requestControlClass, paramTypes); if (constructor == null) { throw new IllegalArgumentException("Failed to find an appropriate RequestControl constructor"); } @@ -186,13 +186,13 @@ public abstract class AbstractFallbackRequestAndResponseControlDirContextProcess // Go through response controls and get info, regardless of class for (Control responseControl : responseControls) { // check for match, try fallback otherwise - if (responseControl.getClass().isAssignableFrom(responseControlClass)) { + if (responseControl.getClass().isAssignableFrom(this.responseControlClass)) { handleResponse(responseControl); return; } } - log.info("No matching response control found - looking for '" + responseControlClass); + this.log.info("No matching response control found - looking for '" + this.responseControlClass); } /** diff --git a/core/src/main/java/org/springframework/ldap/control/AbstractRequestControlDirContextProcessor.java b/core/src/main/java/org/springframework/ldap/control/AbstractRequestControlDirContextProcessor.java index 29abe7f8..c7bfbcdf 100644 --- a/core/src/main/java/org/springframework/ldap/control/AbstractRequestControlDirContextProcessor.java +++ b/core/src/main/java/org/springframework/ldap/control/AbstractRequestControlDirContextProcessor.java @@ -47,7 +47,7 @@ public abstract class AbstractRequestControlDirContextProcessor implements DirCo * @return true if an already existing control will be replaced */ public boolean isReplaceSameControlEnabled() { - return replaceSameControlEnabled; + return this.replaceSameControlEnabled; } /** @@ -93,8 +93,8 @@ public abstract class AbstractRequestControlDirContextProcessor implements DirCo Control[] newControls = new Control[requestControls.length + 1]; for (int i = 0; i < requestControls.length; i++) { - if (replaceSameControlEnabled && requestControls[i].getClass() == newControl.getClass()) { - log.debug("Replacing already existing control in context: " + newControl); + if (this.replaceSameControlEnabled && requestControls[i].getClass() == newControl.getClass()) { + this.log.debug("Replacing already existing control in context: " + newControl); requestControls[i] = newControl; ldapContext.setRequestControls(requestControls); return; diff --git a/core/src/main/java/org/springframework/ldap/control/PagedResult.java b/core/src/main/java/org/springframework/ldap/control/PagedResult.java index 695d53de..acbe6165 100644 --- a/core/src/main/java/org/springframework/ldap/control/PagedResult.java +++ b/core/src/main/java/org/springframework/ldap/control/PagedResult.java @@ -46,7 +46,7 @@ public class PagedResult { * @return the cookie. */ public PagedResultsCookie getCookie() { - return cookie; + return this.cookie; } /** @@ -54,7 +54,7 @@ public class PagedResult { * @return the result list. */ public List getResultList() { - return resultList; + return this.resultList; } @Override @@ -66,9 +66,9 @@ public class PagedResult { PagedResult that = (PagedResult) o; - if (cookie != null ? !cookie.equals(that.cookie) : that.cookie != null) + if (this.cookie != null ? !this.cookie.equals(that.cookie) : that.cookie != null) return false; - if (resultList != null ? !resultList.equals(that.resultList) : that.resultList != null) + if (this.resultList != null ? !this.resultList.equals(that.resultList) : that.resultList != null) return false; return true; @@ -76,8 +76,8 @@ public class PagedResult { @Override public int hashCode() { - int result = resultList != null ? resultList.hashCode() : 0; - result = 31 * result + (cookie != null ? cookie.hashCode() : 0); + int result = this.resultList != null ? this.resultList.hashCode() : 0; + result = 31 * result + (this.cookie != null ? this.cookie.hashCode() : 0); return result; } diff --git a/core/src/main/java/org/springframework/ldap/control/PagedResultsCookie.java b/core/src/main/java/org/springframework/ldap/control/PagedResultsCookie.java index 71161985..7de7c5c5 100644 --- a/core/src/main/java/org/springframework/ldap/control/PagedResultsCookie.java +++ b/core/src/main/java/org/springframework/ldap/control/PagedResultsCookie.java @@ -47,8 +47,8 @@ public class PagedResultsCookie { * no more requests, or that the control wasn't supported by the server. */ public byte[] getCookie() { - if (cookie != null) { - return Arrays.copyOf(cookie, cookie.length); + if (this.cookie != null) { + return Arrays.copyOf(this.cookie, this.cookie.length); } else { return null; @@ -64,7 +64,7 @@ public class PagedResultsCookie { PagedResultsCookie that = (PagedResultsCookie) o; - if (!Arrays.equals(cookie, that.cookie)) + if (!Arrays.equals(this.cookie, that.cookie)) return false; return true; @@ -72,7 +72,7 @@ public class PagedResultsCookie { @Override public int hashCode() { - return cookie != null ? Arrays.hashCode(cookie) : 0; + return this.cookie != null ? Arrays.hashCode(this.cookie) : 0; } } diff --git a/core/src/main/java/org/springframework/ldap/control/PagedResultsDirContextProcessor.java b/core/src/main/java/org/springframework/ldap/control/PagedResultsDirContextProcessor.java index 0a7371e2..7e5fe5ac 100644 --- a/core/src/main/java/org/springframework/ldap/control/PagedResultsDirContextProcessor.java +++ b/core/src/main/java/org/springframework/ldap/control/PagedResultsDirContextProcessor.java @@ -68,10 +68,10 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR this.pageSize = pageSize; this.cookie = cookie; - defaultRequestControl = DEFAULT_REQUEST_CONTROL; - defaultResponseControl = DEFAULT_RESPONSE_CONTROL; - fallbackRequestControl = FALLBACK_REQUEST_CONTROL; - fallbackResponseControl = FALLBACK_RESPONSE_CONTROL; + this.defaultRequestControl = DEFAULT_REQUEST_CONTROL; + this.defaultResponseControl = DEFAULT_RESPONSE_CONTROL; + this.fallbackRequestControl = FALLBACK_REQUEST_CONTROL; + this.fallbackResponseControl = FALLBACK_RESPONSE_CONTROL; loadControlClasses(); } @@ -84,7 +84,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR * @see #hasMore() */ public PagedResultsCookie getCookie() { - return cookie; + return this.cookie; } /** @@ -92,7 +92,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR * @return the page size. */ public int getPageSize() { - return pageSize; + return this.pageSize; } /** @@ -102,7 +102,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR * @return the estimated result size, if returned from the server. */ public int getResultSize() { - return resultSize; + return this.resultSize; } /* @@ -111,11 +111,11 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR */ public Control createRequestControl() { byte[] actualCookie = null; - if (cookie != null) { - actualCookie = cookie.getCookie(); + if (this.cookie != null) { + actualCookie = this.cookie.getCookie(); } return super.createRequestControl(new Class[] { int.class, byte[].class, boolean.class }, - new Object[] { pageSize, actualCookie, critical }); + new Object[] { this.pageSize, actualCookie, this.critical }); } /** @@ -127,7 +127,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR * @since 2.0 */ public boolean hasMore() { - return more; + return this.more; } /* @@ -136,12 +136,12 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR * #handleResponse(java.lang.Object) */ protected void handleResponse(Object control) { - byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control); + byte[] result = (byte[]) invokeMethod("getCookie", this.responseControlClass, control); if (result == null) { - more = false; + this.more = false; } this.cookie = new PagedResultsCookie(result); - this.resultSize = (Integer) invokeMethod("getResultSize", responseControlClass, control); + this.resultSize = (Integer) invokeMethod("getResultSize", this.responseControlClass, control); } } diff --git a/core/src/main/java/org/springframework/ldap/control/PagedResultsRequestControl.java b/core/src/main/java/org/springframework/ldap/control/PagedResultsRequestControl.java index 51223f65..c9a4ba48 100644 --- a/core/src/main/java/org/springframework/ldap/control/PagedResultsRequestControl.java +++ b/core/src/main/java/org/springframework/ldap/control/PagedResultsRequestControl.java @@ -89,15 +89,15 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext private void loadControlClasses() { try { - requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL); - responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL); + this.requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL); + this.responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL); } catch (ClassNotFoundException e) { - log.debug("Default control classes not found - falling back to LdapBP classes", e); + this.log.debug("Default control classes not found - falling back to LdapBP classes", e); try { - requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL); - responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL); + this.requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL); + this.responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL); } catch (ClassNotFoundException e1) { throw new UncategorizedLdapException( @@ -112,7 +112,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext * @return the cookie. */ public PagedResultsCookie getCookie() { - return cookie; + return this.cookie; } /** @@ -120,7 +120,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext * @return the page size. */ public int getPageSize() { - return pageSize; + return this.pageSize; } /** @@ -130,7 +130,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext * @return the estimated result size, if returned from the server. */ public int getResultSize() { - return resultSize; + return this.resultSize; } /** @@ -152,10 +152,10 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext public Control createRequestControl() { byte[] actualCookie = null; - if (cookie != null) { - actualCookie = cookie.getCookie(); + if (this.cookie != null) { + actualCookie = this.cookie.getCookie(); } - Constructor constructor = ClassUtils.getConstructorIfAvailable(requestControlClass, + Constructor constructor = ClassUtils.getConstructorIfAvailable(this.requestControlClass, new Class[] { int.class, byte[].class, boolean.class }); if (constructor == null) { throw new IllegalArgumentException("Failed to find an appropriate RequestControl constructor"); @@ -163,7 +163,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext Control result = null; try { - result = (Control) constructor.newInstance(pageSize, actualCookie, critical); + result = (Control) constructor.newInstance(this.pageSize, actualCookie, this.critical); } catch (Exception e) { ReflectionUtils.handleReflectionException(e); @@ -190,17 +190,18 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext Control responseControl = responseControls[i]; // check for match, try fallback otherwise - if (responseControl.getClass().isAssignableFrom(responseControlClass)) { + if (responseControl.getClass().isAssignableFrom(this.responseControlClass)) { Object control = responseControl; - byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control); + byte[] result = (byte[]) invokeMethod("getCookie", this.responseControlClass, control); this.cookie = new PagedResultsCookie(result); - Integer wrapper = (Integer) invokeMethod("getResultSize", responseControlClass, control); + Integer wrapper = (Integer) invokeMethod("getResultSize", this.responseControlClass, control); this.resultSize = wrapper.intValue(); return; } } - log.error("No matching response control found for paged results - looking for '{}", responseControlClass); + this.log.error("No matching response control found for paged results - looking for '{}", + this.responseControlClass); } private Object invokeMethod(String method, Class clazz, Object control) { diff --git a/core/src/main/java/org/springframework/ldap/control/SortControlDirContextProcessor.java b/core/src/main/java/org/springframework/ldap/control/SortControlDirContextProcessor.java index 375af4bf..bdf81a61 100644 --- a/core/src/main/java/org/springframework/ldap/control/SortControlDirContextProcessor.java +++ b/core/src/main/java/org/springframework/ldap/control/SortControlDirContextProcessor.java @@ -58,11 +58,11 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe this.sorted = false; this.resultCode = -1; - defaultRequestControl = DEFAULT_REQUEST_CONTROL; - defaultResponseControl = DEFAULT_RESPONSE_CONTROL; + this.defaultRequestControl = DEFAULT_REQUEST_CONTROL; + this.defaultResponseControl = DEFAULT_RESPONSE_CONTROL; - fallbackRequestControl = FALLBACK_REQUEST_CONTROL; - fallbackResponseControl = FALLBACK_RESPONSE_CONTROL; + this.fallbackRequestControl = FALLBACK_REQUEST_CONTROL; + this.fallbackResponseControl = FALLBACK_RESPONSE_CONTROL; loadControlClasses(); } @@ -72,7 +72,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe * @return true if the result was sorted, false otherwise. */ public boolean isSorted() { - return sorted; + return this.sorted; } /** @@ -80,7 +80,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe * @return result code. */ public int getResultCode() { - return resultCode; + return this.resultCode; } /** @@ -88,7 +88,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe * @return the sort key. */ public String getSortKey() { - return sortKey; + return this.sortKey; } /* @@ -97,7 +97,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe */ public Control createRequestControl() { return super.createRequestControl(new Class[] { String[].class, boolean.class }, - new Object[] { new String[] { sortKey }, critical }); + new Object[] { new String[] { this.sortKey }, this.critical }); } /* @@ -106,8 +106,8 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe * #handleResponse(java.lang.Object) */ protected void handleResponse(Object control) { - this.sorted = (Boolean) invokeMethod("isSorted", responseControlClass, control); - this.resultCode = (Integer) invokeMethod("getResultCode", responseControlClass, control); + this.sorted = (Boolean) invokeMethod("isSorted", this.responseControlClass, control); + this.resultCode = (Integer) invokeMethod("getResultCode", this.responseControlClass, control); } } diff --git a/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java index 0544edc1..c8ae92ba 100644 --- a/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java @@ -57,7 +57,7 @@ public class AttributesMapperCallbackHandler extends CollectingNameClassPairC SearchResult searchResult = (SearchResult) nameClassPair; Attributes attributes = searchResult.getAttributes(); try { - return mapper.mapFromAttributes(attributes); + return this.mapper.mapFromAttributes(attributes); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); diff --git a/core/src/main/java/org/springframework/ldap/core/CollectingAuthenticationErrorCallback.java b/core/src/main/java/org/springframework/ldap/core/CollectingAuthenticationErrorCallback.java index c4fbc562..1f73b1f0 100644 --- a/core/src/main/java/org/springframework/ldap/core/CollectingAuthenticationErrorCallback.java +++ b/core/src/main/java/org/springframework/ldap/core/CollectingAuthenticationErrorCallback.java @@ -43,7 +43,7 @@ public final class CollectingAuthenticationErrorCallback implements Authenticati * @return the collected exception */ public Exception getError() { - return error; + return this.error; } /** @@ -52,7 +52,7 @@ public final class CollectingAuthenticationErrorCallback implements Authenticati * otherwise. */ public boolean hasError() { - return error != null; + return this.error != null; } } \ No newline at end of file diff --git a/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java index b6ce8950..f7732812 100644 --- a/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java @@ -35,7 +35,7 @@ public abstract class CollectingNameClassPairCallbackHandler implements NameC * @return the list of all assembled objects. */ public List getList() { - return list; + return this.list; } /** @@ -44,7 +44,7 @@ public abstract class CollectingNameClassPairCallbackHandler implements NameC * internal list. */ public final void handleNameClassPair(NameClassPair nameClassPair) throws NamingException { - list.add(getObjectFromNameClassPair(nameClassPair)); + this.list.add(getObjectFromNameClassPair(nameClassPair)); } /** diff --git a/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java index 089320b4..42993499 100644 --- a/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java @@ -61,7 +61,7 @@ public class ContextMapperCallbackHandler extends CollectingNameClassPairCall if (object == null) { throw new ObjectRetrievalException("Binding did not contain any object."); } - return mapper.mapFromContext(object); + return this.mapper.mapFromContext(object); } } \ No newline at end of file diff --git a/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java b/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java index 55e3dbbf..51c12581 100644 --- a/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java +++ b/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java @@ -279,7 +279,8 @@ class DefaultLdapClient implements LdapClient { DirContext ctx = null; try { String password = (this.password != null) ? new String(this.password) : null; - ctx = contextSource.getContext(identification.get(0).getAbsoluteName().toString(), password); + ctx = DefaultLdapClient.this.contextSource + .getContext(identification.get(0).getAbsoluteName().toString(), password); return mapper.mapWithContext(ctx, identification.get(0)); } finally { @@ -370,13 +371,13 @@ class DefaultLdapClient implements LdapClient { controls.setReturningObjFlag(returnObjFlag); controls.setReturningAttributes(this.query.attributes()); if (this.query.searchScope() != null) { - controls.setSearchScope(query.searchScope().getId()); + controls.setSearchScope(this.query.searchScope().getId()); } if (this.query.countLimit() != null) { - controls.setCountLimit(query.countLimit()); + controls.setCountLimit(this.query.countLimit()); } if (this.query.timeLimit() != null) { - controls.setTimeLimit(query.timeLimit()); + controls.setTimeLimit(this.query.timeLimit()); } return controls; } @@ -574,7 +575,7 @@ class DefaultLdapClient implements LdapClient { return enumeration.hasMore(); } catch (NamingException ex) { - namingExceptionHandler.accept(ex); + DefaultLdapClient.this.namingExceptionHandler.accept(ex); return false; } } @@ -585,7 +586,7 @@ class DefaultLdapClient implements LdapClient { return enumeration.next(); } catch (NamingException ex) { - namingExceptionHandler.accept(ex); + DefaultLdapClient.this.namingExceptionHandler.accept(ex); throw new NoSuchElementException("no such element", ex); } } diff --git a/core/src/main/java/org/springframework/ldap/core/DirContextAdapter.java b/core/src/main/java/org/springframework/ldap/core/DirContextAdapter.java index 50f2af17..dba07083 100644 --- a/core/src/main/java/org/springframework/ldap/core/DirContextAdapter.java +++ b/core/src/main/java/org/springframework/ldap/core/DirContextAdapter.java @@ -214,8 +214,8 @@ public class DirContextAdapter implements DirContextOperations { */ public void setUpdateMode(boolean mode) { this.updateMode = mode; - if (updateMode) { - updatedAttrs = new NameAwareAttributes(); + if (this.updateMode) { + this.updatedAttrs = new NameAwareAttributes(); } } @@ -224,7 +224,7 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public boolean isUpdateMode() { - return updateMode; + return this.updateMode; } /** @@ -237,10 +237,10 @@ public class DirContextAdapter implements DirContextOperations { NamingEnumeration attributesEnumeration; if (isUpdateMode()) { - attributesEnumeration = updatedAttrs.getAll(); + attributesEnumeration = this.updatedAttrs.getAll(); } else { - attributesEnumeration = originalAttrs.getAll(); + attributesEnumeration = this.originalAttrs.getAll(); } try { @@ -275,14 +275,14 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public ModificationItem[] getModificationItems() { - if (!updateMode) { + if (!this.updateMode) { return new ModificationItem[0]; } List tmpList = new LinkedList(); NamingEnumeration attributesEnumeration = null; try { - attributesEnumeration = updatedAttrs.getAll(); + attributesEnumeration = this.updatedAttrs.getAll(); // find attributes that have been changed, removed or added while (attributesEnumeration.hasMore()) { @@ -319,7 +319,7 @@ public class DirContextAdapter implements DirContextOperations { */ private void collectModifications(NameAwareAttribute changedAttr, List modificationList) throws NamingException { - NameAwareAttribute currentAttribute = originalAttrs.get(changedAttr.getID()); + NameAwareAttribute currentAttribute = this.originalAttrs.get(changedAttr.getID()); if (currentAttribute != null && changedAttr.hasValuesAsNames()) { try { currentAttribute.initValuesAsNames(); @@ -431,8 +431,8 @@ public class DirContextAdapter implements DirContextOperations { */ private boolean isChanged(String name, Object[] values, boolean orderMatters) { - NameAwareAttribute orig = originalAttrs.get(name); - NameAwareAttribute prev = updatedAttrs.get(name); + NameAwareAttribute orig = this.originalAttrs.get(name); + NameAwareAttribute prev = this.updatedAttrs.get(name); // values == null and values.length == 0 is treated the same way boolean emptyNewValue = (values == null || values.length == 0); @@ -522,7 +522,7 @@ public class DirContextAdapter implements DirContextOperations { * @return true if the attribute exists in the entry. */ protected final boolean exists(String attrId) { - return originalAttrs.get(attrId) != null; + return this.originalAttrs.get(attrId) != null; } /** @@ -538,7 +538,7 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public Object getObjectAttribute(String name) { - Attribute oneAttr = originalAttrs.get(name); + Attribute oneAttr = this.originalAttrs.get(name); if (oneAttr == null || oneAttr.size() == 0) { // LDAP-215 return null; } @@ -556,7 +556,7 @@ public class DirContextAdapter implements DirContextOperations { @Override // LDAP-215 public boolean attributeExists(String name) { - Attribute oneAttr = originalAttrs.get(name); + Attribute oneAttr = this.originalAttrs.get(name); return oneAttr != null; } @@ -566,17 +566,17 @@ public class DirContextAdapter implements DirContextOperations { @Override public void setAttributeValue(String name, Object value) { // new entry - if (!updateMode && value != null) { - originalAttrs.put(name, value); + if (!this.updateMode && value != null) { + this.originalAttrs.put(name, value); } // updating entry - if (updateMode) { + if (this.updateMode) { Attribute attribute = new NameAwareAttribute(name); if (value != null) { attribute.add(value); } - updatedAttrs.put(attribute); + this.updatedAttrs.put(attribute); } } @@ -593,31 +593,31 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public void addAttributeValue(String name, Object value, boolean addIfDuplicateExists) { - if (!updateMode && value != null) { - Attribute attr = originalAttrs.get(name); + if (!this.updateMode && value != null) { + Attribute attr = this.originalAttrs.get(name); if (attr == null) { - originalAttrs.put(name, value); + this.originalAttrs.put(name, value); } else { attr.add(value); } } - else if (updateMode) { - Attribute attr = updatedAttrs.get(name); + else if (this.updateMode) { + Attribute attr = this.updatedAttrs.get(name); if (attr == null) { - if (originalAttrs.get(name) == null) { + if (this.originalAttrs.get(name) == null) { // No match in the original attributes - // add a new Attribute to updatedAttrs - updatedAttrs.put(name, value); + this.updatedAttrs.put(name, value); } else { // The attribute exists in the original attributes - clone // that and add the new entry to it - attr = (Attribute) originalAttrs.get(name).clone(); + attr = (Attribute) this.originalAttrs.get(name).clone(); if (addIfDuplicateExists || !attr.contains(value)) { attr.add(value); } - updatedAttrs.put(attr); + this.updatedAttrs.put(attr); } } else { @@ -631,22 +631,22 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public void removeAttributeValue(String name, Object value) { - if (!updateMode && value != null) { - Attribute attr = originalAttrs.get(name); + if (!this.updateMode && value != null) { + Attribute attr = this.originalAttrs.get(name); if (attr != null) { attr.remove(value); if (attr.size() == 0) { - originalAttrs.remove(name); + this.originalAttrs.remove(name); } } } - else if (updateMode) { - Attribute attr = updatedAttrs.get(name); + else if (this.updateMode) { + Attribute attr = this.updatedAttrs.get(name); if (attr == null) { - if (originalAttrs.get(name) != null) { - attr = (Attribute) originalAttrs.get(name).clone(); + if (this.originalAttrs.get(name) != null) { + attr = (Attribute) this.originalAttrs.get(name).clone(); attr.remove(value); - updatedAttrs.put(attr); + this.updatedAttrs.put(attr); } } else { @@ -675,14 +675,14 @@ public class DirContextAdapter implements DirContextOperations { } // only change the original attribute if not in update mode - if (!updateMode && values != null && values.length > 0) { + if (!this.updateMode && values != null && values.length > 0) { // don't save empty arrays - originalAttrs.put(a); + this.originalAttrs.put(a); } // possible to set an already existing attribute to an empty array - if (updateMode && isChanged(name, values, orderMatters)) { - updatedAttrs.put(a); + if (this.updateMode && isChanged(name, values, orderMatters)) { + this.updatedAttrs.put(a); } } @@ -694,7 +694,7 @@ public class DirContextAdapter implements DirContextOperations { NamingEnumeration attributesEnumeration = null; try { - attributesEnumeration = updatedAttrs.getAll(); + attributesEnumeration = this.updatedAttrs.getAll(); // find what to update while (attributesEnumeration.hasMore()) { @@ -702,11 +702,11 @@ public class DirContextAdapter implements DirContextOperations { // if it does not exist it should be added if (isEmptyAttribute(a)) { - originalAttrs.remove(a.getID()); + this.originalAttrs.remove(a.getID()); } else { // Otherwise it should be set. - originalAttrs.put(a); + this.originalAttrs.put(a); } } } @@ -718,7 +718,7 @@ public class DirContextAdapter implements DirContextOperations { } // Reset the attributes to be updated - updatedAttrs = new NameAwareAttributes(); + this.updatedAttrs = new NameAwareAttributes(); } /** @@ -753,7 +753,7 @@ public class DirContextAdapter implements DirContextOperations { private List collectAttributeValuesAsList(String name, Class clazz) { List list = new LinkedList(); - LdapUtils.collectAttributeValues(originalAttrs, name, list, clazz); + LdapUtils.collectAttributeValues(this.originalAttrs, name, list, clazz); return list; } @@ -764,7 +764,7 @@ public class DirContextAdapter implements DirContextOperations { public SortedSet getAttributeSortedStringSet(String name) { try { TreeSet attrSet = new TreeSet(); - LdapUtils.collectAttributeValues(originalAttrs, name, attrSet, String.class); + LdapUtils.collectAttributeValues(this.originalAttrs, name, attrSet, String.class); return attrSet; } catch (NoSuchAttributeException e) { @@ -778,11 +778,11 @@ public class DirContextAdapter implements DirContextOperations { * @param attribute the attribute to set. */ public void setAttribute(Attribute attribute) { - if (!updateMode) { - originalAttrs.put(attribute); + if (!this.updateMode) { + this.originalAttrs.put(attribute); } else { - updatedAttrs.put(attribute); + this.updatedAttrs.put(attribute); } } @@ -791,7 +791,7 @@ public class DirContextAdapter implements DirContextOperations { * @return all attributes. */ public Attributes getAttributes() { - return originalAttrs; + return this.originalAttrs; } /** @@ -810,7 +810,7 @@ public class DirContextAdapter implements DirContextOperations { if (StringUtils.hasLength(name)) { throw new NameNotFoundException(); } - return (Attributes) originalAttrs.clone(); + return (Attributes) this.originalAttrs.clone(); } /** @@ -833,7 +833,7 @@ public class DirContextAdapter implements DirContextOperations { Attributes a = new NameAwareAttributes(); Attribute target; for (String attrId : attrIds) { - target = originalAttrs.get(attrId); + target = this.originalAttrs.get(attrId); if (target != null) { a.put(target); } @@ -1253,13 +1253,13 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public String getNameInNamespace() { - if (base.size() == 0) { - return dn.toString(); + if (this.base.size() == 0) { + return this.dn.toString(); } try { - LdapName result = (LdapName) dn.clone(); - result.addAll(0, base); + LdapName result = (LdapName) this.dn.clone(); + result.addAll(0, this.base); return result.toString(); } catch (InvalidNameException e) { @@ -1272,7 +1272,7 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public Name getDn() { - return LdapUtils.newLdapName(dn); + return LdapUtils.newLdapName(this.dn); } /** @@ -1280,7 +1280,7 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public final void setDn(Name dn) { - if (!updateMode) { + if (!this.updateMode) { this.dn = LdapUtils.newLdapName(dn); } else { @@ -1301,17 +1301,17 @@ public class DirContextAdapter implements DirContextOperations { DirContextAdapter that = (DirContextAdapter) o; - if (updateMode != that.updateMode) + if (this.updateMode != that.updateMode) return false; - if (base != null ? !base.equals(that.base) : that.base != null) + if (this.base != null ? !this.base.equals(that.base) : that.base != null) return false; - if (dn != null ? !dn.equals(that.dn) : that.dn != null) + if (this.dn != null ? !this.dn.equals(that.dn) : that.dn != null) return false; - if (originalAttrs != null ? !originalAttrs.equals(that.originalAttrs) : that.originalAttrs != null) + if (this.originalAttrs != null ? !this.originalAttrs.equals(that.originalAttrs) : that.originalAttrs != null) return false; - if (referralUrl != null ? !referralUrl.equals(that.referralUrl) : that.referralUrl != null) + if (this.referralUrl != null ? !this.referralUrl.equals(that.referralUrl) : that.referralUrl != null) return false; - if (updatedAttrs != null ? !updatedAttrs.equals(that.updatedAttrs) : that.updatedAttrs != null) + if (this.updatedAttrs != null ? !this.updatedAttrs.equals(that.updatedAttrs) : that.updatedAttrs != null) return false; return true; @@ -1322,12 +1322,12 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public int hashCode() { - int result = originalAttrs != null ? originalAttrs.hashCode() : 0; - result = 31 * result + (dn != null ? dn.hashCode() : 0); - result = 31 * result + (base != null ? base.hashCode() : 0); - result = 31 * result + (updateMode ? 1 : 0); - result = 31 * result + (updatedAttrs != null ? updatedAttrs.hashCode() : 0); - result = 31 * result + (referralUrl != null ? referralUrl.hashCode() : 0); + int result = this.originalAttrs != null ? this.originalAttrs.hashCode() : 0; + result = 31 * result + (this.dn != null ? this.dn.hashCode() : 0); + result = 31 * result + (this.base != null ? this.base.hashCode() : 0); + result = 31 * result + (this.updateMode ? 1 : 0); + result = 31 * result + (this.updatedAttrs != null ? this.updatedAttrs.hashCode() : 0); + result = 31 * result + (this.referralUrl != null ? this.referralUrl.hashCode() : 0); return result; } @@ -1339,13 +1339,13 @@ public class DirContextAdapter implements DirContextOperations { StringBuilder builder = new StringBuilder(); builder.append(getClass().getName()); builder.append(":"); - if (dn != null) { - builder.append(" dn=").append(dn); + if (this.dn != null) { + builder.append(" dn=").append(this.dn); } builder.append(" {"); try { - for (NamingEnumeration i = originalAttrs.getAll(); i.hasMore();) { + for (NamingEnumeration i = this.originalAttrs.getAll(); i.hasMore();) { Attribute attribute = i.next(); if (attribute.size() == 1) { builder.append(attribute.getID()); @@ -1390,7 +1390,7 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public String getReferralUrl() { - return referralUrl; + return this.referralUrl; } /** @@ -1398,7 +1398,7 @@ public class DirContextAdapter implements DirContextOperations { */ @Override public boolean isReferral() { - return StringUtils.hasLength(referralUrl); + return StringUtils.hasLength(this.referralUrl); } } diff --git a/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java b/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java index 9c52fd35..6d48a88f 100644 --- a/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java +++ b/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java @@ -164,7 +164,7 @@ public class DistinguishedName implements Name { * Construct a new DistinguishedName with no components. */ public DistinguishedName() { - names = new LinkedList(); + this.names = new LinkedList(); } /** @@ -173,7 +173,7 @@ public class DistinguishedName implements Name { */ public DistinguishedName(String path) { if (!StringUtils.hasText(path)) { - names = new LinkedList(); + this.names = new LinkedList(); } else { parse(path); @@ -201,9 +201,9 @@ public class DistinguishedName implements Name { parse(LdapUtils.convertCompositeNameToString((CompositeName) name)); return; } - names = new LinkedList(); + this.names = new LinkedList(); for (int i = 0; i < name.size(); i++) { - names.add(new LdapRdn(name.get(i))); + this.names.add(new LdapRdn(name.get(i))); } } @@ -221,7 +221,7 @@ public class DistinguishedName implements Name { catch (ParseException e) { throw new BadLdapGrammarException("Failed to parse DN", e); } - catch (TokenMgrError e) { + catch (org.springframework.ldap.core.TokenMgrError e) { throw new BadLdapGrammarException("Failed to parse DN", e); } this.names = dn.names; @@ -254,7 +254,7 @@ public class DistinguishedName implements Name { * @return the {@link LdapRdn} at the requested position. */ public LdapRdn getLdapRdn(int index) { - return (LdapRdn) names.get(index); + return (LdapRdn) this.names.get(index); } /** @@ -265,7 +265,7 @@ public class DistinguishedName implements Name { * @throws IllegalArgumentException if no Rdn matches the given key. */ public LdapRdn getLdapRdn(String key) { - for (Iterator iter = names.iterator(); iter.hasNext();) { + for (Iterator iter = this.names.iterator(); iter.hasNext();) { LdapRdn rdn = (LdapRdn) iter.next(); if (ObjectUtils.nullSafeEquals(rdn.getKey(), key)) { return rdn; @@ -293,7 +293,7 @@ public class DistinguishedName implements Name { * consists of. */ public List getNames() { - return names; + return this.names; } /** @@ -337,13 +337,13 @@ public class DistinguishedName implements Name { private String format(boolean compact) { // empty path - if (names.size() == 0) { + if (this.names.size() == 0) { return ""; } StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE); - ListIterator i = names.listIterator(names.size()); + ListIterator i = this.names.listIterator(this.names.size()); while (i.hasPrevious()) { LdapRdn rdn = (LdapRdn) i.previous(); buffer.append(rdn.getLdapEncoded()); @@ -370,8 +370,8 @@ public class DistinguishedName implements Name { public String toUrl() { StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE); - for (int i = names.size() - 1; i >= 0; i--) { - LdapRdn n = (LdapRdn) names.get(i); + for (int i = this.names.size() - 1; i >= 0; i--) { + LdapRdn n = (LdapRdn) this.names.get(i); buffer.append(n.encodeUrl()); if (i > 0) { buffer.append(","); @@ -474,7 +474,7 @@ public class DistinguishedName implements Name { public void prepend(DistinguishedName path) { ListIterator i = path.getNames().listIterator(path.getNames().size()); while (i.hasPrevious()) { - names.add(0, i.previous()); + this.names.add(0, i.previous()); } } @@ -483,7 +483,7 @@ public class DistinguishedName implements Name { * @return the removed entry. */ public LdapRdn removeFirst() { - return (LdapRdn) names.remove(0); + return (LdapRdn) this.names.remove(0); } /** @@ -506,7 +506,7 @@ public class DistinguishedName implements Name { public Object clone() { try { DistinguishedName result = (DistinguishedName) super.clone(); - result.names = new LinkedList(names); + result.names = new LinkedList(this.names); return result; } catch (CloneNotSupportedException e) { @@ -552,11 +552,11 @@ public class DistinguishedName implements Name { } public int size() { - return names.size(); + return this.names.size(); } public boolean isEmpty() { - return names.size() == 0; + return this.names.size() == 0; } /* @@ -566,7 +566,7 @@ public class DistinguishedName implements Name { */ public Enumeration getAll() { LinkedList strings = new LinkedList(); - for (Iterator iter = names.iterator(); iter.hasNext();) { + for (Iterator iter = this.names.iterator(); iter.hasNext();) { LdapRdn rdn = (LdapRdn) iter.next(); strings.add(rdn.getLdapEncoded()); } @@ -580,7 +580,7 @@ public class DistinguishedName implements Name { * @see javax.naming.Name#get(int) */ public String get(int index) { - LdapRdn rdn = (LdapRdn) names.get(index); + LdapRdn rdn = (LdapRdn) this.names.get(index); return rdn.getLdapEncoded(); } @@ -592,7 +592,7 @@ public class DistinguishedName implements Name { public Name getPrefix(int index) { LinkedList newNames = new LinkedList(); for (int i = 0; i < index; i++) { - newNames.add(names.get(i)); + newNames.add(this.names.get(i)); } return new DistinguishedName(newNames); @@ -604,13 +604,13 @@ public class DistinguishedName implements Name { * @see javax.naming.Name#getSuffix(int) */ public Name getSuffix(int index) { - if (index > names.size()) { + if (index > this.names.size()) { throw new ArrayIndexOutOfBoundsException(); } LinkedList newNames = new LinkedList(); - for (int i = index; i < names.size(); i++) { - newNames.add(names.get(i)); + for (int i = index; i < this.names.size(); i++) { + newNames.add(this.names.get(i)); } return new DistinguishedName(newNames); @@ -638,7 +638,7 @@ public class DistinguishedName implements Name { return false; } - Iterator longiter = names.iterator(); + Iterator longiter = this.names.iterator(); Iterator shortiter = start.getNames().iterator(); while (shortiter.hasNext()) { @@ -705,7 +705,7 @@ public class DistinguishedName implements Name { * @see javax.naming.Name#addAll(javax.naming.Name) */ public Name addAll(Name name) throws InvalidNameException { - return addAll(names.size(), name); + return addAll(this.names.size(), name); } /* @@ -722,7 +722,7 @@ public class DistinguishedName implements Name { throw new InvalidNameException("Invalid name type"); } - names.addAll(arg0, distinguishedName.getNames()); + this.names.addAll(arg0, distinguishedName.getNames()); return this; } @@ -732,7 +732,7 @@ public class DistinguishedName implements Name { * @see javax.naming.Name#add(java.lang.String) */ public Name add(String string) throws InvalidNameException { - return add(names.size(), string); + return add(this.names.size(), string); } /* @@ -742,7 +742,7 @@ public class DistinguishedName implements Name { */ public Name add(int index, String string) throws InvalidNameException { try { - names.add(index, new LdapRdn(string)); + this.names.add(index, new LdapRdn(string)); } catch (BadLdapGrammarException e) { throw new InvalidNameException("Failed to parse rdn '" + string + "'"); @@ -756,7 +756,7 @@ public class DistinguishedName implements Name { * @see javax.naming.Name#remove(int) */ public Object remove(int arg0) throws InvalidNameException { - LdapRdn rdn = (LdapRdn) names.remove(arg0); + LdapRdn rdn = (LdapRdn) this.names.remove(arg0); return rdn.getLdapEncoded(); } @@ -765,7 +765,7 @@ public class DistinguishedName implements Name { * @return the removed {@link LdapRdn}. */ public LdapRdn removeLast() { - return (LdapRdn) names.remove(names.size() - 1); + return (LdapRdn) this.names.remove(this.names.size() - 1); } /** @@ -774,7 +774,7 @@ public class DistinguishedName implements Name { * @param value the value of the {@link LdapRdn}. */ public void add(String key, String value) { - names.add(new LdapRdn(key, value)); + this.names.add(new LdapRdn(key, value)); } /** @@ -782,7 +782,7 @@ public class DistinguishedName implements Name { * @param rdn the {@link LdapRdn} to add. */ public void add(LdapRdn rdn) { - names.add(rdn); + this.names.add(rdn); } /** @@ -791,7 +791,7 @@ public class DistinguishedName implements Name { * @param rdn the LdapRdn to add. */ public void add(int idx, LdapRdn rdn) { - names.add(idx, rdn); + this.names.add(idx, rdn); } /** @@ -802,8 +802,8 @@ public class DistinguishedName implements Name { * @since 1.2 */ public DistinguishedName immutableDistinguishedName() { - List listWithImmutableRdns = new ArrayList(names.size()); - for (Iterator iterator = names.iterator(); iterator.hasNext();) { + List listWithImmutableRdns = new ArrayList(this.names.size()); + for (Iterator iterator = this.names.iterator(); iterator.hasNext();) { LdapRdn rdn = (LdapRdn) iterator.next(); listWithImmutableRdns.add(rdn.immutableLdapRdn()); } diff --git a/core/src/main/java/org/springframework/ldap/core/IterableNamingEnumeration.java b/core/src/main/java/org/springframework/ldap/core/IterableNamingEnumeration.java index 6c498084..ac405e97 100644 --- a/core/src/main/java/org/springframework/ldap/core/IterableNamingEnumeration.java +++ b/core/src/main/java/org/springframework/ldap/core/IterableNamingEnumeration.java @@ -17,12 +17,12 @@ final class IterableNamingEnumeration implements NamingEnumeration { @Override public T next() { - return iterator.next(); + return this.iterator.next(); } @Override public boolean hasMore() { - return iterator.hasNext(); + return this.iterator.hasNext(); } @Override diff --git a/core/src/main/java/org/springframework/ldap/core/LdapAttribute.java b/core/src/main/java/org/springframework/ldap/core/LdapAttribute.java index 4bf5952b..8fac5369 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapAttribute.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapAttribute.java @@ -178,7 +178,7 @@ public class LdapAttribute extends BasicAttribute { * @return boolean indicating result. */ public boolean hasOptions() { - return !options.isEmpty(); + return !this.options.isEmpty(); } /** diff --git a/core/src/main/java/org/springframework/ldap/core/LdapAttributes.java b/core/src/main/java/org/springframework/ldap/core/LdapAttributes.java index 04f0cd20..c787c5e6 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapAttributes.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapAttributes.java @@ -96,7 +96,7 @@ public class LdapAttributes extends BasicAttributes { * deprecated as of 2.0}. use {@link #getName()} instead. */ public DistinguishedName getDN() { - return new DistinguishedName(dn); + return new DistinguishedName(this.dn); } /** @@ -104,7 +104,7 @@ public class LdapAttributes extends BasicAttributes { * @return {@link LdapName} specifying the name to which the object is bound. */ public LdapName getName() { - return LdapUtils.newLdapName(dn); + return LdapUtils.newLdapName(this.dn); } /** diff --git a/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java b/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java index dee28642..cef0e7c6 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java @@ -82,7 +82,7 @@ public class LdapEntryIdentification { * @since 2.0 */ public LdapName getAbsoluteName() { - return LdapUtils.newLdapName(absoluteDn); + return LdapUtils.newLdapName(this.absoluteDn); } /** @@ -92,7 +92,7 @@ public class LdapEntryIdentification { * @since 2.0 */ public LdapName getRelativeName() { - return LdapUtils.newLdapName(relativeDn); + return LdapUtils.newLdapName(this.relativeDn); } /** @@ -103,7 +103,7 @@ public class LdapEntryIdentification { * deprecated as of 2.0. use {@link #getRelativeName()} instead. */ public DistinguishedName getRelativeDn() { - return new DistinguishedName(relativeDn); + return new DistinguishedName(this.relativeDn); } /** @@ -114,7 +114,7 @@ public class LdapEntryIdentification { * deprecated as of 2.0. use {@link #getAbsoluteName()} instead. */ public DistinguishedName getAbsoluteDn() { - return new DistinguishedName(absoluteDn); + return new DistinguishedName(this.absoluteDn); } public boolean equals(Object obj) { @@ -127,7 +127,7 @@ public class LdapEntryIdentification { } public int hashCode() { - return absoluteDn.hashCode() ^ relativeDn.hashCode(); + return this.absoluteDn.hashCode() ^ this.relativeDn.hashCode(); } } diff --git a/core/src/main/java/org/springframework/ldap/core/LdapRdn.java b/core/src/main/java/org/springframework/ldap/core/LdapRdn.java index 4991e3d2..29c03194 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapRdn.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapRdn.java @@ -65,7 +65,7 @@ public class LdapRdn implements Serializable, Comparable { catch (ParseException e) { throw new BadLdapGrammarException("Failed to parse Rdn", e); } - catch (TokenMgrError e) { + catch (org.springframework.ldap.core.TokenMgrError e) { throw new BadLdapGrammarException("Failed to parse Rdn", e); } this.components = rdn.components; @@ -77,7 +77,7 @@ public class LdapRdn implements Serializable, Comparable { * @param value the attribute value. */ public LdapRdn(String key, String value) { - components.put(key, new LdapRdnComponent(key, value)); + this.components.put(key, new LdapRdnComponent(key, value)); } /** @@ -85,7 +85,7 @@ public class LdapRdn implements Serializable, Comparable { * @param rdnComponent the LdapRdnComponent to add.s */ public void addComponent(LdapRdnComponent rdnComponent) { - components.put(rdnComponent.getKey(), rdnComponent); + this.components.put(rdnComponent.getKey(), rdnComponent); } /** @@ -93,7 +93,7 @@ public class LdapRdn implements Serializable, Comparable { * @return the List of all LdapRdnComponents composing this LdapRdn. */ public List getComponents() { - return new ArrayList(components.values()); + return new ArrayList(this.components.values()); } /** @@ -102,11 +102,11 @@ public class LdapRdn implements Serializable, Comparable { * @throws IndexOutOfBoundsException if there are no components in this Rdn. */ public LdapRdnComponent getComponent() { - if (components.size() == 0) { + if (this.components.size() == 0) { throw new IndexOutOfBoundsException("No components"); } - return components.values().iterator().next(); + return this.components.values().iterator().next(); } /** @@ -116,11 +116,11 @@ public class LdapRdn implements Serializable, Comparable { * @throws IndexOutOfBoundsException if there are no components in this Rdn. */ public LdapRdnComponent getComponent(int idx) { - if (idx >= components.size()) { + if (idx >= this.components.size()) { throw new IndexOutOfBoundsException(); } - return (LdapRdnComponent) new ArrayList(components.values()).get(idx); + return (LdapRdnComponent) new ArrayList(this.components.values()).get(idx); } /** @@ -129,11 +129,11 @@ public class LdapRdn implements Serializable, Comparable { * @throws IndexOutOfBoundsException if there are no components in this Rdn. */ public String getLdapEncoded() { - if (components.size() == 0) { + if (this.components.size() == 0) { throw new IndexOutOfBoundsException("No components in Rdn."); } StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE); - for (Iterator iter = components.values().iterator(); iter.hasNext();) { + for (Iterator iter = this.components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); sb.append(component.encodeLdap()); if (iter.hasNext()) { @@ -150,7 +150,7 @@ public class LdapRdn implements Serializable, Comparable { */ public String encodeUrl() { StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE); - for (Iterator iter = components.values().iterator(); iter.hasNext();) { + for (Iterator iter = this.components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); sb.append(component.encodeUrl()); if (iter.hasNext()) { @@ -262,7 +262,7 @@ public class LdapRdn implements Serializable, Comparable { * @throws IllegalArgumentException if there is no component with the specified key. */ public String getValue(String key) { - for (Iterator iter = components.values().iterator(); iter.hasNext();) { + for (Iterator iter = this.components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); if (ObjectUtils.nullSafeEquals(component.getKey(), key)) { return component.getValue(); @@ -280,8 +280,8 @@ public class LdapRdn implements Serializable, Comparable { */ public LdapRdn immutableLdapRdn() { Map mapWithImmutableRdns = new LinkedHashMap( - components.size()); - for (Iterator iterator = components.values().iterator(); iterator.hasNext();) { + this.components.size()); + for (Iterator iterator = this.components.values().iterator(); iterator.hasNext();) { LdapRdnComponent rdnComponent = (LdapRdnComponent) iterator.next(); mapWithImmutableRdns.put(rdnComponent.getKey(), rdnComponent.immutableLdapRdnComponent()); } diff --git a/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java b/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java index c649fc18..01fd4674 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java @@ -100,7 +100,7 @@ public class LdapRdnComponent implements Comparable, Serializable { * @return the key. */ public String getKey() { - return key; + return this.key; } /** @@ -119,7 +119,7 @@ public class LdapRdnComponent implements Comparable, Serializable { * @return the value. */ public String getValue() { - return value; + return this.value; } /** @@ -138,11 +138,11 @@ public class LdapRdnComponent implements Comparable, Serializable { * @return Properly ldap escaped rdn. */ protected String encodeLdap() { - StringBuffer buff = new StringBuffer(key.length() + value.length() * 2); + StringBuffer buff = new StringBuffer(this.key.length() + this.value.length() * 2); - buff.append(key); + buff.append(this.key); buff.append('='); - buff.append(LdapEncoder.nameEncode(value)); + buff.append(LdapEncoder.nameEncode(this.value)); return buff.toString(); } @@ -170,12 +170,12 @@ public class LdapRdnComponent implements Comparable, Serializable { public String encodeUrl() { // Use the URI class to properly URL encode the value. try { - URI valueUri = new URI(null, null, value, null); - return key + "=" + valueUri.toString(); + URI valueUri = new URI(null, null, this.value, null); + return this.key + "=" + valueUri.toString(); } catch (URISyntaxException e) { // This should really never happen... - return key + "=" + "value"; + return this.key + "=" + "value"; } } @@ -185,7 +185,7 @@ public class LdapRdnComponent implements Comparable, Serializable { * @see java.lang.Object#hashCode() */ public int hashCode() { - return key.toUpperCase().hashCode() ^ value.toUpperCase().hashCode(); + return this.key.toUpperCase().hashCode() ^ this.value.toUpperCase().hashCode(); } /* @@ -235,7 +235,7 @@ public class LdapRdnComponent implements Comparable, Serializable { * @since 1.3 */ public LdapRdnComponent immutableLdapRdnComponent() { - return new ImmutableLdapRdnComponent(key, value); + return new ImmutableLdapRdnComponent(this.key, this.value); } private static class ImmutableLdapRdnComponent extends LdapRdnComponent { diff --git a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java index e79303f8..f7b586cf 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java @@ -127,7 +127,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public ObjectDirectoryMapper getObjectDirectoryMapper() { - return odm; + return this.odm; } /** @@ -144,7 +144,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * @return the ContextSource. */ public ContextSource getContextSource() { - return contextSource; + return this.contextSource; } /** @@ -342,7 +342,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public void search(SearchExecutor se, NameClassPairCallbackHandler handler, DirContextProcessor processor) { - DirContext ctx = contextSource.getReadOnlyContext(); + DirContext ctx = this.contextSource.getReadOnlyContext(); NamingEnumeration results = null; RuntimeException ex = null; @@ -357,7 +357,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } catch (NameNotFoundException e) { // It is possible to ignore errors caused by base not found - if (ignoreNameNotFoundException) { + if (this.ignoreNameNotFoundException) { LOG.warn("Base context not found, ignoring: " + e.getMessage()); } else { @@ -366,7 +366,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } catch (PartialResultException e) { // Workaround for AD servers not handling referrals correctly. - if (ignorePartialResultException) { + if (this.ignorePartialResultException) { LOG.debug("PartialResultException encountered and ignored", e); } else { @@ -374,7 +374,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } } catch (SizeLimitExceededException e) { - if (ignoreSizeLimitExceededException) { + if (this.ignoreSizeLimitExceededException) { LOG.debug("SizeLimitExceededException encountered and ignored", e); } else { @@ -432,7 +432,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { @Override public void search(Name base, String filter, NameClassPairCallbackHandler handler) { - SearchControls controls = getDefaultSearchControls(defaultSearchScope, DONT_RETURN_OBJ_FLAG, ALL_ATTRIBUTES); + SearchControls controls = getDefaultSearchControls(this.defaultSearchScope, DONT_RETURN_OBJ_FLAG, + ALL_ATTRIBUTES); if (handler instanceof ContextMapperCallbackHandler) { assureReturnObjFlagSet(controls); } @@ -445,7 +446,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { @Override public void search(String base, String filter, NameClassPairCallbackHandler handler) { - SearchControls controls = getDefaultSearchControls(defaultSearchScope, DONT_RETURN_OBJ_FLAG, ALL_ATTRIBUTES); + SearchControls controls = getDefaultSearchControls(this.defaultSearchScope, DONT_RETURN_OBJ_FLAG, + ALL_ATTRIBUTES); if (handler instanceof ContextMapperCallbackHandler) { assureReturnObjFlagSet(controls); } @@ -489,7 +491,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public List search(Name base, String filter, AttributesMapper mapper) { - return search(base, filter, defaultSearchScope, mapper); + return search(base, filter, this.defaultSearchScope, mapper); } /** @@ -497,7 +499,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public List search(String base, String filter, AttributesMapper mapper) { - return search(base, filter, defaultSearchScope, mapper); + return search(base, filter, this.defaultSearchScope, mapper); } /** @@ -537,7 +539,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public List search(Name base, String filter, ContextMapper mapper) { - return search(base, filter, defaultSearchScope, mapper); + return search(base, filter, this.defaultSearchScope, mapper); } /** @@ -545,7 +547,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public List search(String base, String filter, ContextMapper mapper) { - return search(base, filter, defaultSearchScope, mapper); + return search(base, filter, this.defaultSearchScope, mapper); } /** @@ -789,7 +791,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public T executeReadOnly(ContextExecutor ce) { - DirContext ctx = contextSource.getReadOnlyContext(); + DirContext ctx = this.contextSource.getReadOnlyContext(); return executeWithContext(ce, ctx); } @@ -798,7 +800,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public T executeReadWrite(ContextExecutor ce) { - DirContext ctx = contextSource.getReadWriteContext(); + DirContext ctx = this.contextSource.getReadWriteContext(); return executeWithContext(ce, ctx); } @@ -1168,7 +1170,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public void afterPropertiesSet() throws Exception { - Assert.notNull(contextSource, "Property 'contextSource' must be set."); + Assert.notNull(this.contextSource, "Property 'contextSource' must be set."); } private void closeContextAndNamingEnumeration(DirContext ctx, NamingEnumeration results) { @@ -1212,8 +1214,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { private SearchControls getDefaultSearchControls(int searchScope, boolean returningObjFlag, String[] attrs) { SearchControls controls = new SearchControls(); controls.setSearchScope(searchScope); - controls.setTimeLimit(defaultTimeLimit); - controls.setCountLimit(defaultCountLimit); + controls.setTimeLimit(this.defaultTimeLimit); + controls.setCountLimit(this.defaultCountLimit); controls.setReturningObjFlag(returningObjFlag); controls.setReturningAttributes(attrs); return controls; @@ -1271,7 +1273,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ public T getObjectFromNameClassPair(NameClassPair nameClassPair) { try { - return mapper.mapFromNameClassPair(nameClassPair); + return this.mapper.mapFromNameClassPair(nameClassPair); } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); @@ -1410,8 +1412,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { public boolean authenticate(Name base, String filter, String password, final AuthenticatedLdapEntryContextCallback callback, final AuthenticationErrorCallback errorCallback) { - return authenticate(base, filter, password, getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, null), - callback, errorCallback).isSuccess(); + return authenticate(base, filter, password, + getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, null), callback, errorCallback) + .isSuccess(); } private AuthenticationStatus authenticate(Name base, String filter, String password, SearchControls searchControls, @@ -1432,7 +1435,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { final LdapEntryIdentification entryIdentification = result.get(0); try { - DirContext ctx = contextSource.getContext(entryIdentification.getAbsoluteName().toString(), password); + DirContext ctx = this.contextSource.getContext(entryIdentification.getAbsoluteName().toString(), password); executeWithContext(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { callback.executeWithContext(ctx, entryIdentification); @@ -1495,7 +1498,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { @Override public T searchForObject(Name base, String filter, ContextMapper mapper) { return searchForObject(base, filter, - getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), mapper); + getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), mapper); } /** @@ -1569,7 +1572,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { - collectedObject = mapper.mapWithContext(ctx, ldapEntryIdentification); + this.collectedObject = this.mapper.mapWithContext(ctx, ldapEntryIdentification); } } @@ -1595,7 +1598,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } private SearchControls searchControlsForQuery(LdapQuery query, boolean returnObjFlag) { - SearchControls searchControls = getDefaultSearchControls(defaultSearchScope, returnObjFlag, query.attributes()); + SearchControls searchControls = getDefaultSearchControls(this.defaultSearchScope, returnObjFlag, + query.attributes()); if (query.searchScope() != null) { searchControls.setSearchScope(query.searchScope().getId()); @@ -1673,7 +1677,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { Name base = query.base(); Filter filter = query.filter(); SearchControls searchControls = searchControlsForQuery(query, RETURN_OBJ_FLAG); - DirContext ctx = contextSource.getReadOnlyContext(); + DirContext ctx = this.contextSource.getReadOnlyContext(); String encodedFilter = filter.encode(); if (LOG.isDebugEnabled()) { @@ -1704,12 +1708,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } // Make sure the class is OK before doing the lookup - String[] attributes = odm.manageClass(clazz); + String[] attributes = this.odm.manageClass(clazz); T result = lookup(dn, attributes, new ContextMapper() { @Override public T mapFromContext(Object ctx) throws javax.naming.NamingException { - return odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz); + return LdapTemplate.this.odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz); } }); @@ -1734,16 +1738,16 @@ public class LdapTemplate implements LdapOperations, InitializingBean { LOG.debug(String.format("Creating entry - %1$s", entry)); } - Name id = odm.getId(entry); + Name id = this.odm.getId(entry); if (id == null) { - id = odm.getCalculatedId(entry); - odm.setId(entry, id); + id = this.odm.getCalculatedId(entry); + this.odm.setId(entry, id); } Assert.notNull(id, String.format("Unable to determine id for entry %s", entry.toString())); DirContextAdapter context = new DirContextAdapter(id); - odm.mapToLdapDataEntry(entry, context); + this.odm.mapToLdapDataEntry(entry, context); bind(context); } @@ -1758,8 +1762,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { LOG.debug(String.format("Updating entry - %1$s", entry)); } - Name originalId = odm.getId(entry); - Name calculatedId = odm.getCalculatedId(entry); + Name originalId = this.odm.getId(entry); + Name calculatedId = this.odm.getCalculatedId(entry); if (originalId != null && calculatedId != null && !originalId.equals(calculatedId)) { // The DN has changed - remove the original entry and bind the new one @@ -1773,10 +1777,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean { unbind(originalId); DirContextAdapter context = new DirContextAdapter(calculatedId); - odm.mapToLdapDataEntry(entry, context); + this.odm.mapToLdapDataEntry(entry, context); bind(context); - odm.setId(entry, calculatedId); + this.odm.setId(entry, calculatedId); } else { // DN is the same, just modify the attributes @@ -1784,13 +1788,13 @@ public class LdapTemplate implements LdapOperations, InitializingBean { Name id = originalId; if (id == null) { id = calculatedId; - odm.setId(entry, calculatedId); + this.odm.setId(entry, calculatedId); } Assert.notNull(id, String.format("Unable to determine id for entry %s", entry.toString())); DirContextOperations context = lookupContext(id); - odm.mapToLdapDataEntry(entry, context); + this.odm.mapToLdapDataEntry(entry, context); modifyAttributes(context); } } @@ -1805,9 +1809,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { LOG.debug(String.format("Deleting %1$s", entry)); } - Name id = odm.getId(entry); + Name id = this.odm.getId(entry); if (id == null) { - id = odm.getCalculatedId(entry); + id = this.odm.getCalculatedId(entry); } Assert.notNull(id, String.format("Unable to determine id for entry %s", entry.toString())); @@ -1828,7 +1832,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { @Override public List findAll(Class clazz) { return findAll(LdapUtils.emptyLdapName(), - getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), clazz); + getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), clazz); } /** @@ -1836,7 +1840,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ @Override public List find(Name base, Filter filter, SearchControls searchControls, final Class clazz) { - Filter finalFilter = odm.filterFor(clazz, filter); + Filter finalFilter = this.odm.filterFor(clazz, filter); // Search from the root if we are not told where to search from Name localBase = base; @@ -1858,7 +1862,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { List result = search(localBase, finalFilter.encode(), searchControls, new ContextMapper() { @Override public T mapFromContext(Object ctx) throws javax.naming.NamingException { - return odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz); + return LdapTemplate.this.odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz); } }); result.remove(null); @@ -1903,11 +1907,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean { public Stream findForStream(LdapQuery query, Class clazz) { LdapQueryBuilder builder = LdapQueryBuilder.fromQuery(query); if (query.attributes() == null) { - String[] attributes = odm.manageClass(clazz); + String[] attributes = this.odm.manageClass(clazz); builder.attributes(attributes); } - Filter includeClass = odm.filterFor(clazz, query.filter()); - ContextMapper contextMapper = (object) -> odm.mapFromLdapDataEntry((DirContextOperations) object, clazz); + Filter includeClass = this.odm.filterFor(clazz, query.filter()); + ContextMapper contextMapper = (object) -> this.odm.mapFromLdapDataEntry((DirContextOperations) object, + clazz); return searchForStream(builder.filter(includeClass), contextMapper); } @@ -1917,20 +1922,20 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } catch (NameNotFoundException e) { // It is possible to ignore errors caused by base not found - if (!ignoreNameNotFoundException) { + if (!this.ignoreNameNotFoundException) { throw LdapUtils.convertLdapException(e); } LOG.warn("Base context not found, ignoring: " + e.getMessage()); } catch (PartialResultException e) { // Workaround for AD servers not handling referrals correctly. - if (!ignorePartialResultException) { + if (!this.ignorePartialResultException) { throw LdapUtils.convertLdapException(e); } LOG.debug("PartialResultException encountered and ignored", e); } catch (SizeLimitExceededException e) { - if (!ignoreSizeLimitExceededException) { + if (!this.ignoreSizeLimitExceededException) { throw LdapUtils.convertLdapException(e); } LOG.debug("SizeLimitExceededException encountered and ignored", e); @@ -1978,7 +1983,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * @return */ public boolean isSuccess() { - return success; + return this.success; } } diff --git a/core/src/main/java/org/springframework/ldap/core/NameAwareAttribute.java b/core/src/main/java/org/springframework/ldap/core/NameAwareAttribute.java index a6eb829c..6a93c822 100644 --- a/core/src/main/java/org/springframework/ldap/core/NameAwareAttribute.java +++ b/core/src/main/java/org/springframework/ldap/core/NameAwareAttribute.java @@ -57,7 +57,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { */ public NameAwareAttribute(String id, Object value) { this(id); - values.add(value); + this.values.add(value); } /** @@ -103,31 +103,31 @@ public final class NameAwareAttribute implements Attribute, Iterable { @Override public NamingEnumeration getAll() { - return new IterableNamingEnumeration(values); + return new IterableNamingEnumeration(this.values); } @Override public Object get() { - if (values.isEmpty()) { + if (this.values.isEmpty()) { return null; } - return values.iterator().next(); + return this.values.iterator().next(); } @Override public int size() { - return values.size(); + return this.values.size(); } @Override public String getID() { - return id; + return this.id; } @Override public boolean contains(Object attrVal) { - return values.contains(attrVal); + return this.values.contains(attrVal); } @Override @@ -136,24 +136,24 @@ public final class NameAwareAttribute implements Attribute, Iterable { initValuesAsNames(); Name name = LdapUtils.newLdapName((Name) attrVal); - String currentValue = valuesAsNames.get(name); + String currentValue = this.valuesAsNames.get(name); String nameAsString = name.toString(); if (currentValue == null) { - valuesAsNames.put(name, name.toString()); - values.add(nameAsString); + this.valuesAsNames.put(name, name.toString()); + this.values.add(nameAsString); return true; } else { if (!currentValue.equals(nameAsString)) { - values.remove(currentValue); - values.add(nameAsString); + this.values.remove(currentValue); + this.values.add(nameAsString); } return false; } } - return values.add(attrVal); + return this.values.add(attrVal); } public void initValuesAsNames() { @@ -162,7 +162,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { } Map newValuesAsNames = new HashMap(); - for (Object value : values) { + for (Object value : this.values) { if (value instanceof String) { String s = (String) value; try { @@ -188,7 +188,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { } public boolean hasValuesAsNames() { - return !valuesAsNames.isEmpty(); + return !this.valuesAsNames.isEmpty(); } @Override @@ -197,21 +197,21 @@ public final class NameAwareAttribute implements Attribute, Iterable { initValuesAsNames(); Name name = LdapUtils.newLdapName((Name) attrval); - String removedValue = valuesAsNames.remove(name); + String removedValue = this.valuesAsNames.remove(name); if (removedValue != null) { - values.remove(removedValue); + this.values.remove(removedValue); return true; } return false; } - return values.remove(attrval); + return this.values.remove(attrval); } @Override public void clear() { - values.clear(); + this.values.clear(); } @Override @@ -226,7 +226,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { @Override public boolean isOrdered() { - return orderMatters; + return this.orderMatters; } /** @@ -238,7 +238,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { */ @Override public Object get(int ix) throws NamingException { - Iterator iterator = values.iterator(); + Iterator iterator = this.values.iterator(); try { Object value = iterator.next(); @@ -255,7 +255,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { @Override public Object remove(int ix) { - Iterator iterator = values.iterator(); + Iterator iterator = this.values.iterator(); try { Object value = iterator.next(); @@ -265,7 +265,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { iterator.remove(); if (value instanceof String) { try { - valuesAsNames.remove(new LdapName((String) value)); + this.valuesAsNames.remove(new LdapName((String) value)); } catch (javax.naming.InvalidNameException ignored) { } @@ -308,7 +308,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { NameAwareAttribute that = (NameAwareAttribute) o; - if (id != null ? !id.equals(that.id) : that.id != null) + if (this.id != null ? !this.id.equals(that.id) : that.id != null) return false; if (this.values.size() != that.values.size()) { return false; @@ -332,7 +332,7 @@ public final class NameAwareAttribute implements Attribute, Iterable { theirValues = that.valuesAsNames.keySet(); } - if (orderMatters) { + if (this.orderMatters) { Iterator thisIterator = myValues.iterator(); Iterator thatIterator = theirValues.iterator(); while (thisIterator.hasNext()) { @@ -356,12 +356,12 @@ public final class NameAwareAttribute implements Attribute, Iterable { @Override public int hashCode() { - int result = id != null ? id.hashCode() : 0; + int result = this.id != null ? this.id.hashCode() : 0; int valuesHash = 7; Set myValues = this.values; if (hasValuesAsNames()) { - myValues = valuesAsNames.keySet(); + myValues = this.valuesAsNames.keySet(); } for (Object value : myValues) { @@ -374,13 +374,13 @@ public final class NameAwareAttribute implements Attribute, Iterable { @Override public String toString() { - return String.format("NameAwareAttribute; id: %s; hasValuesAsNames: %s; orderMatters: %s; values: %s", id, - hasValuesAsNames(), orderMatters, values); + return String.format("NameAwareAttribute; id: %s; hasValuesAsNames: %s; orderMatters: %s; values: %s", this.id, + hasValuesAsNames(), this.orderMatters, this.values); } @Override public Iterator iterator() { - return values.iterator(); + return this.values.iterator(); } } diff --git a/core/src/main/java/org/springframework/ldap/core/NameAwareAttributes.java b/core/src/main/java/org/springframework/ldap/core/NameAwareAttributes.java index 5152248b..ffa0fe4e 100644 --- a/core/src/main/java/org/springframework/ldap/core/NameAwareAttributes.java +++ b/core/src/main/java/org/springframework/ldap/core/NameAwareAttributes.java @@ -60,30 +60,30 @@ public final class NameAwareAttributes implements Attributes { @Override public int size() { - return attributes.size(); + return this.attributes.size(); } @Override public NameAwareAttribute get(String attrID) { Assert.hasLength(attrID, "Attribute ID must not be empty"); - return attributes.get(attrID.toLowerCase()); + return this.attributes.get(attrID.toLowerCase()); } @Override public NamingEnumeration getAll() { - return new IterableNamingEnumeration(attributes.values()); + return new IterableNamingEnumeration(this.attributes.values()); } @Override public NamingEnumeration getIDs() { - return new IterableNamingEnumeration(attributes.keySet()); + return new IterableNamingEnumeration(this.attributes.keySet()); } @Override public Attribute put(String attrID, Object val) { Assert.hasLength(attrID, "Attribute ID must not be empty"); NameAwareAttribute newAttribute = new NameAwareAttribute(attrID, val); - attributes.put(attrID.toLowerCase(), newAttribute); + this.attributes.put(attrID.toLowerCase(), newAttribute); return newAttribute; } @@ -92,7 +92,7 @@ public final class NameAwareAttributes implements Attributes { public Attribute put(Attribute attr) { Assert.notNull(attr, "Attribute must not be null"); NameAwareAttribute newAttribute = new NameAwareAttribute(attr); - attributes.put(attr.getID().toLowerCase(), newAttribute); + this.attributes.put(attr.getID().toLowerCase(), newAttribute); return newAttribute; } @@ -100,7 +100,7 @@ public final class NameAwareAttributes implements Attributes { @Override public Attribute remove(String attrID) { Assert.hasLength(attrID, "Attribute ID must not be empty"); - return attributes.remove(attrID.toLowerCase()); + return this.attributes.remove(attrID.toLowerCase()); } @Override @@ -117,7 +117,7 @@ public final class NameAwareAttributes implements Attributes { NameAwareAttributes that = (NameAwareAttributes) o; - if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) + if (this.attributes != null ? !this.attributes.equals(that.attributes) : that.attributes != null) return false; return true; @@ -125,12 +125,12 @@ public final class NameAwareAttributes implements Attributes { @Override public int hashCode() { - return attributes != null ? attributes.hashCode() : 0; + return this.attributes != null ? this.attributes.hashCode() : 0; } @Override public String toString() { - return String.format("NameAwareAttribute; attributes: %s", attributes.toString()); + return String.format("NameAwareAttribute; attributes: %s", this.attributes.toString()); } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java index d37a0338..3a30817d 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java @@ -125,7 +125,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource public AbstractContextSource() { try { - contextFactory = Class.forName(DEFAULT_CONTEXT_FACTORY); + this.contextFactory = Class.forName(DEFAULT_CONTEXT_FACTORY); } catch (ClassNotFoundException e) { LOG.trace("The default for contextFactory cannot be resolved", e); @@ -148,7 +148,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource DirContext ctx = createContext(env); try { - DirContext processedDirContext = authenticationStrategy.processContextAfterCreation(ctx, principal, + DirContext processedDirContext = this.authenticationStrategy.processContextAfterCreation(ctx, principal, credentials); return processedDirContext; } @@ -164,8 +164,8 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @see org.springframework.ldap.core.ContextSource#getReadOnlyContext() */ public DirContext getReadOnlyContext() { - if (!anonymousReadOnly) { - return doGetContext(authenticationSource.getPrincipal(), authenticationSource.getCredentials(), + if (!this.anonymousReadOnly) { + return doGetContext(this.authenticationSource.getPrincipal(), this.authenticationSource.getCredentials(), DONT_DISABLE_POOLING); } else { @@ -179,7 +179,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @see org.springframework.ldap.core.ContextSource#getReadWriteContext() */ public DirContext getReadWriteContext() { - return doGetContext(authenticationSource.getPrincipal(), authenticationSource.getCredentials(), + return doGetContext(this.authenticationSource.getPrincipal(), this.authenticationSource.getCredentials(), DONT_DISABLE_POOLING); } @@ -196,7 +196,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource */ protected void setupAuthenticatedEnvironment(Hashtable env, String principal, String credentials) { try { - authenticationStrategy.setupEnvironment(env, principal, credentials); + this.authenticationStrategy.setupEnvironment(env, principal, credentials); } catch (NamingException e) { throw LdapUtils.convertLdapException(e); @@ -228,12 +228,12 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource StringBuilder providerUrlBuffer = new StringBuilder(DEFAULT_BUFFER_SIZE); for (String ldapUrl : ldapUrls) { providerUrlBuffer.append(ldapUrl); - if (!base.isEmpty()) { + if (!this.base.isEmpty()) { if (!ldapUrl.endsWith("/")) { providerUrlBuffer.append("/"); } } - providerUrlBuffer.append(formatForUrl(base)); + providerUrlBuffer.append(formatForUrl(this.base)); providerUrlBuffer.append(' '); } return providerUrlBuffer.toString().trim(); @@ -324,12 +324,12 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource */ @Override public DistinguishedName getBaseLdapPath() { - return new DistinguishedName(base); + return new DistinguishedName(this.base); } @Override public LdapName getBaseLdapName() { - return (LdapName) base.clone(); + return (LdapName) this.base.clone(); } @Override @@ -376,7 +376,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @return the context factory used when creating Contexts. */ public Class getContextFactory() { - return contextFactory; + return this.contextFactory; } /** @@ -397,7 +397,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * DirObjectFactory will be used. */ public Class getDirObjectFactory() { - return dirObjectFactory; + return this.dirObjectFactory; } /** @@ -407,65 +407,65 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * Spring Context. */ public void afterPropertiesSet() { - if (ObjectUtils.isEmpty(urls)) { + if (ObjectUtils.isEmpty(this.urls)) { throw new IllegalArgumentException("At least one server url must be set"); } - if (contextFactory == null) { + if (this.contextFactory == null) { throw new IllegalArgumentException("contextFactory must be set"); } - if (authenticationSource == null) { + if (this.authenticationSource == null) { LOG.debug("AuthenticationSource not set - " + "using default implementation"); - if (!StringUtils.hasText(userDn)) { + if (!StringUtils.hasText(this.userDn)) { LOG.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations"); - anonymousReadOnly = true; + this.anonymousReadOnly = true; } - if (!anonymousReadOnly) { - if (password == null) { + if (!this.anonymousReadOnly) { + if (this.password == null) { throw new IllegalArgumentException( "Property 'password' cannot be null. To use a blank password, please ensure it is set to \"\""); } - if (!StringUtils.hasText(password)) { + if (!StringUtils.hasText(this.password)) { LOG.info("Property 'password' not set - " + "blank password will be used"); } } - authenticationSource = new SimpleAuthenticationSource(); + this.authenticationSource = new SimpleAuthenticationSource(); } - if (cacheEnvironmentProperties) { - anonymousEnv = setupAnonymousEnv(); + if (this.cacheEnvironmentProperties) { + this.anonymousEnv = setupAnonymousEnv(); } } @SuppressWarnings("deprecation") private Hashtable setupAnonymousEnv() { - if (pooled) { - baseEnv.put(SUN_LDAP_POOLING_FLAG, "true"); + if (this.pooled) { + this.baseEnv.put(SUN_LDAP_POOLING_FLAG, "true"); LOG.debug("Using LDAP pooling."); } else { - baseEnv.remove(SUN_LDAP_POOLING_FLAG); + this.baseEnv.remove(SUN_LDAP_POOLING_FLAG); LOG.debug("Not using LDAP pooling"); } - Hashtable env = new Hashtable(baseEnv); + Hashtable env = new Hashtable(this.baseEnv); - env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory.getName()); - env.put(Context.PROVIDER_URL, assembleProviderUrlString(urls)); + env.put(Context.INITIAL_CONTEXT_FACTORY, this.contextFactory.getName()); + env.put(Context.PROVIDER_URL, assembleProviderUrlString(this.urls)); - if (dirObjectFactory != null) { - env.put(Context.OBJECT_FACTORIES, dirObjectFactory.getName()); + if (this.dirObjectFactory != null) { + env.put(Context.OBJECT_FACTORIES, this.dirObjectFactory.getName()); } - if (StringUtils.hasText(referral)) { - env.put(Context.REFERRAL, referral); + if (StringUtils.hasText(this.referral)) { + env.put(Context.REFERRAL, this.referral); } - if (!base.isEmpty()) { + if (!this.base.isEmpty()) { // Save the base path for use in the DefaultDirObjectFactory. - env.put(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY, base); + env.put(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY, this.base); } - LOG.debug("Trying provider Urls: " + assembleProviderUrlString(urls)); + LOG.debug("Trying provider Urls: " + assembleProviderUrlString(this.urls)); return env; } @@ -483,7 +483,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @return the password */ public String getPassword() { - return password; + return this.password; } /** @@ -517,7 +517,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @return the urls of all servers. */ public String[] getUrls() { - return urls.clone(); + return this.urls.clone(); } /** @@ -553,7 +553,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @return whether Contexts should be pooled. */ public boolean isPooled() { - return pooled; + return this.pooled; } /** @@ -567,8 +567,8 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource } protected Hashtable getAnonymousEnv() { - if (cacheEnvironmentProperties) { - return anonymousEnv; + if (this.cacheEnvironmentProperties) { + return this.anonymousEnv; } else { return setupAnonymousEnv(); @@ -597,7 +597,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * @return the {@link AuthenticationSource} that will provide user info. */ public AuthenticationSource getAuthenticationSource() { - return authenticationSource; + return this.authenticationSource; } /** @@ -630,7 +630,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * operations, false otherwise. */ public boolean isAnonymousReadOnly() { - return anonymousReadOnly; + return this.anonymousReadOnly; } /** @@ -667,11 +667,11 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource class SimpleAuthenticationSource implements AuthenticationSource { public String getPrincipal() { - return userDn; + return AbstractContextSource.this.userDn; } public String getCredentials() { - return password; + return AbstractContextSource.this.password; } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/AbstractTlsDirContextAuthenticationStrategy.java b/core/src/main/java/org/springframework/ldap/core/support/AbstractTlsDirContextAuthenticationStrategy.java index 47b80322..b0b08325 100755 --- a/core/src/main/java/org/springframework/ldap/core/support/AbstractTlsDirContextAuthenticationStrategy.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AbstractTlsDirContextAuthenticationStrategy.java @@ -130,14 +130,14 @@ public abstract class AbstractTlsDirContextAuthenticationStrategy implements Dir final LdapContext ldapCtx = (LdapContext) ctx; final StartTlsResponse tlsResponse = (StartTlsResponse) ldapCtx.extendedOperation(new StartTlsRequest()); try { - if (hostnameVerifier != null) { - tlsResponse.setHostnameVerifier(hostnameVerifier); + if (this.hostnameVerifier != null) { + tlsResponse.setHostnameVerifier(this.hostnameVerifier); } - tlsResponse.negotiate(sslSocketFactory); // If null, the default SSL - // socket factory is used + tlsResponse.negotiate(this.sslSocketFactory); // If null, the default SSL + // socket factory is used applyAuthentication(ldapCtx, userDn, password); - if (shutdownTlsGracefully) { + if (this.shutdownTlsGracefully) { // Wrap the target context in a proxy to intercept any calls // to 'close', so that we can shut down the TLS connection // gracefully first. @@ -187,19 +187,19 @@ public abstract class AbstractTlsDirContextAuthenticationStrategy implements Dir } public DirContext getTargetContext() { - return target; + return this.target; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals(CLOSE_METHOD_NAME)) { - tlsResponse.close(); - return method.invoke(target, args); + this.tlsResponse.close(); + return method.invoke(this.target, args); } else if (method.getName().equals(GET_TARGET_CONTEXT_METHOD_NAME)) { - return target; + return this.target; } else { - return method.invoke(target, args); + return method.invoke(this.target, args); } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/AggregateDirContextProcessor.java b/core/src/main/java/org/springframework/ldap/core/support/AggregateDirContextProcessor.java index 6b218ca1..71e16e8e 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/AggregateDirContextProcessor.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AggregateDirContextProcessor.java @@ -41,7 +41,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor { * @param processor the DirContextpProcessor to add. */ public void addDirContextProcessor(DirContextProcessor processor) { - dirContextProcessors.add(processor); + this.dirContextProcessors.add(processor); } /** @@ -49,7 +49,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor { * @return the managed list of {@link DirContextProcessor} instances. */ public List getDirContextProcessors() { - return dirContextProcessors; + return this.dirContextProcessors; } /** @@ -67,7 +67,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor { * .DirContext) */ public void preProcess(DirContext ctx) throws NamingException { - for (DirContextProcessor processor : dirContextProcessors) { + for (DirContextProcessor processor : this.dirContextProcessors) { processor.preProcess(ctx); } } @@ -77,7 +77,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor { * directory.DirContext) */ public void postProcess(DirContext ctx) throws NamingException { - for (DirContextProcessor processor : dirContextProcessors) { + for (DirContextProcessor processor : this.dirContextProcessors) { processor.postProcess(ctx); } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java index 62f2b242..750084f9 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java +++ b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java @@ -65,8 +65,8 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica if (bean instanceof BaseLdapNameAware) { BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean; - if (basePath != null) { - baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath)); + if (this.basePath != null) { + baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(this.basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); @@ -76,8 +76,8 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica else if (bean instanceof BaseLdapPathAware) { BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean; - if (basePath != null) { - baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath)); + if (this.basePath != null) { + baseLdapPathAware.setBaseLdapPath(new DistinguishedName(this.basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); @@ -88,11 +88,12 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica } BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { - if (StringUtils.hasLength(baseLdapPathSourceName)) { - return applicationContext.getBean(baseLdapPathSourceName, BaseLdapPathSource.class); + if (StringUtils.hasLength(this.baseLdapPathSourceName)) { + return this.applicationContext.getBean(this.baseLdapPathSourceName, BaseLdapPathSource.class); } - Collection beans = applicationContext.getBeansOfType(BaseLdapPathSource.class).values(); + Collection beans = this.applicationContext.getBeansOfType(BaseLdapPathSource.class) + .values(); if (beans.isEmpty()) { throw new NoSuchBeanDefinitionException("No BaseLdapPathSource implementation definition found"); } @@ -178,7 +179,7 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica } public int getOrder() { - return order; + return this.order; } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControls.java b/core/src/main/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControls.java index 51f8d8e9..3acb931a 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControls.java +++ b/core/src/main/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControls.java @@ -60,10 +60,10 @@ public class ContextMapperCallbackHandlerWithControls extends ContextMapperCa } T result; if (nameClassPair instanceof HasControls) { - result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); + result = this.mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); } else { - result = mapper.mapFromContext(object); + result = this.mapper.mapFromContext(object); } return result; } diff --git a/core/src/main/java/org/springframework/ldap/core/support/CountNameClassPairCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/support/CountNameClassPairCallbackHandler.java index e1fce6a9..f728b748 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/CountNameClassPairCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/support/CountNameClassPairCallbackHandler.java @@ -34,7 +34,7 @@ public class CountNameClassPairCallbackHandler implements NameClassPairCallbackH * @return the number of entries that have been handled. */ public int getNoOfRows() { - return noOfRows; + return this.noOfRows; } /* @@ -44,7 +44,7 @@ public class CountNameClassPairCallbackHandler implements NameClassPairCallbackH * naming.directory.SearchResult) */ public void handleNameClassPair(NameClassPair nameClassPair) { - noOfRows++; + this.noOfRows++; } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java b/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java index d405adf4..fec8b12f 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java @@ -169,7 +169,7 @@ public class DefaultIncrementalAttributesMapper } // Reset the affected attributes. - rangedAttributesInNextIteration = new HashSet(); + this.rangedAttributesInNextIteration = new HashSet(); NamingEnumeration attributeNameEnum = attributes.getIDs(); while (attributeNameEnum.hasMore()) { @@ -189,7 +189,7 @@ public class DefaultIncrementalAttributesMapper state.processValues(attributes, attributeName); state.calculateNextRange(responseRange); if (state.hasMore()) { - rangedAttributesInNextIteration.add(state.getRequestedAttributeName()); + this.rangedAttributesInNextIteration.add(state.getRequestedAttributeName()); } } } @@ -200,7 +200,7 @@ public class DefaultIncrementalAttributesMapper } private IncrementalAttributeState getState(String attributeName) { - Object mappedState = stateMap.get(attributeName); + Object mappedState = this.stateMap.get(attributeName); if (mappedState == null) { LOG.warn("Attribute '" + attributeName + "' is not handled by this instance"); mappedState = NOT_FOUND_ATTRIBUTE_STATE; @@ -218,7 +218,7 @@ public class DefaultIncrementalAttributesMapper public final Attributes getCollectedAttributes() { BasicAttributes attributes = new BasicAttributes(); - Set attributeNames = stateMap.keySet(); + Set attributeNames = this.stateMap.keySet(); for (String attributeName : attributeNames) { BasicAttribute oneAttribute = new BasicAttribute(attributeName); List values = getValues(attributeName); @@ -236,15 +236,15 @@ public class DefaultIncrementalAttributesMapper @Override public final boolean hasMore() { - return rangedAttributesInNextIteration.size() > 0; + return this.rangedAttributesInNextIteration.size() > 0; } @Override public final String[] getAttributesForLookup() { - String[] result = new String[rangedAttributesInNextIteration.size()]; + String[] result = new String[this.rangedAttributesInNextIteration.size()]; int index = 0; - for (String next : rangedAttributesInNextIteration) { - IncrementalAttributeState state = stateMap.get(next); + for (String next : this.rangedAttributesInNextIteration) { + IncrementalAttributeState state = this.stateMap.get(next); result[index++] = state.getAttributeNameForQuery(); } @@ -373,30 +373,30 @@ public class DefaultIncrementalAttributesMapper @Override public boolean hasMore() { - return more; + return this.more; } @Override public String getRequestedAttributeName() { - return actualAttributeName; + return this.actualAttributeName; } @Override public void calculateNextRange(RangeOption responseRange) { - more = requestRange.compareTo(responseRange) > 0; + this.more = this.requestRange.compareTo(responseRange) > 0; - if (more) { - requestRange = responseRange.nextRange(pageSize); + if (this.more) { + this.requestRange = responseRange.nextRange(this.pageSize); } } @Override public String getAttributeNameForQuery() { - StringBuilder attributeBuilder = new StringBuilder(actualAttributeName); + StringBuilder attributeBuilder = new StringBuilder(this.actualAttributeName); - if (!(requestRange.isFullRange())) { + if (!(this.requestRange.isFullRange())) { attributeBuilder.append(';'); - requestRange.appendTo(attributeBuilder); + this.requestRange.appendTo(attributeBuilder); } return attributeBuilder.toString(); @@ -409,20 +409,20 @@ public class DefaultIncrementalAttributesMapper initValuesIfApplicable(); while (valueEnum.hasMore()) { - values.add(valueEnum.next()); + this.values.add(valueEnum.next()); } } private void initValuesIfApplicable() { - if (values == null) { - values = new LinkedList(); + if (this.values == null) { + this.values = new LinkedList(); } } @Override public List getValues() { - if (values != null) { - return new ArrayList(values); + if (this.values != null) { + return new ArrayList(this.values); } else { return null; diff --git a/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java b/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java index 6355a8c0..b8fbff26 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java +++ b/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java @@ -63,19 +63,19 @@ class RangeOption implements Comparable { } public boolean isTerminalEndOfRange() { - return terminal == TERMINAL_END_OF_RANGE; + return this.terminal == TERMINAL_END_OF_RANGE; } public boolean isTerminalMissing() { - return terminal == TERMINAL_MISSING; + return this.terminal == TERMINAL_MISSING; } public int getInitial() { - return initial; + return this.initial; } public int getTerminal() { - return terminal; + return this.terminal; } public boolean isFullRange() { @@ -90,7 +90,7 @@ class RangeOption implements Comparable { } public void appendTo(StringBuilder rangeBuilder) { - rangeBuilder.append("Range=").append(initial); + rangeBuilder.append("Range=").append(this.initial); if (!isTerminalMissing()) { rangeBuilder.append('-'); @@ -99,7 +99,7 @@ class RangeOption implements Comparable { rangeBuilder.append('*'); } else { - rangeBuilder.append(terminal); + rangeBuilder.append(this.terminal); } } } @@ -169,9 +169,9 @@ class RangeOption implements Comparable { RangeOption that = (RangeOption) o; - if (initial != that.initial) + if (this.initial != that.initial) return false; - if (terminal != that.terminal) + if (this.terminal != that.terminal) return false; return true; @@ -179,8 +179,8 @@ class RangeOption implements Comparable { @Override public int hashCode() { - int result = initial; - result = 31 * result + terminal; + int result = this.initial; + result = 31 * result + this.terminal; return result; } diff --git a/core/src/main/java/org/springframework/ldap/core/support/SingleContextSource.java b/core/src/main/java/org/springframework/ldap/core/support/SingleContextSource.java index cae43e62..90ddc7d2 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/SingleContextSource.java +++ b/core/src/main/java/org/springframework/ldap/core/support/SingleContextSource.java @@ -60,14 +60,14 @@ public class SingleContextSource implements ContextSource, DisposableBean { * @see org.springframework.ldap.ContextSource#getReadOnlyContext() */ public DirContext getReadOnlyContext() { - return getNonClosingDirContextProxy(ctx); + return getNonClosingDirContextProxy(this.ctx); } /* * @see org.springframework.ldap.ContextSource#getReadWriteContext() */ public DirContext getReadWriteContext() { - return getNonClosingDirContextProxy(ctx); + return getNonClosingDirContextProxy(this.ctx); } private DirContext getNonClosingDirContextProxy(DirContext context) { @@ -87,7 +87,7 @@ public class SingleContextSource implements ContextSource, DisposableBean { */ public void destroy() { try { - ctx.close(); + this.ctx.close(); } catch (javax.naming.NamingException e) { LOG.warn("Error when closing", e); @@ -186,7 +186,7 @@ public class SingleContextSource implements ContextSource, DisposableBean { String methodName = method.getName(); if (methodName.equals("getTargetContext")) { - return target; + return this.target; } else if (methodName.equals("equals")) { // Only consider equal when proxies are identical. @@ -203,7 +203,7 @@ public class SingleContextSource implements ContextSource, DisposableBean { } try { - return method.invoke(target, args); + return method.invoke(this.target, args); } catch (InvocationTargetException e) { throw e.getTargetException(); diff --git a/core/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java b/core/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java index 775f62fd..b7b985ac 100644 --- a/core/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java +++ b/core/src/main/java/org/springframework/ldap/filter/BinaryLogicalFilter.java @@ -30,23 +30,23 @@ public abstract class BinaryLogicalFilter extends AbstractFilter { private List queryList = new LinkedList(); public StringBuffer encode(StringBuffer buff) { - if (queryList.size() <= 0) { + if (this.queryList.size() <= 0) { // only output query if contains anything return buff; } - else if (queryList.size() == 1) { + else if (this.queryList.size() == 1) { // don't add the & - Filter query = queryList.get(0); + Filter query = this.queryList.get(0); return query.encode(buff); } else { buff.append("(").append(getLogicalOperator()); - for (Filter query : queryList) { + for (Filter query : this.queryList) { query.encode(buff); } @@ -72,7 +72,7 @@ public abstract class BinaryLogicalFilter extends AbstractFilter { BinaryLogicalFilter that = (BinaryLogicalFilter) o; - if (queryList != null ? !queryList.equals(that.queryList) : that.queryList != null) + if (this.queryList != null ? !this.queryList.equals(that.queryList) : that.queryList != null) return false; return true; @@ -80,7 +80,7 @@ public abstract class BinaryLogicalFilter extends AbstractFilter { @Override public int hashCode() { - return queryList != null ? queryList.hashCode() : 0; + return this.queryList != null ? this.queryList.hashCode() : 0; } /** @@ -89,12 +89,12 @@ public abstract class BinaryLogicalFilter extends AbstractFilter { * @return This instance. */ public final BinaryLogicalFilter append(Filter query) { - queryList.add(query); + this.queryList.add(query); return this; } public final BinaryLogicalFilter appendAll(Collection subQueries) { - queryList.addAll(subQueries); + this.queryList.addAll(subQueries); return this; } diff --git a/core/src/main/java/org/springframework/ldap/filter/CompareFilter.java b/core/src/main/java/org/springframework/ldap/filter/CompareFilter.java index e704258f..24d3bec1 100644 --- a/core/src/main/java/org/springframework/ldap/filter/CompareFilter.java +++ b/core/src/main/java/org/springframework/ldap/filter/CompareFilter.java @@ -41,7 +41,7 @@ public abstract class CompareFilter extends AbstractFilter { * @return the encoded value. */ String getEncodedValue() { - return encodedValue; + return this.encodedValue; } /** @@ -69,7 +69,7 @@ public abstract class CompareFilter extends AbstractFilter { */ public StringBuffer encode(StringBuffer buff) { buff.append('('); - buff.append(attribute).append(getCompareString()).append(encodedValue); + buff.append(this.attribute).append(getCompareString()).append(this.encodedValue); buff.append(')'); return buff; @@ -84,9 +84,9 @@ public abstract class CompareFilter extends AbstractFilter { CompareFilter that = (CompareFilter) o; - if (attribute != null ? !attribute.equals(that.attribute) : that.attribute != null) + if (this.attribute != null ? !this.attribute.equals(that.attribute) : that.attribute != null) return false; - if (value != null ? !value.equals(that.value) : that.value != null) + if (this.value != null ? !this.value.equals(that.value) : that.value != null) return false; return true; @@ -94,8 +94,8 @@ public abstract class CompareFilter extends AbstractFilter { @Override public int hashCode() { - int result = attribute != null ? attribute.hashCode() : 0; - result = 31 * result + (value != null ? value.hashCode() : 0); + int result = this.attribute != null ? this.attribute.hashCode() : 0; + result = 31 * result + (this.value != null ? this.value.hashCode() : 0); return result; } diff --git a/core/src/main/java/org/springframework/ldap/filter/HardcodedFilter.java b/core/src/main/java/org/springframework/ldap/filter/HardcodedFilter.java index cec2d5c0..59cf7fc2 100644 --- a/core/src/main/java/org/springframework/ldap/filter/HardcodedFilter.java +++ b/core/src/main/java/org/springframework/ldap/filter/HardcodedFilter.java @@ -57,11 +57,11 @@ public class HardcodedFilter extends AbstractFilter { } public StringBuffer encode(StringBuffer buff) { - if (!StringUtils.hasLength(filter)) { + if (!StringUtils.hasLength(this.filter)) { return buff; } - buff.append(filter); + buff.append(this.filter); return buff; } @@ -74,7 +74,7 @@ public class HardcodedFilter extends AbstractFilter { HardcodedFilter that = (HardcodedFilter) o; - if (filter != null ? !filter.equals(that.filter) : that.filter != null) + if (this.filter != null ? !this.filter.equals(that.filter) : that.filter != null) return false; return true; @@ -82,7 +82,7 @@ public class HardcodedFilter extends AbstractFilter { @Override public int hashCode() { - return filter != null ? filter.hashCode() : 0; + return this.filter != null ? this.filter.hashCode() : 0; } } diff --git a/core/src/main/java/org/springframework/ldap/filter/NotFilter.java b/core/src/main/java/org/springframework/ldap/filter/NotFilter.java index ab95df67..b0dea625 100644 --- a/core/src/main/java/org/springframework/ldap/filter/NotFilter.java +++ b/core/src/main/java/org/springframework/ldap/filter/NotFilter.java @@ -50,7 +50,7 @@ public class NotFilter extends AbstractFilter { public StringBuffer encode(StringBuffer buff) { buff.append("(!"); - filter.encode(buff); + this.filter.encode(buff); buff.append(')'); return buff; @@ -65,7 +65,7 @@ public class NotFilter extends AbstractFilter { NotFilter notFilter = (NotFilter) o; - if (filter != null ? !filter.equals(notFilter.filter) : notFilter.filter != null) + if (this.filter != null ? !this.filter.equals(notFilter.filter) : notFilter.filter != null) return false; return true; @@ -73,7 +73,7 @@ public class NotFilter extends AbstractFilter { @Override public int hashCode() { - return filter != null ? filter.hashCode() : 0; + return this.filter != null ? this.filter.hashCode() : 0; } } diff --git a/core/src/main/java/org/springframework/ldap/filter/NotPresentFilter.java b/core/src/main/java/org/springframework/ldap/filter/NotPresentFilter.java index 8edb3964..52066dcf 100644 --- a/core/src/main/java/org/springframework/ldap/filter/NotPresentFilter.java +++ b/core/src/main/java/org/springframework/ldap/filter/NotPresentFilter.java @@ -48,7 +48,7 @@ public class NotPresentFilter extends AbstractFilter { public StringBuffer encode(StringBuffer buff) { buff.append("(!("); - buff.append(attribute); + buff.append(this.attribute); buff.append("=*))"); return buff; } @@ -62,7 +62,7 @@ public class NotPresentFilter extends AbstractFilter { NotPresentFilter that = (NotPresentFilter) o; - if (attribute != null ? !attribute.equals(that.attribute) : that.attribute != null) + if (this.attribute != null ? !this.attribute.equals(that.attribute) : that.attribute != null) return false; return true; @@ -70,7 +70,7 @@ public class NotPresentFilter extends AbstractFilter { @Override public int hashCode() { - return attribute != null ? attribute.hashCode() : 0; + return this.attribute != null ? this.attribute.hashCode() : 0; } } \ No newline at end of file diff --git a/core/src/main/java/org/springframework/ldap/filter/PresentFilter.java b/core/src/main/java/org/springframework/ldap/filter/PresentFilter.java index f24a3c18..0914dc77 100644 --- a/core/src/main/java/org/springframework/ldap/filter/PresentFilter.java +++ b/core/src/main/java/org/springframework/ldap/filter/PresentFilter.java @@ -49,7 +49,7 @@ public class PresentFilter extends AbstractFilter { public StringBuffer encode(StringBuffer buff) { buff.append("("); - buff.append(attribute); + buff.append(this.attribute); buff.append("=*)"); return buff; } @@ -63,7 +63,7 @@ public class PresentFilter extends AbstractFilter { PresentFilter that = (PresentFilter) o; - if (attribute != null ? !attribute.equals(that.attribute) : that.attribute != null) + if (this.attribute != null ? !this.attribute.equals(that.attribute) : that.attribute != null) return false; return true; @@ -71,7 +71,7 @@ public class PresentFilter extends AbstractFilter { @Override public int hashCode() { - return attribute != null ? attribute.hashCode() : 0; + return this.attribute != null ? this.attribute.hashCode() : 0; } } \ No newline at end of file diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/AttributeMetaData.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/AttributeMetaData.java index 3f5f5deb..54e6305b 100755 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/AttributeMetaData.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/AttributeMetaData.java @@ -86,13 +86,13 @@ import java.util.TreeSet; // syntax, isBinary, isObjectClass and name. private boolean processAttributeAnnotation(Field field) { // Default to no syntax specified - syntax = ""; + this.syntax = ""; // Default to a String based attribute - isBinary = false; + this.isBinary = false; // Default name of attribute to the name of the field - name = new CaseIgnoreString(field.getName()); + this.name = new CaseIgnoreString(field.getName()); // We have not yet found the @Attribute annotation boolean foundAnnotation = false; @@ -110,16 +110,16 @@ import java.util.TreeSet; // Would be more efficient to use !isEmpty - but that then makes us Java 6 // dependent if (localAttributeName != null && localAttributeName.length() > 0) { - name = new CaseIgnoreString(localAttributeName); + this.name = new CaseIgnoreString(localAttributeName); attrList.add(localAttributeName); } - syntax = attribute.syntax(); - isBinary = attribute.type() == Attribute.Type.BINARY; - isReadOnly = attribute.readonly(); + this.syntax = attribute.syntax(); + this.isBinary = attribute.type() == Attribute.Type.BINARY; + this.isReadOnly = attribute.readonly(); } - attributes = attrList.toArray(new String[attrList.size()]); + this.attributes = attrList.toArray(new String[attrList.size()]); - isObjectClass = name.equals(OBJECT_CLASS_ATTRIBUTE_CI); + this.isObjectClass = this.name.equals(OBJECT_CLASS_ATTRIBUTE_CI); return foundAnnotation; } @@ -130,12 +130,12 @@ import java.util.TreeSet; // Determine the class of data stored in the field Class fieldType = field.getType(); - isCollection = Collection.class.isAssignableFrom(fieldType); + this.isCollection = Collection.class.isAssignableFrom(fieldType); - valueClass = null; - if (!isCollection) { + this.valueClass = null; + if (!this.isCollection) { // It's not a list so assume its single valued - so just take the field type - valueClass = fieldType; + this.valueClass = fieldType; } else { determineCollectionClass(fieldType); @@ -155,14 +155,14 @@ import java.util.TreeSet; Type[] actualParamArguments = paramType.getActualTypeArguments(); if (actualParamArguments.length == 1) { if (actualParamArguments[0] instanceof Class) { - valueClass = (Class) actualParamArguments[0]; + this.valueClass = (Class) actualParamArguments[0]; } else { if (actualParamArguments[0] instanceof GenericArrayType) { // Deal with arrays Type type = ((GenericArrayType) actualParamArguments[0]).getGenericComponentType(); if (type instanceof Class) { - valueClass = Array.newInstance((Class) type, 0).getClass(); + this.valueClass = Array.newInstance((Class) type, 0).getClass(); } } } @@ -170,7 +170,7 @@ import java.util.TreeSet; } // Check we have been able to determine the value class - if (valueClass == null) { + if (this.valueClass == null) { throw new MetaDataException(String.format("Can't determine destination type for field %1$s in class %2$s", field, field.getDeclaringClass())); } @@ -180,27 +180,27 @@ import java.util.TreeSet; private void determineCollectionClass(Class fieldType) { if (fieldType.isInterface()) { if (Collection.class.equals(fieldType) || List.class.equals(fieldType)) { - collectionClass = ArrayList.class; + this.collectionClass = ArrayList.class; } else if (SortedSet.class.equals(fieldType)) { - collectionClass = TreeSet.class; + this.collectionClass = TreeSet.class; } else if (Set.class.isAssignableFrom(fieldType)) { - collectionClass = LinkedHashSet.class; + this.collectionClass = LinkedHashSet.class; } else { throw new MetaDataException(String.format("Collection class %s is not supported", fieldType)); } } else { - collectionClass = (Class) fieldType; + this.collectionClass = (Class) fieldType; } } @SuppressWarnings("unchecked") public Collection newCollectionInstance() { try { - return (Collection) collectionClass.newInstance(); + return (Collection) this.collectionClass.newInstance(); } catch (Exception e) { throw new UncategorizedLdapException("Failed to instantiate collection class", e); @@ -211,9 +211,9 @@ import java.util.TreeSet; // isId private boolean processIdAnnotation(Field field, Class fieldType) { // Are we dealing with the Id field? - isId = field.getAnnotation(Id.class) != null; + this.isId = field.getAnnotation(Id.class) != null; - if (isId) { + if (this.isId) { // It must be of type Name or a subclass of that of if (!Name.class.isAssignableFrom(fieldType)) { throw new MetaDataException(String.format( @@ -222,7 +222,7 @@ import java.util.TreeSet; } } - return isId; + return this.isId; } // Extract meta-data from the given field @@ -249,7 +249,7 @@ import java.util.TreeSet; boolean foundAttributeAnnotation = processAttributeAnnotation(field); // Data from the @Id annotation - boolean foundIdAnnoation = processIdAnnotation(field, valueClass); + boolean foundIdAnnoation = processIdAnnotation(field, this.valueClass); // Check that the field has not been annotated with both @Attribute and with @Id if (foundAttributeAnnotation && foundIdAnnoation) { @@ -259,7 +259,7 @@ import java.util.TreeSet; } // If this is the objectclass attribute then it must be of type List - if (isObjectClass() && (!isCollection() || valueClass != String.class)) { + if (isObjectClass() && (!isCollection() || this.valueClass != String.class)) { throw new MetaDataException( String.format("The type of the objectclass attribute must be List in classs %1$s", field.getDeclaringClass())); @@ -267,62 +267,62 @@ import java.util.TreeSet; } public String getSyntax() { - return syntax; + return this.syntax; } public boolean isBinary() { - return isBinary; + return this.isBinary; } public Field getField() { - return field; + return this.field; } public CaseIgnoreString getName() { - return name; + return this.name; } public boolean isCollection() { - return isCollection; + return this.isCollection; } public boolean isId() { - return isId; + return this.isId; } public boolean isReadOnly() { - return isReadOnly; + return this.isReadOnly; } public boolean isTransient() { - return isTransient; + return this.isTransient; } public DnAttribute getDnAttribute() { - return dnAttribute; + return this.dnAttribute; } public boolean isDnAttribute() { - return dnAttribute != null; + return this.dnAttribute != null; } public boolean isObjectClass() { - return isObjectClass; + return this.isObjectClass; } public Class getValueClass() { - return valueClass; + return this.valueClass; } public String[] getAttributes() { - return attributes; + return this.attributes; } public Class getJndiClass() { if (isBinary()) { return byte[].class; } - else if (Name.class.isAssignableFrom(valueClass)) { + else if (Name.class.isAssignableFrom(this.valueClass)) { return Name.class; } else { diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/CaseIgnoreString.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/CaseIgnoreString.java index 91f120b2..6a0e894a 100755 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/CaseIgnoreString.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/CaseIgnoreString.java @@ -28,24 +28,24 @@ import org.springframework.util.Assert; public CaseIgnoreString(String string) { Assert.notNull(string, "string must not be null"); this.string = string; - hashCode = string.toUpperCase().hashCode(); + this.hashCode = string.toUpperCase().hashCode(); } public boolean equals(Object other) { - return other instanceof CaseIgnoreString && ((CaseIgnoreString) other).string.equalsIgnoreCase(string); + return other instanceof CaseIgnoreString && ((CaseIgnoreString) other).string.equalsIgnoreCase(this.string); } public int hashCode() { - return hashCode; + return this.hashCode; } public int compareTo(CaseIgnoreString other) { CaseIgnoreString cis = other; - return String.CASE_INSENSITIVE_ORDER.compare(string, cis.string); + return String.CASE_INSENSITIVE_ORDER.compare(this.string, cis.string); } public String toString() { - return string; + return this.string; } } diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java index 64c03b51..7651f448 100644 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java @@ -72,7 +72,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { private static final CaseIgnoreString OBJECT_CLASS_ATTRIBUTE_CI = new CaseIgnoreString(OBJECT_CLASS_ATTRIBUTE); public DefaultObjectDirectoryMapper() { - converterManager = createDefaultConverterManager(); + this.converterManager = createDefaultConverterManager(); } private static ConverterManager createDefaultConverterManager() { @@ -111,7 +111,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { private final ConcurrentMap, EntityData> metaDataMap = new ConcurrentHashMap, EntityData>(); private EntityData getEntityData(Class managedClass) { - EntityData result = metaDataMap.get(managedClass); + EntityData result = this.metaDataMap.get(managedClass); if (result == null) { return addManagedClass(managedClass); } @@ -185,7 +185,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { } EntityData newValue = new EntityData(metaData, ocFilter); - EntityData previousValue = metaDataMap.putIfAbsent(managedClass, newValue); + EntityData previousValue = this.metaDataMap.putIfAbsent(managedClass, newValue); // Just in case someone beat us to it if (previousValue != null) { return previousValue; @@ -197,13 +197,13 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { private void verifyConversion(Class managedClass, Field field, AttributeMetaData attributeInfo) { Class jndiClass = attributeInfo.getJndiClass(); Class javaClass = attributeInfo.getValueClass(); - if (!converterManager.canConvert(jndiClass, attributeInfo.getSyntax(), javaClass)) { + if (!this.converterManager.canConvert(jndiClass, attributeInfo.getSyntax(), javaClass)) { throw new InvalidEntryException( String.format("Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s", jndiClass, javaClass, field.getName(), managedClass)); } if (!attributeInfo.isReadOnly() - && !converterManager.canConvert(javaClass, attributeInfo.getSyntax(), jndiClass)) { + && !this.converterManager.canConvert(javaClass, attributeInfo.getSyntax(), jndiClass)) { throw new InvalidEntryException( String.format("Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s", javaClass, jndiClass, field.getName(), managedClass)); @@ -273,7 +273,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { for (final Object o : fieldValues) { // Ignore null values if (o != null) { - attributeValues.add(converterManager.convert(o, attributeInfo.getSyntax(), targetClass)); + attributeValues.add(this.converterManager.convert(o, attributeInfo.getSyntax(), targetClass)); } } context.setAttributeValues(attributeInfo.getName().toString(), attributeValues.toArray()); @@ -289,7 +289,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { // Convert the field value to the required type and write it into the JNDI // context context.setAttributeValue(attributeInfo.getName().toString(), - converterManager.convert(fieldValue, attributeInfo.getSyntax(), targetClass)); + this.converterManager.convert(fieldValue, attributeInfo.getSyntax(), targetClass)); } else { context.setAttributeValue(attributeInfo.getName().toString(), null); @@ -367,8 +367,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { } } else if (attributeInfo.isId()) { // The id field - field.set(result, - converterManager.convert(dn, attributeInfo.getSyntax(), attributeInfo.getValueClass())); + field.set(result, this.converterManager.convert(dn, attributeInfo.getSyntax(), + attributeInfo.getValueClass())); } DnAttribute dnAttribute = attributeInfo.getDnAttribute(); @@ -423,8 +423,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { if (value != null) { // Convert the value to its Java representation and add it to our // working list - fieldValues.add( - converterManager.convert(value, attributeInfo.getSyntax(), attributeInfo.getValueClass())); + fieldValues.add(this.converterManager.convert(value, attributeInfo.getSyntax(), + attributeInfo.getValueClass())); } } } @@ -445,7 +445,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { // Convert the JNDI value to its Java representation - this will throw if // the // conversion fails - Object convertedValue = converterManager.convert(value, attributeInfo.getSyntax(), + Object convertedValue = this.converterManager.convert(value, attributeInfo.getSyntax(), attributeInfo.getValueClass()); // Set it in the Java version field.set(result, convertedValue); @@ -529,7 +529,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { // For testing purposes ConcurrentMap, EntityData> getMetaDataMap() { - return metaDataMap; + return this.metaDataMap; } static boolean collectionContainsAll(Collection collection, Set shouldBePresent) { diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java index 22e9c654..2694642e 100755 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java @@ -66,11 +66,11 @@ import java.util.TreeSet; private Name base = LdapUtils.emptyLdapName(); public Set getObjectClasses() { - return objectClasses; + return this.objectClasses; } public AttributeMetaData getIdAttribute() { - return idAttribute; + return this.idAttribute; } /* @@ -79,11 +79,11 @@ import java.util.TreeSet; * @see java.lang.Iterable#iterator() */ public Iterator iterator() { - return fieldToAttribute.keySet().iterator(); + return this.fieldToAttribute.keySet().iterator(); } public AttributeMetaData getAttribute(Field field) { - return fieldToAttribute.get(field); + return this.fieldToAttribute.get(field); } public ObjectMetaData(Class clazz) { @@ -99,11 +99,11 @@ import java.util.TreeSet; String[] localObjectClasses = entity.objectClasses(); if (localObjectClasses != null && localObjectClasses.length > 0 && localObjectClasses[0].length() > 0) { for (String localObjectClass : localObjectClasses) { - objectClasses.add(new CaseIgnoreString(localObjectClass)); + this.objectClasses.add(new CaseIgnoreString(localObjectClass)); } } else { - objectClasses.add(new CaseIgnoreString(clazz.getSimpleName())); + this.objectClasses.add(new CaseIgnoreString(clazz.getSimpleName())); } String base = entity.base(); @@ -134,21 +134,21 @@ import java.util.TreeSet; AttributeMetaData currentAttributeMetaData = new AttributeMetaData(field); if (currentAttributeMetaData.isId()) { - if (idAttribute != null) { + if (this.idAttribute != null) { // There can be only one id field throw new MetaDataException(String.format( "You man have only one field with the %1$s annotation in class %2$s", Id.class, clazz)); } - idAttribute = currentAttributeMetaData; + this.idAttribute = currentAttributeMetaData; } - fieldToAttribute.put(field, currentAttributeMetaData); + this.fieldToAttribute.put(field, currentAttributeMetaData); if (currentAttributeMetaData.isDnAttribute()) { - dnAttributes.add(currentAttributeMetaData); + this.dnAttributes.add(currentAttributeMetaData); } } - if (idAttribute == null) { + if (this.idAttribute == null) { throw new MetaDataException( String.format("All Entry classes must define a field with the %1$s annotation, error in class %2$s", Id.class, clazz)); @@ -165,7 +165,7 @@ import java.util.TreeSet; boolean hasIndexed = false; boolean hasNonIndexed = false; - for (AttributeMetaData dnAttribute : dnAttributes) { + for (AttributeMetaData dnAttribute : this.dnAttributes) { int declaredIndex = dnAttribute.getDnAttribute().index(); if (declaredIndex != -1) { @@ -182,23 +182,23 @@ import java.util.TreeSet; + "which means that all DnAttributes must be indexed", clazz.toString())); } - indexedDnAttributes = hasIndexed; + this.indexedDnAttributes = hasIndexed; } int size() { - return fieldToAttribute.size(); + return this.fieldToAttribute.size(); } boolean canCalculateDn() { - return dnAttributes.size() > 0 && indexedDnAttributes; + return this.dnAttributes.size() > 0 && this.indexedDnAttributes; } public Set getDnAttributes() { - return dnAttributes; + return this.dnAttributes; } Name getBase() { - return base; + return this.base; } /* @@ -208,8 +208,8 @@ import java.util.TreeSet; */ @Override public String toString() { - return String.format("objectsClasses=%1$s | idField=%2$s | attributes=%3$s", objectClasses, - idAttribute.getName(), fieldToAttribute); + return String.format("objectsClasses=%1$s | idField=%2$s | attributes=%3$s", this.objectClasses, + this.idAttribute.getName(), this.fieldToAttribute); } } diff --git a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConversionServiceConverterManager.java b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConversionServiceConverterManager.java index d22b21d7..b66949e8 100644 --- a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConversionServiceConverterManager.java +++ b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConversionServiceConverterManager.java @@ -43,31 +43,31 @@ public class ConversionServiceConverterManager implements ConverterManager { if (ClassUtils.isPresent(DEFAULT_CONVERSION_SERVICE_CLASS, defaultClassLoader)) { try { Class clazz = ClassUtils.forName(DEFAULT_CONVERSION_SERVICE_CLASS, defaultClassLoader); - conversionService = (GenericConversionService) clazz.newInstance(); + this.conversionService = (GenericConversionService) clazz.newInstance(); } catch (Exception e) { ReflectionUtils.handleReflectionException(e); } } else { - conversionService = new GenericConversionService(); + this.conversionService = new GenericConversionService(); } prePopulateWithNameConverter(); } private void prePopulateWithNameConverter() { - conversionService.addConverter(new StringToNameConverter()); + this.conversionService.addConverter(new StringToNameConverter()); } @Override public boolean canConvert(Class fromClass, String syntax, Class toClass) { - return conversionService.canConvert(fromClass, toClass); + return this.conversionService.canConvert(fromClass, toClass); } @Override public T convert(Object source, String syntax, Class toClass) { - return conversionService.convert(source, toClass); + return this.conversionService.convert(source, toClass); } public final static class NameToStringConverter diff --git a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerFactoryBean.java b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerFactoryBean.java index 4eb12a03..50c971a4 100755 --- a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerFactoryBean.java +++ b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerFactoryBean.java @@ -149,8 +149,8 @@ public final class ConverterManagerFactoryBean implements FactoryBean { @Override public String toString() { - return String.format("fromClasses=%1$s, syntax=%2$s, toClasses=%3$s, converter=%4$s", fromClasses, syntax, - toClasses, converter); + return String.format("fromClasses=%1$s, syntax=%2$s, toClasses=%3$s, converter=%4$s", this.fromClasses, + this.syntax, this.toClasses, this.converter); } } @@ -175,12 +175,12 @@ public final class ConverterManagerFactoryBean implements FactoryBean { * @see org.springframework.beans.factory.FactoryBean#getObject() */ public Object getObject() throws Exception { - if (converterConfigList == null) { + if (this.converterConfigList == null) { throw new FactoryBeanNotInitializedException("converterConfigList has not been set"); } ConverterManagerImpl result = new ConverterManagerImpl(); - for (ConverterConfig converterConfig : converterConfigList) { + for (ConverterConfig converterConfig : this.converterConfigList) { if (converterConfig.fromClasses == null || converterConfig.toClasses == null || converterConfig.converter == null) { diff --git a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java index aab7112b..0b396554 100755 --- a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java +++ b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java @@ -109,8 +109,8 @@ public final class ConverterManagerImpl implements ConverterManager { fixedFromClass = primitiveTypeMap.get(fromClass); } return fixedToClass.isAssignableFrom(fixedFromClass) - || (converters.get(makeConverterKey(fixedFromClass, syntax, fixedToClass)) != null) - || (converters.get(makeConverterKey(fixedFromClass, null, fixedToClass)) != null); + || (this.converters.get(makeConverterKey(fixedFromClass, syntax, fixedToClass)) != null) + || (this.converters.get(makeConverterKey(fixedFromClass, null, fixedToClass)) != null); } /* @@ -134,7 +134,7 @@ public final class ConverterManagerImpl implements ConverterManager { } // Try to convert with any syntax we have been given - Converter syntaxConverter = converters.get(makeConverterKey(fromClass, syntax, targetClass)); + Converter syntaxConverter = this.converters.get(makeConverterKey(fromClass, syntax, targetClass)); if (syntaxConverter != null) { try { result = syntaxConverter.convert(source, targetClass); @@ -152,7 +152,7 @@ public final class ConverterManagerImpl implements ConverterManager { // If we were given a syntax and we failed to convert drop back to any mapping // that will work from class -> to class if (result == null && syntax != null) { - Converter nullSyntaxConverter = converters.get(makeConverterKey(fromClass, null, targetClass)); + Converter nullSyntaxConverter = this.converters.get(makeConverterKey(fromClass, null, targetClass)); if (nullSyntaxConverter != null) { try { result = nullSyntaxConverter.convert(source, targetClass); @@ -183,7 +183,7 @@ public final class ConverterManagerImpl implements ConverterManager { * @param converter The Converter to add. */ public void addConverter(Class fromClass, String syntax, Class toClass, Converter converter) { - converters.put(makeConverterKey(fromClass, syntax, toClass), converter); + this.converters.put(makeConverterKey(fromClass, syntax, toClass), converter); } } diff --git a/core/src/main/java/org/springframework/ldap/pool/DirContextType.java b/core/src/main/java/org/springframework/ldap/pool/DirContextType.java index b777a264..202ac718 100644 --- a/core/src/main/java/org/springframework/ldap/pool/DirContextType.java +++ b/core/src/main/java/org/springframework/ldap/pool/DirContextType.java @@ -35,7 +35,7 @@ public final class DirContextType { } public String toString() { - return name; + return this.name; } /** diff --git a/core/src/main/java/org/springframework/ldap/pool/PoolExhaustedAction.java b/core/src/main/java/org/springframework/ldap/pool/PoolExhaustedAction.java index 776907fb..aa413cb8 100644 --- a/core/src/main/java/org/springframework/ldap/pool/PoolExhaustedAction.java +++ b/core/src/main/java/org/springframework/ldap/pool/PoolExhaustedAction.java @@ -14,7 +14,7 @@ public enum PoolExhaustedAction { } public byte getValue() { - return value; + return this.value; } } diff --git a/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java b/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java index c25835eb..f071ecbe 100644 --- a/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java @@ -242,23 +242,23 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory { String methodName = method.getName(); if (methodName.equals("getTargetContext")) { - return target; + return this.target; } else if (methodName.equals("hasFailed")) { - return hasFailed; + return this.hasFailed; } try { - return method.invoke(target, args); + return method.invoke(this.target, args); } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); Class targetExceptionClass = targetException.getClass(); boolean nonTransientEncountered = false; - for (Class clazz : nonTransientExceptions) { + for (Class clazz : DirContextPoolableObjectFactory.this.nonTransientExceptions) { if (clazz.isAssignableFrom(targetExceptionClass)) { - logger.info(String.format( + DirContextPoolableObjectFactory.this.logger.info(String.format( "An %s - explicitly configured to be a non-transient exception - encountered; eagerly invalidating the target context.", targetExceptionClass)); nonTransientEncountered = true; @@ -267,11 +267,11 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory { } if (nonTransientEncountered) { - hasFailed = true; + this.hasFailed = true; } else { - if (logger.isDebugEnabled()) { - logger.debug(String.format( + if (DirContextPoolableObjectFactory.this.logger.isDebugEnabled()) { + DirContextPoolableObjectFactory.this.logger.debug(String.format( "An %s - not explicitly configured to be a non-transient exception - encountered; ignoring.", targetExceptionClass)); } diff --git a/core/src/main/java/org/springframework/ldap/pool2/DirContextType.java b/core/src/main/java/org/springframework/ldap/pool2/DirContextType.java index dc865b51..4a4d0b86 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/DirContextType.java +++ b/core/src/main/java/org/springframework/ldap/pool2/DirContextType.java @@ -35,7 +35,7 @@ public final class DirContextType { } public String toString() { - return name; + return this.name; } /** diff --git a/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java b/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java index a7bcb269..dffddf44 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java @@ -265,24 +265,24 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory targetExceptionClass = targetException.getClass(); boolean nonTransientEncountered = false; - for (Class clazz : nonTransientExceptions) { + for (Class clazz : DirContextPooledObjectFactory.this.nonTransientExceptions) { if (clazz.isAssignableFrom(targetExceptionClass)) { - if (logger.isDebugEnabled()) { - logger.debug(String.format( + if (DirContextPooledObjectFactory.this.logger.isDebugEnabled()) { + DirContextPooledObjectFactory.this.logger.debug(String.format( "A %s - explicitly configured to be a non-transient exception - encountered; eagerly invalidating the target context.", targetExceptionClass)); } @@ -292,11 +292,11 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory attributesMapper = getAttributesMapper(attributeNameArray); while (attributesMapper.hasMore()) { - ldapOperations.lookup(dn, attributesMapper.getAttributesForLookup(), attributesMapper); + this.ldapOperations.lookup(dn, attributesMapper.getAttributesForLookup(), attributesMapper); } Attributes currentAttributes = attributesMapper.getCollectedAttributes(); @@ -88,7 +88,7 @@ public class ModifyAttributesOperationRecorder implements CompensatingTransactio rollbackItems[i] = getCompensatingModificationItem(currentAttributes, incomingModifications[i]); } - return new ModifyAttributesOperationExecutor(ldapOperations, dn, incomingModifications, rollbackItems); + return new ModifyAttributesOperationExecutor(this.ldapOperations, dn, incomingModifications, rollbackItems); } /** @@ -154,7 +154,7 @@ public class ModifyAttributesOperationRecorder implements CompensatingTransactio } LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutor.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutor.java index b80eb5bd..d7ab4b02 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutor.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutor.java @@ -72,7 +72,7 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation * @return the LdapOperations. */ LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } /* @@ -82,11 +82,13 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation public void rollback() { log.debug("Rolling back rebind operation"); try { - ldapOperations.unbind(originalDn); - ldapOperations.rename(temporaryDn, originalDn); + this.ldapOperations.unbind(this.originalDn); + this.ldapOperations.rename(this.temporaryDn, this.originalDn); } catch (Exception e) { - log.warn("Failed to rollback operation, dn: " + originalDn + "; temporary DN: " + temporaryDn, e); + log.warn( + "Failed to rollback operation, dn: " + this.originalDn + "; temporary DN:this. " + this.temporaryDn, + e); } } @@ -96,7 +98,7 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation */ public void commit() { log.debug("Committing rebind operation"); - ldapOperations.unbind(temporaryDn); + this.ldapOperations.unbind(this.temporaryDn); } /* @@ -105,24 +107,24 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation */ public void performOperation() { log.debug("Performing rebind operation - " + "renaming original entry and " + "binding new contents to entry."); - ldapOperations.rename(originalDn, temporaryDn); - ldapOperations.bind(originalDn, originalObject, originalAttributes); + this.ldapOperations.rename(this.originalDn, this.temporaryDn); + this.ldapOperations.bind(this.originalDn, this.originalObject, this.originalAttributes); } Attributes getOriginalAttributes() { - return originalAttributes; + return this.originalAttributes; } Name getOriginalDn() { - return originalDn; + return this.originalDn; } Object getOriginalObject() { - return originalObject; + return this.originalObject; } Name getTemporaryDn() { - return temporaryDn; + return this.temporaryDn; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorder.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorder.java index 4b4f629f..c96769c4 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorder.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorder.java @@ -65,9 +65,9 @@ public class RebindOperationRecorder implements CompensatingTransactionOperation attributes = (Attributes) args[2]; } - Name temporaryName = renamingStrategy.getTemporaryName(dn); + Name temporaryName = this.renamingStrategy.getTemporaryName(dn); - return new RebindOperationExecutor(ldapOperations, dn, temporaryName, object, attributes); + return new RebindOperationExecutor(this.ldapOperations, dn, temporaryName, object, attributes); } /** @@ -75,11 +75,11 @@ public class RebindOperationRecorder implements CompensatingTransactionOperation * @return the LdapOperations. */ LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } public TempEntryRenamingStrategy getRenamingStrategy() { - return renamingStrategy; + return this.renamingStrategy; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutor.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutor.java index 61e3717f..2dd81274 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutor.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutor.java @@ -60,10 +60,11 @@ public class RenameOperationExecutor implements CompensatingTransactionOperation public void rollback() { log.debug("Rolling back rename operation"); try { - ldapOperations.rename(newDn, originalDn); + this.ldapOperations.rename(this.newDn, this.originalDn); } catch (Exception e) { - log.warn("Unable to rollback rename operation. " + "originalDn: " + newDn + "; newDn: " + originalDn); + log.warn("Unable to rollback rename operation. " + "originalDn: " + this.newDn + "; newDn:this. " + + this.originalDn); } } @@ -81,19 +82,19 @@ public class RenameOperationExecutor implements CompensatingTransactionOperation */ public void performOperation() { log.debug("Performing rename operation"); - ldapOperations.rename(originalDn, newDn); + this.ldapOperations.rename(this.originalDn, this.newDn); } Name getNewDn() { - return newDn; + return this.newDn; } LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } Name getOriginalDn() { - return originalDn; + return this.originalDn; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorder.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorder.java index a09ff222..75bd210d 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorder.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorder.java @@ -59,11 +59,11 @@ public class RenameOperationRecorder implements CompensatingTransactionOperation } Name oldDn = LdapTransactionUtils.getArgumentAsName(args[0]); Name newDn = LdapTransactionUtils.getArgumentAsName(args[1]); - return new RenameOperationExecutor(ldapOperations, oldDn, newDn); + return new RenameOperationExecutor(this.ldapOperations, oldDn, newDn); } LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutor.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutor.java index ad2a89ea..9654427b 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutor.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutor.java @@ -62,10 +62,11 @@ public class UnbindOperationExecutor implements CompensatingTransactionOperation */ public void rollback() { try { - ldapOperations.rename(temporaryDn, originalDn); + this.ldapOperations.rename(this.temporaryDn, this.originalDn); } catch (Exception e) { - log.warn("Filed to rollback unbind operation, temporaryDn: " + temporaryDn + "; originalDn: " + originalDn); + log.warn("Filed to rollback unbind operation, temporaryDn: " + this.temporaryDn + "; originalDn:this. " + + this.originalDn); } } @@ -75,7 +76,7 @@ public class UnbindOperationExecutor implements CompensatingTransactionOperation */ public void commit() { log.debug("Committing unbind operation - unbinding temporary entry"); - ldapOperations.unbind(temporaryDn); + this.ldapOperations.unbind(this.temporaryDn); } /* @@ -84,19 +85,19 @@ public class UnbindOperationExecutor implements CompensatingTransactionOperation */ public void performOperation() { log.debug("Performing operation for unbind -" + " renaming to temporary entry."); - ldapOperations.rename(originalDn, temporaryDn); + this.ldapOperations.rename(this.originalDn, this.temporaryDn); } LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } Name getOriginalDn() { - return originalDn; + return this.originalDn; } Name getTemporaryDn() { - return temporaryDn; + return this.temporaryDn; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorder.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorder.java index ee013b05..f6aa6d39 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorder.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorder.java @@ -53,17 +53,17 @@ public class UnbindOperationRecorder implements CompensatingTransactionOperation */ public CompensatingTransactionOperationExecutor recordOperation(Object[] args) { Name dn = LdapTransactionUtils.getFirstArgumentAsName(args); - Name temporaryDn = renamingStrategy.getTemporaryName(dn); + Name temporaryDn = this.renamingStrategy.getTemporaryName(dn); - return new UnbindOperationExecutor(ldapOperations, dn, temporaryDn); + return new UnbindOperationExecutor(this.ldapOperations, dn, temporaryDn); } LdapOperations getLdapOperations() { - return ldapOperations; + return this.ldapOperations; } public TempEntryRenamingStrategy getRenamingStrategy() { - return renamingStrategy; + return this.renamingStrategy; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java index 9246acc6..813b3976 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java @@ -65,7 +65,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran */ protected Object doGetTransaction() { Object dataSourceTransactionObject = super.doGetTransaction(); - Object contextSourceTransactionObject = ldapManagerDelegate.doGetTransaction(); + Object contextSourceTransactionObject = this.ldapManagerDelegate.doGetTransaction(); return new ContextSourceAndDataSourceTransactionObject(contextSourceTransactionObject, dataSourceTransactionObject); @@ -81,7 +81,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran super.doBegin(actualTransactionObject.getDataSourceTransactionObject(), definition); try { - ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition); + this.ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition); } catch (TransactionException e) { // Failed to start LDAP transaction - make sure we clean up properly @@ -98,7 +98,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) transaction; super.doCleanupAfterCompletion(actualTransactionObject.getDataSourceTransactionObject()); - ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject()); + this.ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject()); } /* @@ -128,9 +128,9 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran + " proceeding to commit ldap resource."); } } - ldapManagerDelegate.doCommit(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(), - status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), - status.getSuspendedResources())); + this.ldapManagerDelegate.doCommit(new DefaultTransactionStatus( + actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(), + status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources())); } /* @@ -145,21 +145,21 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources())); - ldapManagerDelegate.doRollback(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(), - status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), - status.getSuspendedResources())); + this.ldapManagerDelegate.doRollback(new DefaultTransactionStatus( + actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(), + status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources())); } public ContextSource getContextSource() { - return ldapManagerDelegate.getContextSource(); + return this.ldapManagerDelegate.getContextSource(); } public void setContextSource(ContextSource contextSource) { - ldapManagerDelegate.setContextSource(contextSource); + this.ldapManagerDelegate.setContextSource(contextSource); } public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) { - ldapManagerDelegate.setRenamingStrategy(renamingStrategy); + this.ldapManagerDelegate.setRenamingStrategy(renamingStrategy); } private final static class ContextSourceAndDataSourceTransactionObject { @@ -175,11 +175,11 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran } public Object getDataSourceTransactionObject() { - return dataSourceTransactionObject; + return this.dataSourceTransactionObject; } public Object getLdapTransactionObject() { - return ldapTransactionObject; + return this.ldapTransactionObject; } } @@ -206,7 +206,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran public void afterPropertiesSet() { super.afterPropertiesSet(); - ldapManagerDelegate.checkRenamingStrategy(); + this.ldapManagerDelegate.checkRenamingStrategy(); } } \ No newline at end of file diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java index 9c5eccec..01bc9809 100755 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java @@ -66,7 +66,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa */ protected Object doGetTransaction() { Object dataSourceTransactionObject = super.doGetTransaction(); - Object contextSourceTransactionObject = ldapManagerDelegate.doGetTransaction(); + Object contextSourceTransactionObject = this.ldapManagerDelegate.doGetTransaction(); return new ContextSourceAndHibernateTransactionObject(contextSourceTransactionObject, dataSourceTransactionObject); @@ -82,7 +82,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa super.doBegin(actualTransactionObject.getHibernateTransactionObject(), definition); try { - ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition); + this.ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition); } catch (TransactionException e) { // Failed to start LDAP transaction - make sure we clean up properly @@ -99,7 +99,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction; super.doCleanupAfterCompletion(actualTransactionObject.getHibernateTransactionObject()); - ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject()); + this.ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject()); } /* @@ -129,9 +129,9 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa + " proceeding to commit ldap resource."); } } - ldapManagerDelegate.doCommit(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(), - status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), - status.getSuspendedResources())); + this.ldapManagerDelegate.doCommit(new DefaultTransactionStatus( + actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(), + status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources())); } /* @@ -145,21 +145,21 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources())); - ldapManagerDelegate.doRollback(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(), - status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), - status.getSuspendedResources())); + this.ldapManagerDelegate.doRollback(new DefaultTransactionStatus( + actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(), + status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources())); } public ContextSource getContextSource() { - return ldapManagerDelegate.getContextSource(); + return this.ldapManagerDelegate.getContextSource(); } public void setContextSource(ContextSource contextSource) { - ldapManagerDelegate.setContextSource(contextSource); + this.ldapManagerDelegate.setContextSource(contextSource); } public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) { - ldapManagerDelegate.setRenamingStrategy(renamingStrategy); + this.ldapManagerDelegate.setRenamingStrategy(renamingStrategy); } private static final class ContextSourceAndHibernateTransactionObject { @@ -175,11 +175,11 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } public Object getHibernateTransactionObject() { - return hibernateTransactionObject; + return this.hibernateTransactionObject; } public Object getLdapTransactionObject() { - return ldapTransactionObject; + return this.ldapTransactionObject; } } @@ -206,7 +206,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa public void afterPropertiesSet() { super.afterPropertiesSet(); - ldapManagerDelegate.checkRenamingStrategy(); + this.ldapManagerDelegate.checkRenamingStrategy(); } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManager.java index 845ca196..6adc5b07 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManager.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManager.java @@ -112,7 +112,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * java.lang.Object, org.springframework.transaction.TransactionDefinition) */ protected void doBegin(Object transaction, TransactionDefinition definition) { - delegate.doBegin(transaction, definition); + this.delegate.doBegin(transaction, definition); } /* @@ -120,7 +120,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * doCleanupAfterCompletion(java.lang.Object) */ protected void doCleanupAfterCompletion(Object transaction) { - delegate.doCleanupAfterCompletion(transaction); + this.delegate.doCleanupAfterCompletion(transaction); } /* @@ -129,7 +129,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * (org.springframework.transaction.support.DefaultTransactionStatus) */ protected void doCommit(DefaultTransactionStatus status) { - delegate.doCommit(status); + this.delegate.doCommit(status); } /* @@ -137,7 +137,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * doGetTransaction() */ protected Object doGetTransaction() { - return delegate.doGetTransaction(); + return this.delegate.doGetTransaction(); } /* @@ -145,7 +145,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * doRollback(org.springframework.transaction.support.DefaultTransactionStatus) */ protected void doRollback(DefaultTransactionStatus status) { - delegate.doRollback(status); + this.delegate.doRollback(status); } /** @@ -154,7 +154,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * @see ContextSourceTransactionManagerDelegate#getContextSource() */ public ContextSource getContextSource() { - return delegate.getContextSource(); + return this.delegate.getContextSource(); } /** @@ -163,7 +163,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * @see ContextSourceTransactionManagerDelegate#setContextSource(ContextSource) */ public void setContextSource(ContextSource contextSource) { - delegate.setContextSource(contextSource); + this.delegate.setContextSource(contextSource); } /** @@ -172,11 +172,11 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction * @see ContextSourceTransactionManagerDelegate#setRenamingStrategy(TempEntryRenamingStrategy) */ public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) { - delegate.setRenamingStrategy(renamingStrategy); + this.delegate.setRenamingStrategy(renamingStrategy); } public void afterPropertiesSet() throws Exception { - delegate.checkRenamingStrategy(); + this.delegate.checkRenamingStrategy(); } @Override diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java index e147176f..9107016d 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java @@ -75,7 +75,7 @@ public class ContextSourceTransactionManagerDelegate extends AbstractCompensatin } public ContextSource getContextSource() { - return contextSource; + return this.contextSource; } /* @@ -93,7 +93,7 @@ public class ContextSourceTransactionManagerDelegate extends AbstractCompensatin protected CompensatingTransactionHolderSupport getNewHolder() { DirContext newCtx = getContextSource().getReadWriteContext(); return new DirContextHolder(new DefaultCompensatingTransactionOperationManager( - new LdapCompensatingTransactionOperationFactory(renamingStrategy)), newCtx); + new LdapCompensatingTransactionOperationFactory(this.renamingStrategy)), newCtx); } /* @@ -126,7 +126,7 @@ public class ContextSourceTransactionManagerDelegate extends AbstractCompensatin } void checkRenamingStrategy() { - Assert.notNull(renamingStrategy, "RenamingStrategy must be specified"); + Assert.notNull(this.renamingStrategy, "RenamingStrategy must be specified"); } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/DirContextHolder.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/DirContextHolder.java index d9a566a8..8d2e0dc8 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/DirContextHolder.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/DirContextHolder.java @@ -55,7 +55,7 @@ public class DirContextHolder extends CompensatingTransactionHolderSupport { * Return the DirContext associated with the current transaction. */ public DirContext getCtx() { - return ctx; + return this.ctx; } /* @@ -63,7 +63,7 @@ public class DirContextHolder extends CompensatingTransactionHolderSupport { * CompensatingTransactionHolderSupport#getTransactedResource() */ protected Object getTransactedResource() { - return ctx; + return this.ctx; } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxy.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxy.java index bbab7574..8059493d 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxy.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxy.java @@ -49,7 +49,7 @@ public class TransactionAwareContextSourceProxy extends DelegatingBaseLdapPathCo @Override public ContextSource getTarget() { - return target; + return this.target; } @Override @@ -66,7 +66,7 @@ public class TransactionAwareContextSourceProxy extends DelegatingBaseLdapPathCo @Override public DirContext getReadWriteContext() { - DirContextHolder contextHolder = (DirContextHolder) TransactionSynchronizationManager.getResource(target); + DirContextHolder contextHolder = (DirContextHolder) TransactionSynchronizationManager.getResource(this.target); DirContext ctx = null; if (contextHolder != null) { @@ -74,17 +74,17 @@ public class TransactionAwareContextSourceProxy extends DelegatingBaseLdapPathCo } if (ctx == null) { - ctx = target.getReadWriteContext(); + ctx = this.target.getReadWriteContext(); if (contextHolder != null) { contextHolder.setCtx(ctx); } } - return getTransactionAwareDirContextProxy(ctx, target); + return getTransactionAwareDirContextProxy(ctx, this.target); } @Override public DirContext getContext(String principal, String credentials) { - return target.getContext(principal, credentials); + return this.target.getContext(principal, credentials); } } diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java index e0efa939..0ee72ec7 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java @@ -63,7 +63,7 @@ public class TransactionAwareDirContextInvocationHandler implements InvocationHa String methodName = method.getName(); if (methodName.equals("getTargetContext")) { - return target; + return this.target; } else if (methodName.equals("equals")) { // Only consider equal when proxies are identical. @@ -74,17 +74,17 @@ public class TransactionAwareDirContextInvocationHandler implements InvocationHa return hashCode(); } else if (methodName.equals("close")) { - doCloseConnection(target, contextSource); + doCloseConnection(this.target, this.contextSource); return null; } else if (LdapTransactionUtils.isSupportedWriteTransactionOperation(methodName)) { // Store transaction data and allow operation to proceed. - CompensatingTransactionUtils.performOperation(contextSource, target, method, args); + CompensatingTransactionUtils.performOperation(this.contextSource, this.target, method, args); return null; } else { try { - return method.invoke(target, args); + return method.invoke(this.target, args); } catch (InvocationTargetException e) { throw e.getTargetException(); diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategy.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategy.java index 92ee21e2..bc1e881b 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategy.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategy.java @@ -64,7 +64,7 @@ public class DefaultTempEntryRenamingStrategy implements TempEntryRenamingStrate // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); - temporaryName.add(new Rdn(leafNode + tempSuffix)); + temporaryName.add(new Rdn(leafNode + this.tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); @@ -78,7 +78,7 @@ public class DefaultTempEntryRenamingStrategy implements TempEntryRenamingStrate * @return the suffix. */ public String getTempSuffix() { - return tempSuffix; + return this.tempSuffix; } /** diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategy.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategy.java index c1e8c9b7..59ec98aa 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategy.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategy.java @@ -56,7 +56,7 @@ public class DifferentSubtreeTempEntryRenamingStrategy implements TempEntryRenam } public Name getSubtreeNode() { - return subtreeNode; + return this.subtreeNode; } public void setSubtreeNode(Name subtreeNode) { @@ -77,7 +77,7 @@ public class DifferentSubtreeTempEntryRenamingStrategy implements TempEntryRenam LdapName tempName = LdapUtils.newLdapName(originalName); try { String leafNode = tempName.get(tempName.size() - 1) + thisSequenceNo; - LdapName newName = LdapUtils.newLdapName(subtreeNode); + LdapName newName = LdapUtils.newLdapName(this.subtreeNode); newName.add(leafNode); return newName; diff --git a/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionHolderSupport.java b/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionHolderSupport.java index a4342752..8e60db58 100644 --- a/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionHolderSupport.java +++ b/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionHolderSupport.java @@ -48,7 +48,7 @@ public abstract class CompensatingTransactionHolderSupport extends ResourceHolde */ public void clear() { super.clear(); - transactionOperationManager = null; + this.transactionOperationManager = null; } /** @@ -57,7 +57,7 @@ public abstract class CompensatingTransactionHolderSupport extends ResourceHolde * @return the CompensatingTransactionOperationManager. */ public CompensatingTransactionOperationManager getTransactionOperationManager() { - return transactionOperationManager; + return this.transactionOperationManager; } /** diff --git a/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionObject.java b/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionObject.java index 7bb8599d..648a8e2f 100644 --- a/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionObject.java +++ b/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionObject.java @@ -41,7 +41,7 @@ public class CompensatingTransactionObject { * @return the DirContextHolder. */ public CompensatingTransactionHolderSupport getHolder() { - return holder; + return this.holder; } /** diff --git a/core/src/main/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManager.java b/core/src/main/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManager.java index e1e3a7b9..14face0b 100644 --- a/core/src/main/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManager.java +++ b/core/src/main/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManager.java @@ -55,14 +55,14 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat * java.lang.String, java.lang.Object[]) */ public void performOperation(Object resource, String operation, Object[] args) { - CompensatingTransactionOperationRecorder recorder = operationFactory.createRecordingOperation(resource, + CompensatingTransactionOperationRecorder recorder = this.operationFactory.createRecordingOperation(resource, operation); CompensatingTransactionOperationExecutor executor = recorder.recordOperation(args); executor.performOperation(); // Don't push the executor until the actual operation passed. - operationExecutors.push(executor); + this.operationExecutors.push(executor); } /* @@ -71,8 +71,8 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat */ public void rollback() { log.debug("Performing rollback"); - while (!operationExecutors.isEmpty()) { - CompensatingTransactionOperationExecutor rollbackOperation = operationExecutors.pop(); + while (!this.operationExecutors.isEmpty()) { + CompensatingTransactionOperationExecutor rollbackOperation = this.operationExecutors.pop(); try { rollbackOperation.rollback(); } @@ -87,7 +87,7 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat * @return the rollback operations. */ protected Stack getOperationExecutors() { - return operationExecutors; + return this.operationExecutors; } /** @@ -104,7 +104,7 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat */ public void commit() { log.debug("Performing commit"); - for (CompensatingTransactionOperationExecutor operationExecutor : operationExecutors) { + for (CompensatingTransactionOperationExecutor operationExecutor : this.operationExecutors) { try { operationExecutor.commit(); } diff --git a/core/src/test/java/org/springframework/ldap/NamingExceptionTest.java b/core/src/test/java/org/springframework/ldap/NamingExceptionTest.java index 4af91715..92edd256 100644 --- a/core/src/test/java/org/springframework/ldap/NamingExceptionTest.java +++ b/core/src/test/java/org/springframework/ldap/NamingExceptionTest.java @@ -50,7 +50,7 @@ public class NamingExceptionTest { } private NamingException readFromStream() throws IOException, ClassNotFoundException { - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.byteArrayOutputStream.toByteArray()); ObjectInputStream in = new ObjectInputStream(byteArrayInputStream); NamingException deSerializedException; try { @@ -63,8 +63,8 @@ public class NamingExceptionTest { } private void writeToStream(NamingException exception) throws IOException { - byteArrayOutputStream = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(byteArrayOutputStream); + this.byteArrayOutputStream = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(this.byteArrayOutputStream); try { out.writeObject(exception); out.flush(); diff --git a/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTest.java b/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTest.java index 19bf4fb3..8e2c847f 100644 --- a/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTest.java +++ b/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTest.java @@ -36,55 +36,55 @@ public class DefaultValuesAuthenticationSourceDecoratorTest { @Before public void setUp() throws Exception { - authenticationSourceMock = mock(AuthenticationSource.class); - tested = new DefaultValuesAuthenticationSourceDecorator(); - tested.setDefaultUser(DEFAULT_USER); - tested.setDefaultPassword(DEFAULT_PASSWORD); - tested.setTarget(authenticationSourceMock); + this.authenticationSourceMock = mock(AuthenticationSource.class); + this.tested = new DefaultValuesAuthenticationSourceDecorator(); + this.tested.setDefaultUser(DEFAULT_USER); + this.tested.setDefaultPassword(DEFAULT_PASSWORD); + this.tested.setTarget(this.authenticationSourceMock); } @Test public void testGetPrincipal_TargetHasPrincipal() { - when(authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser"); - String principal = tested.getPrincipal(); + when(this.authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser"); + String principal = this.tested.getPrincipal(); assertThat(principal).isEqualTo("cn=someUser"); } @Test public void testGetPrincipal_TargetHasNoPrincipal() { - when(authenticationSourceMock.getPrincipal()).thenReturn(""); + when(this.authenticationSourceMock.getPrincipal()).thenReturn(""); - String principal = tested.getPrincipal(); + String principal = this.tested.getPrincipal(); assertThat(principal).isEqualTo(DEFAULT_USER); } @Test public void testGetCredentials_TargetHasPrincipal() { - when(authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser"); - when(authenticationSourceMock.getCredentials()).thenReturn("somepassword"); + when(this.authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser"); + when(this.authenticationSourceMock.getCredentials()).thenReturn("somepassword"); - String credentials = tested.getCredentials(); + String credentials = this.tested.getCredentials(); assertThat(credentials).isEqualTo("somepassword"); } @Test public void testGetCredentials_TargetHasNoPrincipal() { - when(authenticationSourceMock.getPrincipal()).thenReturn(""); - when(authenticationSourceMock.getCredentials()).thenReturn("somepassword"); + when(this.authenticationSourceMock.getPrincipal()).thenReturn(""); + when(this.authenticationSourceMock.getCredentials()).thenReturn("somepassword"); - String credentials = tested.getCredentials(); + String credentials = this.tested.getCredentials(); assertThat(credentials).isEqualTo(DEFAULT_PASSWORD); } @Test public void testAfterPropertiesSet_noTarget() throws Exception { - tested.setTarget(null); + this.tested.setTarget(null); try { - tested.afterPropertiesSet(); + this.tested.afterPropertiesSet(); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { @@ -94,9 +94,9 @@ public class DefaultValuesAuthenticationSourceDecoratorTest { @Test public void testAfterPropertiesSet_noDefaultUser() throws Exception { - tested.setDefaultUser(null); + this.tested.setDefaultUser(null); try { - tested.afterPropertiesSet(); + this.tested.afterPropertiesSet(); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { @@ -106,9 +106,9 @@ public class DefaultValuesAuthenticationSourceDecoratorTest { @Test public void testAfterPropertiesSet_noDefaultPassword() throws Exception { - tested.setDefaultPassword(null); + this.tested.setDefaultPassword(null); try { - tested.afterPropertiesSet(); + this.tested.afterPropertiesSet(); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { diff --git a/core/src/test/java/org/springframework/ldap/config/MockFactoryBean.java b/core/src/test/java/org/springframework/ldap/config/MockFactoryBean.java index 8d5e9e23..6e1dabca 100644 --- a/core/src/test/java/org/springframework/ldap/config/MockFactoryBean.java +++ b/core/src/test/java/org/springframework/ldap/config/MockFactoryBean.java @@ -33,12 +33,12 @@ public class MockFactoryBean extends AbstractFactoryBean { @Override public Class getObjectType() { - return clazz; + return this.clazz; } @Override protected Object createInstance() throws Exception { - return mock(clazz); + return mock(this.clazz); } } diff --git a/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTest.java b/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTest.java index ab5ac339..c8af605b 100644 --- a/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTest.java +++ b/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTest.java @@ -42,22 +42,22 @@ public class PagedResultsDirContextProcessorTest { @Before public void setUp() throws Exception { - tested = new PagedResultsDirContextProcessor(20); + this.tested = new PagedResultsDirContextProcessor(20); // Create ldapContext mock - ldapContextMock = mock(LdapContext.class); + this.ldapContextMock = mock(LdapContext.class); } @After public void tearDown() throws Exception { - tested = null; - ldapContextMock = null; + this.tested = null; + this.ldapContextMock = null; } @Test public void testCreateRequestControl() throws Exception { - PagedResultsControl control = (PagedResultsControl) tested.createRequestControl(); + PagedResultsControl control = (PagedResultsControl) this.tested.createRequestControl(); assertThat(control).isNotNull(); } @@ -80,13 +80,13 @@ public class PagedResultsDirContextProcessorTest { byte[] cookie = encodeValue(resultSize, value); PagedResultsResponseControl control = new PagedResultsResponseControl("dummy", true, cookie); - when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); - tested.postProcess(ldapContextMock); + when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); + this.tested.postProcess(this.ldapContextMock); - PagedResultsCookie returnedCookie = tested.getCookie(); + PagedResultsCookie returnedCookie = this.tested.getCookie(); assertThat(returnedCookie.getCookie()[0]).isEqualTo((byte) 8); - assertThat(tested.getPageSize()).isEqualTo(20); - assertThat(tested.getResultSize()).isEqualTo(50); + assertThat(this.tested.getPageSize()).isEqualTo(20); + assertThat(this.tested.getResultSize()).isEqualTo(50); } @Test @@ -101,23 +101,23 @@ public class PagedResultsDirContextProcessorTest { // Using another response control to verify that it is ignored DirSyncResponseControl control = new DirSyncResponseControl("dummy", true, cookie); - when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); - tested.postProcess(ldapContextMock); + when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); + this.tested.postProcess(this.ldapContextMock); - assertThat(tested.getCookie()).isNull(); - assertThat(tested.getPageSize()).isEqualTo(20); - assertThat(tested.getResultSize()).isEqualTo(0); + assertThat(this.tested.getCookie()).isNull(); + assertThat(this.tested.getPageSize()).isEqualTo(20); + assertThat(this.tested.getResultSize()).isEqualTo(0); } @Test public void testPostProcess_NoResponseControls() throws Exception { - when(ldapContextMock.getResponseControls()).thenReturn(null); + when(this.ldapContextMock.getResponseControls()).thenReturn(null); - tested.postProcess(ldapContextMock); + this.tested.postProcess(this.ldapContextMock); - assertThat(tested.getCookie()).isNull(); - assertThat(tested.getPageSize()).isEqualTo(20); - assertThat(tested.getResultSize()).isEqualTo(0); + assertThat(this.tested.getCookie()).isNull(); + assertThat(this.tested.getPageSize()).isEqualTo(20); + assertThat(this.tested.getResultSize()).isEqualTo(0); } @Test diff --git a/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTest.java b/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTest.java index 9b21d6b9..cda46df0 100644 --- a/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTest.java +++ b/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTest.java @@ -44,21 +44,21 @@ public class RequestControlDirContextProcessorTest { @Before public void setUp() throws Exception { // Create requestControl mock - requestControlMock = mock(Control.class); + this.requestControlMock = mock(Control.class); // Create requestControl2 mock - requestControl2Mock = mock(Control.class); + this.requestControl2Mock = mock(Control.class); // Create ldapContext mock - ldapContextMock = mock(LdapContext.class); + this.ldapContextMock = mock(LdapContext.class); // Create dirContext mock - dirContextMock = mock(DirContext.class); + this.dirContextMock = mock(DirContext.class); - tested = new AbstractRequestControlDirContextProcessor() { + this.tested = new AbstractRequestControlDirContextProcessor() { public Control createRequestControl() { - return requestControlMock; + return RequestControlDirContextProcessorTest.this.requestControlMock; } public void postProcess(DirContext ctx) throws NamingException { @@ -69,63 +69,64 @@ public class RequestControlDirContextProcessorTest { @After public void tearDown() throws Exception { - requestControlMock = null; - requestControl2Mock = null; - ldapContextMock = null; - dirContextMock = null; + this.requestControlMock = null; + this.requestControl2Mock = null; + this.ldapContextMock = null; + this.dirContextMock = null; } @Test public void testPreProcessWithExistingControlOfDifferentClassShouldAdd() throws Exception { SortControl existingControl = new SortControl(new String[] { "cn" }, true); - when(ldapContextMock.getRequestControls()).thenReturn(new Control[] { existingControl }); + when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[] { existingControl }); - tested.preProcess(ldapContextMock); + this.tested.preProcess(this.ldapContextMock); - verify(ldapContextMock).setRequestControls(new Control[] { existingControl, requestControlMock }); + verify(this.ldapContextMock).setRequestControls(new Control[] { existingControl, this.requestControlMock }); } @Test public void testPreProcessWithExistingControlOfSameClassShouldReplace() throws Exception { - when(ldapContextMock.getRequestControls()).thenReturn(new Control[] { requestControl2Mock }); + when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[] { this.requestControl2Mock }); - tested.preProcess(ldapContextMock); + this.tested.preProcess(this.ldapContextMock); - verify(ldapContextMock).setRequestControls(new Control[] { requestControlMock }); + verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock }); } @Test public void testPreProcessWithExistingControlOfSameClassAndPropertyFalseShouldAdd() throws Exception { - when(ldapContextMock.getRequestControls()).thenReturn(new Control[] { requestControl2Mock }); + when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[] { this.requestControl2Mock }); - tested.setReplaceSameControlEnabled(false); - tested.preProcess(ldapContextMock); + this.tested.setReplaceSameControlEnabled(false); + this.tested.preProcess(this.ldapContextMock); - verify(ldapContextMock).setRequestControls(new Control[] { requestControl2Mock, requestControlMock }); + verify(this.ldapContextMock) + .setRequestControls(new Control[] { this.requestControl2Mock, this.requestControlMock }); } @Test public void testPreProcessWithNoExistingControlsShouldAdd() throws NamingException { - when(ldapContextMock.getRequestControls()).thenReturn(new Control[0]); + when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[0]); - tested.preProcess(ldapContextMock); + this.tested.preProcess(this.ldapContextMock); - verify(ldapContextMock).setRequestControls(new Control[] { requestControlMock }); + verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock }); } @Test public void testPreProcessWithNullControlsShouldAdd() throws NamingException { - when(ldapContextMock.getRequestControls()).thenReturn(null); + when(this.ldapContextMock.getRequestControls()).thenReturn(null); - tested.preProcess(ldapContextMock); + this.tested.preProcess(this.ldapContextMock); - verify(ldapContextMock).setRequestControls(new Control[] { requestControlMock }); + verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock }); } @Test(expected = IllegalArgumentException.class) public void testPreProcessWhenNotLdapContextShouldFail() throws Exception { - tested.preProcess(dirContextMock); + this.tested.preProcess(this.dirContextMock); } } diff --git a/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTest.java b/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTest.java index a9bee451..cb619839 100644 --- a/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTest.java +++ b/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTest.java @@ -45,15 +45,15 @@ public class SortControlDirContextProcessorTest { @Before public void setUp() throws Exception { - tested = new SortControlDirContextProcessor("key"); + this.tested = new SortControlDirContextProcessor("key"); // Create ldapContext mock - ldapContextMock = mock(LdapContext.class); + this.ldapContextMock = mock(LdapContext.class); } @Test public void testCreateRequestControl() throws Exception { - SortControl result = (SortControl) tested.createRequestControl(); + SortControl result = (SortControl) this.tested.createRequestControl(); assertThat(result).isNotNull(); assertThat(result.getID()).isEqualTo("1.2.840.113556.1.4.473"); assertThat(result.getEncodedValue().length).isEqualTo(9); @@ -66,12 +66,12 @@ public class SortControlDirContextProcessorTest { byte[] value = encodeValue(sortResult); SortResponseControl control = new SortResponseControl("dummy", true, value); - when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); + when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); - tested.postProcess(ldapContextMock); + this.tested.postProcess(this.ldapContextMock); - assertThat(tested.isSorted()).isEqualTo(true); - assertThat(tested.getResultCode()).isEqualTo(0); + assertThat(this.tested.isSorted()).isEqualTo(true); + assertThat(this.tested.getResultCode()).isEqualTo(0); } @Test @@ -81,12 +81,12 @@ public class SortControlDirContextProcessorTest { byte[] value = encodeValue(sortResult); SortResponseControl control = new SortResponseControl("dummy", true, value); - when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); + when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); - tested.postProcess(ldapContextMock); + this.tested.postProcess(this.ldapContextMock); - assertThat(tested.isSorted()).isEqualTo(false); - assertThat(tested.getResultCode()).isEqualTo(1); + assertThat(this.tested.isSorted()).isEqualTo(false); + assertThat(this.tested.getResultCode()).isEqualTo(1); } @Test @@ -101,11 +101,11 @@ public class SortControlDirContextProcessorTest { // Using another response control to verify that it is ignored DirSyncResponseControl control = new DirSyncResponseControl("dummy", true, cookie); - when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); + when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); - tested.postProcess(ldapContextMock); + this.tested.postProcess(this.ldapContextMock); - assertThat(tested.isSorted()).isEqualTo(false); + assertThat(this.tested.isSorted()).isEqualTo(false); } @Test diff --git a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java index e5aac0fd..7bc412ea 100644 --- a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java +++ b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java @@ -36,22 +36,23 @@ public class CollectingNameClassPairCallbackHandlerTest { @Before public void setUp() throws Exception { - expectedResult = new Object(); - expectedNameClassPair = new NameClassPair(null, null); - tested = new CollectingNameClassPairCallbackHandler() { + this.expectedResult = new Object(); + this.expectedNameClassPair = new NameClassPair(null, null); + this.tested = new CollectingNameClassPairCallbackHandler() { public Object getObjectFromNameClassPair(NameClassPair nameClassPair) { - assertThat(nameClassPair).isSameAs(expectedNameClassPair); - return expectedResult; + assertThat(nameClassPair) + .isSameAs(CollectingNameClassPairCallbackHandlerTest.this.expectedNameClassPair); + return CollectingNameClassPairCallbackHandlerTest.this.expectedResult; } }; } @Test public void testHandleNameClassPair() throws NamingException { - tested.handleNameClassPair(expectedNameClassPair); - List result = tested.getList(); + this.tested.handleNameClassPair(this.expectedNameClassPair); + List result = this.tested.getList(); assertThat(result).hasSize(1); - assertThat(result.get(0)).isSameAs(expectedResult); + assertThat(result.get(0)).isSameAs(this.expectedResult); } } diff --git a/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java b/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java index 9ab871c5..7d354cb1 100644 --- a/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java +++ b/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java @@ -33,8 +33,8 @@ public class ContextMapperCallbackHandlerTest { @Before public void setUp() throws Exception { - mapperMock = mock(ContextMapper.class); - tested = new ContextMapperCallbackHandler(mapperMock); + this.mapperMock = mock(ContextMapper.class); + this.tested = new ContextMapperCallbackHandler(this.mapperMock); } @Test(expected = IllegalArgumentException.class) @@ -48,15 +48,15 @@ public class ContextMapperCallbackHandlerTest { Object expectedResult = "result"; Binding expectedBinding = new Binding("some name", expectedObject); - when(mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - Object actualResult = tested.getObjectFromNameClassPair(expectedBinding); + when(this.mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + Object actualResult = this.tested.getObjectFromNameClassPair(expectedBinding); assertThat(actualResult).isEqualTo(expectedResult); } @Test(expected = ObjectRetrievalException.class) public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException { Binding expectedBinding = new Binding("some name", null); - tested.getObjectFromNameClassPair(expectedBinding); + this.tested.getObjectFromNameClassPair(expectedBinding); } } diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTest.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTest.java index f663d2ee..e9299d6d 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTest.java @@ -67,38 +67,38 @@ public class DefaultLdapClientListTest { @Before public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); // Setup NamingEnumeration mock - namingEnumerationMock = mock(NamingEnumeration.class); + this.namingEnumerationMock = mock(NamingEnumeration.class); - contextMapperMock = mock(ContextMapper.class); + this.contextMapperMock = mock(ContextMapper.class); - tested = (DefaultLdapClient) LdapClient.create(contextSourceMock); + this.tested = (DefaultLdapClient) LdapClient.create(this.contextSourceMock); } private void expectGetReadOnlyContext() { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); } private void setupListAndNamingEnumeration(NameClassPair listResult) throws NamingException { - when(dirContextMock.list(nameMock)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.list(this.nameMock)).thenReturn(this.namingEnumerationMock); setupNamingEnumeration(listResult); } private void setupListBindingsAndNamingEnumeration(NameClassPair listResult) throws NamingException { - when(dirContextMock.listBindings(nameMock)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(this.nameMock)).thenReturn(this.namingEnumerationMock); setupNamingEnumeration(listResult); } private void setupNamingEnumeration(NameClassPair listResult) throws NamingException { - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(listResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(listResult); } @Test @@ -109,10 +109,10 @@ public class DefaultLdapClientListTest { setupListAndNamingEnumeration(listResult); - List list = tested.list(nameMock).toList(NameClassPair::getName); + List list = this.tested.list(this.nameMock).toList(NameClassPair::getName); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -127,10 +127,10 @@ public class DefaultLdapClientListTest { setupListAndNamingEnumeration(listResult); - List list = tested.list(NAME).toList(NameClassPair::getName); + List list = this.tested.list(NAME).toList(NameClassPair::getName); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -141,24 +141,24 @@ public class DefaultLdapClientListTest { public void testList_PartialResultException() throws NamingException { expectGetReadOnlyContext(); javax.naming.PartialResultException pre = new javax.naming.PartialResultException(); - when(dirContextMock.list(nameMock)).thenThrow(pre); + when(this.dirContextMock.list(this.nameMock)).thenThrow(pre); assertThatExceptionOfType(PartialResultException.class) - .isThrownBy(() -> tested.list(NAME).toList(NameClassPair::getName)); + .isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName)); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testList_Stream_PartialResultException() throws NamingException { expectGetReadOnlyContext(); javax.naming.PartialResultException pre = new javax.naming.PartialResultException(); - when(dirContextMock.list(nameMock)).thenThrow(pre); + when(this.dirContextMock.list(this.nameMock)).thenThrow(pre); assertThatExceptionOfType(PartialResultException.class) - .isThrownBy(() -> tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList())); + .isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList())); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -166,13 +166,13 @@ public class DefaultLdapClientListTest { expectGetReadOnlyContext(); javax.naming.PartialResultException pre = new javax.naming.PartialResultException(); - when(dirContextMock.list(this.nameMock)).thenThrow(pre); + when(this.dirContextMock.list(this.nameMock)).thenThrow(pre); - tested.setIgnorePartialResultException(true); + this.tested.setIgnorePartialResultException(true); - List list = tested.list(NAME).toList(NameClassPair::getName); + List list = this.tested.list(NAME).toList(NameClassPair::getName); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).isEmpty(); @@ -183,37 +183,37 @@ public class DefaultLdapClientListTest { expectGetReadOnlyContext(); javax.naming.PartialResultException pre = new javax.naming.PartialResultException(); - when(dirContextMock.list(this.nameMock)).thenThrow(pre); + when(this.dirContextMock.list(this.nameMock)).thenThrow(pre); - tested.setIgnorePartialResultException(true); + this.tested.setIgnorePartialResultException(true); - try (Stream results = tested.list(NAME).toStream(NameClassPair::getName)) { + try (Stream results = this.tested.list(NAME).toStream(NameClassPair::getName)) { List list = results.collect(Collectors.toList()); assertThat(list).isNotNull(); assertThat(list).isEmpty(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testList_NamingException() throws NamingException { expectGetReadOnlyContext(); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(dirContextMock.list(nameMock)).thenThrow(ne); + when(this.dirContextMock.list(this.nameMock)).thenThrow(ne); assertThatExceptionOfType(LimitExceededException.class) - .isThrownBy(() -> tested.list(NAME).toList(NameClassPair::getName)); - verify(dirContextMock).close(); + .isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName)); + verify(this.dirContextMock).close(); } @Test public void testList_AsStream_NamingException() throws NamingException { expectGetReadOnlyContext(); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(dirContextMock.list(nameMock)).thenThrow(ne); + when(this.dirContextMock.list(this.nameMock)).thenThrow(ne); assertThatExceptionOfType(LimitExceededException.class) - .isThrownBy(() -> tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList())); - verify(dirContextMock).close(); + .isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList())); + verify(this.dirContextMock).close(); } // Tests for listBindings @@ -226,10 +226,10 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); - List list = tested.listBindings(NAME).toList(NameClassPair::getName); + List list = this.tested.listBindings(NAME).toList(NameClassPair::getName); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -244,15 +244,15 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); - try (Stream results = tested.listBindings(NAME).toStream(NameClassPair::getName)) { + try (Stream results = this.tested.listBindings(NAME).toStream(NameClassPair::getName)) { List list = results.collect(Collectors.toList()); assertThat(list).isNotNull(); assertThat(list).hasSize(1); assertThat(list.get(0)).isSameAs(NAME); } - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); } @Test @@ -263,10 +263,10 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); - List list = tested.listBindings(nameMock).toList(NameClassPair::getName); + List list = this.tested.listBindings(this.nameMock).toList(NameClassPair::getName); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -281,15 +281,15 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); - try (Stream results = tested.listBindings(nameMock).toStream(NameClassPair::getName)) { + try (Stream results = this.tested.listBindings(this.nameMock).toStream(NameClassPair::getName)) { List list = results.collect(Collectors.toList()); assertThat(list).isNotNull(); assertThat(list).hasSize(1); assertThat(list.get(0)).isSameAs(NAME); } - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); } @Test @@ -302,12 +302,12 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.listBindings(NAME).toList(contextMapperMock); + List list = this.tested.listBindings(NAME).toList(this.contextMapperMock); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -324,17 +324,17 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - try (Stream results = tested.listBindings(NAME).toStream(contextMapperMock)) { + try (Stream results = this.tested.listBindings(NAME).toStream(this.contextMapperMock)) { List list = results.collect(Collectors.toList()); assertThat(list).isNotNull(); assertThat(list).hasSize(1); assertThat(list.get(0)).isSameAs(expectedResult); } - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); } @Test @@ -347,12 +347,12 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.listBindings(nameMock).toList(contextMapperMock); + List list = this.tested.listBindings(this.nameMock).toList(this.contextMapperMock); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -369,17 +369,17 @@ public class DefaultLdapClientListTest { setupListBindingsAndNamingEnumeration(listResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - try (Stream results = tested.listBindings(nameMock).toStream(contextMapperMock)) { + try (Stream results = this.tested.listBindings(this.nameMock).toStream(this.contextMapperMock)) { List list = results.collect(Collectors.toList()); assertThat(list).isNotNull(); assertThat(list).hasSize(1); assertThat(list.get(0)).isSameAs(expectedResult); } - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); } } diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTest.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTest.java index 559d031a..e520a0a3 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTest.java @@ -58,13 +58,13 @@ public class DefaultLdapClientLookupTest { @Before public void setUp() throws Exception { - contextSourceMock = mock(ContextSource.class); - dirContextMock = mock(LdapContext.class); - tested = LdapClient.create(contextSourceMock); + this.contextSourceMock = mock(ContextSource.class); + this.dirContextMock = mock(LdapContext.class); + this.tested = LdapClient.create(this.contextSourceMock); } private void expectGetReadOnlyContext() { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); } @Test @@ -72,11 +72,11 @@ public class DefaultLdapClientLookupTest { expectGetReadOnlyContext(); LdapDataEntry expected = new DirContextAdapter(); - whenSearching(name).thenReturn(result(expected, null)); + whenSearching(this.name).thenReturn(result(expected, null)); - LdapDataEntry actual = tested.search().name(name).toEntry(); + LdapDataEntry actual = this.tested.search().name(this.name).toEntry(); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -87,9 +87,9 @@ public class DefaultLdapClientLookupTest { LdapDataEntry expected = new DirContextAdapter(); whenSearching(DEFAULT_BASE).thenReturn(result(expected, null)); - LdapDataEntry actual = tested.search().name(DEFAULT_BASE.toString()).toEntry(); + LdapDataEntry actual = this.tested.search().name(DEFAULT_BASE.toString()).toEntry(); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -98,11 +98,11 @@ public class DefaultLdapClientLookupTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - whenSearching(name).thenThrow(ne); + whenSearching(this.name).thenThrow(ne); assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected") - .isThrownBy(() -> tested.search().name(name).toEntry()); - verify(dirContextMock).close(); + .isThrownBy(() -> this.tested.search().name(this.name).toEntry()); + verify(this.dirContextMock).close(); } @Test @@ -110,12 +110,12 @@ public class DefaultLdapClientLookupTest { expectGetReadOnlyContext(); Attributes expected = new BasicAttributes(); - whenSearching(name).thenReturn(result(null, expected)); + whenSearching(this.name).thenReturn(result(null, expected)); AttributesMapper mapper = (attributes) -> attributes; - Attributes actual = tested.search().name(name).toObject(mapper); + Attributes actual = this.tested.search().name(this.name).toObject(mapper); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -127,9 +127,9 @@ public class DefaultLdapClientLookupTest { whenSearching(DEFAULT_BASE).thenReturn(result(null, expected)); AttributesMapper mapper = (attributes) -> attributes; - Attributes actual = tested.search().name(DEFAULT_BASE.toString()).toObject(mapper); + Attributes actual = this.tested.search().name(DEFAULT_BASE.toString()).toObject(mapper); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -138,12 +138,12 @@ public class DefaultLdapClientLookupTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - whenSearching(name).thenThrow(ne); + whenSearching(this.name).thenThrow(ne); AttributesMapper mapper = (attributes) -> attributes; assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected") - .isThrownBy(() -> tested.search().name(name).toObject(mapper)); - verify(dirContextMock).close(); + .isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper)); + verify(this.dirContextMock).close(); } // Tests for lookup(name, ContextMapper) @@ -153,12 +153,12 @@ public class DefaultLdapClientLookupTest { expectGetReadOnlyContext(); Object expected = new Object(); - whenSearching(name).thenReturn(result(expected, null)); + whenSearching(this.name).thenReturn(result(expected, null)); ContextMapper mapper = (ctx) -> ctx; - Object actual = tested.search().name(name).toObject(mapper); + Object actual = this.tested.search().name(this.name).toObject(mapper); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -170,9 +170,9 @@ public class DefaultLdapClientLookupTest { whenSearching(DEFAULT_BASE).thenReturn(result(expected, null)); ContextMapper mapper = (ctx) -> ctx; - Object actual = tested.search().name(DEFAULT_BASE.toString()).toObject(mapper); + Object actual = this.tested.search().name(DEFAULT_BASE.toString()).toObject(mapper); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -181,12 +181,12 @@ public class DefaultLdapClientLookupTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - whenSearching(name).thenThrow(ne); + whenSearching(this.name).thenThrow(ne); ContextMapper mapper = (ctx) -> ctx; assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected") - .isThrownBy(() -> tested.search().name(name).toObject(mapper)); - verify(dirContextMock).close(); + .isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper)); + verify(this.dirContextMock).close(); } private static NamingEnumeration result(Object object, Attributes attributes) { @@ -198,7 +198,7 @@ public class DefaultLdapClientLookupTest { } private OngoingStubbing> whenSearching(Name name) throws Exception { - return when(dirContextMock.search(eq(name), anyString(), any())); + return when(this.dirContextMock.search(eq(name), anyString(), any())); } private static class NamingEnumeration implements javax.naming.NamingEnumeration { @@ -206,7 +206,7 @@ public class DefaultLdapClientLookupTest { private final Iterator names; public NamingEnumeration(SearchResult... results) { - names = Arrays.asList(results).iterator(); + this.names = Arrays.asList(results).iterator(); } @Override diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTest.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTest.java index 7e6e8c61..97f25f69 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTest.java @@ -54,26 +54,26 @@ public class DefaultLdapClientRenameTest { @Before public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); - tested = LdapClient.create(contextSourceMock); + this.tested = LdapClient.create(this.contextSourceMock); } private void expectGetReadWriteContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); } @Test public void testRename() throws Exception { expectGetReadWriteContext(); - tested.modify(oldName).name(newName).execute(); + this.tested.modify(this.oldName).name(this.newName).execute(); - verify(dirContextMock).rename(oldName, newName); - verify(dirContextMock).close(); + verify(this.dirContextMock).rename(this.oldName, this.newName); + verify(this.dirContextMock).close(); } @Test @@ -81,17 +81,17 @@ public class DefaultLdapClientRenameTest { expectGetReadWriteContext(); javax.naming.NameAlreadyBoundException ne = new javax.naming.NameAlreadyBoundException(); - doThrow(ne).when(dirContextMock).rename(oldName, newName); + doThrow(ne).when(this.dirContextMock).rename(this.oldName, this.newName); try { - tested.modify(oldName).name(newName).execute(); + this.tested.modify(this.oldName).name(this.newName).execute(); fail("NameAlreadyBoundException expected"); } catch (NameAlreadyBoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -100,28 +100,28 @@ public class DefaultLdapClientRenameTest { javax.naming.NamingException ne = new javax.naming.NamingException(); - doThrow(ne).when(dirContextMock).rename(oldName, newName); + doThrow(ne).when(this.dirContextMock).rename(this.oldName, this.newName); try { - tested.modify(oldName).name(newName).execute(); + this.tested.modify(this.oldName).name(this.newName).execute(); fail("UncategorizedLdapException expected"); } catch (UncategorizedLdapException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testRename_String() throws Exception { expectGetReadWriteContext(); - tested.modify("o=example.com").name("o=somethingelse.com").execute(); + this.tested.modify("o=example.com").name("o=somethingelse.com").execute(); - verify(dirContextMock).rename(LdapUtils.newLdapName("o=example.com"), + verify(this.dirContextMock).rename(LdapUtils.newLdapName("o=example.com"), LdapUtils.newLdapName("o=somethingelse.com")); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } } diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTest.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTest.java index 8f5e35d0..629a2bd3 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTest.java @@ -106,36 +106,36 @@ public class DefaultLdapClientTest { public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); // Setup NamingEnumeration mock - namingEnumerationMock = mock(NamingEnumeration.class); + this.namingEnumerationMock = mock(NamingEnumeration.class); // Setup Name mock - nameMock = LdapUtils.emptyLdapName(); + this.nameMock = LdapUtils.emptyLdapName(); // Setup Handler mock - handlerMock = mock(NameClassPairCallbackHandler.class); - contextMapperMock = mock(ContextMapper.class); - attributesMapperMock = mock(AttributesMapper.class); - contextExecutorMock = mock(ContextExecutor.class); - searchExecutorMock = mock(SearchExecutor.class); - dirContextProcessorMock = mock(DirContextProcessor.class); - dirContextOperationsMock = mock(DirContextOperations.class); - authenticatedContextMock = mock(DirContext.class); - entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class); - odmMock = mock(ObjectDirectoryMapper.class); - query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user"); - authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class); + this.handlerMock = mock(NameClassPairCallbackHandler.class); + this.contextMapperMock = mock(ContextMapper.class); + this.attributesMapperMock = mock(AttributesMapper.class); + this.contextExecutorMock = mock(ContextExecutor.class); + this.searchExecutorMock = mock(SearchExecutor.class); + this.dirContextProcessorMock = mock(DirContextProcessor.class); + this.dirContextOperationsMock = mock(DirContextOperations.class); + this.authenticatedContextMock = mock(DirContext.class); + this.entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class); + this.odmMock = mock(ObjectDirectoryMapper.class); + this.query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user"); + this.authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class); - tested = LdapClient.create(contextSourceMock); + this.tested = LdapClient.create(this.contextSourceMock); } private void expectGetReadWriteContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); } private void expectGetReadOnlyContext() { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); } @Test @@ -146,12 +146,12 @@ public class DefaultLdapClientTest { singleSearchResult(searchControlsOneLevel(), searchResult); - tested.search() - .query((builder) -> builder.base(nameMock).searchScope(SearchScope.ONELEVEL).filter("(ou=somevalue)")) - .toObject(contextMapperMock); + this.tested.search().query( + (builder) -> builder.base(this.nameMock).searchScope(SearchScope.ONELEVEL).filter("(ou=somevalue)")) + .toObject(this.contextMapperMock); - verify(contextMapperMock).mapFromContext(any()); - verify(dirContextMock).close(); + verify(this.contextMapperMock).mapFromContext(any()); + verify(this.dirContextMock).close(); } @Test @@ -164,11 +164,11 @@ public class DefaultLdapClientTest { singleSearchResultWithStringBase(controls, searchResult); - tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.ONELEVEL) - .filter("(ou=somevalue)")).toObject(contextMapperMock); + this.tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.ONELEVEL) + .filter("(ou=somevalue)")).toObject(this.contextMapperMock); - verify(contextMapperMock).mapFromContext(any()); - verify(dirContextMock).close(); + verify(this.contextMapperMock).mapFromContext(any()); + verify(this.dirContextMock).close(); } @Test @@ -182,12 +182,12 @@ public class DefaultLdapClientTest { singleSearchResult(controls, searchResult); - tested.search() - .query((builder) -> builder.base(nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)")) - .toObject(attributesMapperMock); + this.tested.search().query( + (builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)")) + .toObject(this.attributesMapperMock); - verify(attributesMapperMock).mapFromAttributes(any()); - verify(dirContextMock).close(); + verify(this.attributesMapperMock).mapFromAttributes(any()); + verify(this.dirContextMock).close(); } @Test @@ -201,11 +201,11 @@ public class DefaultLdapClientTest { singleSearchResultWithStringBase(controls, searchResult); - tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.SUBTREE) - .filter("(ou=somevalue)")).toObject(attributesMapperMock); + this.tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.SUBTREE) + .filter("(ou=somevalue)")).toObject(this.attributesMapperMock); - verify(attributesMapperMock).mapFromAttributes(any()); - verify(dirContextMock).close(); + verify(this.attributesMapperMock).mapFromAttributes(any()); + verify(this.dirContextMock).close(); } @Test @@ -216,19 +216,19 @@ public class DefaultLdapClientTest { controls.setReturningObjFlag(false); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException("some text"); - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenThrow(ne); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenThrow(ne); try { - tested.search().query( - (builder) -> builder.base(nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)")) - .toObject(attributesMapperMock); + this.tested.search().query( + (builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)")) + .toObject(this.attributesMapperMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -239,36 +239,36 @@ public class DefaultLdapClientTest { controls.setReturningObjFlag(false); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenThrow(ne); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenThrow(ne); try { - tested.search().query((builder) -> builder.base(nameMock).filter("(ou=somevalue)")) - .toObject(attributesMapperMock); + this.tested.search().query((builder) -> builder.base(this.nameMock).filter("(ou=somevalue)")) + .toObject(this.attributesMapperMock); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { // expected } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void verifyThatDefaultSearchControlParametersAreAutomaticallyAppliedInSearch() throws Exception { Supplier defaults = mock(Supplier.class); when(defaults.get()).thenReturn(new SearchControls()); - LdapClient tested = LdapClient.builder().contextSource(contextSourceMock).defaultSearchControls(defaults) + LdapClient tested = LdapClient.builder().contextSource(this.contextSourceMock).defaultSearchControls(defaults) .build(); expectGetReadOnlyContext(); - when(dirContextMock.search(eq(nameMock), anyString(), any())).thenReturn(namingEnumerationMock); - tested.search().name(nameMock).toEntry(); + when(this.dirContextMock.search(eq(this.nameMock), anyString(), any())).thenReturn(this.namingEnumerationMock); + tested.search().name(this.nameMock).toEntry(); verify(defaults).get(); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -277,10 +277,10 @@ public class DefaultLdapClientTest { ModificationItem[] mods = new ModificationItem[1]; - tested.modify(nameMock).attributes(mods).execute(); + this.tested.modify(this.nameMock).attributes(mods).execute(); - verify(dirContextMock).modifyAttributes(nameMock, mods); - verify(dirContextMock).close(); + verify(this.dirContextMock).modifyAttributes(this.nameMock, mods); + verify(this.dirContextMock).close(); } @Test @@ -289,10 +289,10 @@ public class DefaultLdapClientTest { ModificationItem[] mods = new ModificationItem[1]; - tested.modify(DEFAULT_BASE.toString()).attributes(mods).execute(); + this.tested.modify(DEFAULT_BASE.toString()).attributes(mods).execute(); - verify(dirContextMock).modifyAttributes(DEFAULT_BASE, mods); - verify(dirContextMock).close(); + verify(this.dirContextMock).modifyAttributes(DEFAULT_BASE, mods); + verify(this.dirContextMock).close(); } @Test @@ -302,17 +302,17 @@ public class DefaultLdapClientTest { ModificationItem[] mods = new ModificationItem[1]; javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - doThrow(ne).when(dirContextMock).modifyAttributes(nameMock, mods); + doThrow(ne).when(this.dirContextMock).modifyAttributes(this.nameMock, mods); try { - tested.modify(nameMock).attributes(mods).execute(); + this.tested.modify(this.nameMock).attributes(mods).execute(); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -322,10 +322,10 @@ public class DefaultLdapClientTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.bind(nameMock).object(expectedObject).attributes(expectedAttributes).execute(); + this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).execute(); - verify(dirContextMock).bind(nameMock, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).bind(this.nameMock, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @@ -336,10 +336,10 @@ public class DefaultLdapClientTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes).execute(); + this.tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes).execute(); - verify(dirContextMock).bind(DEFAULT_BASE, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).bind(DEFAULT_BASE, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @Test @@ -349,43 +349,43 @@ public class DefaultLdapClientTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - doThrow(ne).when(dirContextMock).bind(nameMock, expectedObject, expectedAttributes); + doThrow(ne).when(this.dirContextMock).bind(this.nameMock, expectedObject, expectedAttributes); try { - tested.bind(nameMock).object(expectedObject).attributes(expectedAttributes).execute(); + this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).execute(); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testBindWithContext() throws Exception { expectGetReadWriteContext(); - when(dirContextOperationsMock.getDn()).thenReturn(nameMock); - when(dirContextOperationsMock.isUpdateMode()).thenReturn(false); + when(this.dirContextOperationsMock.getDn()).thenReturn(this.nameMock); + when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false); - tested.bind(nameMock).object(dirContextOperationsMock).execute(); + this.tested.bind(this.nameMock).object(this.dirContextOperationsMock).execute(); - verify(dirContextMock).bind(nameMock, dirContextOperationsMock, null); - verify(dirContextMock).close(); + verify(this.dirContextMock).bind(this.nameMock, this.dirContextOperationsMock, null); + verify(this.dirContextMock).close(); } @Test public void testRebindWithContext() throws Exception { expectGetReadWriteContext(); - when(dirContextOperationsMock.getDn()).thenReturn(nameMock); - when(dirContextOperationsMock.isUpdateMode()).thenReturn(false); + when(this.dirContextOperationsMock.getDn()).thenReturn(this.nameMock); + when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false); - tested.bind(nameMock).object(dirContextOperationsMock).replaceExisting(true).execute(); + this.tested.bind(this.nameMock).object(this.dirContextOperationsMock).replaceExisting(true).execute(); - verify(dirContextMock).rebind(nameMock, dirContextOperationsMock, null); - verify(dirContextMock).close(); + verify(this.dirContextMock).rebind(this.nameMock, this.dirContextOperationsMock, null); + verify(this.dirContextMock).close(); } @Test @@ -395,10 +395,11 @@ public class DefaultLdapClientTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.bind(nameMock).object(expectedObject).attributes(expectedAttributes).replaceExisting(true).execute(); + this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).replaceExisting(true) + .execute(); - verify(dirContextMock).rebind(nameMock, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).rebind(this.nameMock, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @Test @@ -408,73 +409,73 @@ public class DefaultLdapClientTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes).replaceExisting(true) - .execute(); + this.tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes) + .replaceExisting(true).execute(); - verify(dirContextMock).rebind(DEFAULT_BASE, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).rebind(DEFAULT_BASE, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @Test public void testUnbind() throws Exception { expectGetReadWriteContext(); - tested.unbind(nameMock).execute(); + this.tested.unbind(this.nameMock).execute(); - verify(dirContextMock).unbind(nameMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(this.nameMock); + verify(this.dirContextMock).close(); } @Test public void testUnbind_String() throws Exception { expectGetReadWriteContext(); - tested.unbind(DEFAULT_BASE.toString()).execute(); + this.tested.unbind(DEFAULT_BASE.toString()).execute(); - verify(dirContextMock).unbind(DEFAULT_BASE); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(DEFAULT_BASE); + verify(this.dirContextMock).close(); } @Test public void testUnbindRecursive() throws Exception { expectGetReadWriteContext(); - when(namingEnumerationMock.hasMore()).thenReturn(true, false, false); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false, false); Binding binding = new Binding("cn=Some name", null); - when(namingEnumerationMock.next()).thenReturn(binding); + when(this.namingEnumerationMock.next()).thenReturn(binding); LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE); - when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(listDn)).thenReturn(this.namingEnumerationMock); LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com"); - when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(subListDn)).thenReturn(this.namingEnumerationMock); - tested.unbind(new CompositeName(DEFAULT_BASE.toString())).recursive(true).execute(); + this.tested.unbind(new CompositeName(DEFAULT_BASE.toString())).recursive(true).execute(); - verify(dirContextMock).unbind(subListDn); - verify(dirContextMock).unbind(listDn); - verify(namingEnumerationMock, times(2)).close(); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(subListDn); + verify(this.dirContextMock).unbind(listDn); + verify(this.namingEnumerationMock, times(2)).close(); + verify(this.dirContextMock).close(); } @Test public void testUnbindRecursive_String() throws Exception { expectGetReadWriteContext(); - when(namingEnumerationMock.hasMore()).thenReturn(true, false, false); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false, false); Binding binding = new Binding("cn=Some name", null); - when(namingEnumerationMock.next()).thenReturn(binding); + when(this.namingEnumerationMock.next()).thenReturn(binding); LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE); - when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(listDn)).thenReturn(this.namingEnumerationMock); LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com"); - when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(subListDn)).thenReturn(this.namingEnumerationMock); - tested.unbind(DEFAULT_BASE.toString()).recursive(true).execute(); + this.tested.unbind(DEFAULT_BASE.toString()).recursive(true).execute(); - verify(dirContextMock).unbind(subListDn); - verify(dirContextMock).unbind(listDn); - verify(namingEnumerationMock, times(2)).close(); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(subListDn); + verify(this.dirContextMock).unbind(listDn); + verify(this.namingEnumerationMock, times(2)).close(); + verify(this.dirContextMock).close(); } @Test @@ -482,17 +483,17 @@ public class DefaultLdapClientTest { expectGetReadWriteContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - doThrow(ne).when(dirContextMock).unbind(nameMock); + doThrow(ne).when(this.dirContextMock).unbind(this.nameMock); try { - tested.unbind(nameMock).execute(); + this.tested.unbind(this.nameMock).execute(); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -500,32 +501,32 @@ public class DefaultLdapClientTest { expectGetReadOnlyContext(); javax.naming.PartialResultException ex = new javax.naming.PartialResultException(); - when(dirContextMock.search(eq(nameMock), anyString(), any())).thenThrow(ex); + when(this.dirContextMock.search(eq(this.nameMock), anyString(), any())).thenThrow(ex); try { - tested.search().name(nameMock).toEntryList(); + this.tested.search().name(this.nameMock).toEntryList(); fail("PartialResultException expected"); } catch (PartialResultException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testSearch_PartialResult_IgnoreSet() throws Exception { - LdapClient tested = LdapClient.builder().contextSource(contextSourceMock).ignorePartialResultException(true) - .build(); + LdapClient tested = LdapClient.builder().contextSource(this.contextSourceMock) + .ignorePartialResultException(true).build(); expectGetReadOnlyContext(); - when(dirContextMock.search(eq(nameMock), anyString(), any())) + when(this.dirContextMock.search(eq(this.nameMock), anyString(), any())) .thenThrow(javax.naming.PartialResultException.class); - tested.search().name(nameMock).toEntryStream(); + tested.search().name(this.nameMock).toEntryStream(); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -533,28 +534,28 @@ public class DefaultLdapClientTest { AuthenticatedLdapEntryContextMapper entryContextMapper = mock( AuthenticatedLdapEntryContextMapper.class); - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes()); singleSearchResult(searchControlsRecursive(), searchResult); - when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) - .thenReturn(authenticatedContextMock); + when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) + .thenReturn(this.authenticatedContextMock); when(entryContextMapper.mapWithContext(any(), any())).thenReturn(new Object()); - LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)"); - Object result = tested.authenticate().query(query).password("password").execute(entryContextMapper); + LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)"); + Object result = this.tested.authenticate().query(query).password("password").execute(entryContextMapper); - verify(authenticatedContextMock).close(); - verify(dirContextMock).close(); + verify(this.authenticatedContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isNotNull(); } @Test public void testAuthenticateWithTwoUsersFoundShouldThrowException() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); @@ -564,47 +565,47 @@ public class DefaultLdapClientTest { setupSearchResults(searchControlsRecursive(), new SearchResult[] { searchResult1, searchResult2 }); try { - LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)"); - tested.authenticate().query(query).password("password").execute(); + LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)"); + this.tested.authenticate().query(query).password("password").execute(); fail("IncorrectResultSizeDataAccessException expected"); } catch (IncorrectResultSizeDataAccessException expected) { // expected } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testAuthenticateWhenNoUserWasFoundShouldFail() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); noSearchResults(searchControlsRecursive()); - LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)"); + LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)"); assertThatExceptionOfType(EmptyResultDataAccessException.class) - .isThrownBy(() -> tested.authenticate().query(query).password("password").execute()); + .isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute()); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @SuppressWarnings("unchecked") public void testAuthenticateQueryPasswordWhenNoUserWasFoundShouldThrowEmptyResult() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); noSearchResults(searchControlsRecursive()); - LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)"); - assertThatExceptionOfType(EmptyResultDataAccessException.class).isThrownBy( - () -> tested.authenticate().query(query).password("password").execute((ctx, entry) -> new Object())); + LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)"); + assertThatExceptionOfType(EmptyResultDataAccessException.class).isThrownBy(() -> this.tested.authenticate() + .query(query).password("password").execute((ctx, entry) -> new Object())); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testAuthenticateWithFailedAuthenticationShouldFail() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); @@ -612,20 +613,20 @@ public class DefaultLdapClientTest { singleSearchResult(searchControlsRecursive(), searchResult); - when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) + when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) .thenThrow(new UncategorizedLdapException("Authentication failed")); - LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)"); + LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)"); assertThatExceptionOfType(UncategorizedLdapException.class) - .isThrownBy(() -> tested.authenticate().query(query).password("password").execute()); - verify(dirContextMock).close(); + .isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute()); + verify(this.dirContextMock).close(); } private void noSearchResults(SearchControls controls) throws Exception { - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(false); + when(this.namingEnumerationMock.hasMore()).thenReturn(false); } private void singleSearchResult(SearchControls controls, SearchResult searchResult) throws Exception { @@ -633,16 +634,16 @@ public class DefaultLdapClientTest { } private void setupSearchResults(SearchControls controls, SearchResult... searchResults) throws Exception { - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); if (searchResults.length == 1) { - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(searchResults[0]); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResults[0]); } else if (searchResults.length == 2) { - when(namingEnumerationMock.hasMore()).thenReturn(true, true, false); - when(namingEnumerationMock.next()).thenReturn(searchResults[0], searchResults[1]); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResults[0], searchResults[1]); } else { throw new IllegalArgumentException("Cannot handle " + searchResults.length + " search results"); @@ -650,11 +651,11 @@ public class DefaultLdapClientTest { } private void singleSearchResultWithStringBase(SearchControls controls, SearchResult searchResult) throws Exception { - when(dirContextMock.search(eq(DEFAULT_BASE), eq("(ou=somevalue)"), - argThat(new SearchControlsMatcher(controls)))).thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(DEFAULT_BASE), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(searchResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResult); } private SearchControls searchControlsRecursive() { @@ -684,12 +685,12 @@ public class DefaultLdapClientTest { if (item instanceof SearchControls) { SearchControls s1 = item; - return controls.getSearchScope() == s1.getSearchScope() - && controls.getReturningObjFlag() == s1.getReturningObjFlag() - && controls.getDerefLinkFlag() == s1.getDerefLinkFlag() - && controls.getCountLimit() == s1.getCountLimit() - && controls.getTimeLimit() == s1.getTimeLimit() - && controls.getReturningAttributes() == s1.getReturningAttributes(); + return this.controls.getSearchScope() == s1.getSearchScope() + && this.controls.getReturningObjFlag() == s1.getReturningObjFlag() + && this.controls.getDerefLinkFlag() == s1.getDerefLinkFlag() + && this.controls.getCountLimit() == s1.getCountLimit() + && this.controls.getTimeLimit() == s1.getTimeLimit() + && this.controls.getReturningAttributes() == s1.getReturningAttributes(); } else { throw new IllegalArgumentException(); diff --git a/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java b/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java index 554c71a1..e4da5770 100644 --- a/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java @@ -53,37 +53,37 @@ public class DirContextAdapterTest { @Before public void setUp() throws Exception { - tested = new DirContextAdapter(); + this.tested = new DirContextAdapter(); } @Test public void testSetUpdateMode() throws Exception { - assertThat(tested.isUpdateMode()).isFalse(); - tested.setUpdateMode(true); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setUpdateMode(false); - assertThat(tested.isUpdateMode()).isFalse(); + assertThat(this.tested.isUpdateMode()).isFalse(); + this.tested.setUpdateMode(true); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setUpdateMode(false); + assertThat(this.tested.isUpdateMode()).isFalse(); } @Test public void testGetModificationItems() throws Exception { - ModificationItem[] items = tested.getModificationItems(); + ModificationItem[] items = this.tested.getModificationItems(); assertThat(items.length).isEqualTo(0); - tested.setUpdateMode(true); + this.tested.setUpdateMode(true); assertThat(items.length).isEqualTo(0); } @Test public void testAlwaysReplace() throws Exception { - ModificationItem[] items = tested.getModificationItems(); + ModificationItem[] items = this.tested.getModificationItems(); assertThat(items.length).isEqualTo(0); - tested.setUpdateMode(true); + this.tested.setUpdateMode(true); assertThat(items.length).isEqualTo(0); } @Test public void testGetStringAttributeWhenAttributeDoesNotExist() throws Exception { - String s = tested.getStringAttribute("does not exist"); + String s = this.tested.getStringAttribute("does not exist"); assertThat(s).isNull(); } @@ -98,8 +98,8 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - String s = tested.getStringAttribute("abc"); + this.tested = new TestableDirContextAdapter(); + String s = this.tested.getStringAttribute("abc"); assertThat(s).isNull(); } @@ -114,14 +114,14 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - boolean result = tested.attributeExists("abc"); + this.tested = new TestableDirContextAdapter(); + boolean result = this.tested.attributeExists("abc"); assertThat(result).isEqualTo(true); } @Test public void testAttributeExistsWhenAttributeDoesNotExist() throws Exception { - boolean result = tested.attributeExists("does not exist"); + boolean result = this.tested.attributeExists("does not exist"); assertThat(result).isEqualTo(false); } @@ -136,8 +136,8 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - String s = tested.getStringAttribute("abc"); + this.tested = new TestableDirContextAdapter(); + String s = this.tested.getStringAttribute("abc"); assertThat(s).isEqualTo("def"); } @@ -155,8 +155,8 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - String s[] = tested.getStringAttributes("abc"); + this.tested = new TestableDirContextAdapter(); + String s[] = this.tested.getStringAttributes("abc"); assertThat(s[0]).isEqualTo("123"); assertThat(s[1]).isEqualTo("234"); assertThat(s.length).isEqualTo(2); @@ -175,9 +175,9 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); + this.tested = new TestableDirContextAdapter(); try { - tested.getStringAttributes("abc"); + this.tested.getStringAttributes("abc"); fail("ClassCastException expected"); } catch (IllegalArgumentException expected) { @@ -197,15 +197,15 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - String s[] = tested.getStringAttributes("abc"); + this.tested = new TestableDirContextAdapter(); + String s[] = this.tested.getStringAttributes("abc"); assertThat(s).isNotNull(); assertThat(s.length).isEqualTo(0); } @Test public void testGetStringAttributesNotExists() throws Exception { - String s[] = tested.getStringAttributes("abc"); + String s[] = this.tested.getStringAttributes("abc"); assertThat(s).isNull(); } @@ -223,8 +223,8 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - SortedSet s = tested.getAttributeSortedStringSet("abc"); + this.tested = new TestableDirContextAdapter(); + SortedSet s = this.tested.getAttributeSortedStringSet("abc"); assertThat(s).isNotNull(); assertThat(s).hasSize(2); Iterator it = s.iterator(); @@ -242,29 +242,29 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - SortedSet s = tested.getAttributeSortedStringSet("abc"); + this.tested = new TestableDirContextAdapter(); + SortedSet s = this.tested.getAttributeSortedStringSet("abc"); assertThat(s).isNull(); } @Test public void testAddAttributeValue() throws NamingException { // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("123"); } @Test public void testAddAttributeValueAttributeWithOtherValueExists() throws NamingException { - tested.setAttribute(new BasicAttribute("abc", "321")); + this.tested.setAttribute(new BasicAttribute("abc", "321")); // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat((String) attr.get(0)).isEqualTo("321"); assertThat((String) attr.get(1)).isEqualTo("123"); @@ -272,12 +272,12 @@ public class DirContextAdapterTest { @Test public void testAddAttributeValueAttributeWithSameValueExists() throws NamingException { - tested.setAttribute(new BasicAttribute("abc", "123")); + this.tested.setAttribute(new BasicAttribute("abc", "123")); // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat(attr.size()).isEqualTo(1); assertThat((String) attr.get(0)).isEqualTo("123"); @@ -285,14 +285,14 @@ public class DirContextAdapterTest { @Test public void testAddAttributeValueInUpdateMode() throws NamingException { - tested.setUpdateMode(true); - tested.addAttributeValue("abc", "123"); + this.tested.setUpdateMode(true); + this.tested.addAttributeValue("abc", "123"); // Perform test - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute attribute = modificationItems[0].getAttribute(); assertThat(attribute.getID()).isEqualTo("abc"); @@ -302,16 +302,16 @@ public class DirContextAdapterTest { @Test public void testAddAttributeValueInUpdateModeAttributeWhenOtherValueExistsInOrigAttrs() throws NamingException { - tested.setAttribute(new BasicAttribute("abc", "321")); - tested.setUpdateMode(true); + this.tested.setAttribute(new BasicAttribute("abc", "321")); + this.tested.setUpdateMode(true); // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("abc")).isNotNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute attribute = modificationItems[0].getAttribute(); assertThat(attribute.size()).isEqualTo(1); @@ -323,31 +323,31 @@ public class DirContextAdapterTest { public void testGetModificationItemsOnAddAttributeValueInUpdateModeAttributeWhenSameValueExistsInOrigAttrs() throws NamingException { - tested.setAttribute(new BasicAttribute("abc", "123")); - tested.setUpdateMode(true); + this.tested.setAttribute(new BasicAttribute("abc", "123")); + this.tested.setUpdateMode(true); // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("abc")).isNotNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(0); } @Test public void testAddAttributeValueInUpdateModeAttributeWithOtherValueExistsInUpdAttrs() throws NamingException { - tested.setUpdateMode(true); - tested.setAttributeValue("abc", "321"); + this.tested.setUpdateMode(true); + this.tested.setAttributeValue("abc", "321"); // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute attribute = modificationItems[0].getAttribute(); assertThat(attribute.getID()).isEqualTo("abc"); @@ -357,16 +357,16 @@ public class DirContextAdapterTest { @Test public void testAddAttributeValueInUpdateModeAttributeWithSameValueExistsInUpdAttrs() throws NamingException { - tested.setUpdateMode(true); - tested.setAttributeValue("abc", "123"); + this.tested.setUpdateMode(true); + this.tested.setAttributeValue("abc", "123"); // Perform test - tested.addAttributeValue("abc", "123"); + this.tested.addAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute attribute = modificationItems[0].getAttribute(); assertThat(attribute.size()).isEqualTo(1); @@ -376,20 +376,20 @@ public class DirContextAdapterTest { @Test public void testNewLdapNameWithString() throws NamingException { - tested.addAttributeValue("member", LdapUtils.newLdapName("CN=test,DC=root")); - tested.addAttributeValue("member2", LdapUtils.newLdapName("CN=test2,DC=root")); + this.tested.addAttributeValue("member", LdapUtils.newLdapName("CN=test,DC=root")); + this.tested.addAttributeValue("member2", LdapUtils.newLdapName("CN=test2,DC=root")); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("member").get()).isEqualTo(LdapUtils.newLdapName("CN=test,DC=root")); assertThat(attrs.get("member2").get()).isEqualTo(LdapUtils.newLdapName("CN=test2,DC=root")); } @Test public void testNewLdapNameWithLdapName() throws NamingException { - tested.addAttributeValue("member", "CN=test,DC=root"); - tested.addAttributeValue("member2", LdapUtils.newLdapName("CN=test2,DC=root")); + this.tested.addAttributeValue("member", "CN=test,DC=root"); + this.tested.addAttributeValue("member2", LdapUtils.newLdapName("CN=test2,DC=root")); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); assertThat(attrs.get("member").get()).isEqualTo("CN=test,DC=root"); assertThat(attrs.get("member2").get()).isEqualTo(LdapUtils.newLdapName("CN=test2,DC=root")); } @@ -397,20 +397,20 @@ public class DirContextAdapterTest { @Test public void testRemoveAttributeValueAttributeDoesntExist() { // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - Attributes attributes = tested.getAttributes(); + Attributes attributes = this.tested.getAttributes(); assertThat(attributes.get("abc")).isNull(); } @Test public void testRemoveAttributeValueAttributeWithOtherValueExists() throws NamingException { - tested.setAttribute(new BasicAttribute("abc", "321")); + this.tested.setAttribute(new BasicAttribute("abc", "321")); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - Attributes attributes = tested.getAttributes(); + Attributes attributes = this.tested.getAttributes(); Attribute attr = attributes.get("abc"); assertThat(attr).isNotNull(); assertThat(attr.size()).isEqualTo(1); @@ -419,12 +419,12 @@ public class DirContextAdapterTest { @Test public void testRemoveAttributeValueAttributeWithSameValueExists() { - tested.setAttribute(new BasicAttribute("abc", "123")); + this.tested.setAttribute(new BasicAttribute("abc", "123")); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - Attributes attributes = tested.getAttributes(); + Attributes attributes = this.tested.getAttributes(); Attribute attr = attributes.get("abc"); assertThat(attr).isNull(); } @@ -434,12 +434,12 @@ public class DirContextAdapterTest { BasicAttribute basicAttribute = new BasicAttribute("abc"); basicAttribute.add("123"); basicAttribute.add("321"); - tested.setAttribute(basicAttribute); + this.tested.setAttribute(basicAttribute); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - Attributes attributes = tested.getAttributes(); + Attributes attributes = this.tested.getAttributes(); Attribute attr = attributes.get("abc"); assertThat(attr).isNotNull(); assertThat(attr.size()).isEqualTo(1); @@ -448,42 +448,42 @@ public class DirContextAdapterTest { @Test public void testRemoveAttributeValueInUpdateMode() { - tested.setUpdateMode(true); + this.tested.setUpdateMode(true); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - assertThat(tested.getAttributes().get("abc")).isNull(); + assertThat(this.tested.getAttributes().get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(0); } @Test public void testRemoveAttributeValueInUpdateModeSameValueExistsInUpdatedAttrs() { - tested.setUpdateMode(true); - tested.setAttributeValue("abc", "123"); + this.tested.setUpdateMode(true); + this.tested.setAttributeValue("abc", "123"); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - assertThat(tested.getAttributes().get("abc")).isNull(); + assertThat(this.tested.getAttributes().get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(0); } @Test public void testRemoveAttributeValueInUpdateModeOtherValueExistsInUpdatedAttrs() throws NamingException { - tested.setUpdateMode(true); - tested.setAttributeValue("abc", "321"); + this.tested.setUpdateMode(true); + this.tested.setAttributeValue("abc", "321"); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - assertThat(tested.getAttributes().get("abc")).isNull(); + assertThat(this.tested.getAttributes().get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute modificationAttribute = modificationItems[0].getAttribute(); assertThat(modificationAttribute.getID()).isEqualTo("abc"); @@ -493,15 +493,15 @@ public class DirContextAdapterTest { @Test public void testRemoveAttributeValueInUpdateModeOtherAndSameValueExistsInUpdatedAttrs() throws NamingException { - tested.setUpdateMode(true); - tested.setAttributeValues("abc", new String[] { "321", "123" }); + this.tested.setUpdateMode(true); + this.tested.setAttributeValues("abc", new String[] { "321", "123" }); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - assertThat(tested.getAttributes().get("abc")).isNull(); + assertThat(this.tested.getAttributes().get("abc")).isNull(); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute modificationAttribute = modificationItems[0].getAttribute(); assertThat(modificationAttribute.getID()).isEqualTo("abc"); @@ -510,13 +510,13 @@ public class DirContextAdapterTest { @Test public void testRemoveAttributeValueInUpdateModeSameValueExistsInOrigAttrs() { - tested.setAttribute(new BasicAttribute("abc", "123")); - tested.setUpdateMode(true); + this.tested.setAttribute(new BasicAttribute("abc", "123")); + this.tested.setUpdateMode(true); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute modificationAttribute = modificationItems[0].getAttribute(); assertThat(modificationAttribute.getID()).isEqualTo("abc"); @@ -529,13 +529,13 @@ public class DirContextAdapterTest { BasicAttribute basicAttribute = new BasicAttribute("abc"); basicAttribute.add("123"); basicAttribute.add("321"); - tested.setAttribute(basicAttribute); - tested.setUpdateMode(true); + this.tested.setAttribute(basicAttribute); + this.tested.setUpdateMode(true); // Perform test - tested.removeAttributeValue("abc", "123"); + this.tested.removeAttributeValue("abc", "123"); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); Attribute modificationAttribute = modificationItems[0].getAttribute(); assertThat(modificationAttribute.getID()).isEqualTo("abc"); @@ -546,47 +546,47 @@ public class DirContextAdapterTest { @Test public void testSetStringAttribute() throws Exception { - assertThat(tested.isUpdateMode()).isFalse(); - tested.setAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + assertThat(this.tested.isUpdateMode()).isFalse(); + this.tested.setAttributeValue("abc", "123"); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("123"); } @Test public void testSetStringAttributeNull() throws Exception { - assertThat(tested.isUpdateMode()).isFalse(); - tested.setAttributeValue("abc", null); - Attributes attrs = tested.getAttributes(); + assertThat(this.tested.isUpdateMode()).isFalse(); + this.tested.setAttributeValue("abc", null); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat(attr).isNull(); } @Test public void testAddAttribute() throws Exception { - tested.setUpdateMode(true); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValue("abc", "123"); - Attributes attrs = tested.getAttributes(); + this.tested.setUpdateMode(true); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValue("abc", "123"); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat(attr).isNull(); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.ADD_ATTRIBUTE); attr = mods[0].getAttribute(); assertThat((String) attr.get()).isEqualTo("123"); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(1); assertThat(modNames[0]).isEqualTo("abc"); - tested.update(); - mods = tested.getModificationItems(); + this.tested.update(); + mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - modNames = tested.getNamesOfModifiedAttributes(); + modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); - attrs = tested.getAttributes(); + attrs = this.tested.getAttributes(); attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("123"); } @@ -594,12 +594,12 @@ public class DirContextAdapterTest { // LDAP-304 @Test public void testModifyNull() throws Exception { - tested.setAttributeValue("memberDN", null); - tested.setUpdateMode(true); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValue("memberDN", new LdapName("ou=test")); + this.tested.setAttributeValue("memberDN", null); + this.tested.setUpdateMode(true); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValue("memberDN", new LdapName("ou=test")); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); } @@ -633,13 +633,13 @@ public class DirContextAdapterTest { @Test public void testAddMultiAttributes() throws Exception { - tested.setUpdateMode(true); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123", "456" }); - Attributes attrs = tested.getAttributes(); + this.tested.setUpdateMode(true); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123", "456" }); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat(attr).isNull(); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.ADD_ATTRIBUTE); attr = mods[0].getAttribute(); @@ -647,16 +647,16 @@ public class DirContextAdapterTest { assertThat((String) attr.get(0)).isEqualTo("123"); assertThat((String) attr.get(1)).isEqualTo("456"); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(1); assertThat(modNames[0]).isEqualTo("abc"); - tested.update(); - mods = tested.getModificationItems(); + this.tested.update(); + mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - modNames = tested.getNamesOfModifiedAttributes(); + modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); - attrs = tested.getAttributes(); + attrs = this.tested.getAttributes(); attr = attrs.get("abc"); assertThat((String) attr.get(0)).isEqualTo("123"); assertThat((String) attr.get(1)).isEqualTo("456"); @@ -674,30 +674,30 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); + this.tested = new TestableDirContextAdapter(); - tested.setUpdateMode(true); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValue("abc", null); - Attributes attrs = tested.getAttributes(); + this.tested.setUpdateMode(true); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValue("abc", null); + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("123"); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); attr = mods[0].getAttribute(); assertThat((String) attr.getID()).isEqualTo("abc"); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(1); assertThat(modNames[0]).isEqualTo("abc"); - tested.update(); - mods = tested.getModificationItems(); + this.tested.update(); + mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - modNames = tested.getNamesOfModifiedAttributes(); + modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); - attrs = tested.getAttributes(); + attrs = this.tested.getAttributes(); attr = attrs.get("abc"); assertThat(attr).isNull(); } @@ -717,12 +717,12 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); + this.tested = new TestableDirContextAdapter(); - tested.setUpdateMode(true); - tested.setAttributeValues("abc", new String[] {}); + this.tested.setUpdateMode(true); + this.tested.setAttributeValues("abc", new String[] {}); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); Attribute attr = mods[0].getAttribute(); @@ -742,10 +742,10 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - tested.setAttributeValue("abc", "234"); // change + this.tested = new TestableDirContextAdapter(); + this.tested.setAttributeValue("abc", "234"); // change - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); Attribute attr = mods[0].getAttribute(); @@ -765,11 +765,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValue("abc", "123"); // change + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValue("abc", "123"); // change - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); } @@ -788,13 +788,13 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123", "qwe" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123", "qwe" }); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); } @@ -813,12 +813,12 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - tested.setAttributeValues("abc", new String[] { "qwe", "123" }); + this.tested = new TestableDirContextAdapter(); + this.tested.setAttributeValues("abc", new String[] { "qwe", "123" }); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); } @@ -837,12 +837,12 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "qwe", "123" }, true); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "qwe", "123" }, true); // change - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); Attribute attr = mods[0].getAttribute(); @@ -869,12 +869,12 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("title", new String[] { "Jim", "George", "Juergen" }, true); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("title", new String[] { "Jim", "George", "Juergen" }, true); // change - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); Attribute attr = mods[0].getAttribute(); @@ -898,11 +898,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123", "qwe", "klytt" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123", "qwe", "klytt" }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); assertThat(modificationItems[0].getModificationOp()).isEqualTo(DirContext.ADD_ATTRIBUTE); assertThat(modificationItems[0].getAttribute().get()).isEqualTo("klytt"); @@ -923,11 +923,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123" }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); assertThat(modificationItems[0].getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); assertThat(modificationItems[0].getAttribute().get()).isEqualTo("qwe"); @@ -949,11 +949,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123" }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); assertThat(modificationItems[0].getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); assertThat(modificationItems[0].getAttribute().get(0)).isEqualTo("qwe"); @@ -975,11 +975,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", null); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", null); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); assertThat(modificationItems[0].getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); } @@ -999,11 +999,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123", "qwe" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123", "qwe" }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(0); } @@ -1024,11 +1024,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("abc", new String[] { "123", "qwe", "klytt", "kalle" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("abc", new String[] { "123", "qwe", "klytt", "kalle" }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(2); Attribute modifiedAttribute = modificationItems[0].getAttribute(); @@ -1061,11 +1061,11 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValues("def", new String[] { "kalle", "klytt" }); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValues("def", new String[] { "kalle", "klytt" }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(1); assertThat(modificationItems[0].getAttribute().getID()).isEqualTo("def"); } @@ -1082,27 +1082,27 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValue("abc", "234"); // change - tested.setAttributeValue("abc", "987"); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValue("abc", "234"); // change + this.tested.setAttributeValue("abc", "987"); // change a second time - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); Attribute attr = mods[0].getAttribute(); assertThat((String) attr.getID()).isEqualTo("abc"); assertThat((String) attr.get()).isEqualTo("987"); - tested.update(); - mods = tested.getModificationItems(); + this.tested.update(); + mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); - Attributes attrs = tested.getAttributes(); + Attributes attrs = this.tested.getAttributes(); attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("987"); - assertThat(tested.getStringAttribute("abc")).isEqualTo("987"); + assertThat(this.tested.getStringAttribute("abc")).isEqualTo("987"); } @Test @@ -1118,19 +1118,19 @@ public class DirContextAdapterTest { } } - tested = new TestableDirContextAdapter(); - assertThat(tested.isUpdateMode()).isTrue(); - tested.setAttributeValue("abc", "234"); // change - tested.setAttributeValue("qwe", null); // remove - tested.setAttributeValue("zzz", "new"); // new - Attributes attrs = tested.getAttributes(); + this.tested = new TestableDirContextAdapter(); + assertThat(this.tested.isUpdateMode()).isTrue(); + this.tested.setAttributeValue("abc", "234"); // change + this.tested.setAttributeValue("qwe", null); // remove + this.tested.setAttributeValue("zzz", "new"); // new + Attributes attrs = this.tested.getAttributes(); Attribute attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("123"); assertThat(attrs.size()).isEqualTo(2); - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(3); - String[] modNames = tested.getNamesOfModifiedAttributes(); + String[] modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(3); ModificationItem mod = getModificationItem(mods, DirContext.REPLACE_ATTRIBUTE); @@ -1150,17 +1150,17 @@ public class DirContextAdapterTest { assertThat((String) attr.getID()).isEqualTo("zzz"); assertThat((String) attr.get()).isEqualTo("new"); - tested.update(); - mods = tested.getModificationItems(); + this.tested.update(); + mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(0); - modNames = tested.getNamesOfModifiedAttributes(); + modNames = this.tested.getNamesOfModifiedAttributes(); assertThat(modNames.length).isEqualTo(0); - attrs = tested.getAttributes(); + attrs = this.tested.getAttributes(); assertThat(attrs.size()).isEqualTo(2); attr = attrs.get("abc"); assertThat((String) attr.get()).isEqualTo("234"); - assertThat(tested.getStringAttribute("zzz")).isEqualTo("new"); + assertThat(this.tested.getStringAttribute("zzz")).isEqualTo("new"); } /** @@ -1172,17 +1172,17 @@ public class DirContextAdapterTest { public void testSetAttribute_UpdateMode() throws NamingException { // Set original attribute value Attribute attribute = new BasicAttribute("cn", "john doe"); - tested.setAttribute(attribute); + this.tested.setAttribute(attribute); // Set to update mode - tested.setUpdateMode(true); + this.tested.setUpdateMode(true); // Perform test - update the attribute Attribute updatedAttribute = new BasicAttribute("cn", "nisse hult"); - tested.setAttribute(updatedAttribute); + this.tested.setAttribute(updatedAttribute); // Verify result - ModificationItem[] mods = tested.getModificationItems(); + ModificationItem[] mods = this.tested.getModificationItems(); assertThat(mods.length).isEqualTo(1); assertThat(mods[0].getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); @@ -1193,14 +1193,14 @@ public class DirContextAdapterTest { @Test public void testGetStringAttributes_NullValue() { - String result = tested.getStringAttribute("someAbsentAttribute"); + String result = this.tested.getStringAttribute("someAbsentAttribute"); assertThat(result).isNull(); } @Test public void testGetStringAttributes_AttributeExists_NullValue() { - tested.setAttribute(new BasicAttribute("someAttribute", null)); - String result = tested.getStringAttribute("someAttribute"); + this.tested.setAttribute(new BasicAttribute("someAttribute", null)); + String result = this.tested.getStringAttribute("someAttribute"); assertThat(result).isNull(); } @@ -1218,13 +1218,13 @@ public class DirContextAdapterTest { attribute.add("Some Person"); attribute.add("Some Other Person"); - tested.setAttribute(attribute); - tested.setUpdateMode(true); + this.tested.setAttribute(attribute); + this.tested.setUpdateMode(true); - tested.setAttributeValues("abc", new String[] { "some person", "Some Other Person" }); + this.tested.setAttributeValues("abc", new String[] { "some person", "Some Other Person" }); // Perform test - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(2); ModificationItem modificationItem = modificationItems[0]; assertThat(modificationItem.getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); @@ -1239,14 +1239,14 @@ public class DirContextAdapterTest { */ @Test public void testModifyAttributeByteArray() { - tested.setAttribute(new BasicAttribute("abc", new byte[] { 1, 2, 3 })); + this.tested.setAttribute(new BasicAttribute("abc", new byte[] { 1, 2, 3 })); - tested.setUpdateMode(true); + this.tested.setUpdateMode(true); // Perform test - tested.setAttributeValue("abc", new byte[] { 1, 2, 3 }); + this.tested.setAttributeValue("abc", new byte[] { 1, 2, 3 }); - ModificationItem[] modificationItems = tested.getModificationItems(); + ModificationItem[] modificationItems = this.tested.getModificationItems(); assertThat(modificationItems.length).isEqualTo(0); } diff --git a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTest.java b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTest.java index 7eee79ca..f7041d41 100644 --- a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTest.java @@ -32,15 +32,15 @@ public class DistinguishedNameEditorTest { @Before public void setUp() throws Exception { - tested = new DistinguishedNameEditor(); + this.tested = new DistinguishedNameEditor(); } @Test public void testSetAsText() throws Exception { String expectedDn = "dc=jayway, dc=se"; - tested.setAsText(expectedDn); - DistinguishedName result = (DistinguishedName) tested.getValue(); + this.tested.setAsText(expectedDn); + DistinguishedName result = (DistinguishedName) this.tested.getValue(); assertThat(result).isEqualTo(new DistinguishedName(expectedDn)); try { @@ -54,23 +54,23 @@ public class DistinguishedNameEditorTest { @Test public void testSetAsTextNullValue() throws Exception { - tested.setAsText(null); - Object result = tested.getValue(); + this.tested.setAsText(null); + Object result = this.tested.getValue(); assertThat(result).isNull(); } @Test public void testGetAsText() throws Exception { String expectedDn = "dc=jayway,dc=se"; - tested.setValue(new DistinguishedName(expectedDn)); - String text = tested.getAsText(); + this.tested.setValue(new DistinguishedName(expectedDn)); + String text = this.tested.getAsText(); assertThat(text).isEqualTo(expectedDn); } @Test public void testGetAsTextNullValue() throws Exception { - tested.setValue(null); - String text = tested.getAsText(); + this.tested.setValue(null); + String text = this.tested.getAsText(); assertThat(text).isNull(); } diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTest.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTest.java index a5425411..71ac8a39 100644 --- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTest.java +++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTest.java @@ -64,56 +64,56 @@ public class LdapTemplateListTest { @Before public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); // Setup NamingEnumeration mock - namingEnumerationMock = mock(NamingEnumeration.class); + this.namingEnumerationMock = mock(NamingEnumeration.class); // Setup Name mock - nameMock = mock(Name.class); + this.nameMock = mock(Name.class); // Setup Handler mock - handlerMock = mock(NameClassPairCallbackHandler.class); + this.handlerMock = mock(NameClassPairCallbackHandler.class); - contextMapperMock = mock(ContextMapper.class); + this.contextMapperMock = mock(ContextMapper.class); - tested = new LdapTemplate(contextSourceMock); + this.tested = new LdapTemplate(this.contextSourceMock); } private void expectGetReadOnlyContext() { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); } private void setupStringListAndNamingEnumeration(NameClassPair listResult) throws NamingException { - when(dirContextMock.list(NAME)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.list(NAME)).thenReturn(this.namingEnumerationMock); setupNamingEnumeration(listResult); } private void setupListAndNamingEnumeration(NameClassPair listResult) throws NamingException { - when(dirContextMock.list(nameMock)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.list(this.nameMock)).thenReturn(this.namingEnumerationMock); setupNamingEnumeration(listResult); } private void setupStringListBindingsAndNamingEnumeration(NameClassPair listResult) throws NamingException { - when(dirContextMock.listBindings(NAME)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(NAME)).thenReturn(this.namingEnumerationMock); setupNamingEnumeration(listResult); } private void setupListBindingsAndNamingEnumeration(NameClassPair listResult) throws NamingException { - when(dirContextMock.listBindings(nameMock)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(this.nameMock)).thenReturn(this.namingEnumerationMock); setupNamingEnumeration(listResult); } private void setupNamingEnumeration(NameClassPair listResult) throws NamingException { - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(listResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(listResult); } @Test @@ -124,10 +124,10 @@ public class LdapTemplateListTest { setupListAndNamingEnumeration(listResult); - List list = tested.list(nameMock); + List list = this.tested.list(this.nameMock); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -142,10 +142,10 @@ public class LdapTemplateListTest { setupStringListAndNamingEnumeration(listResult); - List list = tested.list(NAME); + List list = this.tested.list(NAME); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -160,11 +160,11 @@ public class LdapTemplateListTest { setupListAndNamingEnumeration(listResult); - tested.list(nameMock, handlerMock); + this.tested.list(this.nameMock, this.handlerMock); - verify(handlerMock).handleNameClassPair(listResult); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(listResult); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -175,11 +175,11 @@ public class LdapTemplateListTest { setupStringListAndNamingEnumeration(listResult); - tested.list("o=example.com", handlerMock); + this.tested.list("o=example.com", this.handlerMock); - verify(handlerMock).handleNameClassPair(listResult); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(listResult); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -187,17 +187,17 @@ public class LdapTemplateListTest { expectGetReadOnlyContext(); javax.naming.PartialResultException pre = new javax.naming.PartialResultException(); - when(dirContextMock.list(NAME)).thenThrow(pre); + when(this.dirContextMock.list(NAME)).thenThrow(pre); try { - tested.list(NAME); + this.tested.list(NAME); fail("PartialResultException expected"); } catch (PartialResultException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -205,13 +205,13 @@ public class LdapTemplateListTest { expectGetReadOnlyContext(); javax.naming.PartialResultException pre = new javax.naming.PartialResultException(); - when(dirContextMock.list(NAME)).thenThrow(pre); + when(this.dirContextMock.list(NAME)).thenThrow(pre); - tested.setIgnorePartialResultException(true); + this.tested.setIgnorePartialResultException(true); - List list = tested.list(NAME); + List list = this.tested.list(NAME); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).isEmpty(); @@ -222,17 +222,17 @@ public class LdapTemplateListTest { expectGetReadOnlyContext(); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(dirContextMock.list(NAME)).thenThrow(ne); + when(this.dirContextMock.list(NAME)).thenThrow(ne); try { - tested.list(NAME); + this.tested.list(NAME); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } // Tests for listBindings @@ -245,10 +245,10 @@ public class LdapTemplateListTest { setupStringListBindingsAndNamingEnumeration(listResult); - List list = tested.listBindings(NAME); + List list = this.tested.listBindings(NAME); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -263,10 +263,10 @@ public class LdapTemplateListTest { setupListBindingsAndNamingEnumeration(listResult); - List list = tested.listBindings(nameMock); + List list = this.tested.listBindings(this.nameMock); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -283,12 +283,12 @@ public class LdapTemplateListTest { setupStringListBindingsAndNamingEnumeration(listResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.listBindings(NAME, contextMapperMock); + List list = this.tested.listBindings(NAME, this.contextMapperMock); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -305,12 +305,12 @@ public class LdapTemplateListTest { setupListBindingsAndNamingEnumeration(listResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.listBindings(nameMock, contextMapperMock); + List list = this.tested.listBindings(this.nameMock, this.contextMapperMock); - verify(dirContextMock).close(); - verify(namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.namingEnumerationMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTest.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTest.java index b8891c46..3959ce89 100644 --- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTest.java +++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTest.java @@ -58,23 +58,23 @@ public class LdapTemplateLookupTest { @Before public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); // Setup Name mock - nameMock = mock(Name.class); - contextMapperMock = mock(ContextMapper.class); - attributesMapperMock = mock(AttributesMapper.class); - odmMock = mock(ObjectDirectoryMapper.class); + this.nameMock = mock(Name.class); + this.contextMapperMock = mock(ContextMapper.class); + this.attributesMapperMock = mock(AttributesMapper.class); + this.odmMock = mock(ObjectDirectoryMapper.class); - tested = new LdapTemplate(contextSourceMock); - tested.setObjectDirectoryMapper(odmMock); + this.tested = new LdapTemplate(this.contextSourceMock); + this.tested.setObjectDirectoryMapper(this.odmMock); } private void expectGetReadOnlyContext() { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); } // Tests for lookup(name) @@ -84,11 +84,11 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); Object expected = new Object(); - when(dirContextMock.lookup(nameMock)).thenReturn(expected); + when(this.dirContextMock.lookup(this.nameMock)).thenReturn(expected); - Object actual = tested.lookup(nameMock); + Object actual = this.tested.lookup(this.nameMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -98,11 +98,11 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); Object expected = new Object(); - when(dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected); + when(this.dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected); - Object actual = tested.lookup(DEFAULT_BASE_STRING); + Object actual = this.tested.lookup(DEFAULT_BASE_STRING); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -112,17 +112,17 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - when(dirContextMock.lookup(nameMock)).thenThrow(ne); + when(this.dirContextMock.lookup(this.nameMock)).thenThrow(ne); try { - tested.lookup(nameMock); + this.tested.lookup(this.nameMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } // Tests for lookup(name, AttributesMapper) @@ -132,14 +132,14 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); BasicAttributes expectedAttributes = new BasicAttributes(); - when(dirContextMock.getAttributes(nameMock)).thenReturn(expectedAttributes); + when(this.dirContextMock.getAttributes(this.nameMock)).thenReturn(expectedAttributes); Object expected = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); - Object actual = tested.lookup(nameMock, attributesMapperMock); + Object actual = this.tested.lookup(this.nameMock, this.attributesMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -149,14 +149,14 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); BasicAttributes expectedAttributes = new BasicAttributes(); - when(dirContextMock.getAttributes(DEFAULT_BASE_STRING)).thenReturn(expectedAttributes); + when(this.dirContextMock.getAttributes(DEFAULT_BASE_STRING)).thenReturn(expectedAttributes); Object expected = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); - Object actual = tested.lookup(DEFAULT_BASE_STRING, attributesMapperMock); + Object actual = this.tested.lookup(DEFAULT_BASE_STRING, this.attributesMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -166,17 +166,17 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - when(dirContextMock.getAttributes(nameMock)).thenThrow(ne); + when(this.dirContextMock.getAttributes(this.nameMock)).thenThrow(ne); try { - tested.lookup(nameMock, attributesMapperMock); + this.tested.lookup(this.nameMock, this.attributesMapperMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } // Tests for lookup(name, ContextMapper) @@ -187,13 +187,13 @@ public class LdapTemplateLookupTest { Object transformed = new Object(); Object expected = new Object(); - when(dirContextMock.lookup(nameMock)).thenReturn(expected); + when(this.dirContextMock.lookup(this.nameMock)).thenReturn(expected); - when(contextMapperMock.mapFromContext(expected)).thenReturn(transformed); + when(this.contextMapperMock.mapFromContext(expected)).thenReturn(transformed); - Object actual = tested.lookup(nameMock, contextMapperMock); + Object actual = this.tested.lookup(this.nameMock, this.contextMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(transformed); } @@ -206,15 +206,15 @@ public class LdapTemplateLookupTest { Class expectedClass = Object.class; DirContextAdapter expectedContext = new DirContextAdapter(); - when(dirContextMock.lookup(nameMock)).thenReturn(expectedContext); - when(odmMock.mapFromLdapDataEntry(expectedContext, expectedClass)).thenReturn(transformed); + when(this.dirContextMock.lookup(this.nameMock)).thenReturn(expectedContext); + when(this.odmMock.mapFromLdapDataEntry(expectedContext, expectedClass)).thenReturn(transformed); - when(nameMock.getAll()).thenReturn(Collections.enumeration(Collections.emptyList())); + when(this.nameMock.getAll()).thenReturn(Collections.enumeration(Collections.emptyList())); // Perform test - Object result = tested.findByDn(nameMock, expectedClass); + Object result = this.tested.findByDn(this.nameMock, expectedClass); assertThat(result).isSameAs(transformed); - verify(odmMock).manageClass(expectedClass); + verify(this.odmMock).manageClass(expectedClass); } @Test @@ -223,13 +223,13 @@ public class LdapTemplateLookupTest { Object transformed = new Object(); Object expected = new Object(); - when(dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected); + when(this.dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected); - when(contextMapperMock.mapFromContext(expected)).thenReturn(transformed); + when(this.contextMapperMock.mapFromContext(expected)).thenReturn(transformed); - Object actual = tested.lookup(DEFAULT_BASE_STRING, contextMapperMock); + Object actual = this.tested.lookup(DEFAULT_BASE_STRING, this.contextMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(transformed); } @@ -239,17 +239,17 @@ public class LdapTemplateLookupTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - when(dirContextMock.lookup(nameMock)).thenThrow(ne); + when(this.dirContextMock.lookup(this.nameMock)).thenThrow(ne); try { - tested.lookup(nameMock, contextMapperMock); + this.tested.lookup(this.nameMock, this.contextMapperMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } // Tests for lookup(name, attributes, AttributesMapper) @@ -263,14 +263,14 @@ public class LdapTemplateLookupTest { BasicAttributes expectedAttributes = new BasicAttributes(); expectedAttributes.put("cn", "Some Name"); - when(dirContextMock.getAttributes(nameMock, attributeNames)).thenReturn(expectedAttributes); + when(this.dirContextMock.getAttributes(this.nameMock, attributeNames)).thenReturn(expectedAttributes); Object expected = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); - Object actual = tested.lookup(nameMock, attributeNames, attributesMapperMock); + Object actual = this.tested.lookup(this.nameMock, attributeNames, this.attributesMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -284,14 +284,14 @@ public class LdapTemplateLookupTest { BasicAttributes expectedAttributes = new BasicAttributes(); expectedAttributes.put("cn", "Some Name"); - when(dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes); + when(this.dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes); Object expected = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected); - Object actual = tested.lookup(DEFAULT_BASE_STRING, attributeNames, attributesMapperMock); + Object actual = this.tested.lookup(DEFAULT_BASE_STRING, attributeNames, this.attributesMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(expected); } @@ -310,14 +310,14 @@ public class LdapTemplateLookupTest { LdapName name = LdapUtils.newLdapName(DEFAULT_BASE_STRING); DirContextAdapter adapter = new DirContextAdapter(expectedAttributes, name); - when(dirContextMock.getAttributes(name, attributeNames)).thenReturn(expectedAttributes); + when(this.dirContextMock.getAttributes(name, attributeNames)).thenReturn(expectedAttributes); Object transformed = new Object(); - when(contextMapperMock.mapFromContext(adapter)).thenReturn(transformed); + when(this.contextMapperMock.mapFromContext(adapter)).thenReturn(transformed); - Object actual = tested.lookup(name, attributeNames, contextMapperMock); + Object actual = this.tested.lookup(name, attributeNames, this.contextMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(transformed); } @@ -331,17 +331,17 @@ public class LdapTemplateLookupTest { BasicAttributes expectedAttributes = new BasicAttributes(); expectedAttributes.put("cn", "Some Name"); - when(dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes); + when(this.dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes); LdapName name = LdapUtils.newLdapName(DEFAULT_BASE_STRING); DirContextAdapter adapter = new DirContextAdapter(expectedAttributes, name); Object transformed = new Object(); - when(contextMapperMock.mapFromContext(adapter)).thenReturn(transformed); + when(this.contextMapperMock.mapFromContext(adapter)).thenReturn(transformed); - Object actual = tested.lookup(DEFAULT_BASE_STRING, attributeNames, contextMapperMock); + Object actual = this.tested.lookup(DEFAULT_BASE_STRING, attributeNames, this.contextMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(actual).isSameAs(transformed); } diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTest.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTest.java index aae7a1ca..a753bbf3 100644 --- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTest.java +++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTest.java @@ -19,12 +19,12 @@ public class LdapTemplateOdmTest { @Before public void prepareTestedClass() { - tested = mock(LdapTemplate.class); + this.tested = mock(LdapTemplate.class); - doCallRealMethod().when(tested).setObjectDirectoryMapper(any(ObjectDirectoryMapper.class)); - odmMock = mock(ObjectDirectoryMapper.class); + doCallRealMethod().when(this.tested).setObjectDirectoryMapper(any(ObjectDirectoryMapper.class)); + this.odmMock = mock(ObjectDirectoryMapper.class); - tested.setObjectDirectoryMapper(odmMock); + this.tested.setObjectDirectoryMapper(this.odmMock); } @Test diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTest.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTest.java index 0e2bf27b..758823e0 100644 --- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTest.java +++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTest.java @@ -52,32 +52,32 @@ public class LdapTemplateRenameTest { @Before public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); // Setup Name mock for old name - oldNameMock = mock(Name.class); + this.oldNameMock = mock(Name.class); // Setup Name mock for new name - newNameMock = mock(Name.class); + this.newNameMock = mock(Name.class); - tested = new LdapTemplate(contextSourceMock); + this.tested = new LdapTemplate(this.contextSourceMock); } private void expectGetReadWriteContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); } @Test public void testRename() throws Exception { expectGetReadWriteContext(); - tested.rename(oldNameMock, newNameMock); + this.tested.rename(this.oldNameMock, this.newNameMock); - verify(dirContextMock).rename(oldNameMock, newNameMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).rename(this.oldNameMock, this.newNameMock); + verify(this.dirContextMock).close(); } @Test @@ -85,17 +85,17 @@ public class LdapTemplateRenameTest { expectGetReadWriteContext(); javax.naming.NameAlreadyBoundException ne = new javax.naming.NameAlreadyBoundException(); - doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock); + doThrow(ne).when(this.dirContextMock).rename(this.oldNameMock, this.newNameMock); try { - tested.rename(oldNameMock, newNameMock); + this.tested.rename(this.oldNameMock, this.newNameMock); fail("NameAlreadyBoundException expected"); } catch (NameAlreadyBoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -104,27 +104,27 @@ public class LdapTemplateRenameTest { javax.naming.NamingException ne = new javax.naming.NamingException(); - doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock); + doThrow(ne).when(this.dirContextMock).rename(this.oldNameMock, this.newNameMock); try { - tested.rename(oldNameMock, newNameMock); + this.tested.rename(this.oldNameMock, this.newNameMock); fail("UncategorizedLdapException expected"); } catch (UncategorizedLdapException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testRename_String() throws Exception { expectGetReadWriteContext(); - tested.rename("o=example.com", "o=somethingelse.com"); + this.tested.rename("o=example.com", "o=somethingelse.com"); - verify(dirContextMock).rename("o=example.com", "o=somethingelse.com"); - verify(dirContextMock).close(); + verify(this.dirContextMock).rename("o=example.com", "o=somethingelse.com"); + verify(this.dirContextMock).close(); } } diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateTest.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateTest.java index cab77562..f29c1d7f 100644 --- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateTest.java +++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateTest.java @@ -112,37 +112,37 @@ public class LdapTemplateTest { public void setUp() throws Exception { // Setup ContextSource mock - contextSourceMock = mock(ContextSource.class); + this.contextSourceMock = mock(ContextSource.class); // Setup LdapContext mock - dirContextMock = mock(LdapContext.class); + this.dirContextMock = mock(LdapContext.class); // Setup NamingEnumeration mock - namingEnumerationMock = mock(NamingEnumeration.class); + this.namingEnumerationMock = mock(NamingEnumeration.class); // Setup Name mock - nameMock = LdapUtils.emptyLdapName(); + this.nameMock = LdapUtils.emptyLdapName(); // Setup Handler mock - handlerMock = mock(NameClassPairCallbackHandler.class); - contextMapperMock = mock(ContextMapper.class); - attributesMapperMock = mock(AttributesMapper.class); - contextExecutorMock = mock(ContextExecutor.class); - searchExecutorMock = mock(SearchExecutor.class); - dirContextProcessorMock = mock(DirContextProcessor.class); - dirContextOperationsMock = mock(DirContextOperations.class); - authenticatedContextMock = mock(DirContext.class); - entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class); - odmMock = mock(ObjectDirectoryMapper.class); - query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user"); - authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class); + this.handlerMock = mock(NameClassPairCallbackHandler.class); + this.contextMapperMock = mock(ContextMapper.class); + this.attributesMapperMock = mock(AttributesMapper.class); + this.contextExecutorMock = mock(ContextExecutor.class); + this.searchExecutorMock = mock(SearchExecutor.class); + this.dirContextProcessorMock = mock(DirContextProcessor.class); + this.dirContextOperationsMock = mock(DirContextOperations.class); + this.authenticatedContextMock = mock(DirContext.class); + this.entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class); + this.odmMock = mock(ObjectDirectoryMapper.class); + this.query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user"); + this.authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class); - tested = new LdapTemplate(contextSourceMock); - tested.setObjectDirectoryMapper(odmMock); + this.tested = new LdapTemplate(this.contextSourceMock); + this.tested.setObjectDirectoryMapper(this.odmMock); } private void expectGetReadWriteContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); } private void expectGetReadOnlyContext() { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); } @Test @@ -153,10 +153,10 @@ public class LdapTemplateTest { singleSearchResult(searchControlsOneLevel(), searchResult); - tested.search(nameMock, "(ou=somevalue)", 1, true, handlerMock); + this.tested.search(this.nameMock, "(ou=somevalue)", 1, true, this.handlerMock); - verify(handlerMock).handleNameClassPair(searchResult); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.dirContextMock).close(); } @Test @@ -169,10 +169,10 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); - tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, true, handlerMock); + this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, true, this.handlerMock); - verify(handlerMock).handleNameClassPair(searchResult); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.dirContextMock).close(); } @Test @@ -186,10 +186,10 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); - tested.search(nameMock, "(ou=somevalue)", handlerMock); + this.tested.search(this.nameMock, "(ou=somevalue)", this.handlerMock); - verify(handlerMock).handleNameClassPair(searchResult); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.dirContextMock).close(); } @Test @@ -203,10 +203,10 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); - tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", handlerMock); + this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", this.handlerMock); - verify(handlerMock).handleNameClassPair(searchResult); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.dirContextMock).close(); } @Test @@ -217,17 +217,17 @@ public class LdapTemplateTest { controls.setReturningObjFlag(false); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException("some text"); - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenThrow(ne); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenThrow(ne); try { - tested.search(nameMock, "(ou=somevalue)", handlerMock); + this.tested.search(this.nameMock, "(ou=somevalue)", this.handlerMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -238,18 +238,18 @@ public class LdapTemplateTest { controls.setReturningObjFlag(false); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenThrow(ne); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenThrow(ne); try { - tested.search(nameMock, "(ou=somevalue)", handlerMock); + this.tested.search(this.nameMock, "(ou=somevalue)", this.handlerMock); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { // expected } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -263,13 +263,13 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); - tested.search(nameMock, "(ou=somevalue)", controls, handlerMock, dirContextProcessorMock); + this.tested.search(this.nameMock, "(ou=somevalue)", controls, this.handlerMock, this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(namingEnumerationMock).close(); - verify(handlerMock).handleNameClassPair(searchResult); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.namingEnumerationMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.dirContextMock).close(); } @Test @@ -283,13 +283,14 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); - tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, handlerMock, dirContextProcessorMock); + this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, this.handlerMock, + this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(namingEnumerationMock).close(); - verify(handlerMock).handleNameClassPair(searchResult); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.namingEnumerationMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.dirContextMock).close(); } @Test @@ -305,15 +306,15 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, attributesMapperMock, - dirContextProcessorMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, this.attributesMapperMock, + this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -333,14 +334,15 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", controls, attributesMapperMock, dirContextProcessorMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", controls, this.attributesMapperMock, + this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -359,15 +361,15 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, contextMapperMock, - dirContextProcessorMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, this.contextMapperMock, + this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -386,14 +388,15 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", controls, contextMapperMock, dirContextProcessorMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", controls, this.contextMapperMock, + this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -416,12 +419,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", 1, attrs, attributesMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", 1, attrs, this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -444,12 +447,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, attrs, attributesMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, attrs, this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -458,9 +461,9 @@ public class LdapTemplateTest { @Test public void verifyThatDefaultSearchControlParametersAreAutomaticallyAppliedInSearch() throws Exception { - tested.setDefaultSearchScope(SearchControls.ONELEVEL_SCOPE); - tested.setDefaultCountLimit(5000); - tested.setDefaultTimeLimit(500); + this.tested.setDefaultSearchScope(SearchControls.ONELEVEL_SCOPE); + this.tested.setDefaultCountLimit(5000); + this.tested.setDefaultTimeLimit(500); expectGetReadOnlyContext(); @@ -476,12 +479,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", attributesMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -501,12 +504,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", 1, attributesMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", 1, this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -526,12 +529,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, attributesMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -551,12 +554,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", attributesMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -576,12 +579,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", attributesMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -597,12 +600,12 @@ public class LdapTemplateTest { singleSearchResult(searchControlsOneLevel(), searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", 1, contextMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", 1, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -613,8 +616,8 @@ public class LdapTemplateTest { public void testFindOne() throws Exception { Class expectedClass = Object.class; - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue"))) + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue"))) .thenReturn(new EqualsFilter("ou", "somevalue")); DirContextAdapter expectedObject = new DirContextAdapter(); @@ -622,12 +625,12 @@ public class LdapTemplateTest { singleSearchResult(searchControlsRecursive(), searchResult); Object expectedResult = expectedObject; - when(odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult); + when(this.odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult); - Object result = tested.findOne(query().where("ou").is("somevalue"), expectedClass); + Object result = this.tested.findOne(query().where("ou").is("somevalue"), expectedClass); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isSameAs(expectedResult); } @@ -636,31 +639,31 @@ public class LdapTemplateTest { public void verifyThatFindOneThrowsEmptyResultIfNoResult() throws Exception { Class expectedClass = Object.class; - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue"))) + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue"))) .thenReturn(new EqualsFilter("ou", "somevalue")); noSearchResults(searchControlsRecursive()); try { - tested.findOne(query().where("ou").is("somevalue"), expectedClass); + this.tested.findOne(query().where("ou").is("somevalue"), expectedClass); fail("EmptyResultDataAccessException expected"); } catch (EmptyResultDataAccessException expected) { assertThat(true).isTrue(); } - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); - verify(odmMock, never()).mapFromLdapDataEntry(any(LdapDataEntry.class), any(Class.class)); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); + verify(this.odmMock, never()).mapFromLdapDataEntry(any(LdapDataEntry.class), any(Class.class)); } @Test public void verifyThatFindOneThrowsIncorrectResultSizeDataAccessExceptionWhenMoreResults() throws Exception { Class expectedClass = Object.class; - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue"))) + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue"))) .thenReturn(new EqualsFilter("ou", "somevalue")); DirContextAdapter expectedObject = new DirContextAdapter(); @@ -669,18 +672,19 @@ public class LdapTemplateTest { setupSearchResults(searchControlsRecursive(), new SearchResult[] { searchResult, searchResult }); Object expectedResult = expectedObject; - when(odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult, expectedResult); + when(this.odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult, + expectedResult); try { - tested.findOne(query().where("ou").is("somevalue"), expectedClass); + this.tested.findOne(query().where("ou").is("somevalue"), expectedClass); fail("EmptyResultDataAccessException expected"); } catch (IncorrectResultSizeDataAccessException expected) { assertThat(true).isTrue(); } - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -689,22 +693,23 @@ public class LdapTemplateTest { Class expectedClass = Object.class; Filter filter = new EqualsFilter("ou", "somevalue"); - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(odmMock.filterFor(any(Class.class), any(Filter.class))).thenReturn(filter); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.odmMock.filterFor(any(Class.class), any(Filter.class))).thenReturn(filter); SearchControls controls = new SearchControls(); controls.setReturningAttributes(new String[] { "attribute" }); DirContextAdapter expectedObject = new DirContextAdapter(); SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes()); setupSearchResults(controls, searchResult); Object expectedResult = expectedObject; - when(odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult, expectedResult); + when(this.odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult, + expectedResult); - List results = tested.find(nameMock, filter, controls, expectedClass); + List results = this.tested.find(this.nameMock, filter, controls, expectedClass); assertThat(results).hasSize(1); - verify(odmMock, never()).manageClass(any(Class.class)); + verify(this.odmMock, never()).manageClass(any(Class.class)); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -717,22 +722,23 @@ public class LdapTemplateTest { expectedControls.setReturningAttributes(expectedReturningAttributes); Filter filter = new EqualsFilter("ou", "somevalue"); - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(odmMock.filterFor(eq(expectedClass), any(Filter.class))).thenReturn(filter); - when(odmMock.manageClass(eq(expectedClass))).thenReturn(expectedReturningAttributes); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.odmMock.filterFor(eq(expectedClass), any(Filter.class))).thenReturn(filter); + when(this.odmMock.manageClass(eq(expectedClass))).thenReturn(expectedReturningAttributes); SearchControls controls = new SearchControls(); DirContextAdapter expectedObject = new DirContextAdapter(); SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes()); setupSearchResults(expectedControls, searchResult); Object expectedResult = expectedObject; - when(odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult, expectedResult); + when(this.odmMock.mapFromLdapDataEntry(expectedObject, expectedClass)).thenReturn(expectedResult, + expectedResult); - List results = tested.find(nameMock, filter, controls, expectedClass); + List results = this.tested.find(this.nameMock, filter, controls, expectedClass); assertThat(results).hasSize(1); - verify(odmMock).manageClass(eq(expectedClass)); + verify(this.odmMock).manageClass(eq(expectedClass)); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -750,12 +756,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", 1, attrs, contextMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", 1, attrs, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -777,12 +783,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, attrs, contextMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, attrs, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -801,12 +807,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, contextMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", 1, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -823,12 +829,12 @@ public class LdapTemplateTest { singleSearchResult(searchControlsRecursive(), searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", contextMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -847,12 +853,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", contextMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -871,12 +877,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, contextMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -900,12 +906,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(expectedControls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, contextMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -924,12 +930,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", controls, contextMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", controls, this.contextMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -949,12 +955,12 @@ public class LdapTemplateTest { singleSearchResultWithStringBase(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, attributesMapperMock); + List list = this.tested.search(DEFAULT_BASE_STRING, "(ou=somevalue)", controls, this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -974,12 +980,12 @@ public class LdapTemplateTest { singleSearchResult(controls, searchResult); Object expectedResult = new Object(); - when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); + when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expectedResult); - List list = tested.search(nameMock, "(ou=somevalue)", controls, attributesMapperMock); + List list = this.tested.search(this.nameMock, "(ou=somevalue)", controls, this.attributesMapperMock); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); assertThat(list).isNotNull(); assertThat(list).hasSize(1); @@ -992,10 +998,10 @@ public class LdapTemplateTest { ModificationItem[] mods = new ModificationItem[0]; - tested.modifyAttributes(nameMock, mods); + this.tested.modifyAttributes(this.nameMock, mods); - verify(dirContextMock).modifyAttributes(nameMock, mods); - verify(dirContextMock).close(); + verify(this.dirContextMock).modifyAttributes(this.nameMock, mods); + verify(this.dirContextMock).close(); } @Test @@ -1004,10 +1010,10 @@ public class LdapTemplateTest { ModificationItem[] mods = new ModificationItem[0]; - tested.modifyAttributes(DEFAULT_BASE_STRING, mods); + this.tested.modifyAttributes(DEFAULT_BASE_STRING, mods); - verify(dirContextMock).modifyAttributes(DEFAULT_BASE_STRING, mods); - verify(dirContextMock).close(); + verify(this.dirContextMock).modifyAttributes(DEFAULT_BASE_STRING, mods); + verify(this.dirContextMock).close(); } @Test @@ -1017,17 +1023,17 @@ public class LdapTemplateTest { ModificationItem[] mods = new ModificationItem[0]; javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - doThrow(ne).when(dirContextMock).modifyAttributes(nameMock, mods); + doThrow(ne).when(this.dirContextMock).modifyAttributes(this.nameMock, mods); try { - tested.modifyAttributes(nameMock, mods); + this.tested.modifyAttributes(this.nameMock, mods); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1037,10 +1043,10 @@ public class LdapTemplateTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.bind(nameMock, expectedObject, expectedAttributes); + this.tested.bind(this.nameMock, expectedObject, expectedAttributes); - verify(dirContextMock).bind(nameMock, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).bind(this.nameMock, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @@ -1051,10 +1057,10 @@ public class LdapTemplateTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.bind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); + this.tested.bind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); - verify(dirContextMock).bind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).bind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @Test @@ -1064,30 +1070,30 @@ public class LdapTemplateTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - doThrow(ne).when(dirContextMock).bind(nameMock, expectedObject, expectedAttributes); + doThrow(ne).when(this.dirContextMock).bind(this.nameMock, expectedObject, expectedAttributes); try { - tested.bind(nameMock, expectedObject, expectedAttributes); + this.tested.bind(this.nameMock, expectedObject, expectedAttributes); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testBindWithContext() throws Exception { expectGetReadWriteContext(); - when(dirContextOperationsMock.getDn()).thenReturn(nameMock); - when(dirContextOperationsMock.isUpdateMode()).thenReturn(false); + when(this.dirContextOperationsMock.getDn()).thenReturn(this.nameMock); + when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false); - tested.bind(dirContextOperationsMock); + this.tested.bind(this.dirContextOperationsMock); - verify(dirContextMock).bind(nameMock, dirContextOperationsMock, null); - verify(dirContextMock).close(); + verify(this.dirContextMock).bind(this.nameMock, this.dirContextOperationsMock, null); + verify(this.dirContextMock).close(); } @Test @@ -1096,16 +1102,16 @@ public class LdapTemplateTest { Object expectedObject = new Object(); LdapName expectedName = LdapUtils.newLdapName("ou=someOu"); - when(odmMock.getId(expectedObject)).thenReturn(expectedName); + when(this.odmMock.getId(expectedObject)).thenReturn(expectedName); ArgumentCaptor ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class); - doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); + doNothing().when(this.odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); - tested.create(expectedObject); + this.tested.create(expectedObject); - verify(odmMock, never()).setId(expectedObject, expectedName); - verify(dirContextMock).bind(expectedName, ctxCaptor.getValue(), null); - verify(dirContextMock).close(); + verify(this.odmMock, never()).setId(expectedObject, expectedName); + verify(this.dirContextMock).bind(expectedName, ctxCaptor.getValue(), null); + verify(this.dirContextMock).close(); } @Test @@ -1114,27 +1120,27 @@ public class LdapTemplateTest { Object expectedObject = new Object(); LdapName expectedName = LdapUtils.newLdapName("ou=someOu"); - when(odmMock.getId(expectedObject)).thenReturn(null); - when(odmMock.getCalculatedId(expectedObject)).thenReturn(expectedName); + when(this.odmMock.getId(expectedObject)).thenReturn(null); + when(this.odmMock.getCalculatedId(expectedObject)).thenReturn(expectedName); ArgumentCaptor ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class); - doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); + doNothing().when(this.odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); - tested.create(expectedObject); + this.tested.create(expectedObject); - verify(odmMock).setId(expectedObject, expectedName); - verify(dirContextMock).bind(expectedName, ctxCaptor.getValue(), null); - verify(dirContextMock).close(); + verify(this.odmMock).setId(expectedObject, expectedName); + verify(this.dirContextMock).bind(expectedName, ctxCaptor.getValue(), null); + verify(this.dirContextMock).close(); } @Test public void testCreateWithNoIdAvailableThrows() throws NamingException { Object expectedObject = new Object(); - when(odmMock.getId(expectedObject)).thenReturn(null); - when(odmMock.getCalculatedId(expectedObject)).thenReturn(null); + when(this.odmMock.getId(expectedObject)).thenReturn(null); + when(this.odmMock.getCalculatedId(expectedObject)).thenReturn(null); try { - tested.create(expectedObject); + this.tested.create(expectedObject); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { @@ -1144,8 +1150,8 @@ public class LdapTemplateTest { @Test public void testUpdateWithIdSpecified() throws NamingException { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); LdapName expectedName = LdapUtils.newLdapName("ou=someOu"); ModificationItem[] expectedModificationItems = new ModificationItem[0]; @@ -1155,24 +1161,24 @@ public class LdapTemplateTest { when(ctxMock.getModificationItems()).thenReturn(expectedModificationItems); Object expectedObject = new Object(); - when(odmMock.getId(expectedObject)).thenReturn(expectedName); - when(odmMock.getCalculatedId(expectedObject)).thenReturn(null); + when(this.odmMock.getId(expectedObject)).thenReturn(expectedName); + when(this.odmMock.getCalculatedId(expectedObject)).thenReturn(null); - when(dirContextMock.lookup(expectedName)).thenReturn(ctxMock); + when(this.dirContextMock.lookup(expectedName)).thenReturn(ctxMock); - tested.update(expectedObject); + this.tested.update(expectedObject); - verify(odmMock, never()).setId(expectedObject, expectedName); - verify(odmMock).mapToLdapDataEntry(expectedObject, ctxMock); - verify(dirContextMock).modifyAttributes(expectedName, expectedModificationItems); + verify(this.odmMock, never()).setId(expectedObject, expectedName); + verify(this.odmMock).mapToLdapDataEntry(expectedObject, ctxMock); + verify(this.dirContextMock).modifyAttributes(expectedName, expectedModificationItems); - verify(dirContextMock, times(2)).close(); + verify(this.dirContextMock, times(2)).close(); } @Test public void testUpdateWithIdCalculated() throws NamingException { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); LdapName expectedName = LdapUtils.newLdapName("ou=someOu"); ModificationItem[] expectedModificationItems = new ModificationItem[0]; @@ -1182,115 +1188,115 @@ public class LdapTemplateTest { when(ctxMock.getModificationItems()).thenReturn(expectedModificationItems); Object expectedObject = new Object(); - when(odmMock.getId(expectedObject)).thenReturn(null); - when(odmMock.getCalculatedId(expectedObject)).thenReturn(expectedName); + when(this.odmMock.getId(expectedObject)).thenReturn(null); + when(this.odmMock.getCalculatedId(expectedObject)).thenReturn(expectedName); - when(dirContextMock.lookup(expectedName)).thenReturn(ctxMock); + when(this.dirContextMock.lookup(expectedName)).thenReturn(ctxMock); - tested.update(expectedObject); + this.tested.update(expectedObject); - verify(odmMock).setId(expectedObject, expectedName); - verify(odmMock).mapToLdapDataEntry(expectedObject, ctxMock); - verify(dirContextMock).modifyAttributes(expectedName, expectedModificationItems); + verify(this.odmMock).setId(expectedObject, expectedName); + verify(this.odmMock).mapToLdapDataEntry(expectedObject, ctxMock); + verify(this.dirContextMock).modifyAttributes(expectedName, expectedModificationItems); - verify(dirContextMock, times(2)).close(); + verify(this.dirContextMock, times(2)).close(); } @Test public void testUpdateWithIdChanged() throws NamingException { Object expectedObject = new Object(); - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock, dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock, this.dirContextMock); LdapName expectedOriginalName = LdapUtils.newLdapName("ou=someOu"); LdapName expectedNewName = LdapUtils.newLdapName("ou=someOtherOu"); ArgumentCaptor ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class); - doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); + doNothing().when(this.odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); - when(odmMock.getId(expectedObject)).thenReturn(expectedOriginalName); - when(odmMock.getCalculatedId(expectedObject)).thenReturn(expectedNewName); + when(this.odmMock.getId(expectedObject)).thenReturn(expectedOriginalName); + when(this.odmMock.getCalculatedId(expectedObject)).thenReturn(expectedNewName); - tested.update(expectedObject); + this.tested.update(expectedObject); - verify(odmMock).setId(expectedObject, expectedNewName); - verify(dirContextMock).unbind(expectedOriginalName); - verify(dirContextMock).bind(expectedNewName, ctxCaptor.getValue(), null); - verify(dirContextMock, times(2)).close(); + verify(this.odmMock).setId(expectedObject, expectedNewName); + verify(this.dirContextMock).unbind(expectedOriginalName); + verify(this.dirContextMock).bind(expectedNewName, ctxCaptor.getValue(), null); + verify(this.dirContextMock, times(2)).close(); } @Test public void testUnbind() throws Exception { expectGetReadWriteContext(); - tested.unbind(nameMock); + this.tested.unbind(this.nameMock); - verify(dirContextMock).unbind(nameMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(this.nameMock); + verify(this.dirContextMock).close(); } @Test public void testUnbind_String() throws Exception { expectGetReadWriteContext(); - tested.unbind(DEFAULT_BASE_STRING); + this.tested.unbind(DEFAULT_BASE_STRING); - verify(dirContextMock).unbind(DEFAULT_BASE_STRING); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(DEFAULT_BASE_STRING); + verify(this.dirContextMock).close(); } @Test public void testRebindWithContext() throws Exception { expectGetReadWriteContext(); - when(dirContextOperationsMock.getDn()).thenReturn(nameMock); - when(dirContextOperationsMock.isUpdateMode()).thenReturn(false); + when(this.dirContextOperationsMock.getDn()).thenReturn(this.nameMock); + when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false); - tested.rebind(dirContextOperationsMock); + this.tested.rebind(this.dirContextOperationsMock); - verify(dirContextMock).rebind(nameMock, dirContextOperationsMock, null); - verify(dirContextMock).close(); + verify(this.dirContextMock).rebind(this.nameMock, this.dirContextOperationsMock, null); + verify(this.dirContextMock).close(); } @Test public void testUnbindRecursive() throws Exception { expectGetReadWriteContext(); - when(namingEnumerationMock.hasMore()).thenReturn(true, false, false); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false, false); Binding binding = new Binding("cn=Some name", null); - when(namingEnumerationMock.next()).thenReturn(binding); + when(this.namingEnumerationMock.next()).thenReturn(binding); LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE_STRING); - when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(listDn)).thenReturn(this.namingEnumerationMock); LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com"); - when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(subListDn)).thenReturn(this.namingEnumerationMock); - tested.unbind(new CompositeName(DEFAULT_BASE_STRING), true); + this.tested.unbind(new CompositeName(DEFAULT_BASE_STRING), true); - verify(dirContextMock).unbind(subListDn); - verify(dirContextMock).unbind(listDn); - verify(namingEnumerationMock, times(2)).close(); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(subListDn); + verify(this.dirContextMock).unbind(listDn); + verify(this.namingEnumerationMock, times(2)).close(); + verify(this.dirContextMock).close(); } @Test public void testUnbindRecursive_String() throws Exception { expectGetReadWriteContext(); - when(namingEnumerationMock.hasMore()).thenReturn(true, false, false); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false, false); Binding binding = new Binding("cn=Some name", null); - when(namingEnumerationMock.next()).thenReturn(binding); + when(this.namingEnumerationMock.next()).thenReturn(binding); LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE_STRING); - when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(listDn)).thenReturn(this.namingEnumerationMock); LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com"); - when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock); + when(this.dirContextMock.listBindings(subListDn)).thenReturn(this.namingEnumerationMock); - tested.unbind(DEFAULT_BASE_STRING, true); + this.tested.unbind(DEFAULT_BASE_STRING, true); - verify(dirContextMock).unbind(subListDn); - verify(dirContextMock).unbind(listDn); - verify(namingEnumerationMock, times(2)).close(); - verify(dirContextMock).close(); + verify(this.dirContextMock).unbind(subListDn); + verify(this.dirContextMock).unbind(listDn); + verify(this.namingEnumerationMock, times(2)).close(); + verify(this.dirContextMock).close(); } @Test @@ -1300,10 +1306,10 @@ public class LdapTemplateTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.rebind(nameMock, expectedObject, expectedAttributes); + this.tested.rebind(this.nameMock, expectedObject, expectedAttributes); - verify(dirContextMock).rebind(nameMock, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).rebind(this.nameMock, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @Test @@ -1313,10 +1319,10 @@ public class LdapTemplateTest { Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - tested.rebind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); + this.tested.rebind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); - verify(dirContextMock).rebind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); - verify(dirContextMock).close(); + verify(this.dirContextMock).rebind(DEFAULT_BASE_STRING, expectedObject, expectedAttributes); + verify(this.dirContextMock).close(); } @Test @@ -1324,17 +1330,17 @@ public class LdapTemplateTest { expectGetReadWriteContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - doThrow(ne).when(dirContextMock).unbind(nameMock); + doThrow(ne).when(this.dirContextMock).unbind(this.nameMock); try { - tested.unbind(nameMock); + this.tested.unbind(this.nameMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1342,11 +1348,11 @@ public class LdapTemplateTest { expectGetReadOnlyContext(); Object object = new Object(); - when(contextExecutorMock.executeWithContext(dirContextMock)).thenReturn(object); + when(this.contextExecutorMock.executeWithContext(this.dirContextMock)).thenReturn(object); - Object result = tested.executeReadOnly(contextExecutorMock); + Object result = this.tested.executeReadOnly(this.contextExecutorMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isSameAs(object); } @@ -1356,17 +1362,17 @@ public class LdapTemplateTest { expectGetReadOnlyContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - when(contextExecutorMock.executeWithContext(dirContextMock)).thenThrow(ne); + when(this.contextExecutorMock.executeWithContext(this.dirContextMock)).thenThrow(ne); try { - tested.executeReadOnly(contextExecutorMock); + this.tested.executeReadOnly(this.contextExecutorMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1374,11 +1380,11 @@ public class LdapTemplateTest { expectGetReadWriteContext(); Object object = new Object(); - when(contextExecutorMock.executeWithContext(dirContextMock)).thenReturn(object); + when(this.contextExecutorMock.executeWithContext(this.dirContextMock)).thenReturn(object); - Object result = tested.executeReadWrite(contextExecutorMock); + Object result = this.tested.executeReadWrite(this.contextExecutorMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isSameAs(object); } @@ -1388,17 +1394,17 @@ public class LdapTemplateTest { expectGetReadWriteContext(); javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException(); - when(contextExecutorMock.executeWithContext(dirContextMock)).thenThrow(ne); + when(this.contextExecutorMock.executeWithContext(this.dirContextMock)).thenThrow(ne); try { - tested.executeReadWrite(contextExecutorMock); + this.tested.executeReadWrite(this.contextExecutorMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1407,18 +1413,18 @@ public class LdapTemplateTest { SearchResult searchResult = new SearchResult(null, null, null); - when(searchExecutorMock.executeSearch(dirContextMock)).thenReturn(namingEnumerationMock); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(searchResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResult); - tested.search(searchExecutorMock, handlerMock, dirContextProcessorMock); + this.tested.search(this.searchExecutorMock, this.handlerMock, this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(handlerMock).handleNameClassPair(searchResult); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1426,19 +1432,19 @@ public class LdapTemplateTest { expectGetReadOnlyContext(); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(searchExecutorMock.executeSearch(dirContextMock)).thenThrow(ne); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)).thenThrow(ne); try { - tested.search(searchExecutorMock, handlerMock, dirContextProcessorMock); + this.tested.search(this.searchExecutorMock, this.handlerMock, this.dirContextProcessorMock); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { assertThat(true).isTrue(); } - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.dirContextMock).close(); } @Test @@ -1447,16 +1453,16 @@ public class LdapTemplateTest { SearchResult searchResult = new SearchResult(null, null, null); - when(searchExecutorMock.executeSearch(dirContextMock)).thenReturn(namingEnumerationMock); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(searchResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResult); - tested.search(searchExecutorMock, handlerMock); + this.tested.search(this.searchExecutorMock, this.handlerMock); - verify(handlerMock).handleNameClassPair(searchResult); - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.handlerMock).handleNameClassPair(searchResult); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1464,55 +1470,56 @@ public class LdapTemplateTest { expectGetReadOnlyContext(); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(searchExecutorMock.executeSearch(dirContextMock)).thenThrow(ne); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)).thenThrow(ne); try { - tested.search(searchExecutorMock, handlerMock); + this.tested.search(this.searchExecutorMock, this.handlerMock); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testDoSearch_NamingException_NamingEnumeration() throws Exception { expectGetReadOnlyContext(); - when(searchExecutorMock.executeSearch(dirContextMock)).thenReturn(namingEnumerationMock); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)).thenReturn(this.namingEnumerationMock); javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException(); - when(namingEnumerationMock.hasMore()).thenThrow(ne); + when(this.namingEnumerationMock.hasMore()).thenThrow(ne); try { - tested.search(searchExecutorMock, handlerMock); + this.tested.search(this.searchExecutorMock, this.handlerMock); fail("LimitExceededException expected"); } catch (LimitExceededException expected) { assertThat(true).isTrue(); } - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test public void testDoSearch_NameNotFoundException() throws Exception { expectGetReadOnlyContext(); - when(searchExecutorMock.executeSearch(dirContextMock)).thenThrow(new javax.naming.NameNotFoundException()); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)) + .thenThrow(new javax.naming.NameNotFoundException()); try { - tested.search(searchExecutorMock, handlerMock); + this.tested.search(this.searchExecutorMock, this.handlerMock); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1520,34 +1527,35 @@ public class LdapTemplateTest { expectGetReadOnlyContext(); javax.naming.PartialResultException ex = new javax.naming.PartialResultException(); - when(searchExecutorMock.executeSearch(dirContextMock)).thenThrow(ex); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)).thenThrow(ex); try { - tested.search(searchExecutorMock, handlerMock, dirContextProcessorMock); + this.tested.search(this.searchExecutorMock, this.handlerMock, this.dirContextProcessorMock); fail("PartialResultException expected"); } catch (PartialResultException expected) { assertThat(true).isTrue(); } - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.dirContextMock).close(); } @Test public void testSearch_PartialResult_IgnoreSet() throws Exception { - tested.setIgnorePartialResultException(true); + this.tested.setIgnorePartialResultException(true); expectGetReadOnlyContext(); - when(searchExecutorMock.executeSearch(dirContextMock)).thenThrow(new javax.naming.PartialResultException()); + when(this.searchExecutorMock.executeSearch(this.dirContextMock)) + .thenThrow(new javax.naming.PartialResultException()); - tested.search(searchExecutorMock, handlerMock, dirContextProcessorMock); + this.tested.search(this.searchExecutorMock, this.handlerMock, this.dirContextProcessorMock); - verify(dirContextProcessorMock).preProcess(dirContextMock); - verify(dirContextProcessorMock).postProcess(dirContextMock); - verify(dirContextMock).close(); + verify(this.dirContextProcessorMock).preProcess(this.dirContextMock); + verify(this.dirContextProcessorMock).postProcess(this.dirContextMock); + verify(this.dirContextMock).close(); } @Test @@ -1588,9 +1596,9 @@ public class LdapTemplateTest { final ModificationItem[] expectedModifications = new ModificationItem[0]; final LdapName epectedDn = LdapUtils.emptyLdapName(); - when(dirContextOperationsMock.getDn()).thenReturn(epectedDn); - when(dirContextOperationsMock.isUpdateMode()).thenReturn(true); - when(dirContextOperationsMock.getModificationItems()).thenReturn(expectedModifications); + when(this.dirContextOperationsMock.getDn()).thenReturn(epectedDn); + when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(true); + when(this.dirContextOperationsMock.getModificationItems()).thenReturn(expectedModifications); LdapTemplate tested = new LdapTemplate() { public void modifyAttributes(Name dn, ModificationItem[] mods) { @@ -1599,14 +1607,14 @@ public class LdapTemplateTest { } }; - tested.modifyAttributes(dirContextOperationsMock); + tested.modifyAttributes(this.dirContextOperationsMock); } @Test public void testModifyAttributesWithDirContextOperationsNotInitializedDn() throws Exception { - when(dirContextOperationsMock.getDn()).thenReturn(LdapUtils.emptyLdapName()); - when(dirContextOperationsMock.isUpdateMode()).thenReturn(false); + when(this.dirContextOperationsMock.getDn()).thenReturn(LdapUtils.emptyLdapName()); + when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false); LdapTemplate tested = new LdapTemplate() { public void modifyAttributes(Name dn, ModificationItem[] mods) { @@ -1615,7 +1623,7 @@ public class LdapTemplateTest { }; try { - tested.modifyAttributes(dirContextOperationsMock); + tested.modifyAttributes(this.dirContextOperationsMock); fail("IllegalStateException expected"); } catch (IllegalStateException expected) { @@ -1625,7 +1633,7 @@ public class LdapTemplateTest { @Test public void testModifyAttributesWithDirContextOperationsNotInitializedInUpdateMode() throws Exception { - when(dirContextOperationsMock.getDn()).thenReturn(null); + when(this.dirContextOperationsMock.getDn()).thenReturn(null); LdapTemplate tested = new LdapTemplate() { public void modifyAttributes(Name dn, ModificationItem[] mods) { @@ -1634,7 +1642,7 @@ public class LdapTemplateTest { }; try { - tested.modifyAttributes(dirContextOperationsMock); + tested.modifyAttributes(this.dirContextOperationsMock); fail("IllegalStateException expected"); } catch (IllegalStateException expected) { @@ -1652,11 +1660,11 @@ public class LdapTemplateTest { singleSearchResult(searchControlsRecursive(), searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - Object result = tested.searchForObject(nameMock, "(ou=somevalue)", contextMapperMock); + Object result = this.tested.searchForObject(this.nameMock, "(ou=somevalue)", this.contextMapperMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isNotNull(); assertThat(result).isSameAs(expectedResult); @@ -1671,26 +1679,26 @@ public class LdapTemplateTest { Object expectedObject = new Object(); SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes()); - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(true, true, false); - when(namingEnumerationMock.next()).thenReturn(searchResult, searchResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResult, searchResult); Object expectedResult = expectedObject; - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); try { - tested.searchForObject(nameMock, "(ou=somevalue)", contextMapperMock); + this.tested.searchForObject(this.nameMock, "(ou=somevalue)", this.contextMapperMock); fail("IncorrectResultSizeDataAccessException expected"); } catch (IncorrectResultSizeDataAccessException expected) { assertThat(true).isTrue(); } - verify(namingEnumerationMock).close(); - verify(dirContextMock).close(); + verify(this.namingEnumerationMock).close(); + verify(this.dirContextMock).close(); } @Test @@ -1700,19 +1708,19 @@ public class LdapTemplateTest { noSearchResults(searchControlsRecursive()); try { - tested.searchForObject(nameMock, "(ou=somevalue)", contextMapperMock); + this.tested.searchForObject(this.nameMock, "(ou=somevalue)", this.contextMapperMock); fail("EmptyResultDataAccessException expected"); } catch (EmptyResultDataAccessException expected) { assertThat(true).isTrue(); } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testAuthenticateWithSingleUserFoundShouldBeSuccessful() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); @@ -1720,22 +1728,23 @@ public class LdapTemplateTest { singleSearchResult(searchControlsRecursive(), searchResult); - when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) - .thenReturn(authenticatedContextMock); - entryContextCallbackMock.executeWithContext(authenticatedContextMock, new LdapEntryIdentification( + when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) + .thenReturn(this.authenticatedContextMock); + this.entryContextCallbackMock.executeWithContext(this.authenticatedContextMock, new LdapEntryIdentification( LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe"))); - boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock); + boolean result = this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password", + this.entryContextCallbackMock); - verify(authenticatedContextMock).close(); - verify(dirContextMock).close(); + verify(this.authenticatedContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isTrue(); } @Test public void testAuthenticateWithTwoUsersFoundShouldThrowException() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); @@ -1745,25 +1754,26 @@ public class LdapTemplateTest { setupSearchResults(searchControlsRecursive(), new SearchResult[] { searchResult1, searchResult2 }); try { - tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock); + this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password", this.entryContextCallbackMock); fail("IncorrectResultSizeDataAccessException expected"); } catch (IncorrectResultSizeDataAccessException expected) { // expected } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testAuthenticateWhenNoUserWasFoundShouldFail() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); noSearchResults(searchControlsRecursive()); - boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock); + boolean result = this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password", + this.entryContextCallbackMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isFalse(); } @@ -1772,45 +1782,45 @@ public class LdapTemplateTest { @SuppressWarnings("unchecked") public void testAuthenticateQueryPasswordMapperWhenNoUserWasFoundShouldThrowEmptyResult() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); - when(dirContextMock.search(any(Name.class), any(String.class), any(SearchControls.class))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(any(Name.class), any(String.class), any(SearchControls.class))) + .thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(false); + when(this.namingEnumerationMock.hasMore()).thenReturn(false); try { - tested.authenticate(query, "", authContextMapperMock); + this.tested.authenticate(this.query, "", this.authContextMapperMock); fail("Expected Exception"); } catch (EmptyResultDataAccessException success) { } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test @SuppressWarnings("unchecked") public void testAuthenticateQueryPasswordWhenNoUserWasFoundShouldThrowEmptyResult() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); - when(dirContextMock.search(any(Name.class), any(String.class), any(SearchControls.class))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(any(Name.class), any(String.class), any(SearchControls.class))) + .thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(false); + when(this.namingEnumerationMock.hasMore()).thenReturn(false); try { - tested.authenticate(query, ""); + this.tested.authenticate(this.query, ""); fail("Expected Exception"); } catch (EmptyResultDataAccessException success) { } - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testAuthenticateWithFailedAuthenticationShouldFail() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); @@ -1818,19 +1828,20 @@ public class LdapTemplateTest { singleSearchResult(searchControlsRecursive(), searchResult); - when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) + when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) .thenThrow(new UncategorizedLdapException("Authentication failed")); - boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock); + boolean result = this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password", + this.entryContextCallbackMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isFalse(); } @Test public void testAuthenticateWithErrorInCallbackShouldFail() throws Exception { - when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock); Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"), LdapUtils.newLdapName("dc=jayway, dc=se")); @@ -1838,25 +1849,26 @@ public class LdapTemplateTest { singleSearchResult(searchControlsRecursive(), searchResult); - when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) - .thenReturn(authenticatedContextMock); - doThrow(new UncategorizedLdapException("Authentication failed")).when(entryContextCallbackMock) - .executeWithContext(authenticatedContextMock, new LdapEntryIdentification( + when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password")) + .thenReturn(this.authenticatedContextMock); + doThrow(new UncategorizedLdapException("Authentication failed")).when(this.entryContextCallbackMock) + .executeWithContext(this.authenticatedContextMock, new LdapEntryIdentification( LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe"))); - boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock); + boolean result = this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password", + this.entryContextCallbackMock); - verify(authenticatedContextMock).close(); - verify(dirContextMock).close(); + verify(this.authenticatedContextMock).close(); + verify(this.dirContextMock).close(); assertThat(result).isFalse(); } private void noSearchResults(SearchControls controls) throws Exception { - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(false); + when(this.namingEnumerationMock.hasMore()).thenReturn(false); } private void singleSearchResult(SearchControls controls, SearchResult searchResult) throws Exception { @@ -1864,16 +1876,16 @@ public class LdapTemplateTest { } private void setupSearchResults(SearchControls controls, SearchResult... searchResults) throws Exception { - when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls)))) - .thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); if (searchResults.length == 1) { - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(searchResults[0]); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResults[0]); } else if (searchResults.length == 2) { - when(namingEnumerationMock.hasMore()).thenReturn(true, true, false); - when(namingEnumerationMock.next()).thenReturn(searchResults[0], searchResults[1]); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResults[0], searchResults[1]); } else { throw new IllegalArgumentException("Cannot handle " + searchResults.length + " search results"); @@ -1881,11 +1893,11 @@ public class LdapTemplateTest { } private void singleSearchResultWithStringBase(SearchControls controls, SearchResult searchResult) throws Exception { - when(dirContextMock.search(eq(DEFAULT_BASE_STRING), eq("(ou=somevalue)"), - argThat(new SearchControlsMatcher(controls)))).thenReturn(namingEnumerationMock); + when(this.dirContextMock.search(eq(DEFAULT_BASE_STRING), eq("(ou=somevalue)"), + argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock); - when(namingEnumerationMock.hasMore()).thenReturn(true, false); - when(namingEnumerationMock.next()).thenReturn(searchResult); + when(this.namingEnumerationMock.hasMore()).thenReturn(true, false); + when(this.namingEnumerationMock.next()).thenReturn(searchResult); } private SearchControls searchControlsRecursive() { @@ -1915,12 +1927,12 @@ public class LdapTemplateTest { if (item instanceof SearchControls) { SearchControls s1 = item; - return controls.getSearchScope() == s1.getSearchScope() - && controls.getReturningObjFlag() == s1.getReturningObjFlag() - && controls.getDerefLinkFlag() == s1.getDerefLinkFlag() - && controls.getCountLimit() == s1.getCountLimit() - && controls.getTimeLimit() == s1.getTimeLimit() - && controls.getReturningAttributes() == s1.getReturningAttributes(); + return this.controls.getSearchScope() == s1.getSearchScope() + && this.controls.getReturningObjFlag() == s1.getReturningObjFlag() + && this.controls.getDerefLinkFlag() == s1.getDerefLinkFlag() + && this.controls.getCountLimit() == s1.getCountLimit() + && this.controls.getTimeLimit() == s1.getTimeLimit() + && this.controls.getReturningAttributes() == s1.getReturningAttributes(); } else { throw new IllegalArgumentException(); diff --git a/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTest.java b/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTest.java index 1bca269e..1f23633d 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTest.java @@ -35,31 +35,31 @@ public class AggregateDirContextProcessorTest { @Before public void setUp() throws Exception { // Create processor1 mock - processor1Mock = mock(DirContextProcessor.class); + this.processor1Mock = mock(DirContextProcessor.class); // Create processor2 mock - processor2Mock = mock(DirContextProcessor.class); + this.processor2Mock = mock(DirContextProcessor.class); - tested = new AggregateDirContextProcessor(); - tested.addDirContextProcessor(processor1Mock); - tested.addDirContextProcessor(processor2Mock); + this.tested = new AggregateDirContextProcessor(); + this.tested.addDirContextProcessor(this.processor1Mock); + this.tested.addDirContextProcessor(this.processor2Mock); } @Test public void testPreProcess() throws NamingException { - tested.preProcess(null); + this.tested.preProcess(null); - verify(processor1Mock).preProcess(null); - verify(processor2Mock).preProcess(null); + verify(this.processor1Mock).preProcess(null); + verify(this.processor2Mock).preProcess(null); } @Test public void testPostProcess() throws NamingException { - tested.postProcess(null); + this.tested.postProcess(null); - verify(processor1Mock).postProcess(null); - verify(processor2Mock).postProcess(null); + verify(this.processor1Mock).postProcess(null); + verify(this.processor2Mock).postProcess(null); } } diff --git a/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTest.java b/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTest.java index 85b03980..6e6b5f7d 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTest.java @@ -46,38 +46,38 @@ public class BaseLdapPathBeanPostProcessorTest { @Before public void setUp() throws Exception { - tested = new BaseLdapPathBeanPostProcessor(); + this.tested = new BaseLdapPathBeanPostProcessor(); - ldapPathAwareMock = mock(BaseLdapPathAware.class); - ldapNameAwareMock = mock(BaseLdapNameAware.class); + this.ldapPathAwareMock = mock(BaseLdapPathAware.class); + this.ldapNameAwareMock = mock(BaseLdapNameAware.class); - applicationContextMock = mock(ApplicationContext.class); + this.applicationContextMock = mock(ApplicationContext.class); - tested.setApplicationContext(applicationContextMock); + this.tested.setApplicationContext(this.applicationContextMock); } @Test public void testPostProcessBeforeInitializationWithLdapPathAwareBasePathSet() throws Exception { String expectedPath = "dc=example, dc=com"; - tested.setBasePath(new DistinguishedName(expectedPath)); + this.tested.setBasePath(new DistinguishedName(expectedPath)); - Object result = tested.postProcessBeforeInitialization(ldapPathAwareMock, "someName"); + Object result = this.tested.postProcessBeforeInitialization(this.ldapPathAwareMock, "someName"); - verify(ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); + verify(this.ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); - assertThat(result).isSameAs(ldapPathAwareMock); + assertThat(result).isSameAs(this.ldapPathAwareMock); } @Test public void testPostProcessBeforeInitializationWithLdapNameAwareBasePathSet() throws Exception { String expectedPath = "dc=example, dc=com"; - tested.setBasePath(expectedPath); + this.tested.setBasePath(expectedPath); - Object result = tested.postProcessBeforeInitialization(ldapNameAwareMock, "someName"); + Object result = this.tested.postProcessBeforeInitialization(this.ldapNameAwareMock, "someName"); - verify(ldapNameAwareMock).setBaseLdapPath(LdapUtils.newLdapName(expectedPath)); + verify(this.ldapNameAwareMock).setBaseLdapPath(LdapUtils.newLdapName(expectedPath)); - assertThat(result).isSameAs(ldapNameAwareMock); + assertThat(result).isSameAs(this.ldapNameAwareMock); } @Test @@ -86,17 +86,17 @@ public class BaseLdapPathBeanPostProcessorTest { String expectedPath = "dc=example, dc=com"; expectedContextSource.setBase(expectedPath); - tested = new BaseLdapPathBeanPostProcessor() { + this.tested = new BaseLdapPathBeanPostProcessor() { BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { return expectedContextSource; } }; - Object result = tested.postProcessBeforeInitialization(ldapPathAwareMock, "someName"); + Object result = this.tested.postProcessBeforeInitialization(this.ldapPathAwareMock, "someName"); - verify(ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); + verify(this.ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); - assertThat(result).isSameAs(ldapPathAwareMock); + assertThat(result).isSameAs(this.ldapPathAwareMock); } @Test @@ -105,22 +105,22 @@ public class BaseLdapPathBeanPostProcessorTest { String expectedPath = "dc=example, dc=com"; expectedContextSource.setBase(expectedPath); - tested = new BaseLdapPathBeanPostProcessor() { + this.tested = new BaseLdapPathBeanPostProcessor() { BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { return expectedContextSource; } }; - Object result = tested.postProcessBeforeInitialization(ldapNameAwareMock, "someName"); + Object result = this.tested.postProcessBeforeInitialization(this.ldapNameAwareMock, "someName"); - verify(ldapNameAwareMock).setBaseLdapPath(LdapUtils.newLdapName(expectedPath)); + verify(this.ldapNameAwareMock).setBaseLdapPath(LdapUtils.newLdapName(expectedPath)); - assertThat(result).isSameAs(ldapNameAwareMock); + assertThat(result).isSameAs(this.ldapNameAwareMock); } @Test public void testGetAbstractContextSourceFromApplicationContext() throws Exception { - when(applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)) + when(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)) .thenReturn(new String[] { "contextSource" }); final LdapContextSource expectedContextSource = new LdapContextSource(); @@ -129,35 +129,35 @@ public class BaseLdapPathBeanPostProcessorTest { put("dummy", expectedContextSource); } }; - when(applicationContextMock.getBeansOfType(BaseLdapPathSource.class)).thenReturn(expectedBeans); + when(this.applicationContextMock.getBeansOfType(BaseLdapPathSource.class)).thenReturn(expectedBeans); - BaseLdapPathSource result = tested.getBaseLdapPathSourceFromApplicationContext(); + BaseLdapPathSource result = this.tested.getBaseLdapPathSourceFromApplicationContext(); assertThat(result).isSameAs(expectedContextSource); } @Test(expected = NoSuchBeanDefinitionException.class) public void testGetAbstractContextSourceFromApplicationContextNoContextSource() throws Exception { - when(applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).thenReturn(new String[0]); + when(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).thenReturn(new String[0]); - tested.getBaseLdapPathSourceFromApplicationContext(); + this.tested.getBaseLdapPathSourceFromApplicationContext(); } @Test(expected = NoSuchBeanDefinitionException.class) public void testGetAbstractContextSourceFromApplicationContextTwoContextSources() throws Exception { - when(applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).thenReturn(new String[2]); + when(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).thenReturn(new String[2]); - tested.getBaseLdapPathSourceFromApplicationContext(); + this.tested.getBaseLdapPathSourceFromApplicationContext(); } @Test public void testGetAbstractContextSourceFromApplicationContextTwoContextSourcesAndSpecifiedName() throws Exception { LdapContextSource expectedContextSource = new LdapContextSource(); - tested.setBaseLdapPathSourceName("myContextSource"); - when(applicationContextMock.getBean("myContextSource")).thenReturn(expectedContextSource); + this.tested.setBaseLdapPathSourceName("myContextSource"); + when(this.applicationContextMock.getBean("myContextSource")).thenReturn(expectedContextSource); - tested.getBaseLdapPathSourceFromApplicationContext(); + this.tested.getBaseLdapPathSourceFromApplicationContext(); } } diff --git a/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTest.java b/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTest.java index b69e09a5..045e843a 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTest.java @@ -56,8 +56,8 @@ public class ContextMapperCallbackHandlerWithControlsTest { @SuppressWarnings("unchecked") @Before public void setUp() throws Exception { - mapperMock = mock(ContextMapperWithControls.class); - tested = new ContextMapperCallbackHandlerWithControls(mapperMock); + this.mapperMock = mock(ContextMapperWithControls.class); + this.tested = new ContextMapperCallbackHandlerWithControls(this.mapperMock); } @Test(expected = IllegalArgumentException.class) @@ -71,9 +71,9 @@ public class ContextMapperCallbackHandlerWithControlsTest { Object expectedResult = "result"; Binding expectedBinding = new Binding("some name", expectedObject); - when(mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); + when(this.mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); - Object actualResult = tested.getObjectFromNameClassPair(expectedBinding); + Object actualResult = this.tested.getObjectFromNameClassPair(expectedBinding); assertThat(actualResult).isEqualTo(expectedResult); } @@ -84,9 +84,9 @@ public class ContextMapperCallbackHandlerWithControlsTest { Object expectedResult = "result"; MyBindingThatHasControls expectedBinding = new MyBindingThatHasControls("some name", expectedObject); - when(mapperMock.mapFromContextWithControls(expectedObject, expectedBinding)).thenReturn(expectedResult); + when(this.mapperMock.mapFromContextWithControls(expectedObject, expectedBinding)).thenReturn(expectedResult); - Object actualResult = tested.getObjectFromNameClassPair(expectedBinding); + Object actualResult = this.tested.getObjectFromNameClassPair(expectedBinding); assertThat(actualResult).isEqualTo(expectedResult); } @@ -95,7 +95,7 @@ public class ContextMapperCallbackHandlerWithControlsTest { public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException { Binding expectedBinding = new Binding("some name", null); - tested.getObjectFromNameClassPair(expectedBinding); + this.tested.getObjectFromNameClassPair(expectedBinding); } } diff --git a/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTest.java b/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTest.java index e5e72366..b4149292 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTest.java @@ -28,17 +28,17 @@ public class CountNameClassPairResultCallbackHandlerTest { @Before public void setUp() throws Exception { - tested = new CountNameClassPairCallbackHandler(); + this.tested = new CountNameClassPairCallbackHandler(); } @Test public void testHandleSearchResult() throws Exception { SearchResult dummy = new SearchResult(null, null, null); - tested.handleNameClassPair(dummy); - tested.handleNameClassPair(dummy); - tested.handleNameClassPair(dummy); + this.tested.handleNameClassPair(dummy); + this.tested.handleNameClassPair(dummy); + this.tested.handleNameClassPair(dummy); - assertThat(tested.getNoOfRows()).isEqualTo(3); + assertThat(this.tested.getNoOfRows()).isEqualTo(3); } } diff --git a/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTest.java b/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTest.java index 213095fe..ad147f8c 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTest.java @@ -48,10 +48,10 @@ public class DefaultDirObjectFactoryTest { @Before public void setUp() throws Exception { - contextMock = mock(Context.class); - contextMock2 = mock(Context.class); + this.contextMock = mock(Context.class); + this.contextMock2 = mock(Context.class); - tested = new DefaultDirObjectFactory(); + this.tested = new DefaultDirObjectFactory(); } @Test @@ -59,10 +59,10 @@ public class DefaultDirObjectFactoryTest { Attributes expectedAttributes = new NameAwareAttributes(); expectedAttributes.put("someAttribute", "someValue"); - DirContextAdapter adapter = (DirContextAdapter) tested.getObjectInstance(contextMock, DN, null, new Hashtable(), - expectedAttributes); + DirContextAdapter adapter = (DirContextAdapter) this.tested.getObjectInstance(this.contextMock, DN, null, + new Hashtable(), expectedAttributes); - verify(contextMock).close(); + verify(this.contextMock).close(); assertThat(adapter.getDn()).isEqualTo(DN); assertThat(adapter.getAttributes()).isEqualTo(expectedAttributes); @@ -76,10 +76,10 @@ public class DefaultDirObjectFactoryTest { CompositeName name = new CompositeName(); name.add(DN_STRING); - DirContextAdapter adapter = (DirContextAdapter) tested.getObjectInstance(contextMock, name, null, + DirContextAdapter adapter = (DirContextAdapter) this.tested.getObjectInstance(this.contextMock, name, null, new Hashtable(), expectedAttributes); - verify(contextMock).close(); + verify(this.contextMock).close(); assertThat(adapter.getDn()).isEqualTo(DN); assertThat(adapter.getAttributes()).isEqualTo(expectedAttributes); @@ -90,7 +90,7 @@ public class DefaultDirObjectFactoryTest { Attributes expectedAttributes = new NameAwareAttributes(); expectedAttributes.put("someAttribute", "someValue"); - DirContextAdapter adapter = (DirContextAdapter) tested.getObjectInstance(null, DN, null, new Hashtable(), + DirContextAdapter adapter = (DirContextAdapter) this.tested.getObjectInstance(null, DN, null, new Hashtable(), expectedAttributes); assertThat(adapter.getDn()).isEqualTo(DN); @@ -102,7 +102,7 @@ public class DefaultDirObjectFactoryTest { Attributes expectedAttributes = new NameAwareAttributes(); expectedAttributes.put("someAttribute", "someValue"); - DirContextAdapter adapter = (DirContextAdapter) tested.getObjectInstance(new Object(), DN, null, + DirContextAdapter adapter = (DirContextAdapter) this.tested.getObjectInstance(new Object(), DN, null, new Hashtable(), expectedAttributes); assertThat(adapter.getDn()).isEqualTo(DN); @@ -118,12 +118,12 @@ public class DefaultDirObjectFactoryTest { Attributes expectedAttributes = new NameAwareAttributes(); expectedAttributes.put("someAttribute", "someValue"); - when(contextMock2.getNameInNamespace()).thenReturn("dc=jayway, dc=se"); + when(this.contextMock2.getNameInNamespace()).thenReturn("dc=jayway, dc=se"); - DirContextAdapter adapter = (DirContextAdapter) tested.getObjectInstance(contextMock, - LdapUtils.newLdapName("ou=some unit"), contextMock2, new Hashtable(), expectedAttributes); + DirContextAdapter adapter = (DirContextAdapter) this.tested.getObjectInstance(this.contextMock, + LdapUtils.newLdapName("ou=some unit"), this.contextMock2, new Hashtable(), expectedAttributes); - verify(contextMock).close(); + verify(this.contextMock).close(); assertThat(adapter.getDn().toString()).isEqualTo("ou=some unit"); assertThat(adapter.getNameInNamespace()).isEqualTo("ou=some unit,dc=jayway,dc=se"); diff --git a/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTest.java b/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTest.java index b78c926f..94178094 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTest.java @@ -38,19 +38,19 @@ public class DefaultIncrementalAttributesMapperTest { @Before public void setUp() throws Exception { - tested = new DefaultIncrementalAttributesMapper("member"); + this.tested = new DefaultIncrementalAttributesMapper("member"); } @Test public void testGetAttributesArray() throws Exception { - String[] attributes = tested.getAttributesForLookup(); + String[] attributes = this.tested.getAttributesForLookup(); assertThat(attributes.length).isEqualTo(1); assertThat(attributes[0]).isEqualTo("member"); - tested = new DefaultIncrementalAttributesMapper(10, "member"); + this.tested = new DefaultIncrementalAttributesMapper(10, "member"); - attributes = tested.getAttributesForLookup(); + attributes = this.tested.getAttributesForLookup(); assertThat(attributes.length).isEqualTo(1); assertThat(attributes[0]).isEqualTo("member;Range=0-10"); @@ -58,8 +58,8 @@ public class DefaultIncrementalAttributesMapperTest { @Test public void testGetAttributesArrayWithTwoAttributes() { - tested = new DefaultIncrementalAttributesMapper(20, new String[] { "member", "cn" }); - String[] attributes = tested.getAttributesForLookup(); + this.tested = new DefaultIncrementalAttributesMapper(20, new String[] { "member", "cn" }); + String[] attributes = this.tested.getAttributesForLookup(); assertThat(attributes.length).isEqualTo(2); @@ -69,104 +69,104 @@ public class DefaultIncrementalAttributesMapperTest { @Test public void testLoopEmpty() throws Exception { - assertThat(tested.hasMore()).isTrue(); + assertThat(this.tested.hasMore()).isTrue(); Attributes attributes = new BasicAttributes(); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isFalse(); - assertThat(tested.getValues("member")).isNull(); + assertThat(this.tested.hasMore()).isFalse(); + assertThat(this.tested.getValues("member")).isNull(); } @Test public void testLoop() throws Exception { Attributes attributes = createAttributes("member", new RangeOption(0, 10)); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isTrue(); - assertThat(tested.getValues("member")).hasSize(11); + assertThat(this.tested.hasMore()).isTrue(); + assertThat(this.tested.getValues("member")).hasSize(11); attributes = createAttributes("member", new RangeOption(11), 5); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isFalse(); - assertThat(tested.getValues("member")).hasSize(16); + assertThat(this.tested.hasMore()).isFalse(); + assertThat(this.tested.getValues("member")).hasSize(16); } @Test public void test1LoopWithPageSizeExact() throws Exception { - tested = new DefaultIncrementalAttributesMapper(10, "member"); + this.tested = new DefaultIncrementalAttributesMapper(10, "member"); Attributes attributes = createAttributes("member", new RangeOption(0, 10)); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isFalse(); - assertThat(tested.getValues("member")).hasSize(11); + assertThat(this.tested.hasMore()).isFalse(); + assertThat(this.tested.getValues("member")).hasSize(11); } @Test public void test2LoopsWithPageSizeExact() throws Exception { - tested = new DefaultIncrementalAttributesMapper(20, "member"); + this.tested = new DefaultIncrementalAttributesMapper(20, "member"); Attributes attributes = createAttributes("member", new RangeOption(0, 10)); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isTrue(); - assertThat(tested.getValues("member")).hasSize(11); + assertThat(this.tested.hasMore()).isTrue(); + assertThat(this.tested.getValues("member")).hasSize(11); attributes = createAttributes("member", new RangeOption(11, 30)); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isFalse(); - assertThat(tested.getValues("member")).hasSize(31); + assertThat(this.tested.hasMore()).isFalse(); + assertThat(this.tested.getValues("member")).hasSize(31); } @Test public void test2LoopsWithPageSize() throws Exception { - tested = new DefaultIncrementalAttributesMapper(20, "member"); + this.tested = new DefaultIncrementalAttributesMapper(20, "member"); Attributes attributes = createAttributes("member", new RangeOption(0, 10)); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isTrue(); - assertThat(tested.getValues("member")).hasSize(11); + assertThat(this.tested.hasMore()).isTrue(); + assertThat(this.tested.getValues("member")).hasSize(11); attributes = createAttributes("member", new RangeOption(11), 5); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isFalse(); - assertThat(tested.getValues("member")).hasSize(16); + assertThat(this.tested.hasMore()).isFalse(); + assertThat(this.tested.getValues("member")).hasSize(16); } @Test public void testLoopWithTwoRangedAttributesLoopOnOneAttribute() throws Exception { - tested = new DefaultIncrementalAttributesMapper(10, new String[] { "member", "cn" }); + this.tested = new DefaultIncrementalAttributesMapper(10, new String[] { "member", "cn" }); Attributes attributes = createAttributes("member", new RangeOption(0, 5)); attributes.put(createRangeAttribute("cn", new RangeOption(0, 10), 10)); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isTrue(); - assertThat(tested.getValues("member")).hasSize(6); - assertThat(tested.getValues("cn")).hasSize(10); + assertThat(this.tested.hasMore()).isTrue(); + assertThat(this.tested.getValues("member")).hasSize(6); + assertThat(this.tested.getValues("cn")).hasSize(10); - assertThat(tested.getAttributesForLookup().length).isEqualTo(1); + assertThat(this.tested.getAttributesForLookup().length).isEqualTo(1); attributes = createAttributes("member", new RangeOption(6), 5); - tested.mapFromAttributes(attributes); + this.tested.mapFromAttributes(attributes); - assertThat(tested.hasMore()).isFalse(); - assertThat(tested.getValues("member")).hasSize(11); + assertThat(this.tested.hasMore()).isFalse(); + assertThat(this.tested.getValues("member")).hasSize(11); } private Attributes createAttributes(String attributeName, RangeOption range) { diff --git a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java index 11792e14..06e9b3b4 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java @@ -38,32 +38,32 @@ public class LdapContextSourceTest { @Before public void setUp() throws Exception { - tested = new LdapContextSource(); + this.tested = new LdapContextSource(); } @Test(expected = IllegalArgumentException.class) public void testAfterPropertiesSet_NoUrl() throws Exception { - tested.afterPropertiesSet(); + this.tested.afterPropertiesSet(); } // gh-538 @Test(expected = IllegalArgumentException.class) public void testAfterPropertiesSet_NullPassword() { - tested.setUrl("ldap://ldap.example.com:389"); - tested.setUserDn("value"); - tested.setPassword(null); - tested.afterPropertiesSet(); + this.tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setUserDn("value"); + this.tested.setPassword(null); + this.tested.afterPropertiesSet(); } @Test public void testGetAnonymousEnv() throws Exception { - tested.setBase("dc=some example,dc=se"); - tested.setUrl("ldap://ldap.example.com:389"); - tested.setPooled(true); - tested.setUserDn("cn=Some User"); - tested.setPassword("secret"); - tested.afterPropertiesSet(); - Hashtable env = tested.getAnonymousEnv(); + this.tested.setBase("dc=some example,dc=se"); + this.tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setPooled(true); + this.tested.setUserDn("cn=Some User"); + this.tested.setPassword("secret"); + this.tested.afterPropertiesSet(); + Hashtable env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389/dc=some%20example,dc=se"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isEqualTo("true"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isNull(); @@ -74,11 +74,11 @@ public class LdapContextSourceTest { .isEqualTo(LdapUtils.newLdapName("dc=some example,dc=se")); // Verify that changing values does not change the environment values. - tested.setBase("dc=other,dc=se"); - tested.setUrl("ldap://ldap2.example.com:389"); - tested.setPooled(false); + this.tested.setBase("dc=other,dc=se"); + this.tested.setUrl("ldap://ldap2.example.com:389"); + this.tested.setPooled(false); - env = tested.getAnonymousEnv(); + env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389/dc=some%20example,dc=se"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isEqualTo("true"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isNull(); @@ -90,9 +90,9 @@ public class LdapContextSourceTest { @Test public void testGetAnonymousEnvWithNoBaseSet() throws Exception { - tested.setUrl("ldap://ldap.example.com:389"); - tested.afterPropertiesSet(); - Hashtable env = tested.getAnonymousEnv(); + this.tested.setUrl("ldap://ldap.example.com:389"); + this.tested.afterPropertiesSet(); + Hashtable env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389"); // check that base was not added to environment @@ -101,35 +101,35 @@ public class LdapContextSourceTest { @Test public void testGetAnonymousEnvWithBaseEnvironment() throws Exception { - tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setUrl("ldap://ldap.example.com:389"); HashMap map = new HashMap(); map.put(LdapContextSource.SUN_LDAP_POOLING_FLAG, "true"); - tested.setBaseEnvironmentProperties(map); - tested.afterPropertiesSet(); - Hashtable env = tested.getAnonymousEnv(); + this.tested.setBaseEnvironmentProperties(map); + this.tested.afterPropertiesSet(); + Hashtable env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isNull(); } @Test public void testGetAnonymousEnvWithPoolingInBaseEnvironmentAndPoolingOff() throws Exception { - tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setUrl("ldap://ldap.example.com:389"); HashMap map = new HashMap(); map.put(LdapContextSource.SUN_LDAP_POOLING_FLAG, "true"); - tested.setBaseEnvironmentProperties(map); - tested.setPooled(false); - tested.afterPropertiesSet(); - Hashtable env = tested.getAnonymousEnv(); + this.tested.setBaseEnvironmentProperties(map); + this.tested.setPooled(false); + this.tested.afterPropertiesSet(); + Hashtable env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isNull(); } @Test public void testGetAnonymousEnvWithEmptyBaseSet() throws Exception { - tested.setUrl("ldap://ldap.example.com:389"); - tested.setBase(null); - tested.afterPropertiesSet(); - Hashtable env = tested.getAnonymousEnv(); + this.tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setBase(null); + this.tested.afterPropertiesSet(); + Hashtable env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389"); // check that base was not added to environment @@ -138,14 +138,14 @@ public class LdapContextSourceTest { @Test public void testGetAuthenticatedEnv() throws Exception { - tested.setBase("dc=example,dc=se"); - tested.setUrl("ldap://ldap.example.com:389"); - tested.setPooled(true); - tested.setUserDn("cn=Some User"); - tested.setPassword("secret"); - tested.afterPropertiesSet(); + this.tested.setBase("dc=example,dc=se"); + this.tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setPooled(true); + this.tested.setUserDn("cn=Some User"); + this.tested.setPassword("secret"); + this.tested.afterPropertiesSet(); - Hashtable env = tested.getAuthenticatedEnv("cn=Some User", "secret"); + Hashtable env = this.tested.getAuthenticatedEnv("cn=Some User", "secret"); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389/dc=example,dc=se"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isEqualTo("true"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isEqualTo("cn=Some User"); @@ -158,21 +158,21 @@ public class LdapContextSourceTest { @Test public void testGetAnonymousEnvWhenCacheIsOff() throws Exception { - tested.setBase("dc=example,dc=se"); - tested.setUrl("ldap://ldap.example.com:389"); - tested.setPooled(true); - tested.setUserDn("cn=Some User"); - tested.setPassword("secret"); - tested.setCacheEnvironmentProperties(false); - tested.afterPropertiesSet(); - Hashtable env = tested.getAnonymousEnv(); + this.tested.setBase("dc=example,dc=se"); + this.tested.setUrl("ldap://ldap.example.com:389"); + this.tested.setPooled(true); + this.tested.setUserDn("cn=Some User"); + this.tested.setPassword("secret"); + this.tested.setCacheEnvironmentProperties(false); + this.tested.afterPropertiesSet(); + Hashtable env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389/dc=example,dc=se"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isEqualTo("true"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isNull(); assertThat(env.get(Context.SECURITY_CREDENTIALS)).isNull(); - tested.setUrl("ldap://ldap2.example.com:389"); - env = tested.getAnonymousEnv(); + this.tested.setUrl("ldap://ldap2.example.com:389"); + env = this.tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap2.example.com:389/dc=example,dc=se"); } diff --git a/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTest.java b/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTest.java index 17ab5aca..b1299395 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTest.java @@ -29,13 +29,13 @@ public class SimpleDirContextAuthenticationStrategyTest { @Before public void setUp() throws Exception { - tested = new SimpleDirContextAuthenticationStrategy(); + this.tested = new SimpleDirContextAuthenticationStrategy(); } @Test public void testSetupEnvironment() { Hashtable env = new Hashtable(); - tested.setupEnvironment(env, "cn=John Doe", "pw"); + this.tested.setupEnvironment(env, "cn=John Doe", "pw"); assertThat(env.get(Context.SECURITY_AUTHENTICATION)).isEqualTo("simple"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isEqualTo("cn=John Doe"); @@ -45,7 +45,7 @@ public class SimpleDirContextAuthenticationStrategyTest { @Test public void testProcessContextAfterCreation() { Hashtable env = new Hashtable(); - tested.processContextAfterCreation(null, "cn=John Doe", "pw"); + this.tested.processContextAfterCreation(null, "cn=John Doe", "pw"); assertThat(env.isEmpty()).isTrue(); } diff --git a/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTest.java b/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTest.java index 288d6496..13c0a2e4 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTest.java @@ -45,23 +45,23 @@ public class SingleContextSourceTest { @Before public void prepareMocks() { - contextSourceMock = mock(ContextSource.class); - dirContextMock = mock(DirContext.class); + this.contextSourceMock = mock(ContextSource.class); + this.dirContextMock = mock(DirContext.class); } @Test public void testDoWithSingleContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); - verifyNoMoreInteractions(contextSourceMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); + verifyNoMoreInteractions(this.contextSourceMock); - SingleContextSource.doWithSingleContext(contextSourceMock, new LdapOperationsCallback() { + SingleContextSource.doWithSingleContext(this.contextSourceMock, new LdapOperationsCallback() { @Override public Object doWithLdapOperations(LdapOperations operations) { operations.executeReadOnly(new ContextExecutor() { @Override public Object executeWithContext(DirContext ctx) throws NamingException { Object targetContex = getInternalState(Proxy.getInvocationHandler(ctx), "target"); - assertThat(targetContex).isSameAs(dirContextMock); + assertThat(targetContex).isSameAs(SingleContextSourceTest.this.dirContextMock); return false; } }); @@ -73,7 +73,7 @@ public class SingleContextSourceTest { @Override public Object executeWithContext(DirContext ctx) throws NamingException { Object targetContex = getInternalState(Proxy.getInvocationHandler(ctx), "target"); - assertThat(targetContex).isSameAs(dirContextMock); + assertThat(targetContex).isSameAs(SingleContextSourceTest.this.dirContextMock); return false; } }); diff --git a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTest.java b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTest.java index 98678f74..89c1342e 100644 --- a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTest.java +++ b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTest.java @@ -29,7 +29,7 @@ public class DefaultObjectDirectoryMapperTest { @Before public void prepareTestedInstance() { - tested = new DefaultObjectDirectoryMapper(); + this.tested = new DefaultObjectDirectoryMapper(); } // LDAP-295 @@ -45,10 +45,10 @@ public class DefaultObjectDirectoryMapperTest { @Test public void testMapping() { - assertThat(tested.manageClass(UnitTestPerson.class)).containsOnlyElementsOf( + assertThat(this.tested.manageClass(UnitTestPerson.class)).containsOnlyElementsOf( Arrays.asList("dn", "cn", "sn", "description", "telephoneNumber", "entryUUID", "objectclass")); - DefaultObjectDirectoryMapper.EntityData entityData = tested.getMetaDataMap().get(UnitTestPerson.class); + DefaultObjectDirectoryMapper.EntityData entityData = this.tested.getMetaDataMap().get(UnitTestPerson.class); assertThat(entityData).isNotNull(); assertThat(entityData.ocFilter).isEqualTo(query().where("objectclass").is("inetOrgPerson").and("objectclass") @@ -76,7 +76,7 @@ public class DefaultObjectDirectoryMapperTest { @Test public void testInvalidType() { try { - tested.manageClass(UnitTestPersonWithInvalidFieldType.class); + this.tested.manageClass(UnitTestPersonWithInvalidFieldType.class); } catch (InvalidEntryException expected) { assertThat(expected.getMessage()).contains("Missing converter from"); @@ -85,20 +85,20 @@ public class DefaultObjectDirectoryMapperTest { @Test public void testIndexedDnAttributes() { - tested.manageClass(UnitTestPersonWithIndexedDnAttributes.class); + this.tested.manageClass(UnitTestPersonWithIndexedDnAttributes.class); UnitTestPersonWithIndexedDnAttributes testPerson = new UnitTestPersonWithIndexedDnAttributes(); testPerson.setFullName("Some Person"); testPerson.setCompany("Some Company"); testPerson.setCountry("Sweden"); - Name calculatedId = tested.getCalculatedId(testPerson); + Name calculatedId = this.tested.getCalculatedId(testPerson); assertThat(calculatedId).isEqualTo(LdapUtils.newLdapName("cn=Some Person, ou=Some Company, c=Sweden")); } @Test(expected = MetaDataException.class) public void testIndexedDnAttributesRequiresThatAllAreIndexed() { - tested.manageClass(UnitTestPersonWithIndexedAndUnindexedDnAttributes.class); + this.tested.manageClass(UnitTestPersonWithIndexedAndUnindexedDnAttributes.class); } private void assertField(DefaultObjectDirectoryMapper.EntityData entityData, String fieldName, diff --git a/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java b/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java index 283a943d..5b36ac43 100644 --- a/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java +++ b/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java @@ -47,12 +47,12 @@ public abstract class AbstractPoolTestCase { @Before public void setUp() throws Exception { - contextMock = mock(Context.class); - dirContextMock = mock(DirContext.class); - ldapContextMock = mock(LdapContext.class); - keyedObjectPoolMock = mock(KeyedObjectPool.class); - contextSourceMock = mock(ContextSource.class); - dirContextValidatorMock = mock(DirContextValidator.class); + this.contextMock = mock(Context.class); + this.dirContextMock = mock(DirContext.class); + this.ldapContextMock = mock(LdapContext.class); + this.keyedObjectPoolMock = mock(KeyedObjectPool.class); + this.contextSourceMock = mock(ContextSource.class); + this.dirContextValidatorMock = mock(DirContextValidator.class); } } diff --git a/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTest.java b/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTest.java index c96956e9..ac1868b1 100644 --- a/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTest.java +++ b/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTest.java @@ -41,8 +41,8 @@ public class DefaultDirContextValidatorTest { @Before public void setUp() throws Exception { - namingEnumerationMock = mock(NamingEnumeration.class); - dirContextMock = mock(DirContext.class); + this.namingEnumerationMock = mock(NamingEnumeration.class); + this.dirContextMock = mock(DirContext.class); } // LDAP-189 @@ -114,7 +114,7 @@ public class DefaultDirContextValidatorTest { } try { - dirContextValidator.validateDirContext(null, dirContextMock); + dirContextValidator.validateDirContext(null, this.dirContextMock); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { @@ -130,10 +130,10 @@ public class DefaultDirContextValidatorTest { final String filter = dirContextValidator.getFilter(); final SearchControls searchControls = dirContextValidator.getSearchControls(); - when(namingEnumerationMock.hasMore()).thenReturn(true); - when(dirContextMock.search(baseName, filter, searchControls)).thenReturn(namingEnumerationMock); + when(this.namingEnumerationMock.hasMore()).thenReturn(true); + when(this.dirContextMock.search(baseName, filter, searchControls)).thenReturn(this.namingEnumerationMock); - final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, dirContextMock); + final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, this.dirContextMock); assertThat(valid).isTrue(); } @@ -145,10 +145,10 @@ public class DefaultDirContextValidatorTest { final String filter = dirContextValidator.getFilter(); final SearchControls searchControls = dirContextValidator.getSearchControls(); - when(namingEnumerationMock.hasMore()).thenReturn(false); - when(dirContextMock.search(baseName, filter, searchControls)).thenReturn(namingEnumerationMock); + when(this.namingEnumerationMock.hasMore()).thenReturn(false); + when(this.dirContextMock.search(baseName, filter, searchControls)).thenReturn(this.namingEnumerationMock); - final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, dirContextMock); + final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, this.dirContextMock); assertThat(valid).isFalse(); } @@ -161,10 +161,10 @@ public class DefaultDirContextValidatorTest { final String filter = dirContextValidator.getFilter(); final SearchControls searchControls = dirContextValidator.getSearchControls(); - when(dirContextMock.search(baseName, filter, searchControls)) + when(this.dirContextMock.search(baseName, filter, searchControls)) .thenThrow(new NamingException("Failed to search")); - final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, dirContextMock); + final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, this.dirContextMock); assertThat(valid).isFalse(); } diff --git a/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java b/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java index d76ed144..ba8bb012 100644 --- a/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java +++ b/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java @@ -47,12 +47,12 @@ public abstract class AbstractPoolTestCase { @Before public void setUp() throws Exception { - contextMock = mock(Context.class); - dirContextMock = mock(DirContext.class); - ldapContextMock = mock(LdapContext.class); - keyedObjectPoolMock = mock(KeyedObjectPool.class); - contextSourceMock = mock(ContextSource.class); - dirContextValidatorMock = mock(DirContextValidator.class); + this.contextMock = mock(Context.class); + this.dirContextMock = mock(DirContext.class); + this.ldapContextMock = mock(LdapContext.class); + this.keyedObjectPoolMock = mock(KeyedObjectPool.class); + this.contextSourceMock = mock(ContextSource.class); + this.dirContextValidatorMock = mock(DirContextValidator.class); } } diff --git a/core/src/test/java/org/springframework/ldap/support/LdapUtilsTest.java b/core/src/test/java/org/springframework/ldap/support/LdapUtilsTest.java index 802a3a7d..6977d361 100644 --- a/core/src/test/java/org/springframework/ldap/support/LdapUtilsTest.java +++ b/core/src/test/java/org/springframework/ldap/support/LdapUtilsTest.java @@ -43,7 +43,7 @@ public class LdapUtilsTest { @Before public void setUp() throws Exception { - handlerMock = mock(AttributeValueCallbackHandler.class); + this.handlerMock = mock(AttributeValueCallbackHandler.class); } @Test @@ -87,10 +87,10 @@ public class LdapUtilsTest { expectedAttribute.add("value1"); expectedAttribute.add("value2"); - LdapUtils.iterateAttributeValues(expectedAttribute, handlerMock); + LdapUtils.iterateAttributeValues(expectedAttribute, this.handlerMock); - verify(handlerMock).handleAttributeValue(expectedAttributeName, "value1", 0); - verify(handlerMock).handleAttributeValue(expectedAttributeName, "value2", 1); + verify(this.handlerMock).handleAttributeValue(expectedAttributeName, "value1", 0); + verify(this.handlerMock).handleAttributeValue(expectedAttributeName, "value2", 1); } @Test @@ -99,7 +99,7 @@ public class LdapUtilsTest { BasicAttribute expectedAttribute = new BasicAttribute(expectedAttributeName); - LdapUtils.iterateAttributeValues(expectedAttribute, handlerMock); + LdapUtils.iterateAttributeValues(expectedAttribute, this.handlerMock); } /** diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTest.java index b1ca72df..b4a597d3 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTest.java @@ -33,7 +33,7 @@ public class BindOperationExecutorTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); } @Test @@ -41,13 +41,13 @@ public class BindOperationExecutorTest { LdapName expectedDn = LdapUtils.newLdapName("cn=john doe"); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - BindOperationExecutor tested = new BindOperationExecutor(ldapOperationsMock, expectedDn, expectedObject, + BindOperationExecutor tested = new BindOperationExecutor(this.ldapOperationsMock, expectedDn, expectedObject, expectedAttributes); // perform teste tested.performOperation(); - verify(ldapOperationsMock).bind(expectedDn, expectedObject, expectedAttributes); + verify(this.ldapOperationsMock).bind(expectedDn, expectedObject, expectedAttributes); } @Test @@ -55,10 +55,10 @@ public class BindOperationExecutorTest { LdapName expectedDn = LdapUtils.newLdapName("cn=john doe"); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - BindOperationExecutor tested = new BindOperationExecutor(ldapOperationsMock, expectedDn, expectedObject, + BindOperationExecutor tested = new BindOperationExecutor(this.ldapOperationsMock, expectedDn, expectedObject, expectedAttributes); - verifyNoMoreInteractions(ldapOperationsMock); + verifyNoMoreInteractions(this.ldapOperationsMock); // perform teste tested.commit(); @@ -67,12 +67,12 @@ public class BindOperationExecutorTest { @Test public void testRollback() { LdapName expectedDn = LdapUtils.newLdapName("cn=john doe"); - BindOperationExecutor tested = new BindOperationExecutor(ldapOperationsMock, expectedDn, null, null); + BindOperationExecutor tested = new BindOperationExecutor(this.ldapOperationsMock, expectedDn, null, null); // perform teste tested.rollback(); - verify(ldapOperationsMock).unbind(expectedDn); + verify(this.ldapOperationsMock).unbind(expectedDn); } } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTest.java index 0a25140a..21459c95 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTest.java @@ -35,13 +35,13 @@ public class BindOperationRecorderTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); } @Test public void testRecordOperation_Name() { - BindOperationRecorder tested = new BindOperationRecorder(ldapOperationsMock); + BindOperationRecorder tested = new BindOperationRecorder(this.ldapOperationsMock); LdapName expectedDn = LdapUtils.newLdapName("cn=John Doe"); Object expectedObject = new Object(); @@ -53,14 +53,14 @@ public class BindOperationRecorderTest { assertThat(operation instanceof BindOperationExecutor).isTrue(); BindOperationExecutor rollbackOperation = (BindOperationExecutor) operation; assertThat(rollbackOperation.getDn()).isSameAs(expectedDn); - assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); assertThat(rollbackOperation.getOriginalObject()).isSameAs(expectedObject); assertSame(expectedAttributes, rollbackOperation.getOriginalAttributes()); } @Test public void testPerformOperation_String() { - BindOperationRecorder tested = new BindOperationRecorder(ldapOperationsMock); + BindOperationRecorder tested = new BindOperationRecorder(this.ldapOperationsMock); String expectedDn = "cn=John Doe"; Object expectedObject = new Object(); @@ -72,12 +72,12 @@ public class BindOperationRecorderTest { assertThat(operation instanceof BindOperationExecutor).isTrue(); BindOperationExecutor rollbackOperation = (BindOperationExecutor) operation; assertThat(rollbackOperation.getDn().toString()).isEqualTo(expectedDn); - assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); } @Test(expected = IllegalArgumentException.class) public void testPerformOperation_Invalid() { - BindOperationRecorder tested = new BindOperationRecorder(ldapOperationsMock); + BindOperationRecorder tested = new BindOperationRecorder(this.ldapOperationsMock); Object expectedDn = new Object(); // Perform test. diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTest.java index 4d6ed70d..f070d4d9 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTest.java @@ -37,15 +37,15 @@ public class LdapCompensatingTransactionOperationFactoryTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); - renamingStrategyMock = mock(TempEntryRenamingStrategy.class); - dirContextMock = mock(DirContext.class); + this.ldapOperationsMock = mock(LdapOperations.class); + this.renamingStrategyMock = mock(TempEntryRenamingStrategy.class); + this.dirContextMock = mock(DirContext.class); - tested = new LdapCompensatingTransactionOperationFactory(renamingStrategyMock) { + this.tested = new LdapCompensatingTransactionOperationFactory(this.renamingStrategyMock) { LdapOperations createLdapOperationsInstance(DirContext ctx) { - assertThat(ctx).isEqualTo(dirContextMock); - return ldapOperationsMock; + assertThat(ctx).isEqualTo(LdapCompensatingTransactionOperationFactoryTest.this.dirContextMock); + return LdapCompensatingTransactionOperationFactoryTest.this.ldapOperationsMock; } }; } @@ -53,45 +53,49 @@ public class LdapCompensatingTransactionOperationFactoryTest { @Test public void testGetRecordingOperation_Bind() throws Exception { - CompensatingTransactionOperationRecorder result = tested.createRecordingOperation(dirContextMock, "bind"); + CompensatingTransactionOperationRecorder result = this.tested.createRecordingOperation(this.dirContextMock, + "bind"); assertThat(result instanceof BindOperationRecorder).isTrue(); BindOperationRecorder bindOperationRecorder = (BindOperationRecorder) result; - assertThat(bindOperationRecorder.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(bindOperationRecorder.getLdapOperations()).isSameAs(this.ldapOperationsMock); } @Test public void testGetRecordingOperation_Rebind() throws Exception { - CompensatingTransactionOperationRecorder result = tested.createRecordingOperation(dirContextMock, "rebind"); + CompensatingTransactionOperationRecorder result = this.tested.createRecordingOperation(this.dirContextMock, + "rebind"); assertThat(result instanceof RebindOperationRecorder).isTrue(); RebindOperationRecorder rebindOperationRecorder = (RebindOperationRecorder) result; - assertThat(rebindOperationRecorder.getLdapOperations()).isSameAs(ldapOperationsMock); - assertThat(rebindOperationRecorder.getRenamingStrategy()).isSameAs(renamingStrategyMock); + assertThat(rebindOperationRecorder.getLdapOperations()).isSameAs(this.ldapOperationsMock); + assertThat(rebindOperationRecorder.getRenamingStrategy()).isSameAs(this.renamingStrategyMock); } @Test public void testGetRecordingOperation_Rename() throws Exception { - CompensatingTransactionOperationRecorder result = tested.createRecordingOperation(dirContextMock, "rename"); + CompensatingTransactionOperationRecorder result = this.tested.createRecordingOperation(this.dirContextMock, + "rename"); assertThat(result instanceof RenameOperationRecorder).isTrue(); RenameOperationRecorder recordingOperation = (RenameOperationRecorder) result; - assertThat(recordingOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(recordingOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); } @Test public void testGetRecordingOperation_ModifyAttributes() throws Exception { - CompensatingTransactionOperationRecorder result = tested.createRecordingOperation(dirContextMock, + CompensatingTransactionOperationRecorder result = this.tested.createRecordingOperation(this.dirContextMock, "modifyAttributes"); assertThat(result instanceof ModifyAttributesOperationRecorder).isTrue(); ModifyAttributesOperationRecorder recordingOperation = (ModifyAttributesOperationRecorder) result; - assertThat(recordingOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(recordingOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); } @Test public void testGetRecordingOperation_Unbind() throws Exception { - CompensatingTransactionOperationRecorder result = tested.createRecordingOperation(dirContextMock, "unbind"); + CompensatingTransactionOperationRecorder result = this.tested.createRecordingOperation(this.dirContextMock, + "unbind"); assertThat(result instanceof UnbindOperationRecorder).isTrue(); UnbindOperationRecorder recordingOperation = (UnbindOperationRecorder) result; - assertThat(recordingOperation.getLdapOperations()).isSameAs(ldapOperationsMock); - assertThat(recordingOperation.getRenamingStrategy()).isSameAs(renamingStrategyMock); + assertThat(recordingOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); + assertThat(recordingOperation.getRenamingStrategy()).isSameAs(this.renamingStrategyMock); } } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTest.java index 6e7314ee..6a025cbc 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTest.java @@ -34,7 +34,7 @@ public class LdapTransactionUtilsTest { @Before public void setUp() throws Exception { - dirContextMock = mock(DirContext.class); + this.dirContextMock = mock(DirContext.class); if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clearSynchronization(); @@ -43,8 +43,8 @@ public class LdapTransactionUtilsTest { @Test public void testCloseContext() throws NamingException { - LdapUtils.closeContext(dirContextMock); - verify(dirContextMock).close(); + LdapUtils.closeContext(this.dirContextMock); + verify(this.dirContextMock).close(); } @Test diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTest.java index 2c45adf1..025a7d81 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTest.java @@ -33,7 +33,7 @@ public class ModifyAttributesOperationExecutorTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); } @Test @@ -43,13 +43,13 @@ public class ModifyAttributesOperationExecutorTest { Name expectedDn = LdapUtils.newLdapName("cn=john doe"); - ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(ldapOperationsMock, expectedDn, - expectedActualItems, expectedCompensatingItems); + ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(this.ldapOperationsMock, + expectedDn, expectedActualItems, expectedCompensatingItems); // Perform test tested.performOperation(); - verify(ldapOperationsMock).modifyAttributes(expectedDn, expectedActualItems); + verify(this.ldapOperationsMock).modifyAttributes(expectedDn, expectedActualItems); } @Test @@ -59,11 +59,11 @@ public class ModifyAttributesOperationExecutorTest { Name expectedDn = LdapUtils.newLdapName("cn=john doe"); - ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(ldapOperationsMock, expectedDn, - expectedActualItems, expectedCompensatingItems); + ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(this.ldapOperationsMock, + expectedDn, expectedActualItems, expectedCompensatingItems); // No operation here - verifyNoMoreInteractions(ldapOperationsMock); + verifyNoMoreInteractions(this.ldapOperationsMock); // Perform test tested.commit(); @@ -76,13 +76,13 @@ public class ModifyAttributesOperationExecutorTest { Name expectedDn = LdapUtils.newLdapName("cn=john doe"); - ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(ldapOperationsMock, expectedDn, - expectedActualItems, expectedCompensatingItems); + ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(this.ldapOperationsMock, + expectedDn, expectedActualItems, expectedCompensatingItems); // Perform test tested.rollback(); - verify(ldapOperationsMock).modifyAttributes(expectedDn, expectedCompensatingItems); + verify(this.ldapOperationsMock).modifyAttributes(expectedDn, expectedCompensatingItems); } } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTest.java index cae69e75..57c7d9b3 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTest.java @@ -46,10 +46,10 @@ public class ModifyAttributesOperationRecorderTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); - attributesMapperMock = mock(IncrementalAttributesMapper.class); + this.ldapOperationsMock = mock(LdapOperations.class); + this.attributesMapperMock = mock(IncrementalAttributesMapper.class); - tested = new ModifyAttributesOperationRecorder(ldapOperationsMock); + this.tested = new ModifyAttributesOperationRecorder(this.ldapOperationsMock); } @Test @@ -62,9 +62,9 @@ public class ModifyAttributesOperationRecorderTest { final Attributes expectedAttributes = new BasicAttributes(); - tested = new ModifyAttributesOperationRecorder(ldapOperationsMock) { + this.tested = new ModifyAttributesOperationRecorder(this.ldapOperationsMock) { IncrementalAttributesMapper getAttributesMapper(String[] attributeNames) { - return attributesMapperMock; + return ModifyAttributesOperationRecorderTest.this.attributesMapperMock; } protected ModificationItem getCompensatingModificationItem(Attributes originalAttributes, @@ -77,21 +77,21 @@ public class ModifyAttributesOperationRecorderTest { LdapName expectedName = LdapUtils.newLdapName("cn=john doe"); - when(attributesMapperMock.hasMore()).thenReturn(true, false); - when(attributesMapperMock.getAttributesForLookup()).thenReturn(new String[] { "attribute1" }); - when(ldapOperationsMock.lookup(expectedName, new String[] { "attribute1" }, attributesMapperMock)) + when(this.attributesMapperMock.hasMore()).thenReturn(true, false); + when(this.attributesMapperMock.getAttributesForLookup()).thenReturn(new String[] { "attribute1" }); + when(this.ldapOperationsMock.lookup(expectedName, new String[] { "attribute1" }, this.attributesMapperMock)) .thenReturn(expectedAttributes); - when(attributesMapperMock.getCollectedAttributes()).thenReturn(expectedAttributes); + when(this.attributesMapperMock.getCollectedAttributes()).thenReturn(expectedAttributes); // Perform test - CompensatingTransactionOperationExecutor operation = tested + CompensatingTransactionOperationExecutor operation = this.tested .recordOperation(new Object[] { expectedName, incomingMods }); // Verify outcome assertThat(operation instanceof ModifyAttributesOperationExecutor).isTrue(); ModifyAttributesOperationExecutor rollbackOperation = (ModifyAttributesOperationExecutor) operation; assertThat(rollbackOperation.getDn()).isSameAs(expectedName); - assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); ModificationItem[] actualModifications = rollbackOperation.getActualModifications(); assertThat(actualModifications.length).isEqualTo(incomingMods.length); assertThat(actualModifications[0]).isEqualTo(incomingMods[0]); @@ -111,7 +111,7 @@ public class ModifyAttributesOperationRecorderTest { new BasicAttribute("someattr")); // Perform test - ModificationItem result = tested.getCompensatingModificationItem(attributes, originalItem); + ModificationItem result = this.tested.getCompensatingModificationItem(attributes, originalItem); // Verify result assertThat(result.getModificationOp()).isEqualTo(DirContext.ADD_ATTRIBUTE); @@ -137,7 +137,7 @@ public class ModifyAttributesOperationRecorderTest { ModificationItem originalItem = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, modificationAttribute); // Perform test - ModificationItem result = tested.getCompensatingModificationItem(attributes, originalItem); + ModificationItem result = this.tested.getCompensatingModificationItem(attributes, originalItem); // Verify result assertThat(result.getModificationOp()).isEqualTo(DirContext.ADD_ATTRIBUTE); @@ -163,7 +163,7 @@ public class ModifyAttributesOperationRecorderTest { new BasicAttribute("someattr")); // Perform test - ModificationItem result = tested.getCompensatingModificationItem(attributes, originalItem); + ModificationItem result = this.tested.getCompensatingModificationItem(attributes, originalItem); // Verify result assertThat(result.getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); @@ -184,7 +184,7 @@ public class ModifyAttributesOperationRecorderTest { ModificationItem originalItem = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, modificationAttribute); // Perform test - ModificationItem result = tested.getCompensatingModificationItem(attributes, originalItem); + ModificationItem result = this.tested.getCompensatingModificationItem(attributes, originalItem); // Verify result assertThat(result.getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); @@ -203,7 +203,7 @@ public class ModifyAttributesOperationRecorderTest { ModificationItem originalItem = new ModificationItem(DirContext.ADD_ATTRIBUTE, modificationAttribute); // Perform test - ModificationItem result = tested.getCompensatingModificationItem(attributes, originalItem); + ModificationItem result = this.tested.getCompensatingModificationItem(attributes, originalItem); // Verify result assertThat(result.getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE); @@ -226,7 +226,7 @@ public class ModifyAttributesOperationRecorderTest { ModificationItem originalItem = new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("someattr")); // Perform test - ModificationItem result = tested.getCompensatingModificationItem(attributes, originalItem); + ModificationItem result = this.tested.getCompensatingModificationItem(attributes, originalItem); // Verify result assertThat(result.getModificationOp()).isEqualTo(DirContext.REPLACE_ATTRIBUTE); diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTest.java index 23a9db78..428ab6a9 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTest.java @@ -32,7 +32,7 @@ public class RebindOperationExecutorTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); } @Test @@ -41,13 +41,13 @@ public class RebindOperationExecutorTest { LdapName expectedTempDn = LdapUtils.newLdapName("cn=john doe_temp"); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - RebindOperationExecutor tested = new RebindOperationExecutor(ldapOperationsMock, expectedOriginalDn, + RebindOperationExecutor tested = new RebindOperationExecutor(this.ldapOperationsMock, expectedOriginalDn, expectedTempDn, expectedObject, expectedAttributes); // perform test tested.performOperation(); - verify(ldapOperationsMock).rename(expectedOriginalDn, expectedTempDn); - verify(ldapOperationsMock).bind(expectedOriginalDn, expectedObject, expectedAttributes); + verify(this.ldapOperationsMock).rename(expectedOriginalDn, expectedTempDn); + verify(this.ldapOperationsMock).bind(expectedOriginalDn, expectedObject, expectedAttributes); } @Test @@ -56,12 +56,12 @@ public class RebindOperationExecutorTest { LdapName expectedTempDn = LdapUtils.newLdapName("cn=john doe_temp"); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - RebindOperationExecutor tested = new RebindOperationExecutor(ldapOperationsMock, expectedOriginalDn, + RebindOperationExecutor tested = new RebindOperationExecutor(this.ldapOperationsMock, expectedOriginalDn, expectedTempDn, expectedObject, expectedAttributes); // perform test tested.commit(); - verify(ldapOperationsMock).unbind(expectedTempDn); + verify(this.ldapOperationsMock).unbind(expectedTempDn); } @Test @@ -70,14 +70,14 @@ public class RebindOperationExecutorTest { LdapName expectedTempDn = LdapUtils.newLdapName("cn=john doe_temp"); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); - RebindOperationExecutor tested = new RebindOperationExecutor(ldapOperationsMock, expectedOriginalDn, + RebindOperationExecutor tested = new RebindOperationExecutor(this.ldapOperationsMock, expectedOriginalDn, expectedTempDn, expectedObject, expectedAttributes); // perform test tested.rollback(); - verify(ldapOperationsMock).unbind(expectedOriginalDn); - verify(ldapOperationsMock).rename(expectedTempDn, expectedOriginalDn); + verify(this.ldapOperationsMock).unbind(expectedOriginalDn); + verify(this.ldapOperationsMock).rename(expectedTempDn, expectedOriginalDn); } } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTest.java index a979ecf2..0ea459fe 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTest.java @@ -36,8 +36,8 @@ public class RebindOperationRecorderTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); - renamingStrategyMock = mock(TempEntryRenamingStrategy.class); + this.ldapOperationsMock = mock(LdapOperations.class); + this.renamingStrategyMock = mock(TempEntryRenamingStrategy.class); } @@ -45,9 +45,10 @@ public class RebindOperationRecorderTest { public void testRecordOperation() { final LdapName expectedDn = LdapUtils.newLdapName("cn=john doe"); final LdapName expectedTempDn = LdapUtils.newLdapName("cn=john doe"); - RebindOperationRecorder tested = new RebindOperationRecorder(ldapOperationsMock, renamingStrategyMock); + RebindOperationRecorder tested = new RebindOperationRecorder(this.ldapOperationsMock, + this.renamingStrategyMock); - when(renamingStrategyMock.getTemporaryName(expectedDn)).thenReturn(expectedTempDn); + when(this.renamingStrategyMock.getTemporaryName(expectedDn)).thenReturn(expectedTempDn); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); @@ -57,7 +58,7 @@ public class RebindOperationRecorderTest { .recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes }); assertThat(result instanceof RebindOperationExecutor).isTrue(); RebindOperationExecutor rollbackOperation = (RebindOperationExecutor) result; - assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); assertThat(rollbackOperation.getOriginalDn()).isSameAs(expectedDn); assertThat(rollbackOperation.getTemporaryDn()).isSameAs(expectedTempDn); assertThat(rollbackOperation.getOriginalObject()).isSameAs(expectedObject); diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTest.java index 91e0aa07..94a3f771 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTest.java @@ -33,7 +33,7 @@ public class RenameOperationExecutorTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); ; } @@ -41,24 +41,24 @@ public class RenameOperationExecutorTest { public void testPerformOperation() { LdapName expectedNewName = LdapUtils.newLdapName("ou=newOu"); LdapName expectedOldName = LdapUtils.newLdapName("ou=someou"); - RenameOperationExecutor tested = new RenameOperationExecutor(ldapOperationsMock, expectedOldName, + RenameOperationExecutor tested = new RenameOperationExecutor(this.ldapOperationsMock, expectedOldName, expectedNewName); // Perform test. tested.performOperation(); - verify(ldapOperationsMock).rename(expectedOldName, expectedNewName); + verify(this.ldapOperationsMock).rename(expectedOldName, expectedNewName); } @Test public void testCommit() { LdapName expectedNewName = LdapUtils.newLdapName("ou=newOu"); LdapName expectedOldName = LdapUtils.newLdapName("ou=someou"); - RenameOperationExecutor tested = new RenameOperationExecutor(ldapOperationsMock, expectedOldName, + RenameOperationExecutor tested = new RenameOperationExecutor(this.ldapOperationsMock, expectedOldName, expectedNewName); // Nothing to do for this operation. - verifyNoMoreInteractions(ldapOperationsMock); + verifyNoMoreInteractions(this.ldapOperationsMock); // Perform test. tested.commit(); @@ -68,13 +68,13 @@ public class RenameOperationExecutorTest { public void testRollback() { LdapName expectedNewName = LdapUtils.newLdapName("ou=newOu"); LdapName expectedOldName = LdapUtils.newLdapName("ou=someou"); - RenameOperationExecutor tested = new RenameOperationExecutor(ldapOperationsMock, expectedOldName, + RenameOperationExecutor tested = new RenameOperationExecutor(this.ldapOperationsMock, expectedOldName, expectedNewName); // Perform test. tested.rollback(); - verify(ldapOperationsMock).rename(expectedNewName, expectedOldName); + verify(this.ldapOperationsMock).rename(expectedNewName, expectedOldName); } } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTest.java index 5b627ac2..6f526f05 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTest.java @@ -29,13 +29,13 @@ public class RenameOperationRecorderTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); ; } @Test public void testRecordOperation() { - RenameOperationRecorder tested = new RenameOperationRecorder(ldapOperationsMock); + RenameOperationRecorder tested = new RenameOperationRecorder(this.ldapOperationsMock); // Perform test CompensatingTransactionOperationExecutor operation = tested @@ -43,7 +43,7 @@ public class RenameOperationRecorderTest { assertThat(operation instanceof RenameOperationExecutor).isTrue(); RenameOperationExecutor rollbackOperation = (RenameOperationExecutor) operation; - assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); assertThat(rollbackOperation.getNewDn().toString()).isEqualTo("ou=newou"); assertThat(rollbackOperation.getOriginalDn().toString()).isEqualTo("ou=someou"); } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTest.java index ff88b09a..fabe0596 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTest.java @@ -31,7 +31,7 @@ public class UnbindOperationExecutorTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); ; } @@ -39,37 +39,37 @@ public class UnbindOperationExecutorTest { public void testPerformOperation() { LdapName expectedOldName = LdapUtils.newLdapName("cn=oldDn"); LdapName expectedTempName = LdapUtils.newLdapName("cn=newDn"); - UnbindOperationExecutor tested = new UnbindOperationExecutor(ldapOperationsMock, expectedOldName, + UnbindOperationExecutor tested = new UnbindOperationExecutor(this.ldapOperationsMock, expectedOldName, expectedTempName); // Perform test tested.performOperation(); - verify(ldapOperationsMock).rename(expectedOldName, expectedTempName); + verify(this.ldapOperationsMock).rename(expectedOldName, expectedTempName); } @Test public void testCommit() { LdapName expectedOldName = LdapUtils.newLdapName("cn=oldDn"); LdapName expectedTempName = LdapUtils.newLdapName("cn=newDn"); - UnbindOperationExecutor tested = new UnbindOperationExecutor(ldapOperationsMock, expectedOldName, + UnbindOperationExecutor tested = new UnbindOperationExecutor(this.ldapOperationsMock, expectedOldName, expectedTempName); // Perform test tested.commit(); - verify(ldapOperationsMock).unbind(expectedTempName); + verify(this.ldapOperationsMock).unbind(expectedTempName); } @Test public void testRollback() { LdapName expectedOldName = LdapUtils.newLdapName("cn=oldDn"); LdapName expectedTempName = LdapUtils.newLdapName("cn=newDn"); - UnbindOperationExecutor tested = new UnbindOperationExecutor(ldapOperationsMock, expectedOldName, + UnbindOperationExecutor tested = new UnbindOperationExecutor(this.ldapOperationsMock, expectedOldName, expectedTempName); // Perform test tested.rollback(); - verify(ldapOperationsMock).rename(expectedTempName, expectedOldName); + verify(this.ldapOperationsMock).rename(expectedTempName, expectedOldName); } } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTest.java index 96d6a1e0..22fc8df6 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTest.java @@ -35,19 +35,20 @@ public class UnbindOperationRecorderTest { @Before public void setUp() throws Exception { - ldapOperationsMock = mock(LdapOperations.class); + this.ldapOperationsMock = mock(LdapOperations.class); ; - renamingStrategyMock = mock(TempEntryRenamingStrategy.class); + this.renamingStrategyMock = mock(TempEntryRenamingStrategy.class); } @Test public void testRecordOperation() { final LdapName expectedTempName = LdapUtils.newLdapName("cn=john doe_temp"); final LdapName expectedDn = LdapUtils.newLdapName("cn=john doe"); - UnbindOperationRecorder tested = new UnbindOperationRecorder(ldapOperationsMock, renamingStrategyMock); + UnbindOperationRecorder tested = new UnbindOperationRecorder(this.ldapOperationsMock, + this.renamingStrategyMock); - when(renamingStrategyMock.getTemporaryName(expectedDn)).thenReturn(expectedTempName); + when(this.renamingStrategyMock.getTemporaryName(expectedDn)).thenReturn(expectedTempName); // Perform test CompensatingTransactionOperationExecutor operation = tested.recordOperation(new Object[] { expectedDn }); @@ -55,7 +56,7 @@ public class UnbindOperationRecorderTest { // Verify result assertThat(operation instanceof UnbindOperationExecutor).isTrue(); UnbindOperationExecutor rollbackOperation = (UnbindOperationExecutor) operation; - assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); + assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock); assertThat(rollbackOperation.getOriginalDn()).isSameAs(expectedDn); assertThat(rollbackOperation.getTemporaryDn()).isSameAs(expectedTempName); } diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTest.java index 777b3e89..874cdd82 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTest.java @@ -39,9 +39,9 @@ public class CompensatingTransactionUtilsTest { @Before public void setUp() throws Exception { - dirContextMock = mock(DirContext.class); - contextSourceMock = mock(ContextSource.class); - operationManagerMock = mock(CompensatingTransactionOperationManager.class); + this.dirContextMock = mock(DirContext.class); + this.contextSourceMock = mock(ContextSource.class); + this.operationManagerMock = mock(CompensatingTransactionOperationManager.class); if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clearSynchronization(); @@ -50,25 +50,25 @@ public class CompensatingTransactionUtilsTest { @Test public void testPerformOperation() throws Throwable { - CompensatingTransactionHolderSupport holder = new DirContextHolder(null, dirContextMock); - holder.setTransactionOperationManager(operationManagerMock); + CompensatingTransactionHolderSupport holder = new DirContextHolder(null, this.dirContextMock); + holder.setTransactionOperationManager(this.operationManagerMock); - TransactionSynchronizationManager.bindResource(contextSourceMock, holder); + TransactionSynchronizationManager.bindResource(this.contextSourceMock, holder); Object[] expectedArgs = new Object[] { "someDn" }; - CompensatingTransactionUtils.performOperation(contextSourceMock, dirContextMock, getUnbindMethod(), + CompensatingTransactionUtils.performOperation(this.contextSourceMock, this.dirContextMock, getUnbindMethod(), expectedArgs); - verify(operationManagerMock).performOperation(dirContextMock, "unbind", expectedArgs); + verify(this.operationManagerMock).performOperation(this.dirContextMock, "unbind", expectedArgs); } @Test public void testPerformOperation_NoTransaction() throws Throwable { Object[] expectedArgs = new Object[] { "someDn" }; - CompensatingTransactionUtils.performOperation(contextSourceMock, dirContextMock, getUnbindMethod(), + CompensatingTransactionUtils.performOperation(this.contextSourceMock, this.dirContextMock, getUnbindMethod(), expectedArgs); - verify(dirContextMock).unbind("someDn"); + verify(this.dirContextMock).unbind("someDn"); } private Method getUnbindMethod() throws NoSuchMethodException { diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTest.java index 3e53ba66..c59822dc 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTest.java @@ -62,20 +62,20 @@ public class ContextSourceTransactionManagerTest { TransactionSynchronizationManager.clearSynchronization(); } - contextSourceMock = mock(ContextSource.class); - contextMock = mock(DirContext.class); - transactionDefinitionMock = mock(TransactionDefinition.class); - transactionDataManagerMock = mock(CompensatingTransactionOperationManager.class); - renamingStrategyMock = mock(TempEntryRenamingStrategy.class); + this.contextSourceMock = mock(ContextSource.class); + this.contextMock = mock(DirContext.class); + this.transactionDefinitionMock = mock(TransactionDefinition.class); + this.transactionDataManagerMock = mock(CompensatingTransactionOperationManager.class); + this.renamingStrategyMock = mock(TempEntryRenamingStrategy.class); - tested = new ContextSourceTransactionManager(); - tested.setContextSource(contextSourceMock); - tested.setRenamingStrategy(renamingStrategyMock); + this.tested = new ContextSourceTransactionManager(); + this.tested.setContextSource(this.contextSourceMock); + this.tested.setRenamingStrategy(this.renamingStrategyMock); } @Test public void testDoGetTransaction() { - Object result = tested.doGetTransaction(); + Object result = this.tested.doGetTransaction(); assertThat(result).isNotNull(); assertThat(result instanceof CompensatingTransactionObject).isTrue(); @@ -86,58 +86,58 @@ public class ContextSourceTransactionManagerTest { @Test public void testDoGetTransactionTransactionActive() { CompensatingTransactionHolderSupport expectedContextHolder = new DirContextHolder(null, null); - TransactionSynchronizationManager.bindResource(contextSourceMock, expectedContextHolder); - Object result = tested.doGetTransaction(); + TransactionSynchronizationManager.bindResource(this.contextSourceMock, expectedContextHolder); + Object result = this.tested.doGetTransaction(); assertThat(((CompensatingTransactionObject) result).getHolder()).isSameAs(expectedContextHolder); } @Test public void testDoBegin() { - when(contextSourceMock.getReadWriteContext()).thenReturn(contextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.contextMock); CompensatingTransactionObject expectedTransactionObject = new CompensatingTransactionObject(null); - tested.doBegin(expectedTransactionObject, transactionDefinitionMock); + this.tested.doBegin(expectedTransactionObject, this.transactionDefinitionMock); DirContextHolder foundContextHolder = (DirContextHolder) TransactionSynchronizationManager - .getResource(contextSourceMock); - assertThat(foundContextHolder.getCtx()).isSameAs(contextMock); + .getResource(this.contextSourceMock); + assertThat(foundContextHolder.getCtx()).isSameAs(this.contextMock); } @Test public void testDoRollback() { - DirContextHolder expectedContextHolder = new DirContextHolder(null, contextMock); - expectedContextHolder.setTransactionOperationManager(transactionDataManagerMock); - TransactionSynchronizationManager.bindResource(contextSourceMock, expectedContextHolder); + DirContextHolder expectedContextHolder = new DirContextHolder(null, this.contextMock); + expectedContextHolder.setTransactionOperationManager(this.transactionDataManagerMock); + TransactionSynchronizationManager.bindResource(this.contextSourceMock, expectedContextHolder); CompensatingTransactionObject transactionObject = new CompensatingTransactionObject(null); transactionObject.setHolder(expectedContextHolder); - tested.doRollback(new DefaultTransactionStatus(transactionObject, false, false, false, false, null)); + this.tested.doRollback(new DefaultTransactionStatus(transactionObject, false, false, false, false, null)); - verify(transactionDataManagerMock).rollback(); + verify(this.transactionDataManagerMock).rollback(); } @Test public void testDoCleanupAfterCompletion() throws Exception { - DirContextHolder expectedContextHolder = new DirContextHolder(null, contextMock); - TransactionSynchronizationManager.bindResource(contextSourceMock, expectedContextHolder); + DirContextHolder expectedContextHolder = new DirContextHolder(null, this.contextMock); + TransactionSynchronizationManager.bindResource(this.contextSourceMock, expectedContextHolder); - tested.doCleanupAfterCompletion(new CompensatingTransactionObject(expectedContextHolder)); + this.tested.doCleanupAfterCompletion(new CompensatingTransactionObject(expectedContextHolder)); - assertThat(TransactionSynchronizationManager.getResource(contextSourceMock)).isNull(); + assertThat(TransactionSynchronizationManager.getResource(this.contextSourceMock)).isNull(); assertThat(expectedContextHolder.getTransactionOperationManager()).isNull(); - verify(contextMock).close(); + verify(this.contextMock).close(); } @Test public void testSetContextSource_Proxy() { - TransactionAwareContextSourceProxy proxy = new TransactionAwareContextSourceProxy(contextSourceMock); + TransactionAwareContextSourceProxy proxy = new TransactionAwareContextSourceProxy(this.contextSourceMock); // Perform test - tested.setContextSource(proxy); - ContextSource result = tested.getContextSource(); + this.tested.setContextSource(proxy); + ContextSource result = this.tested.getContextSource(); // Verify result - assertThat(result).isSameAs(contextSourceMock); + assertThat(result).isSameAs(this.contextSourceMock); } @Test diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTest.java index 8eae0a50..865bda5a 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTest.java @@ -44,18 +44,18 @@ public class TransactionAwareContextSourceProxyTest { @Before public void setUp() throws Exception { - contextSourceMock = mock(ContextSource.class); - ldapContextMock = mock(LdapContext.class); - dirContextMock = mock(DirContext.class); + this.contextSourceMock = mock(ContextSource.class); + this.ldapContextMock = mock(LdapContext.class); + this.dirContextMock = mock(DirContext.class); - tested = new TransactionAwareContextSourceProxy(contextSourceMock); + this.tested = new TransactionAwareContextSourceProxy(this.contextSourceMock); } @Test public void testGetReadWriteContext_LdapContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(ldapContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.ldapContextMock); - DirContext result = tested.getReadWriteContext(); + DirContext result = this.tested.getReadWriteContext(); assertThat(result).isNotNull(); assertThat(result instanceof LdapContext).isTrue(); @@ -64,9 +64,9 @@ public class TransactionAwareContextSourceProxyTest { @Test public void testGetReadWriteContext_DirContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock); - DirContext result = tested.getReadWriteContext(); + DirContext result = this.tested.getReadWriteContext(); assertThat(result).as("Result should not be null").isNotNull(); assertThat(result instanceof DirContext).isTrue(); @@ -76,9 +76,9 @@ public class TransactionAwareContextSourceProxyTest { @Test public void testGetReadOnlyContext_LdapContext() { - when(contextSourceMock.getReadWriteContext()).thenReturn(ldapContextMock); + when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.ldapContextMock); - DirContext result = tested.getReadOnlyContext(); + DirContext result = this.tested.getReadOnlyContext(); assertThat(result).as("Result should not be null").isNotNull(); assertThat(result instanceof LdapContext).isTrue(); diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTest.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTest.java index 83d0b13d..58b39bc7 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTest.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTest.java @@ -39,37 +39,37 @@ public class TransactionAwareDirContextInvocationHandlerTest { @Before public void setUp() throws Exception { - dirContextMock = mock(DirContext.class); - contextSourceMock = mock(ContextSource.class); + this.dirContextMock = mock(DirContext.class); + this.contextSourceMock = mock(ContextSource.class); - holder = new DirContextHolder(null, dirContextMock); - tested = new TransactionAwareDirContextInvocationHandler(null, null); + this.holder = new DirContextHolder(null, this.dirContextMock); + this.tested = new TransactionAwareDirContextInvocationHandler(null, null); } @Test public void testDoCloseConnection_NoTransaction() throws NamingException { - tested.doCloseConnection(dirContextMock, contextSourceMock); + this.tested.doCloseConnection(this.dirContextMock, this.contextSourceMock); - verify(dirContextMock).close(); + verify(this.dirContextMock).close(); } @Test public void testDoCloseConnection_ActiveTransaction() throws NamingException { - TransactionSynchronizationManager.bindResource(contextSourceMock, holder); + TransactionSynchronizationManager.bindResource(this.contextSourceMock, this.holder); // Context should not be closed. - verifyNoMoreInteractions(dirContextMock); + verifyNoMoreInteractions(this.dirContextMock); - tested.doCloseConnection(dirContextMock, contextSourceMock); + this.tested.doCloseConnection(this.dirContextMock, this.contextSourceMock); } @Test public void testDoCloseConnection_NotTransactionalContext() throws NamingException { - TransactionSynchronizationManager.bindResource(contextSourceMock, holder); + TransactionSynchronizationManager.bindResource(this.contextSourceMock, this.holder); DirContext dirContextMock2 = mock(DirContext.class); - tested.doCloseConnection(dirContextMock2, contextSourceMock); + this.tested.doCloseConnection(dirContextMock2, this.contextSourceMock); verify(dirContextMock2).close(); } diff --git a/core/src/test/java/org/springframework/ldap/util/ListComparatorTest.java b/core/src/test/java/org/springframework/ldap/util/ListComparatorTest.java index 52fb62c1..8341e47c 100644 --- a/core/src/test/java/org/springframework/ldap/util/ListComparatorTest.java +++ b/core/src/test/java/org/springframework/ldap/util/ListComparatorTest.java @@ -35,7 +35,7 @@ public class ListComparatorTest { @Before public void setUp() throws Exception { - tested = new ListComparator(); + this.tested = new ListComparator(); } @Test @@ -43,7 +43,7 @@ public class ListComparatorTest { List list1 = Arrays.asList(0, 0); List list2 = Arrays.asList(0, 0); - int result = tested.compare(list1, list2); + int result = this.tested.compare(list1, list2); assertThat(result).isEqualTo(0); } @@ -52,7 +52,7 @@ public class ListComparatorTest { List list1 = Arrays.asList(0, 0); List list2 = Arrays.asList(0, 1); - int result = tested.compare(list1, list2); + int result = this.tested.compare(list1, list2); assertThat(result < 0).isTrue(); } @@ -61,7 +61,7 @@ public class ListComparatorTest { List list1 = Arrays.asList(0, 1); List list2 = Arrays.asList(0, 0); - int result = tested.compare(list1, list2); + int result = this.tested.compare(list1, list2); assertThat(result > 0).isTrue(); } @@ -70,7 +70,7 @@ public class ListComparatorTest { List list1 = Arrays.asList(0, 0, 0); List list2 = Arrays.asList(0, 0); - int result = tested.compare(list1, list2); + int result = this.tested.compare(list1, list2); assertThat(result > 0).isTrue(); } @@ -79,7 +79,7 @@ public class ListComparatorTest { List list1 = Arrays.asList(0, 0); List list2 = Arrays.asList(0, 0, 0); - int result = tested.compare(list1, list2); + int result = this.tested.compare(list1, list2); assertThat(result < 0).isTrue(); } diff --git a/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTest.java b/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTest.java index 83ad1435..596144c8 100644 --- a/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTest.java +++ b/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTest.java @@ -40,9 +40,9 @@ public class DefaultCompensatingTransactionOperationManagerTest { @Before public void setUp() throws Exception { - operationExecutorMock = mock(CompensatingTransactionOperationExecutor.class); - operationFactoryMock = mock(CompensatingTransactionOperationFactory.class); - operationRecorderMock = mock(CompensatingTransactionOperationRecorder.class); + this.operationExecutorMock = mock(CompensatingTransactionOperationExecutor.class); + this.operationFactoryMock = mock(CompensatingTransactionOperationFactory.class); + this.operationRecorderMock = mock(CompensatingTransactionOperationRecorder.class); } @@ -51,37 +51,37 @@ public class DefaultCompensatingTransactionOperationManagerTest { Object[] expectedArgs = new Object[0]; Object expectedResource = new Object(); - when(operationFactoryMock.createRecordingOperation(expectedResource, "some method")) - .thenReturn(operationRecorderMock); - when(operationRecorderMock.recordOperation(expectedArgs)).thenReturn(operationExecutorMock); + when(this.operationFactoryMock.createRecordingOperation(expectedResource, "some method")) + .thenReturn(this.operationRecorderMock); + when(this.operationRecorderMock.recordOperation(expectedArgs)).thenReturn(this.operationExecutorMock); DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager( - operationFactoryMock); + this.operationFactoryMock); tested.performOperation(expectedResource, "some method", expectedArgs); - verify(operationExecutorMock).performOperation(); + verify(this.operationExecutorMock).performOperation(); Stack result = tested.getOperationExecutors(); assertThat(result.isEmpty()).isFalse(); - assertThat(result.peek()).isSameAs(operationExecutorMock); + assertThat(result.peek()).isSameAs(this.operationExecutorMock); } @Test public void testRollback() { DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager( - operationFactoryMock); - tested.getOperationExecutors().push(operationExecutorMock); + this.operationFactoryMock); + tested.getOperationExecutors().push(this.operationExecutorMock); tested.rollback(); - verify(operationExecutorMock).rollback(); + verify(this.operationExecutorMock).rollback(); } @Test(expected = TransactionSystemException.class) public void testRollback_Exception() { DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager( - operationFactoryMock); - tested.getOperationExecutors().push(operationExecutorMock); + this.operationFactoryMock); + tested.getOperationExecutors().push(this.operationExecutorMock); - doThrow(new RuntimeException()).when(operationExecutorMock).rollback(); + doThrow(new RuntimeException()).when(this.operationExecutorMock).rollback(); tested.rollback(); } @@ -89,20 +89,20 @@ public class DefaultCompensatingTransactionOperationManagerTest { @Test public void testCommit() { DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager( - operationFactoryMock); - tested.getOperationExecutors().push(operationExecutorMock); + this.operationFactoryMock); + tested.getOperationExecutors().push(this.operationExecutorMock); tested.commit(); - verify(operationExecutorMock).commit(); + verify(this.operationExecutorMock).commit(); } @Test(expected = TransactionSystemException.class) public void testCommit_Exception() { DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager( - operationFactoryMock); - tested.getOperationExecutors().push(operationExecutorMock); + this.operationFactoryMock); + tested.getOperationExecutors().push(this.operationExecutorMock); - doThrow(new RuntimeException()).when(operationExecutorMock).commit(); + doThrow(new RuntimeException()).when(this.operationExecutorMock).commit(); tested.commit(); }