From 2598beb5b92d03ebe2a87aa661d01d548ffdc70e Mon Sep 17 00:00:00 2001 From: Mattias Arthursson Date: Sun, 31 Dec 2006 13:07:41 +0000 Subject: [PATCH] --- .../RebindRollbackOperationTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 sandbox/src/test/java/org/springframework/ldap/support/transaction/RebindRollbackOperationTest.java diff --git a/sandbox/src/test/java/org/springframework/ldap/support/transaction/RebindRollbackOperationTest.java b/sandbox/src/test/java/org/springframework/ldap/support/transaction/RebindRollbackOperationTest.java new file mode 100644 index 00000000..8542a1c5 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ldap/support/transaction/RebindRollbackOperationTest.java @@ -0,0 +1,62 @@ +package org.springframework.ldap.support.transaction; + +import junit.framework.TestCase; + +import org.easymock.MockControl; +import org.springframework.ldap.LdapOperations; +import org.springframework.ldap.support.DirContextOperations; +import org.springframework.ldap.support.DistinguishedName; + +public class RebindRollbackOperationTest extends TestCase { + + private MockControl ldapOperationsControl; + + private LdapOperations ldapOperationsMock; + + private MockControl dirContextOperationsControl; + + private DirContextOperations dirContextOperationsMock; + + protected void setUp() throws Exception { + ldapOperationsControl = MockControl.createControl(LdapOperations.class); + ldapOperationsMock = (LdapOperations) ldapOperationsControl.getMock(); + + dirContextOperationsControl = MockControl + .createControl(DirContextOperations.class); + dirContextOperationsMock = (DirContextOperations) dirContextOperationsControl + .getMock(); + } + + protected void tearDown() throws Exception { + ldapOperationsControl = null; + ldapOperationsMock = null; + + dirContextOperationsControl = null; + dirContextOperationsMock = null; + } + + protected void replay() { + ldapOperationsControl.replay(); + dirContextOperationsControl.replay(); + } + + protected void verify() { + ldapOperationsControl.verify(); + dirContextOperationsControl.verify(); + } + + public void testRollback() { + RebindRollbackOperation tested = new RebindRollbackOperation( + ldapOperationsMock, dirContextOperationsMock); + + DistinguishedName expectedName = new DistinguishedName("cn=john doe"); + dirContextOperationsControl.expectAndReturn(dirContextOperationsMock + .getDn(), expectedName); + ldapOperationsMock.rebind(expectedName, dirContextOperationsMock, null); + + replay(); + // perform test + tested.rollback(); + verify(); + } +}