Fixed some FindBugs problems and removed all references to acegi-support.
This commit is contained in:
@@ -29,176 +29,187 @@ import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* DirContextProcessor implementation for managing the paged results control.
|
||||
*
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class PagedResultsRequestControl extends
|
||||
AbstractRequestControlDirContextProcessor {
|
||||
public class PagedResultsRequestControl extends AbstractRequestControlDirContextProcessor {
|
||||
|
||||
private static final boolean CRITICAL_CONTROL = true;
|
||||
private static final boolean CRITICAL_CONTROL = true;
|
||||
|
||||
private static final String DEFAULT_REQUEST_CONTROL = "javax.naming.ldap.PagedResultsControl";
|
||||
private static final String LDAPBP_REQUEST_CONTROL = "com.sun.jndi.ldap.ctl.PagedResultsControl";
|
||||
private static final String DEFAULT_RESPONSE_CONTROL = "javax.naming.ldap.PagedResultsResponseControl";
|
||||
private static final String LDAPBP_RESPONSE_CONTROL = "com.sun.jndi.ldap.ctl.PagedResultsResponseControl";
|
||||
private static final String DEFAULT_REQUEST_CONTROL = "javax.naming.ldap.PagedResultsControl";
|
||||
|
||||
private int pageSize;
|
||||
private static final String LDAPBP_REQUEST_CONTROL = "com.sun.jndi.ldap.ctl.PagedResultsControl";
|
||||
|
||||
private PagedResultsCookie cookie;
|
||||
private static final String DEFAULT_RESPONSE_CONTROL = "javax.naming.ldap.PagedResultsResponseControl";
|
||||
|
||||
private int resultSize;
|
||||
private static final String LDAPBP_RESPONSE_CONTROL = "com.sun.jndi.ldap.ctl.PagedResultsResponseControl";
|
||||
|
||||
private boolean critical = CRITICAL_CONTROL;
|
||||
private int pageSize;
|
||||
|
||||
private Class responseControlClass;
|
||||
private Class requestControlClass;
|
||||
private PagedResultsCookie cookie;
|
||||
|
||||
/**
|
||||
* Constructs a new instance. This constructor should be used when
|
||||
* performing the first paged search operation, when no other results have
|
||||
* been retrieved.
|
||||
*
|
||||
* @param pageSize the page size.
|
||||
*/
|
||||
public PagedResultsRequestControl(int pageSize) {
|
||||
this(pageSize, null);
|
||||
}
|
||||
private int resultSize;
|
||||
|
||||
/**
|
||||
* Constructs a new instance with the supplied page size and cookie. The
|
||||
* cookie must be the exact same instance as received from a previous paged
|
||||
* resullts search, or <code>null</code> if it is the first in an
|
||||
* operation sequence.
|
||||
*
|
||||
* @param pageSize the page size.
|
||||
* @param cookie the cookie, as received from a previous search.
|
||||
*/
|
||||
public PagedResultsRequestControl(int pageSize, PagedResultsCookie cookie) {
|
||||
this.pageSize = pageSize;
|
||||
this.cookie = cookie;
|
||||
private boolean critical = CRITICAL_CONTROL;
|
||||
|
||||
loadControlClasses();
|
||||
}
|
||||
private Class responseControlClass;
|
||||
|
||||
private void loadControlClasses() {
|
||||
try {
|
||||
requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL);
|
||||
responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL);
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.debug("Default control classes not found - falling back to LdapBP classes", e);
|
||||
private Class requestControlClass;
|
||||
|
||||
try {
|
||||
requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL);
|
||||
responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
throw new UncategorizedLdapException("Neither default nor fallback classes are available - unable to proceed", e);
|
||||
}
|
||||
/**
|
||||
* Constructs a new instance. This constructor should be used when
|
||||
* performing the first paged search operation, when no other results have
|
||||
* been retrieved.
|
||||
*
|
||||
* @param pageSize the page size.
|
||||
*/
|
||||
public PagedResultsRequestControl(int pageSize) {
|
||||
this(pageSize, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Constructs a new instance with the supplied page size and cookie. The
|
||||
* cookie must be the exact same instance as received from a previous paged
|
||||
* resullts search, or <code>null</code> if it is the first in an operation
|
||||
* sequence.
|
||||
*
|
||||
* @param pageSize the page size.
|
||||
* @param cookie the cookie, as received from a previous search.
|
||||
*/
|
||||
public PagedResultsRequestControl(int pageSize, PagedResultsCookie cookie) {
|
||||
this.pageSize = pageSize;
|
||||
this.cookie = cookie;
|
||||
|
||||
/**
|
||||
* Get the cookie.
|
||||
*
|
||||
* @return the cookie.
|
||||
*/
|
||||
public PagedResultsCookie getCookie() {
|
||||
return cookie;
|
||||
}
|
||||
loadControlClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page size.
|
||||
*
|
||||
* @return the page size.
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
private void loadControlClasses() {
|
||||
try {
|
||||
requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL);
|
||||
responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
log.debug("Default control classes not found - falling back to LdapBP classes", e);
|
||||
|
||||
/**
|
||||
* Get the total estimated number of entries that matches the issued search.
|
||||
* Note that this value is optional for the LDAP server to return, so it
|
||||
* does not always contain any valid data.
|
||||
*
|
||||
* @return the estimated result size, if returned from the server.
|
||||
*/
|
||||
public int getResultSize() {
|
||||
return resultSize;
|
||||
}
|
||||
try {
|
||||
requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL);
|
||||
responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL);
|
||||
}
|
||||
catch (ClassNotFoundException e1) {
|
||||
throw new UncategorizedLdapException(
|
||||
"Neither default nor fallback classes are available - unable to proceed", e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the class of the expected ResponseControl for the paged results
|
||||
* response.
|
||||
*
|
||||
* @param responseControlClass Class of the expected response control.
|
||||
*/
|
||||
public void setResponseControlClass(Class responseControlClass) {
|
||||
this.responseControlClass = responseControlClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRequestControlClass(Class requestControlClass) {
|
||||
this.requestControlClass = requestControlClass;
|
||||
}
|
||||
/**
|
||||
* Get the cookie.
|
||||
*
|
||||
* @return the cookie.
|
||||
*/
|
||||
public PagedResultsCookie getCookie() {
|
||||
return cookie;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.control.AbstractRequestControlDirContextProcessor#createRequestControl()
|
||||
*/
|
||||
/**
|
||||
* Get the page size.
|
||||
*
|
||||
* @return the page size.
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public Control createRequestControl() {
|
||||
byte[] actualCookie = null;
|
||||
if (cookie != null) {
|
||||
actualCookie = cookie.getCookie();
|
||||
}
|
||||
Constructor constructor = ClassUtils.getConstructorIfAvailable(requestControlClass, new Class[]{int.class, byte[].class, boolean.class});
|
||||
if (constructor == null) {
|
||||
throw new IllegalArgumentException("Failed to find an appropriate RequestControl constructor");
|
||||
}
|
||||
/**
|
||||
* Get the total estimated number of entries that matches the issued search.
|
||||
* Note that this value is optional for the LDAP server to return, so it
|
||||
* does not always contain any valid data.
|
||||
*
|
||||
* @return the estimated result size, if returned from the server.
|
||||
*/
|
||||
public int getResultSize() {
|
||||
return resultSize;
|
||||
}
|
||||
|
||||
Control result = null;
|
||||
try {
|
||||
result = (Control) constructor.newInstance(new Object[]{new Integer(pageSize), actualCookie, new Boolean(critical)});
|
||||
} catch (Exception e) {
|
||||
ReflectionUtils.handleReflectionException(e);
|
||||
}
|
||||
/**
|
||||
* Set the class of the expected ResponseControl for the paged results
|
||||
* response.
|
||||
*
|
||||
* @param responseControlClass Class of the expected response control.
|
||||
*/
|
||||
public void setResponseControlClass(Class responseControlClass) {
|
||||
this.responseControlClass = responseControlClass;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public void setRequestControlClass(Class requestControlClass) {
|
||||
this.requestControlClass = requestControlClass;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.core.DirContextProcessor#postProcess(javax.naming.directory.DirContext)
|
||||
*/
|
||||
/*
|
||||
* @see
|
||||
* org.springframework.ldap.control.AbstractRequestControlDirContextProcessor
|
||||
* #createRequestControl()
|
||||
*/
|
||||
|
||||
public void postProcess(DirContext ctx) throws NamingException {
|
||||
public Control createRequestControl() {
|
||||
byte[] actualCookie = null;
|
||||
if (cookie != null) {
|
||||
actualCookie = cookie.getCookie();
|
||||
}
|
||||
Constructor constructor = ClassUtils.getConstructorIfAvailable(requestControlClass, new Class[] { int.class,
|
||||
byte[].class, boolean.class });
|
||||
if (constructor == null) {
|
||||
throw new IllegalArgumentException("Failed to find an appropriate RequestControl constructor");
|
||||
}
|
||||
|
||||
LdapContext ldapContext = (LdapContext) ctx;
|
||||
Control[] responseControls = ldapContext.getResponseControls();
|
||||
if (responseControls == null) {
|
||||
responseControls = new Control[0];
|
||||
}
|
||||
Control result = null;
|
||||
try {
|
||||
result = (Control) constructor.newInstance(new Object[] { new Integer(pageSize), actualCookie,
|
||||
Boolean.valueOf(critical) });
|
||||
}
|
||||
catch (Exception e) {
|
||||
ReflectionUtils.handleReflectionException(e);
|
||||
}
|
||||
|
||||
// Go through response controls and get info, regardless of class
|
||||
for (int i = 0; i < responseControls.length; i++) {
|
||||
Control responseControl = responseControls[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
// check for match, try fallback otherwise
|
||||
if (responseControl.getClass().isAssignableFrom(responseControlClass)) {
|
||||
Object control = responseControl;
|
||||
byte[] result = (byte[]) invokeMethod("getCookie",
|
||||
responseControlClass, control);
|
||||
this.cookie = new PagedResultsCookie(result);
|
||||
Integer wrapper = (Integer) invokeMethod("getResultSize",
|
||||
responseControlClass, control);
|
||||
this.resultSize = wrapper.intValue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* @see
|
||||
* org.springframework.ldap.core.DirContextProcessor#postProcess(javax.naming
|
||||
* .directory.DirContext)
|
||||
*/
|
||||
|
||||
log.fatal("No matching response control found for paged results - looking for '" + responseControlClass);
|
||||
}
|
||||
public void postProcess(DirContext ctx) throws NamingException {
|
||||
|
||||
private Object invokeMethod(String method, Class clazz, Object control) {
|
||||
Method actualMethod = ReflectionUtils.findMethod(clazz, method);
|
||||
return ReflectionUtils.invokeMethod(actualMethod, control);
|
||||
}
|
||||
LdapContext ldapContext = (LdapContext) ctx;
|
||||
Control[] responseControls = ldapContext.getResponseControls();
|
||||
if (responseControls == null) {
|
||||
responseControls = new Control[0];
|
||||
}
|
||||
|
||||
// Go through response controls and get info, regardless of class
|
||||
for (int i = 0; i < responseControls.length; i++) {
|
||||
Control responseControl = responseControls[i];
|
||||
|
||||
// check for match, try fallback otherwise
|
||||
if (responseControl.getClass().isAssignableFrom(responseControlClass)) {
|
||||
Object control = responseControl;
|
||||
byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control);
|
||||
this.cookie = new PagedResultsCookie(result);
|
||||
Integer wrapper = (Integer) invokeMethod("getResultSize", responseControlClass, control);
|
||||
this.resultSize = wrapper.intValue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log.fatal("No matching response control found for paged results - looking for '" + responseControlClass);
|
||||
}
|
||||
|
||||
private Object invokeMethod(String method, Class clazz, Object control) {
|
||||
Method actualMethod = ReflectionUtils.findMethod(clazz, method);
|
||||
return ReflectionUtils.invokeMethod(actualMethod, control);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,35 +32,37 @@ import org.springframework.ldap.support.LdapUtils;
|
||||
* @author Ulrik Sandberg
|
||||
* @since 1.2
|
||||
*/
|
||||
public class AttributesMapperCallbackHandler extends
|
||||
CollectingNameClassPairCallbackHandler {
|
||||
private AttributesMapper mapper;
|
||||
public class AttributesMapperCallbackHandler extends CollectingNameClassPairCallbackHandler {
|
||||
private AttributesMapper mapper;
|
||||
|
||||
/**
|
||||
* Constructs a new instance around the specified {@link AttributesMapper}.
|
||||
*
|
||||
* @param mapper
|
||||
* the target mapper.
|
||||
*/
|
||||
public AttributesMapperCallbackHandler(AttributesMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
/**
|
||||
* Constructs a new instance around the specified {@link AttributesMapper}.
|
||||
*
|
||||
* @param mapper the target mapper.
|
||||
*/
|
||||
public AttributesMapperCallbackHandler(AttributesMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast the NameClassPair to a SearchResult and pass its attributes to the
|
||||
* {@link AttributesMapper}.
|
||||
*
|
||||
* @param nameClassPair
|
||||
* a <code> SearchResult</code> instance.
|
||||
* @return the Object returned from the mapper.
|
||||
*/
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
SearchResult searchResult = (SearchResult) nameClassPair;
|
||||
Attributes attributes = searchResult.getAttributes();
|
||||
try {
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
} catch (javax.naming.NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Cast the NameClassPair to a SearchResult and pass its attributes to the
|
||||
* {@link AttributesMapper}.
|
||||
*
|
||||
* @param nameClassPair a <code> SearchResult</code> instance.
|
||||
* @return the Object returned from the mapper.
|
||||
*/
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
if (!(nameClassPair instanceof SearchResult)) {
|
||||
throw new IllegalArgumentException("Parameter must be an instance of SearchResult");
|
||||
}
|
||||
|
||||
SearchResult searchResult = (SearchResult) nameClassPair;
|
||||
Attributes attributes = searchResult.getAttributes();
|
||||
try {
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
}
|
||||
catch (javax.naming.NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,11 @@ public class ContextMapperCallbackHandler extends
|
||||
* @return the Object returned from the mapper.
|
||||
*/
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
Binding binding = (Binding) nameClassPair;
|
||||
if (!(nameClassPair instanceof Binding)) {
|
||||
throw new IllegalArgumentException("Parameter must be an instance of Binding");
|
||||
}
|
||||
|
||||
Binding binding = (Binding) nameClassPair;
|
||||
Object object = binding.getObject();
|
||||
if (object == null) {
|
||||
throw new ObjectRetrievalException(
|
||||
|
||||
@@ -29,6 +29,8 @@ import javax.naming.Name;
|
||||
import javax.naming.ldap.Rdn;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ldap.BadLdapGrammarException;
|
||||
import org.springframework.ldap.support.ListComparator;
|
||||
|
||||
@@ -88,6 +90,8 @@ public class DistinguishedName implements Name {
|
||||
*/
|
||||
public static final String SPACED_DN_FORMAT_PROPERTY = "org.springframework.ldap.core.spacedDnFormat";
|
||||
|
||||
private static final Log log = LogFactory.getLog(DistinguishedName.class);
|
||||
|
||||
private static final boolean COMPACT = true;
|
||||
|
||||
private static final boolean NON_COMPACT = false;
|
||||
@@ -462,11 +466,15 @@ public class DistinguishedName implements Name {
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
public Object clone() {
|
||||
|
||||
// just duplicate the list, the rdns are immutable.
|
||||
LinkedList list = new LinkedList(getNames());
|
||||
|
||||
return new DistinguishedName(list);
|
||||
try {
|
||||
DistinguishedName result = (DistinguishedName) super.clone();
|
||||
result.names = new LinkedList(names);
|
||||
return result;
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
log.fatal("CloneNotSupported thrown from superclass - this should not happen");
|
||||
throw new RuntimeException("Fatal error in clone", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1255,7 +1255,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
private final class NullDirContextProcessor implements DirContextProcessor {
|
||||
private final static class NullDirContextProcessor implements DirContextProcessor {
|
||||
public void postProcess(DirContext ctx) throws NamingException {
|
||||
// Do nothing
|
||||
}
|
||||
@@ -1271,7 +1271,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class MappingCollectingNameClassPairCallbackHandler extends CollectingNameClassPairCallbackHandler {
|
||||
public final static class MappingCollectingNameClassPairCallbackHandler extends
|
||||
CollectingNameClassPairCallbackHandler {
|
||||
|
||||
private NameClassPairMapper mapper;
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
* @param urls the urls of all servers.
|
||||
*/
|
||||
public void setUrls(String[] urls) {
|
||||
this.urls = urls;
|
||||
this.urls = (String[]) urls.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,7 +402,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
* @return the urls of all servers.
|
||||
*/
|
||||
public String[] getUrls() {
|
||||
return urls;
|
||||
return (String[]) urls.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ldap.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,7 +24,8 @@ import java.util.List;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class ListComparator implements Comparator {
|
||||
public class ListComparator implements Comparator, Serializable {
|
||||
private static final long serialVersionUID = -3068381879731157178L;
|
||||
|
||||
/**
|
||||
* Compare two lists of Comparable objects.
|
||||
|
||||
@@ -65,8 +65,8 @@ public class ModifyAttributesOperationExecutor implements
|
||||
ModificationItem[] compensatingModifications) {
|
||||
this.ldapOperations = ldapOperations;
|
||||
this.dn = dn;
|
||||
this.actualModifications = actualModifications;
|
||||
this.compensatingModifications = compensatingModifications;
|
||||
this.actualModifications = (ModificationItem[]) actualModifications.clone();
|
||||
this.compensatingModifications = (ModificationItem[]) compensatingModifications.clone();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
|
||||
}
|
||||
|
||||
private class ContextSourceAndDataSourceTransactionObject {
|
||||
private final static class ContextSourceAndDataSourceTransactionObject {
|
||||
private Object ldapTransactionObject;
|
||||
|
||||
private Object dataSourceTransactionObject;
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
|
||||
}
|
||||
|
||||
private class ContextSourceAndHibernateTransactionObject {
|
||||
private final static class ContextSourceAndHibernateTransactionObject {
|
||||
private Object ldapTransactionObject;
|
||||
|
||||
private Object hibernateTransactionObject;
|
||||
|
||||
@@ -19,6 +19,7 @@ import javax.naming.Name;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.easymock.internal.ArrayMatcher;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapOperations;
|
||||
import org.springframework.ldap.transaction.compensating.ModifyAttributesOperationExecutor;
|
||||
@@ -26,84 +27,82 @@ import org.springframework.ldap.transaction.compensating.ModifyAttributesOperati
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ModifyAttributesOperationExecutorTest extends TestCase {
|
||||
private MockControl ldapOperationsControl;
|
||||
private MockControl ldapOperationsControl;
|
||||
|
||||
private LdapOperations ldapOperationsMock;
|
||||
private LdapOperations ldapOperationsMock;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
ldapOperationsControl = MockControl.createControl(LdapOperations.class);
|
||||
ldapOperationsMock = (LdapOperations) ldapOperationsControl.getMock();
|
||||
}
|
||||
protected void setUp() throws Exception {
|
||||
ldapOperationsControl = MockControl.createControl(LdapOperations.class);
|
||||
ldapOperationsMock = (LdapOperations) ldapOperationsControl.getMock();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ldapOperationsControl = null;
|
||||
ldapOperationsMock = null;
|
||||
}
|
||||
protected void tearDown() throws Exception {
|
||||
ldapOperationsControl = null;
|
||||
ldapOperationsMock = null;
|
||||
}
|
||||
|
||||
protected void replay() {
|
||||
ldapOperationsControl.replay();
|
||||
}
|
||||
protected void replay() {
|
||||
ldapOperationsControl.replay();
|
||||
}
|
||||
|
||||
protected void verify() {
|
||||
ldapOperationsControl.verify();
|
||||
}
|
||||
protected void verify() {
|
||||
ldapOperationsControl.verify();
|
||||
}
|
||||
|
||||
public void testPerformOperation() {
|
||||
ModificationItem[] expectedCompensatingItems = new ModificationItem[0];
|
||||
ModificationItem[] expectedActualItems = new ModificationItem[0];
|
||||
public void testPerformOperation() {
|
||||
ModificationItem[] expectedCompensatingItems = new ModificationItem[0];
|
||||
ModificationItem[] expectedActualItems = new ModificationItem[0];
|
||||
|
||||
Name expectedDn = new DistinguishedName("cn=john doe");
|
||||
Name expectedDn = new DistinguishedName("cn=john doe");
|
||||
|
||||
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(
|
||||
ldapOperationsMock, expectedDn, expectedActualItems,
|
||||
expectedCompensatingItems);
|
||||
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(ldapOperationsMock,
|
||||
expectedDn, expectedActualItems, expectedCompensatingItems);
|
||||
|
||||
ldapOperationsMock.modifyAttributes(expectedDn, expectedActualItems);
|
||||
ldapOperationsMock.modifyAttributes(expectedDn, expectedActualItems);
|
||||
ldapOperationsControl.setMatcher(new ArrayMatcher());
|
||||
|
||||
replay();
|
||||
// Perform test
|
||||
tested.performOperation();
|
||||
replay();
|
||||
// Perform test
|
||||
tested.performOperation();
|
||||
|
||||
verify();
|
||||
}
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testCommit() {
|
||||
ModificationItem[] expectedCompensatingItems = new ModificationItem[0];
|
||||
ModificationItem[] expectedActualItems = new ModificationItem[0];
|
||||
public void testCommit() {
|
||||
ModificationItem[] expectedCompensatingItems = new ModificationItem[0];
|
||||
ModificationItem[] expectedActualItems = new ModificationItem[0];
|
||||
|
||||
Name expectedDn = new DistinguishedName("cn=john doe");
|
||||
Name expectedDn = new DistinguishedName("cn=john doe");
|
||||
|
||||
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(
|
||||
ldapOperationsMock, expectedDn, expectedActualItems,
|
||||
expectedCompensatingItems);
|
||||
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(ldapOperationsMock,
|
||||
expectedDn, expectedActualItems, expectedCompensatingItems);
|
||||
|
||||
// No operation here
|
||||
|
||||
replay();
|
||||
// Perform test
|
||||
tested.commit();
|
||||
// No operation here
|
||||
|
||||
verify();
|
||||
}
|
||||
replay();
|
||||
// Perform test
|
||||
tested.commit();
|
||||
|
||||
public void testRollback() {
|
||||
ModificationItem[] expectedCompensatingItems = new ModificationItem[0];
|
||||
ModificationItem[] expectedActualItems = new ModificationItem[0];
|
||||
verify();
|
||||
}
|
||||
|
||||
Name expectedDn = new DistinguishedName("cn=john doe");
|
||||
public void testRollback() {
|
||||
ModificationItem[] expectedCompensatingItems = new ModificationItem[0];
|
||||
ModificationItem[] expectedActualItems = new ModificationItem[0];
|
||||
|
||||
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(
|
||||
ldapOperationsMock, expectedDn, expectedActualItems,
|
||||
expectedCompensatingItems);
|
||||
Name expectedDn = new DistinguishedName("cn=john doe");
|
||||
|
||||
ldapOperationsMock.modifyAttributes(expectedDn,
|
||||
expectedCompensatingItems);
|
||||
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(ldapOperationsMock,
|
||||
expectedDn, expectedActualItems, expectedCompensatingItems);
|
||||
|
||||
replay();
|
||||
// Perform test
|
||||
tested.rollback();
|
||||
ldapOperationsMock.modifyAttributes(expectedDn, expectedCompensatingItems);
|
||||
ldapOperationsControl.setMatcher(new ArrayMatcher());
|
||||
|
||||
verify();
|
||||
}
|
||||
replay();
|
||||
// Perform test
|
||||
tested.rollback();
|
||||
|
||||
verify();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,7 +116,9 @@ public class ModifyAttributesOperationRecorderTest extends TestCase {
|
||||
ModifyAttributesOperationExecutor rollbackOperation = (ModifyAttributesOperationExecutor) operation;
|
||||
assertSame(expectedName, rollbackOperation.getDn());
|
||||
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
|
||||
assertSame(incomingMods, rollbackOperation.getActualModifications());
|
||||
ModificationItem[] actualModifications = rollbackOperation.getActualModifications();
|
||||
assertEquals(incomingMods.length, actualModifications.length);
|
||||
assertEquals(incomingMods[0], actualModifications[0]);
|
||||
assertEquals(1, rollbackOperation.getCompensatingModifications().length);
|
||||
assertSame(compensatingItem, rollbackOperation
|
||||
.getCompensatingModifications()[0]);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<includes>
|
||||
<include>org.springframework.ldap:spring-ldap-core</include>
|
||||
<include>org.springframework.ldap:spring-ldap-core-tiger</include>
|
||||
<include>org.springframework.ldap:spring-ldap-acegi-support</include>
|
||||
<include>org.springframework.ldap:spring-ldap-test</include>
|
||||
</includes>
|
||||
<binaries>
|
||||
<outputDirectory/>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<include>org.springframework.ldap:spring-ldap-core</include>
|
||||
<include>org.springframework.ldap:spring-ldap-core-tiger</include>
|
||||
<include>org.springframework.ldap:spring-ldap-test</include>
|
||||
<include>org.springframework.ldap:spring-ldap-acegi-support</include>
|
||||
</includes>
|
||||
<binaries>
|
||||
<includeDependencies>false</includeDependencies>
|
||||
|
||||
@@ -18,9 +18,5 @@
|
||||
<directory>test-support/src/main/java</directory>
|
||||
<outputDirectory/>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>acegi-support/src/main/java</directory>
|
||||
<outputDirectory/>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
|
||||
Reference in New Issue
Block a user