Changed names of CompensatingTransactionRecordingOperation and CompensatingTransactionRollbackOperation, and all implementing classes accordingly.

Also fixed some javadocs.
This commit is contained in:
Mattias Arthursson
2007-01-15 20:17:09 +00:00
parent 4cdc3fc66d
commit 026c836b13
32 changed files with 275 additions and 244 deletions

View File

@@ -23,14 +23,15 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRollbackOperation} to rollback a bind
* operation. Unbinds the entry using the supplied DN.
* A {@link CompensatingTransactionOperationExecutor} to manage a bind
* operation. Performs a bind in {@link #performOperation()}, a corresponding
* unbind in {@link #rollback()}, and nothing in {@link #commit()}.
*
* @author Mattias Arthursson
*/
public class UnbindRollbackOperation implements
CompensatingTransactionRollbackOperation {
private static Log log = LogFactory.getLog(UnbindRollbackOperation.class);
public class BindOperationExecutor implements
CompensatingTransactionOperationExecutor {
private static Log log = LogFactory.getLog(BindOperationExecutor.class);
private LdapOperations ldapOperations;
@@ -55,7 +56,7 @@ public class UnbindRollbackOperation implements
* original value sent to the 'attributes' parameter of the bind
* operation.
*/
public UnbindRollbackOperation(LdapOperations ldapOperations, Name dn,
public BindOperationExecutor(LdapOperations ldapOperations, Name dn,
Object originalObject, Attributes originalAttributes) {
this.ldapOperations = ldapOperations;
this.dn = dn;
@@ -66,7 +67,7 @@ public class UnbindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#rollback()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#rollback()
*/
public void rollback() {
try {
@@ -79,7 +80,7 @@ public class UnbindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#commit()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#commit()
*/
public void commit() {
log.debug("Nothing to do in commit for bind operation");
@@ -88,7 +89,7 @@ public class UnbindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#performOperation()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#performOperation()
*/
public void performOperation() {
log.debug("Performing bind operation");

View File

@@ -21,15 +21,15 @@ import javax.naming.directory.Attributes;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRecordingOperation} to manage LDAP bind
* A {@link CompensatingTransactionOperationRecorder} to manage LDAP bind
* operations. The corresponding
* {@link CompensatingTransactionRollbackOperation} is
* {@link UnbindRollbackOperation}.
* {@link CompensatingTransactionOperationExecutor} is
* {@link BindOperationExecutor}.
*
* @author Mattias Arthursson
*/
public class BindRecordingOperation implements
CompensatingTransactionRecordingOperation {
public class BindOperationRecorder implements
CompensatingTransactionOperationRecorder {
private LdapOperations ldapOperations;
@@ -40,16 +40,16 @@ public class BindRecordingOperation implements
* {@link LdapOperations} to use for supplying to the
* corresponding rollback operation.
*/
public BindRecordingOperation(LdapOperations ldapOperations) {
public BindOperationRecorder(LdapOperations ldapOperations) {
this.ldapOperations = ldapOperations;
}
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRecordingOperation#recordOperation(java.lang.Object[])
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationRecorder#recordOperation(java.lang.Object[])
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args) {
if (args == null || args.length != 3) {
throw new IllegalArgumentException(
@@ -65,7 +65,7 @@ public class BindRecordingOperation implements
attributes = (Attributes) args[2];
}
return new UnbindRollbackOperation(ldapOperations, dn, object,
return new BindOperationExecutor(ldapOperations, dn, object,
attributes);
}

View File

@@ -26,7 +26,7 @@ package org.springframework.ldap.support.transaction;
public interface CompensatingTransactionDataManager {
/**
* Indicates that the supplied operation (method name) has been performed
* and that the supplied {@link CompensatingTransactionRollbackOperation}
* and that the supplied {@link CompensatingTransactionOperationExecutor}
* should be stored for possible rollback. This method is called after the
* the actual invocation of the target method.
*
@@ -34,7 +34,7 @@ public interface CompensatingTransactionDataManager {
* the method to be invoked.
*/
public void operationPerformed(
CompensatingTransactionRollbackOperation operation);
CompensatingTransactionOperationExecutor operation);
/**
* Rollback all recorded operations, by performing each of the recorded

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.support.transaction;
/**
* Responsible for executing a single recorded operation as well as committing
* or rolling it back, depending on the transaction outcome. Instances of this
* interface are constructed by {@link CompensatingTransactionOperationRecorder}
* objects, supplying them with the information necessary for the respective
* operations.
* <p>
* The actual operations performed by the respective methods of this class might
* not be what would originally be expected. E.g. one would expect that the
* {@link #performOperation()} method of a
* CompensatingTransactionOperationExecutor implementation would actually delete
* the entry, leaving it for the {@link #rollback()} method to recreate it using
* data from the original entry. In an LDAP system for instance this will not be
* possible, because it might not be possible to retrieve all the stored data
* from the original entry. In that case, the {@link #performOperation()} method
* will instead move the entry to a temporary location and leave it for the
* {@link #commit()} method to actually remove the entry.
*
* @author Mattias Arthursson
*/
public interface CompensatingTransactionOperationExecutor {
/**
* Rollback the operation, restoring state of the target as it was before
* the operation was performed using the information supplied on creation of
* this instance.
*/
public void rollback();
/**
* Commit the operation. In many cases this will not require any work at all
* to be performed. However in some cases there will be interesting stuff to
* do. See class description for elaboration on this.
*/
public void commit();
/**
* Perform the operation. This will most often require performing the
* recorded operation, but in some cases the actual operation performed by
* this method might be something else. See class description for
* elaboration on this.
*/
public void performOperation();
}

View File

@@ -1,6 +1,6 @@
package org.springframework.ldap.support.transaction;
public interface CompensatingTransactionOperationFactory {
public CompensatingTransactionRecordingOperation createRecordingOperation(
public CompensatingTransactionOperationRecorder createRecordingOperation(
String method);
}

View File

@@ -2,23 +2,24 @@ package org.springframework.ldap.support.transaction;
/**
* An implementation of this interface is responsible for recording data and
* supplying a {@link CompensatingTransactionRollbackOperation} to be invoked
* should the operation need to be rolled back. Recording of an operation should
* not fail (throwing an Exception), but rather log the result.
* supplying a {@link CompensatingTransactionOperationExecutor} to be invoked
* for execution and compensating transaction management of the operation.
* Recording of an operation should not fail (throwing an Exception), but rather
* log the result.
*
* @author Mattias Arthursson
*/
public interface CompensatingTransactionRecordingOperation {
public interface CompensatingTransactionOperationRecorder {
/**
* Record information about the operation performed and return a
* corresponding {@link CompensatingTransactionRollbackOperation} to be used
* corresponding {@link CompensatingTransactionOperationExecutor} to be used
* if the operation would need to be rolled back.
*
* @param args
* The arguments that have been sent to the operation.
* @return A {@link CompensatingTransactionRollbackOperation} to be used if
* @return A {@link CompensatingTransactionOperationExecutor} to be used if
* the recorded operation should need to be rolled back.
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args);
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.support.transaction;
/**
* Responsible for rolling back a single operation, restoring the state of the
* target as it was before the operation was performed. Instances of this
* interface are constructed by
* {@link CompensatingTransactionRecordingOperation} objects, supplying them
* with the information necessary for rollback.
*
* @author Mattias Arthursson
*/
public interface CompensatingTransactionRollbackOperation {
/**
* Rollback the operation, restoring state of the target as it was before
* the operation was performed using the information supplied on creation of
* this instance (supplied by a
* {@link CompensatingTransactionRecordingOperation}).
*/
public void rollback();
public void commit();
public void performOperation();
}

View File

@@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory;
/**
* Default implementation of {@link CompensatingTransactionDataManager}.
* Manages a stack of {@link CompensatingTransactionRollbackOperation} objects
* Manages a stack of {@link CompensatingTransactionOperationExecutor} objects
* and manages rollback of these in the reverse order.
*
* @author Mattias Arthursson
@@ -38,10 +38,10 @@ public class DefaultCompensatingTransactionDataManager implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionDataManager#operationPerformed(org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation)
* @see org.springframework.ldap.support.transaction.CompensatingTransactionDataManager#operationPerformed(org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor)
*/
public void operationPerformed(
CompensatingTransactionRollbackOperation operation) {
CompensatingTransactionOperationExecutor operation) {
rollbackOperations.push(operation);
}
@@ -53,7 +53,7 @@ public class DefaultCompensatingTransactionDataManager implements
public void rollback() {
log.debug("Performing rollback");
while (!rollbackOperations.isEmpty()) {
CompensatingTransactionRollbackOperation rollbackOperation = (CompensatingTransactionRollbackOperation) rollbackOperations
CompensatingTransactionOperationExecutor rollbackOperation = (CompensatingTransactionOperationExecutor) rollbackOperations
.pop();
rollbackOperation.rollback();
}
@@ -86,7 +86,7 @@ public class DefaultCompensatingTransactionDataManager implements
log.debug("Performing rollback");
// TODO: Should this really be done in reverse order?
while (!rollbackOperations.isEmpty()) {
CompensatingTransactionRollbackOperation rollbackOperation = (CompensatingTransactionRollbackOperation) rollbackOperations
CompensatingTransactionOperationExecutor rollbackOperation = (CompensatingTransactionOperationExecutor) rollbackOperations
.pop();
rollbackOperation.commit();
}

View File

@@ -32,28 +32,28 @@ public class LdapCompensatingTransactionOperationFactory implements
this.ldapOperations = new LdapTemplate(new SingleContextSource(ctx));
}
public CompensatingTransactionRecordingOperation createRecordingOperation(
public CompensatingTransactionOperationRecorder createRecordingOperation(
String operation) {
if (StringUtils.equals(operation, LdapUtils.BIND_METHOD_NAME)) {
log.debug("Bind operation recorded");
return new BindRecordingOperation(ldapOperations);
return new BindOperationRecorder(ldapOperations);
} else if (StringUtils.equals(operation, LdapUtils.REBIND_METHOD_NAME)) {
log.debug("Rebind operation recorded");
return new RebindRecordingOperation(ldapOperations);
return new RebindOperationRecorder(ldapOperations);
} else if (StringUtils.equals(operation, LdapUtils.RENAME_METHOD_NAME)) {
log.debug("Rename operation recorded");
return new RenameRecordingOperation(ldapOperations);
return new RenameOperationRecorder(ldapOperations);
} else if (StringUtils.equals(operation,
LdapUtils.MODIFY_ATTRIBUTES_METHOD_NAME)) {
return new ModifyAttributesRecordingOperation(ldapOperations);
return new ModifyAttributesOperationRecorder(ldapOperations);
} else if (StringUtils.equals(operation, LdapUtils.UNBIND_METHOD_NAME)) {
return new UnbindRecordingOperation(ldapOperations);
return new UnbindOperationRecorder(ldapOperations);
}
log
.warn("No suitable CompensatingTransactionRecordingOperation found for method "
.warn("No suitable CompensatingTransactionOperationRecorder found for method "
+ operation + ". Operation will not be transacted.");
return new NullRecordingOperation();
return new NullOperationRecorder();
}
/**

View File

@@ -154,9 +154,9 @@ public class LdapUtils {
.getOperationFactory();
// Record the operation
CompensatingTransactionRecordingOperation operation = operationFactory
CompensatingTransactionOperationRecorder operation = operationFactory
.createRecordingOperation(method.getName());
CompensatingTransactionRollbackOperation rollbackOperation = operation
CompensatingTransactionOperationExecutor rollbackOperation = operation
.recordOperation(args);
Object result = null;

View File

@@ -23,18 +23,18 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRollbackOperation} to rollback a
* A {@link CompensatingTransactionOperationExecutor} to manage a
* <code>modifyAttributes</code> operation. Performs a
* <code>modifyAttributes</code> operation using the DN of the target entry
* and ModificationItems undoing the modifications of the recorded operation.
* <code>modifyAttributes</code> in {@link #performOperation()}, a negating
* modifyAttributes in {@link #rollback()}, and nothing in {@link #commit()}.
*
* @author Mattias Arthursson
*/
public class ModifyAttributesRollbackOperation implements
CompensatingTransactionRollbackOperation {
public class ModifyAttributesOperationExecutor implements
CompensatingTransactionOperationExecutor {
private static Log log = LogFactory
.getLog(ModifyAttributesRollbackOperation.class);
.getLog(ModifyAttributesOperationExecutor.class);
private LdapOperations ldapOperations;
@@ -58,7 +58,7 @@ public class ModifyAttributesRollbackOperation implements
* @param compensatingModifications
* the ModificationItems to undo the recorded operation.
*/
public ModifyAttributesRollbackOperation(LdapOperations ldapOperations,
public ModifyAttributesOperationExecutor(LdapOperations ldapOperations,
Name dn, ModificationItem[] actualModifications,
ModificationItem[] compensatingModifications) {
this.ldapOperations = ldapOperations;
@@ -70,7 +70,7 @@ public class ModifyAttributesRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#rollback()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#rollback()
*/
public void rollback() {
try {
@@ -86,7 +86,7 @@ public class ModifyAttributesRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#commit()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#commit()
*/
public void commit() {
log.debug("Nothing to do in commit for modifyAttributes");
@@ -95,7 +95,7 @@ public class ModifyAttributesRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#performOperation()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#performOperation()
*/
public void performOperation() {
log.debug("Performing modifyAttributes operation");

View File

@@ -31,27 +31,27 @@ import org.springframework.ldap.core.LdapOperations;
import org.springframework.util.Assert;
/**
* A {@link CompensatingTransactionRecordingOperation} keeping track of
* A {@link CompensatingTransactionOperationRecorder} keeping track of
* modifyAttributes operations, creating corresponding
* {@link ModifyAttributesRollbackOperation} instances for rollback.
* {@link ModifyAttributesOperationExecutor} instances for rollback.
*
* @author Mattias Arthursson
*/
public class ModifyAttributesRecordingOperation implements
CompensatingTransactionRecordingOperation {
public class ModifyAttributesOperationRecorder implements
CompensatingTransactionOperationRecorder {
private LdapOperations ldapOperations;
public ModifyAttributesRecordingOperation(LdapOperations ldapOperations) {
public ModifyAttributesOperationRecorder(LdapOperations ldapOperations) {
this.ldapOperations = ldapOperations;
}
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRecordingOperation#recordOperation(java.lang.Object[])
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationRecorder#recordOperation(java.lang.Object[])
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args) {
Assert.notNull(args);
Name dn = LdapUtils.getFirstArgumentAsName(args);
@@ -81,7 +81,7 @@ public class ModifyAttributesRecordingOperation implements
currentAttributes, incomingModifications[i]);
}
return new ModifyAttributesRollbackOperation(ldapOperations, dn,
return new ModifyAttributesOperationExecutor(ldapOperations, dn,
incomingModifications, rollbackItems);
}

View File

@@ -19,19 +19,19 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A {@link CompensatingTransactionRollbackOperation} that performs nothing.
* A {@link CompensatingTransactionOperationExecutor} that performs nothing.
*
* @author Mattias Arthursson
*/
public class NullRollbackOperation implements
CompensatingTransactionRollbackOperation {
public class NullOperationExecutor implements
CompensatingTransactionOperationExecutor {
private static Log log = LogFactory.getLog(NullRollbackOperation.class);
private static Log log = LogFactory.getLog(NullOperationExecutor.class);
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#rollback()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#rollback()
*/
public void rollback() {
log.info("Rolling back null operation");

View File

@@ -16,26 +16,26 @@
package org.springframework.ldap.support.transaction;
/**
* A {@link CompensatingTransactionRecordingOperation} performing nothing,
* returning a {@link NullRollbackOperation} regardless of the input. Instances
* A {@link CompensatingTransactionOperationRecorder} performing nothing,
* returning a {@link NullOperationExecutor} regardless of the input. Instances
* of this class will be created if the
* {@link CompensatingTransactionDataManager} cannot determine any appropriate
* {@link CompensatingTransactionRecordingOperation} for the current operation.
* {@link CompensatingTransactionOperationRecorder} for the current operation.
*
* @author Mattias Arthursson
*
*/
public class NullRecordingOperation implements
CompensatingTransactionRecordingOperation {
public class NullOperationRecorder implements
CompensatingTransactionOperationRecorder {
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRecordingOperation#recordOperation(java.lang.Object[])
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationRecorder#recordOperation(java.lang.Object[])
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args) {
return new NullRollbackOperation();
return new NullOperationExecutor();
}
}

View File

@@ -20,20 +20,24 @@ import javax.naming.directory.Attributes;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRollbackOperation} to rollback a rebind
* operation, performing a rebind operation using the supplied
* {@link DirContextOperations} object.
* A {@link CompensatingTransactionOperationExecutor} to manage a rebind
* operation. The methods in this class do not behave as expected, since it
* might be impossible to retrieve all the original attributes from the entry.
* Instead this class performs a <b>rename</b> in {@link #performOperation()},
* a negating rename in {@link #rollback()}, and the {@link #commit()}
* operation unbinds the original entry from its temporary location and binds a
* new entry to the original location using the attributes supplied to the
* original rebind opertaion.
*
* @author Mattias Arthursson
*/
public class RebindRollbackOperation implements
CompensatingTransactionRollbackOperation {
public class RebindOperationExecutor implements
CompensatingTransactionOperationExecutor {
private static Log log = LogFactory.getLog(RebindRollbackOperation.class);
private static Log log = LogFactory.getLog(RebindOperationExecutor.class);
private LdapOperations ldapOperations;
@@ -59,7 +63,7 @@ public class RebindRollbackOperation implements
* @param originalAttributes
* Original 'attributes' parameter sent to the rebind operation
*/
public RebindRollbackOperation(LdapOperations ldapOperations,
public RebindOperationExecutor(LdapOperations ldapOperations,
Name originalDn, Name temporaryDn, Object originalObject,
Attributes originalAttributes) {
this.ldapOperations = ldapOperations;
@@ -81,7 +85,7 @@ public class RebindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#rollback()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#rollback()
*/
public void rollback() {
log.debug("Rolling back rebind operation");
@@ -97,7 +101,7 @@ public class RebindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#commit()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#commit()
*/
public void commit() {
log.debug("Committing rebind operation");
@@ -107,7 +111,7 @@ public class RebindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#performOperation()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#performOperation()
*/
public void performOperation() {
log.debug("Performing rebind operation - "

View File

@@ -21,14 +21,14 @@ import javax.naming.directory.Attributes;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRecordingOperation} keeping track of a rebind
* operation. Creates {@link RebindRollbackOperation} objects in
* A {@link CompensatingTransactionOperationRecorder} keeping track of a rebind
* operation. Creates {@link RebindOperationExecutor} objects in
* {@link #recordOperation(Object[])}.
*
* @author Mattias Arthursson
*/
public class RebindRecordingOperation implements
CompensatingTransactionRecordingOperation {
public class RebindOperationRecorder implements
CompensatingTransactionOperationRecorder {
private LdapOperations ldapOperations;
@@ -39,18 +39,18 @@ public class RebindRecordingOperation implements
*
* @param ldapOperations
* {@link LdapOperations} to use for getting the rollback
* information and supply to the {@link RebindRollbackOperation}.
* information and supply to the {@link RebindOperationExecutor}.
*/
public RebindRecordingOperation(LdapOperations ldapOperations) {
public RebindOperationRecorder(LdapOperations ldapOperations) {
this.ldapOperations = ldapOperations;
}
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRecordingOperation#recordOperation(java.lang.Object[])
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationRecorder#recordOperation(java.lang.Object[])
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args) {
if (args == null || args.length != 3) {
throw new IllegalArgumentException(
@@ -69,7 +69,7 @@ public class RebindRecordingOperation implements
Name temporaryName = renamingStrategy.getTemporaryName(dn);
ldapOperations.rename(dn, temporaryName);
return new RebindRollbackOperation(ldapOperations, dn, temporaryName,
return new RebindOperationExecutor(ldapOperations, dn, temporaryName,
object, attributes);
}

View File

@@ -22,16 +22,17 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRollbackOperation} to roll back a previous
* rename operation.
* A {@link CompensatingTransactionOperationExecutor} to manage a rename
* operation. Performs a rename operation in {@link #performOperation()}, a
* negating rename in {@link #rollback()}, and nothing in {@link #commit()}.
*
* @author Mattias Arthursson
*
*/
public class RenameRollbackOperation implements
CompensatingTransactionRollbackOperation {
public class RenameOperationExecutor implements
CompensatingTransactionOperationExecutor {
private static Log log = LogFactory.getLog(RenameRollbackOperation.class);
private static Log log = LogFactory.getLog(RenameOperationExecutor.class);
private LdapOperations ldapOperations;
@@ -50,7 +51,7 @@ public class RenameRollbackOperation implements
* @param newDn
* DN that the entry has been moved to in the recorded operation.
*/
public RenameRollbackOperation(LdapOperations ldapOperations,
public RenameOperationExecutor(LdapOperations ldapOperations,
Name originalDn, Name newDn) {
this.ldapOperations = ldapOperations;
this.originalDn = originalDn;
@@ -60,7 +61,7 @@ public class RenameRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#rollback()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#rollback()
*/
public void rollback() {
log.debug("Rolling back rename operation");
@@ -75,7 +76,7 @@ public class RenameRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#commit()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#commit()
*/
public void commit() {
log.debug("Nothing to do in commit for rename operation");
@@ -84,7 +85,7 @@ public class RenameRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#performOperation()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#performOperation()
*/
public void performOperation() {
log.debug("Performing rename operation");

View File

@@ -23,17 +23,17 @@ import org.springframework.ldap.core.LdapOperations;
import org.springframework.util.Assert;
/**
* A {@link CompensatingTransactionRecordingOperation} for keeping track of
* rename operations. Creates {@link RebindRollbackOperation} objects for
* A {@link CompensatingTransactionOperationRecorder} for keeping track of
* rename operations. Creates {@link RebindOperationExecutor} objects for
* rolling back.
*
* @author Mattias Arthursson
*
*/
public class RenameRecordingOperation implements
CompensatingTransactionRecordingOperation {
public class RenameOperationRecorder implements
CompensatingTransactionOperationRecorder {
private static Log log = LogFactory.getLog(RenameRecordingOperation.class);
private static Log log = LogFactory.getLog(RenameOperationRecorder.class);
private LdapOperations ldapOperations;
@@ -42,18 +42,18 @@ public class RenameRecordingOperation implements
*
* @param ldapOperations
* The {@link LdapOperations} to supply to the created
* {@link RebindRollbackOperation} objects.
* {@link RebindOperationExecutor} objects.
*/
public RenameRecordingOperation(LdapOperations ldapOperations) {
public RenameOperationRecorder(LdapOperations ldapOperations) {
this.ldapOperations = ldapOperations;
}
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRecordingOperation#recordOperation(java.lang.Object[])
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationRecorder#recordOperation(java.lang.Object[])
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args) {
log.debug("Storing rollback information for rename operation");
Assert.notEmpty(args);
@@ -63,7 +63,7 @@ public class RenameRecordingOperation implements
}
Name oldDn = LdapUtils.getArgumentAsName(args[0]);
Name newDn = LdapUtils.getArgumentAsName(args[1]);
return new RenameRollbackOperation(ldapOperations, oldDn, newDn);
return new RenameOperationExecutor(ldapOperations, oldDn, newDn);
}
LdapOperations getLdapOperations() {

View File

@@ -23,16 +23,19 @@ import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.LdapOperations;
/**
* A {@link CompensatingTransactionRollbackOperation} to rollback an unbind
* operation. This implementation performs a bind operation using the
* {@link DirContextOperations} instance supplied on construction.
* A {@link CompensatingTransactionOperationExecutor} to manage an unbind
* operation. The methods in this class do not behave as expected, since it
* might be impossible to retrieve all the original attributes from the entry.
* Instead this class performs a <b>rename</b> in {@link #performOperation()},
* a negating rename in {@link #rollback()}, and {@link #commit()} unbinds the
* entry from its temporary location.
*
* @author Mattias Arthursson
*/
public class BindRollbackOperation implements
CompensatingTransactionRollbackOperation {
public class UnbindOperationExecutor implements
CompensatingTransactionOperationExecutor {
private static Log log = LogFactory.getLog(BindRollbackOperation.class);
private static Log log = LogFactory.getLog(UnbindOperationExecutor.class);
private LdapOperations ldapOperations;
@@ -52,7 +55,7 @@ public class BindRollbackOperation implements
* Temporary DN of the entry to be removed; this is where the
* entry is temporarily stored during the transaction.
*/
public BindRollbackOperation(LdapOperations ldapOperations,
public UnbindOperationExecutor(LdapOperations ldapOperations,
Name originalDn, Name temporaryDn) {
this.ldapOperations = ldapOperations;
this.originalDn = originalDn;
@@ -62,7 +65,7 @@ public class BindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#rollback()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#rollback()
*/
public void rollback() {
try {
@@ -76,12 +79,12 @@ public class BindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#commit()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#commit()
*/
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#commit()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#commit()
*/
public void commit() {
log.debug("Committing unbind operation - unbinding temporary entry");
@@ -91,7 +94,7 @@ public class BindRollbackOperation implements
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRollbackOperation#performOperation()
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationExecutor#performOperation()
*/
public void performOperation() {
log.debug("Nothing to do in performOperation for unbind");

View File

@@ -20,14 +20,14 @@ import javax.naming.Name;
import org.springframework.ldap.core.LdapOperations;
/**
* {@link CompensatingTransactionRecordingOperation} to keep track of unbind
* operations. This class creates {@link BindRollbackOperation} objects for
* {@link CompensatingTransactionOperationRecorder} to keep track of unbind
* operations. This class creates {@link UnbindOperationExecutor} objects for
* rollback.
*
* @author Mattias Arthursson
*/
public class UnbindRecordingOperation implements
CompensatingTransactionRecordingOperation {
public class UnbindOperationRecorder implements
CompensatingTransactionOperationRecorder {
private LdapOperations ldapOperations;
@@ -39,25 +39,25 @@ public class UnbindRecordingOperation implements
* @param ldapOperations
* {@link LdapOperations} to use for getting the data prior to
* unbinding the entry and to supply to the
* {@link BindRollbackOperation} for rollback.
* {@link UnbindOperationExecutor} for rollback.
*/
public UnbindRecordingOperation(LdapOperations ldapOperations) {
public UnbindOperationRecorder(LdapOperations ldapOperations) {
this.ldapOperations = ldapOperations;
}
/*
* (non-Javadoc)
*
* @see org.springframework.ldap.support.transaction.CompensatingTransactionRecordingOperation#recordOperation(java.lang.Object[])
* @see org.springframework.ldap.support.transaction.CompensatingTransactionOperationRecorder#recordOperation(java.lang.Object[])
*/
public CompensatingTransactionRollbackOperation recordOperation(
public CompensatingTransactionOperationExecutor recordOperation(
Object[] args) {
Name dn = LdapUtils.getFirstArgumentAsName(args);
Name temporaryDn = renamingStrategy.getTemporaryName(dn);
ldapOperations.rename(dn, temporaryDn);
return new BindRollbackOperation(ldapOperations, dn, temporaryDn);
return new UnbindOperationExecutor(ldapOperations, dn, temporaryDn);
}
LdapOperations getLdapOperations() {

View File

@@ -8,7 +8,7 @@ import org.easymock.MockControl;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class UnbindRollbackOperationTest extends TestCase {
public class BindOperationExecutorTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -35,7 +35,7 @@ public class UnbindRollbackOperationTest extends TestCase {
DistinguishedName expectedDn = new DistinguishedName("cn=john doe");
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
UnbindRollbackOperation tested = new UnbindRollbackOperation(
BindOperationExecutor tested = new BindOperationExecutor(
ldapOperationsMock, expectedDn, expectedObject,
expectedAttributes);
@@ -51,7 +51,7 @@ public class UnbindRollbackOperationTest extends TestCase {
DistinguishedName expectedDn = new DistinguishedName("cn=john doe");
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
UnbindRollbackOperation tested = new UnbindRollbackOperation(
BindOperationExecutor tested = new BindOperationExecutor(
ldapOperationsMock, expectedDn, expectedObject,
expectedAttributes);
@@ -65,7 +65,7 @@ public class UnbindRollbackOperationTest extends TestCase {
public void testRollback() {
DistinguishedName expectedDn = new DistinguishedName("cn=john doe");
UnbindRollbackOperation tested = new UnbindRollbackOperation(
BindOperationExecutor tested = new BindOperationExecutor(
ldapOperationsMock, expectedDn, null, null);
ldapOperationsMock.unbind(expectedDn);

View File

@@ -8,7 +8,7 @@ import org.easymock.MockControl;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class BindRecordingOperationTest extends TestCase {
public class BindOperationRecorderTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -25,19 +25,19 @@ public class BindRecordingOperationTest extends TestCase {
}
public void testRecordOperation_DistinguishedName() {
BindRecordingOperation tested = new BindRecordingOperation(
BindOperationRecorder tested = new BindOperationRecorder(
ldapOperationsMock);
DistinguishedName expectedDn = new DistinguishedName("cn=John Doe");
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
// Perform test.
CompensatingTransactionRollbackOperation operation = tested
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { expectedDn, expectedObject,
expectedAttributes });
assertTrue(operation instanceof UnbindRollbackOperation);
UnbindRollbackOperation rollbackOperation = (UnbindRollbackOperation) operation;
assertTrue(operation instanceof BindOperationExecutor);
BindOperationExecutor rollbackOperation = (BindOperationExecutor) operation;
assertSame(expectedDn, rollbackOperation.getDn());
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
assertSame(expectedObject, rollbackOperation.getOriginalObject());
@@ -46,25 +46,25 @@ public class BindRecordingOperationTest extends TestCase {
}
public void testPerformOperation_String() {
BindRecordingOperation tested = new BindRecordingOperation(
BindOperationRecorder tested = new BindOperationRecorder(
ldapOperationsMock);
String expectedDn = "cn=John Doe";
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
// Perform test.
CompensatingTransactionRollbackOperation operation = tested
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { expectedDn, expectedObject,
expectedAttributes });
assertTrue(operation instanceof UnbindRollbackOperation);
UnbindRollbackOperation rollbackOperation = (UnbindRollbackOperation) operation;
assertTrue(operation instanceof BindOperationExecutor);
BindOperationExecutor rollbackOperation = (BindOperationExecutor) operation;
assertEquals(expectedDn, rollbackOperation.getDn().toString());
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
}
public void testPerformOperation_Invalid() {
BindRecordingOperation tested = new BindRecordingOperation(
BindOperationRecorder tested = new BindOperationRecorder(
ldapOperationsMock);
Object expectedDn = new Object();

View File

@@ -10,13 +10,13 @@ public class DefaultCompensatingTransactionDataManagerTest extends TestCase {
private MockControl rollbackOperationControl;
private CompensatingTransactionRollbackOperation rollbackOperationMock;
private CompensatingTransactionOperationExecutor rollbackOperationMock;
protected void setUp() throws Exception {
super.setUp();
rollbackOperationControl = MockControl
.createControl(CompensatingTransactionRollbackOperation.class);
rollbackOperationMock = (CompensatingTransactionRollbackOperation) rollbackOperationControl
.createControl(CompensatingTransactionOperationExecutor.class);
rollbackOperationMock = (CompensatingTransactionOperationExecutor) rollbackOperationControl
.getMock();
}

View File

@@ -33,11 +33,11 @@ public class LdapCompensatingTransactionOperationFactoryTest extends TestCase {
null);
tested.setLdapOperations(ldapOperationsMock);
CompensatingTransactionRecordingOperation result = tested
CompensatingTransactionOperationRecorder result = tested
.createRecordingOperation("bind");
assertTrue(result instanceof BindRecordingOperation);
BindRecordingOperation bindRecordingOperation = (BindRecordingOperation) result;
assertSame(ldapOperationsMock, bindRecordingOperation
assertTrue(result instanceof BindOperationRecorder);
BindOperationRecorder bindOperationRecorder = (BindOperationRecorder) result;
assertSame(ldapOperationsMock, bindOperationRecorder
.getLdapOperations());
}
@@ -46,11 +46,11 @@ public class LdapCompensatingTransactionOperationFactoryTest extends TestCase {
null);
tested.setLdapOperations(ldapOperationsMock);
CompensatingTransactionRecordingOperation result = tested
CompensatingTransactionOperationRecorder result = tested
.createRecordingOperation("rebind");
assertTrue(result instanceof RebindRecordingOperation);
RebindRecordingOperation rebindRecordingOperation = (RebindRecordingOperation) result;
assertSame(ldapOperationsMock, rebindRecordingOperation
assertTrue(result instanceof RebindOperationRecorder);
RebindOperationRecorder rebindOperationRecorder = (RebindOperationRecorder) result;
assertSame(ldapOperationsMock, rebindOperationRecorder
.getLdapOperations());
}
@@ -59,10 +59,10 @@ public class LdapCompensatingTransactionOperationFactoryTest extends TestCase {
null);
tested.setLdapOperations(ldapOperationsMock);
CompensatingTransactionRecordingOperation result = tested
CompensatingTransactionOperationRecorder result = tested
.createRecordingOperation("rename");
assertTrue(result instanceof RenameRecordingOperation);
RenameRecordingOperation recordingOperation = (RenameRecordingOperation) result;
assertTrue(result instanceof RenameOperationRecorder);
RenameOperationRecorder recordingOperation = (RenameOperationRecorder) result;
assertSame(ldapOperationsMock, recordingOperation.getLdapOperations());
}
@@ -71,10 +71,10 @@ public class LdapCompensatingTransactionOperationFactoryTest extends TestCase {
null);
tested.setLdapOperations(ldapOperationsMock);
CompensatingTransactionRecordingOperation result = tested
CompensatingTransactionOperationRecorder result = tested
.createRecordingOperation("modifyAttributes");
assertTrue(result instanceof ModifyAttributesRecordingOperation);
ModifyAttributesRecordingOperation recordingOperation = (ModifyAttributesRecordingOperation) result;
assertTrue(result instanceof ModifyAttributesOperationRecorder);
ModifyAttributesOperationRecorder recordingOperation = (ModifyAttributesOperationRecorder) result;
assertSame(ldapOperationsMock, recordingOperation.getLdapOperations());
}
@@ -83,10 +83,10 @@ public class LdapCompensatingTransactionOperationFactoryTest extends TestCase {
null);
tested.setLdapOperations(ldapOperationsMock);
CompensatingTransactionRecordingOperation result = tested
CompensatingTransactionOperationRecorder result = tested
.createRecordingOperation("unbind");
assertTrue(result instanceof UnbindRecordingOperation);
UnbindRecordingOperation recordingOperation = (UnbindRecordingOperation) result;
assertTrue(result instanceof UnbindOperationRecorder);
UnbindOperationRecorder recordingOperation = (UnbindOperationRecorder) result;
assertSame(ldapOperationsMock, recordingOperation.getLdapOperations());
}

View File

@@ -9,7 +9,7 @@ import org.springframework.ldap.core.LdapOperations;
import junit.framework.TestCase;
public class ModifyAttributesRollbackOperationTest extends TestCase {
public class ModifyAttributesOperationExecutorTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -38,7 +38,7 @@ public class ModifyAttributesRollbackOperationTest extends TestCase {
Name expectedDn = new DistinguishedName("cn=john doe");
ModifyAttributesRollbackOperation tested = new ModifyAttributesRollbackOperation(
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(
ldapOperationsMock, expectedDn, expectedActualItems,
expectedCompensatingItems);
@@ -57,7 +57,7 @@ public class ModifyAttributesRollbackOperationTest extends TestCase {
Name expectedDn = new DistinguishedName("cn=john doe");
ModifyAttributesRollbackOperation tested = new ModifyAttributesRollbackOperation(
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(
ldapOperationsMock, expectedDn, expectedActualItems,
expectedCompensatingItems);
@@ -76,7 +76,7 @@ public class ModifyAttributesRollbackOperationTest extends TestCase {
Name expectedDn = new DistinguishedName("cn=john doe");
ModifyAttributesRollbackOperation tested = new ModifyAttributesRollbackOperation(
ModifyAttributesOperationExecutor tested = new ModifyAttributesOperationExecutor(
ldapOperationsMock, expectedDn, expectedActualItems,
expectedCompensatingItems);

View File

@@ -15,7 +15,7 @@ import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class ModifyAttributesRecordingOperationTest extends TestCase {
public class ModifyAttributesOperationRecorderTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -24,7 +24,7 @@ public class ModifyAttributesRecordingOperationTest extends TestCase {
private AttributesMapper attributesMapperMock;
private ModifyAttributesRecordingOperation tested;
private ModifyAttributesOperationRecorder tested;
protected void setUp() throws Exception {
ldapOperationsControl = MockControl.createControl(LdapOperations.class);
@@ -35,7 +35,7 @@ public class ModifyAttributesRecordingOperationTest extends TestCase {
attributesMapperMock = (AttributesMapper) attributesMapperControl
.getMock();
tested = new ModifyAttributesRecordingOperation(ldapOperationsMock);
tested = new ModifyAttributesOperationRecorder(ldapOperationsMock);
}
protected void tearDown() throws Exception {
@@ -67,7 +67,7 @@ public class ModifyAttributesRecordingOperationTest extends TestCase {
final Attributes expectedAttributes = new BasicAttributes();
tested = new ModifyAttributesRecordingOperation(ldapOperationsMock) {
tested = new ModifyAttributesOperationRecorder(ldapOperationsMock) {
AttributesMapper getAttributesMapper() {
return attributesMapperMock;
}
@@ -89,13 +89,13 @@ public class ModifyAttributesRecordingOperationTest extends TestCase {
replay();
// Perform test
CompensatingTransactionRollbackOperation operation = tested
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { expectedName, incomingMods });
verify();
// Verify outcome
assertTrue(operation instanceof ModifyAttributesRollbackOperation);
ModifyAttributesRollbackOperation rollbackOperation = (ModifyAttributesRollbackOperation) operation;
assertTrue(operation instanceof ModifyAttributesOperationExecutor);
ModifyAttributesOperationExecutor rollbackOperation = (ModifyAttributesOperationExecutor) operation;
assertSame(expectedName, rollbackOperation.getDn());
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
assertSame(incomingMods, rollbackOperation.getActualModifications());

View File

@@ -8,7 +8,7 @@ import org.easymock.MockControl;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class RebindRollbackOperationTest extends TestCase {
public class RebindOperationExecutorTest extends TestCase {
private MockControl ldapOperationsControl;
@@ -39,7 +39,7 @@ public class RebindRollbackOperationTest extends TestCase {
"cn=john doe_temp");
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
RebindRollbackOperation tested = new RebindRollbackOperation(
RebindOperationExecutor tested = new RebindOperationExecutor(
ldapOperationsMock, expectedOriginalDn, expectedTempDn,
expectedObject, expectedAttributes);
@@ -59,7 +59,7 @@ public class RebindRollbackOperationTest extends TestCase {
"cn=john doe_temp");
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
RebindRollbackOperation tested = new RebindRollbackOperation(
RebindOperationExecutor tested = new RebindOperationExecutor(
ldapOperationsMock, expectedOriginalDn, expectedTempDn,
expectedObject, expectedAttributes);
@@ -78,7 +78,7 @@ public class RebindRollbackOperationTest extends TestCase {
"cn=john doe_temp");
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
RebindRollbackOperation tested = new RebindRollbackOperation(
RebindOperationExecutor tested = new RebindOperationExecutor(
ldapOperationsMock, expectedOriginalDn, expectedTempDn,
expectedObject, expectedAttributes);

View File

@@ -8,7 +8,7 @@ import org.easymock.MockControl;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class RebindRecordingOperationTest extends TestCase {
public class RebindOperationRecorderTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -52,7 +52,7 @@ public class RebindRecordingOperationTest extends TestCase {
"cn=john doe");
final DistinguishedName expectedTempDn = new DistinguishedName(
"cn=john doe");
RebindRecordingOperation tested = new RebindRecordingOperation(
RebindOperationRecorder tested = new RebindOperationRecorder(
ldapOperationsMock);
tested.setRenamingStrategy(renamingStrategyMock);
@@ -66,13 +66,13 @@ public class RebindRecordingOperationTest extends TestCase {
BasicAttributes expectedAttributes = new BasicAttributes();
// perform test
CompensatingTransactionRollbackOperation result = tested
CompensatingTransactionOperationExecutor result = tested
.recordOperation(new Object[] { expectedDn, expectedObject,
expectedAttributes });
verify();
assertTrue(result instanceof RebindRollbackOperation);
RebindRollbackOperation rollbackOperation = (RebindRollbackOperation) result;
assertTrue(result instanceof RebindOperationExecutor);
RebindOperationExecutor rollbackOperation = (RebindOperationExecutor) result;
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
assertSame(expectedDn, rollbackOperation.getOriginalDn());
assertSame(expectedTempDn, rollbackOperation.getTemporaryDn());

View File

@@ -6,7 +6,7 @@ import org.springframework.ldap.core.LdapOperations;
import junit.framework.TestCase;
public class RenameRollbackOperationTest extends TestCase {
public class RenameOperationExecutorTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -32,7 +32,7 @@ public class RenameRollbackOperationTest extends TestCase {
public void testPerformOperation() {
DistinguishedName expectedNewName = new DistinguishedName("ou=newOu");
DistinguishedName expectedOldName = new DistinguishedName("ou=someou");
RenameRollbackOperation tested = new RenameRollbackOperation(
RenameOperationExecutor tested = new RenameOperationExecutor(
ldapOperationsMock, expectedOldName, expectedNewName);
ldapOperationsMock.rename(expectedOldName, expectedNewName);
@@ -46,7 +46,7 @@ public class RenameRollbackOperationTest extends TestCase {
public void testCommit() {
DistinguishedName expectedNewName = new DistinguishedName("ou=newOu");
DistinguishedName expectedOldName = new DistinguishedName("ou=someou");
RenameRollbackOperation tested = new RenameRollbackOperation(
RenameOperationExecutor tested = new RenameOperationExecutor(
ldapOperationsMock, expectedOldName, expectedNewName);
// Nothing to do for this operation.
@@ -60,7 +60,7 @@ public class RenameRollbackOperationTest extends TestCase {
public void testRollback() {
DistinguishedName expectedNewName = new DistinguishedName("ou=newOu");
DistinguishedName expectedOldName = new DistinguishedName("ou=someou");
RenameRollbackOperation tested = new RenameRollbackOperation(
RenameOperationExecutor tested = new RenameOperationExecutor(
ldapOperationsMock, expectedOldName, expectedNewName);
ldapOperationsMock.rename(expectedNewName, expectedOldName);

View File

@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.ldap.core.LdapOperations;
public class RenameRecordingOperationTest extends TestCase {
public class RenameOperationRecorderTest extends TestCase {
private MockControl ldapOperationsControl;
@@ -30,17 +30,17 @@ public class RenameRecordingOperationTest extends TestCase {
}
public void testRecordOperation() {
RenameRecordingOperation tested = new RenameRecordingOperation(
RenameOperationRecorder tested = new RenameOperationRecorder(
ldapOperationsMock);
replay();
// Perform test
CompensatingTransactionRollbackOperation operation = tested
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { "ou=someou", "ou=newou" });
verify();
assertTrue(operation instanceof RenameRollbackOperation);
RenameRollbackOperation rollbackOperation = (RenameRollbackOperation) operation;
assertTrue(operation instanceof RenameOperationExecutor);
RenameOperationExecutor rollbackOperation = (RenameOperationExecutor) operation;
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
assertEquals("ou=newou", rollbackOperation.getNewDn().toString());
assertEquals("ou=someou", rollbackOperation.getOriginalDn().toString());

View File

@@ -6,7 +6,7 @@ import org.easymock.MockControl;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class BindRollbackOperationTest extends TestCase {
public class UnbindOperationExecutorTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -34,7 +34,7 @@ public class BindRollbackOperationTest extends TestCase {
public void testPerformOperation() {
DistinguishedName expectedOldName = new DistinguishedName("cn=oldDn");
DistinguishedName expectedTempName = new DistinguishedName("cn=newDn");
BindRollbackOperation tested = new BindRollbackOperation(
UnbindOperationExecutor tested = new UnbindOperationExecutor(
ldapOperationsMock, expectedOldName, expectedTempName);
// Nothing to do in performOperation for unbind.
@@ -48,7 +48,7 @@ public class BindRollbackOperationTest extends TestCase {
public void testCommit() {
DistinguishedName expectedOldName = new DistinguishedName("cn=oldDn");
DistinguishedName expectedTempName = new DistinguishedName("cn=newDn");
BindRollbackOperation tested = new BindRollbackOperation(
UnbindOperationExecutor tested = new UnbindOperationExecutor(
ldapOperationsMock, expectedOldName, expectedTempName);
ldapOperationsMock.unbind(expectedTempName);
@@ -62,7 +62,7 @@ public class BindRollbackOperationTest extends TestCase {
public void testRollback() {
DistinguishedName expectedOldName = new DistinguishedName("cn=oldDn");
DistinguishedName expectedTempName = new DistinguishedName("cn=newDn");
BindRollbackOperation tested = new BindRollbackOperation(
UnbindOperationExecutor tested = new UnbindOperationExecutor(
ldapOperationsMock, expectedOldName, expectedTempName);
ldapOperationsMock.rename(expectedTempName, expectedOldName);

View File

@@ -6,7 +6,7 @@ import org.easymock.MockControl;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapOperations;
public class UnbindRecordingOperationTest extends TestCase {
public class UnbindOperationRecorderTest extends TestCase {
private MockControl ldapOperationsControl;
private LdapOperations ldapOperationsMock;
@@ -50,7 +50,7 @@ public class UnbindRecordingOperationTest extends TestCase {
"cn=john doe_temp");
final DistinguishedName expectedDn = new DistinguishedName(
"cn=john doe");
UnbindRecordingOperation tested = new UnbindRecordingOperation(
UnbindOperationRecorder tested = new UnbindOperationRecorder(
ldapOperationsMock);
tested.setRenamingStrategy(renamingStrategyMock);
@@ -61,13 +61,13 @@ public class UnbindRecordingOperationTest extends TestCase {
replay();
// Perform test
CompensatingTransactionRollbackOperation operation = tested
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { expectedDn });
verify();
// Verify result
assertTrue(operation instanceof BindRollbackOperation);
BindRollbackOperation rollbackOperation = (BindRollbackOperation) operation;
assertTrue(operation instanceof UnbindOperationExecutor);
UnbindOperationExecutor rollbackOperation = (UnbindOperationExecutor) operation;
assertSame(ldapOperationsMock, rollbackOperation.getLdapOperations());
assertSame(expectedDn, rollbackOperation.getOriginalDn());
assertSame(expectedTempName, rollbackOperation.getTemporaryDn());