LDAP-168, LDAP-244: Added warning when using the default TempEntryRenamingStrategy.
Fixed failing test.
This commit is contained in:
@@ -199,4 +199,9 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
"Transaction manager [" + getClass().getName()
|
||||
+ "] does not support transaction suspension");
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
super.afterPropertiesSet();
|
||||
ldapManagerDelegate.checkRenamingStrategy();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package org.springframework.ldap.transaction.compensating.manager;
|
||||
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy;
|
||||
import org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManagerDelegate;
|
||||
import org.springframework.orm.hibernate3.HibernateTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
@@ -199,5 +198,9 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
"Transaction manager [" + getClass().getName()
|
||||
+ "] does not support transaction suspension");
|
||||
}
|
||||
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
super.afterPropertiesSet();
|
||||
ldapManagerDelegate.checkRenamingStrategy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ldap.transaction.compensating.manager;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy;
|
||||
import org.springframework.ldap.transaction.compensating.UnbindOperationExecutor;
|
||||
@@ -111,7 +112,7 @@ import org.springframework.transaction.support.DefaultTransactionStatus;
|
||||
* @since 1.2
|
||||
*/
|
||||
public class ContextSourceTransactionManager extends
|
||||
AbstractPlatformTransactionManager {
|
||||
AbstractPlatformTransactionManager implements InitializingBean {
|
||||
|
||||
private static final long serialVersionUID = 7138208218687237856L;
|
||||
|
||||
@@ -187,4 +188,8 @@ public class ContextSourceTransactionManager extends
|
||||
public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
|
||||
delegate.setRenamingStrategy(renamingStrategy);
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
delegate.checkRenamingStrategy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.ldap.transaction.compensating.manager;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
@@ -28,6 +25,9 @@ import org.springframework.transaction.compensating.support.AbstractCompensating
|
||||
import org.springframework.transaction.compensating.support.CompensatingTransactionHolderSupport;
|
||||
import org.springframework.transaction.compensating.support.DefaultCompensatingTransactionOperationManager;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
/**
|
||||
* This delegate performs all the work for the
|
||||
* {@link ContextSourceTransactionManager}. The work is delegated in order to
|
||||
@@ -118,4 +118,11 @@ public class ContextSourceTransactionManagerDelegate extends
|
||||
public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
|
||||
this.renamingStrategy = renamingStrategy;
|
||||
}
|
||||
|
||||
void checkRenamingStrategy() {
|
||||
if(renamingStrategy instanceof DefaultTempEntryRenamingStrategy) {
|
||||
log.warn("Using DefaultTempEntryRenamingStrategy. This is not advised for more complex use; " +
|
||||
"see reference documentation for additional information on how to configure TempEntryRenamingStrategy.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.junit.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
@@ -28,7 +29,6 @@ import javax.naming.NamingException;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class AbstractLdapTemplateIntegrationTest extends AbstractJUnit4SpringContextTests {
|
||||
private static final ClassPathResource LDIF_FILE_RESOURCE = new ClassPathResource("/setup_data.ldif");
|
||||
|
||||
@Autowired
|
||||
@Qualifier("contextSource")
|
||||
@@ -36,13 +36,11 @@ public abstract class AbstractLdapTemplateIntegrationTest extends AbstractJUnit4
|
||||
|
||||
@Before
|
||||
public void cleanAndSetup() throws NamingException, IOException {
|
||||
if (cleanBefore()) {
|
||||
LdapTestUtils.cleanAndSetup(contextSource, getRoot(), LDIF_FILE_RESOURCE);
|
||||
}
|
||||
LdapTestUtils.cleanAndSetup(contextSource, getRoot(), getLdifFileResource());
|
||||
}
|
||||
|
||||
protected boolean cleanBefore() {
|
||||
return true;
|
||||
protected Resource getLdifFileResource() {
|
||||
return new ClassPathResource("/setup_data.ldif");
|
||||
}
|
||||
|
||||
protected DistinguishedName getRoot() {
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.ldap.transaction.compensating.manager;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ldap.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
@@ -41,8 +41,6 @@ import static junit.framework.Assert.fail;
|
||||
@ContextConfiguration(locations = { "/conf/ldapTemplateTransactionSubtreeTestContext.xml" })
|
||||
public class ContextSourceTransactionManagerSubtreeIntegrationTest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
private static Log log = LogFactory.getLog(ContextSourceTransactionManagerSubtreeIntegrationTest.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
private DummyDao dummyDao;
|
||||
@@ -57,9 +55,8 @@ public class ContextSourceTransactionManagerSubtreeIntegrationTest extends Abstr
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean cleanBefore() {
|
||||
return false;
|
||||
protected Resource getLdifFileResource() {
|
||||
return new ClassPathResource("/setup_data_subtree.ldif");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user