From 3739079e5ac9e8e7c225f23a1448b8fe91b927f2 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 30 Sep 2016 08:56:13 -0500 Subject: [PATCH] Work with Spring 5 Fixes gh-415 --- .../core/support/AbstractContextSource.java | 65 ++++++++----------- .../core/support/DefaultDirObjectFactory.java | 1 - ...tSourceAndHibernateTransactionManager.java | 24 +++---- .../core/support/LdapContextSourceTest.java | 58 +---------------- gradle/java.gradle | 5 +- test/integration-tests/build.gradle | 2 +- .../DummyDaoLdapAndHibernateImpl.java | 26 ++++---- .../LdapConditionallyFilteredTestRunner.java | 2 +- .../ldap/itest/ldap321/Ldap321Test.java | 4 +- ...nateTransactionManagerIntegrationTest.java | 4 +- ...rnateTransactionManagerNamespaceITest.java | 2 +- ...bernateTransactionNamespaceTestContext.xml | 4 +- ...ldapAndHibernateTransactionTestContext.xml | 4 +- ...LdapAndHibernateTransactionTestContext.xml | 4 +- 14 files changed, 70 insertions(+), 135 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java index b94f23f2..0fbcaa2e 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java @@ -19,7 +19,6 @@ package org.springframework.ldap.core.support; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.JdkVersion; import org.springframework.ldap.UncategorizedLdapException; import org.springframework.ldap.core.AuthenticationSource; import org.springframework.ldap.core.ContextSource; @@ -63,12 +62,12 @@ import java.util.Map; * Note: When using implementations of this class outside of a Spring * Context it is necessary to call {@link #afterPropertiesSet()} when all * properties are set, in order to finish up initialization. - * + * * @see org.springframework.ldap.core.LdapTemplate * @see org.springframework.ldap.core.support.DefaultDirObjectFactory * @see org.springframework.ldap.core.support.LdapContextSource * @see org.springframework.ldap.core.support.DirContextSource - * + * * @author Mattias Hellborg Arthursson * @author Adam Skogman * @author Ulrik Sandberg @@ -168,7 +167,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /* * (non-Javadoc) - * + * * @see org.springframework.ldap.core.ContextSource#getReadWriteContext() */ public DirContext getReadWriteContext() { @@ -183,7 +182,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * This method should typically NOT be overridden; any customization to the * authentication mechanism should be managed by setting a different * {@link DirContextAuthenticationStrategy} on this instance. - * + * * @param env the environment to modify. * @param principal the principal to authenticate with. * @param credentials the credentials to authenticate with. @@ -201,7 +200,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Close the context and swallow any exceptions. - * + * * @param ctx the DirContext to close. */ private void closeContext(DirContext ctx) { @@ -218,7 +217,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Assemble a valid url String from all registered urls to add as * PROVIDER_URL to the environment. - * + * * @param ldapUrls all individual url Strings. * @return the full url String */ @@ -300,7 +299,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * Set the base suffix from which all operations should origin. If a base * suffix is set, you will not have to (and, indeed, must not) specify the * full distinguished names in any operations performed. - * + * * @param base the base suffix. */ public void setBase(String base) { @@ -331,7 +330,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Create a DirContext using the supplied environment. - * + * * @param environment the LDAP environment to use when creating the * DirContext. * @return a new DirContext implementation initialized with the supplied @@ -359,7 +358,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the context factory. Default is com.sun.jndi.ldap.LdapCtxFactory. - * + * * @param contextFactory the context factory used when creating Contexts. */ public void setContextFactory(Class contextFactory) { @@ -368,7 +367,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Get the context factory. - * + * * @return the context factory used when creating Contexts. */ public Class getContextFactory() { @@ -381,7 +380,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * implementation of javax.naming.spi.DirObjectFactory. Note: Setting * this value to null may have cause connection leaks when using * ContextMapper methods in LdapTemplate. - * + * * @param dirObjectFactory the DirObjectFactory to be used. Null means that * no DirObjectFactory will be used. */ @@ -391,7 +390,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Get the DirObjectFactory to use. - * + * * @return the DirObjectFactory to be used. null means that no * DirObjectFactory will be used. */ @@ -410,10 +409,6 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource throw new IllegalArgumentException("At least one server url must be set"); } - if (!base.isEmpty() && getJdkVersion().compareTo(JDK_142) < 0) { - throw new IllegalArgumentException("Base path is not supported for JDK versions < 1.4.2"); - } - if (authenticationSource == null) { LOG.debug("AuthenticationSource not set - " + "using default implementation"); if (!StringUtils.hasText(userDn)) { @@ -466,7 +461,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the password (credentials) to use for getting authenticated contexts. - * + * * @param password the password. */ public void setPassword(String password) { @@ -484,7 +479,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the user distinguished name (principal) to use for getting * authenticated contexts. - * + * * @param userDn the user distinguished name. */ public void setUserDn(String userDn) { @@ -494,7 +489,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Gets the user distinguished name (principal) to use for getting * authenticated contexts. - * + * * @return the user distinguished name. */ public String getUserDn() { @@ -504,7 +499,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the urls of the LDAP servers. Use this method if several servers are * required. - * + * * @param urls the urls of all servers. */ public void setUrls(String[] urls) { @@ -513,7 +508,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Get the urls of the LDAP servers. - * + * * @return the urls of all servers. */ public String[] getUrls() { @@ -523,7 +518,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the url of the LDAP server. Utility method if only one server is * used. - * + * * @param url the url of the LDAP server. */ public void setUrl(String url) { @@ -545,7 +540,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * each individually authenticated connection will be pooled separately. * This means that LDAP pooling will be most efficient using anonymous * connections or connections authenticated using one single system user. - * + * * @param pooled whether Contexts should be pooled. */ public void setPooled(boolean pooled) { @@ -554,7 +549,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Get whether the pooling flag should be set. - * + * * @return whether Contexts should be pooled. */ public boolean isPooled() { @@ -564,7 +559,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * If any custom environment properties are needed, these can be set using * this method. - * + * * @param baseEnvironmentProperties the base environment properties that should always be used when * creating new Context instances. */ @@ -572,10 +567,6 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource this.baseEnv = new Hashtable(baseEnvironmentProperties); } - String getJdkVersion() { - return JdkVersion.getJavaVersion(); - } - protected Hashtable getAnonymousEnv() { if (cacheEnvironmentProperties) { return anonymousEnv; @@ -595,7 +586,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the authentication source to use when retrieving user principal and * credentials. - * + * * @param authenticationSource the {@link AuthenticationSource} that will * provide user info. */ @@ -605,7 +596,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Get the authentication source. - * + * * @return the {@link AuthenticationSource} that will provide user info. */ public AuthenticationSource getAuthenticationSource() { @@ -618,7 +609,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource * property to false causes the environment Hashmap to be * rebuilt from the current property settings of this instance between each * request for an anonymous environment. - * + * * @param cacheEnvironmentProperties true causes that the * anonymous environment properties should be cached, false * causes the Hashmap to be rebuilt for each request. @@ -630,7 +621,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set whether an anonymous environment should be used for read-only * operations. Default is false. - * + * * @param anonymousReadOnly true if an anonymous environment * should be used for read-only operations, false otherwise. */ @@ -641,7 +632,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Get whether an anonymous environment should be used for read-only * operations. - * + * * @return true if an anonymous environment should be used for * read-only operations, false otherwise. */ @@ -652,7 +643,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Set the {@link DirContextAuthenticationStrategy} to use for preparing the * environment and processing the created DirContext instances. - * + * * @param authenticationStrategy the * {@link DirContextAuthenticationStrategy} to use; default is * {@link SimpleDirContextAuthenticationStrategy}. @@ -678,7 +669,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * Implement in subclass to create a DirContext of the desired type (e.g. * InitialDirContext or InitialLdapContext). - * + * * @param environment the environment to use when creating the instance. * @return a new DirContext instance. * @throws NamingException if one is encountered when creating the instance. diff --git a/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java b/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java index 935aa549..ec6f7282 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/core/support/DefaultDirObjectFactory.java @@ -18,7 +18,6 @@ package org.springframework.ldap.core.support; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.core.JdkVersion; import org.springframework.ldap.core.DirContextAdapter; import org.springframework.ldap.support.LdapUtils; import org.springframework.util.StringUtils; diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java index 4001f407..44bbc7d8 100755 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java @@ -18,7 +18,7 @@ package org.springframework.ldap.transaction.compensating.manager; import org.springframework.ldap.core.ContextSource; import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy; -import org.springframework.orm.hibernate3.HibernateTransactionManager; +import org.springframework.orm.hibernate5.HibernateTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionSuspensionNotSupportedException; @@ -28,10 +28,10 @@ import org.springframework.transaction.support.DefaultTransactionStatus; * transaction. Note that even though the same logical transaction is used, this * is not a JTA XA transaction; no two-phase commit will be performed, * and thus commit and rollback may yield unexpected results.
- * This Transaction Manager is as good as it gets when you are using in LDAP in + * This Transaction Manager is as good as it gets when you are using in LDAP in * combination with a Hibernate 3 and unable to use XA transactions because LDAP * is not transactional by design to begin with.
- * + * * Furthermore, this manager does not support nested transactions * @author Hans Westerbeek * @since 1.2.2 @@ -41,14 +41,14 @@ import org.springframework.transaction.support.DefaultTransactionStatus; public class ContextSourceAndHibernateTransactionManager extends HibernateTransactionManager { /** - * + * */ private static final long serialVersionUID = 1L; private ContextSourceTransactionManagerDelegate ldapManagerDelegate = new ContextSourceTransactionManagerDelegate(); /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#isExistingTransaction(java.lang.Object) + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#isExistingTransaction(java.lang.Object) */ protected boolean isExistingTransaction(Object transaction) { ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction; @@ -58,7 +58,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doGetTransaction() + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doGetTransaction() */ protected Object doGetTransaction() { Object dataSourceTransactionObject = super.doGetTransaction(); @@ -70,7 +70,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doBegin(java.lang.Object, + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doBegin(java.lang.Object, * org.springframework.transaction.TransactionDefinition) */ protected void doBegin(Object transaction, TransactionDefinition definition) { @@ -89,7 +89,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doCleanupAfterCompletion(java.lang.Object) + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doCleanupAfterCompletion(java.lang.Object) */ protected void doCleanupAfterCompletion(Object transaction) { ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction; @@ -101,7 +101,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doCommit(org.springframework.transaction.support.DefaultTransactionStatus) + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doCommit(org.springframework.transaction.support.DefaultTransactionStatus) */ protected void doCommit(DefaultTransactionStatus status) { @@ -135,7 +135,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doRollback(org.springframework.transaction.support.DefaultTransactionStatus) + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doRollback(org.springframework.transaction.support.DefaultTransactionStatus) */ protected void doRollback(DefaultTransactionStatus status) { ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status @@ -186,7 +186,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doSuspend(java.lang.Object) + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doSuspend(java.lang.Object) */ protected Object doSuspend(Object transaction) { throw new TransactionSuspensionNotSupportedException( @@ -195,7 +195,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa } /* - * @see org.springframework.orm.hibernate3.HibernateTransactionManager#doResume(java.lang.Object, + * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doResume(java.lang.Object, * java.lang.Object) */ protected void doResume(Object transaction, Object suspendedResources) { diff --git a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java index 641ab933..bd4be811 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java +++ b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTest.java @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * Unit tests for the LdapContextSource class. - * + * * @author Mattias Hellborg Arthursson * @author Ulrik Sandberg */ @@ -46,19 +46,6 @@ public class LdapContextSourceTest { tested.afterPropertiesSet(); } - @Test(expected = IllegalArgumentException.class) - public void testAfterPropertiesSet_BaseAndTooEarlyJdk() throws Exception { - tested = new LdapContextSource() { - String getJdkVersion() { - return "1.4.1_03"; - } - }; - - tested.setUrl("http://ldap.example.com:389"); - tested.setBase("dc=jayway,dc=se"); - tested.afterPropertiesSet(); - } - @Test public void testGetAnonymousEnv() throws Exception { tested.setBase("dc=some example,dc=se"); @@ -138,49 +125,6 @@ public class LdapContextSourceTest { assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY)).isNull(); } - @Test - public void testOldJdkWithNoBaseSetShouldWork() throws Exception { - tested = new LdapContextSource() { - String getJdkVersion() { - return "1.3"; - } - }; - tested.setUrl("ldap://ldap.example.com:389"); - tested.afterPropertiesSet(); - - // check that base was not added to environment - Hashtable env = tested.getAnonymousEnv(); - assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY)).isNull(); - } - - @Test(expected = IllegalArgumentException.class) - public void testOldJdkWithBaseSetShouldNotWork() throws Exception { - tested = new LdapContextSource() { - String getJdkVersion() { - return "1.3"; - } - }; - tested.setUrl("ldap://ldap.example.com:389"); - tested.setBase("dc=example,dc=com"); - tested.afterPropertiesSet(); - } - - @Test - public void testOldJdkWithBaseSetToEmptyPathShouldWork() throws Exception { - tested = new LdapContextSource() { - String getJdkVersion() { - return "1.3"; - } - }; - tested.setUrl("ldap://ldap.example.com:389"); - tested.setBase(null); - tested.afterPropertiesSet(); - - // check that base was not added to environment - Hashtable env = tested.getAnonymousEnv(); - assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY)).isNull(); - } - @Test public void testGetAuthenticatedEnv() throws Exception { tested.setBase("dc=example,dc=se"); diff --git a/gradle/java.gradle b/gradle/java.gradle index a13ecee5..70a32683 100644 --- a/gradle/java.gradle +++ b/gradle/java.gradle @@ -5,11 +5,11 @@ sourceCompatibility = '1.6' targetCompatibility = '1.6' ext.apacheDsVersion = '1.5.5' -ext.springVersion = '4.2.5.RELEASE' +ext.springVersion = '5.0.0.BUILD-SNAPSHOT' ext.springDataVersion = '1.12.1.RELEASE' ext.springDataSpring3Version = '1.10.2.RELEASE' ext.springBatchVersion = '2.0.4.RELEASE' -ext.junitVersion = '4.11' +ext.junitVersion = '4.12' ext.commonsIoVersion = '2.4' ext.commonsPoolVersion = '1.6' ext.commonsLangVersion = '2.6' @@ -22,6 +22,7 @@ ext.slf4jVersion = '1.7.12' ext.powerMockVersion = '1.6.2' ext.commonsPool2Version = '2.4.2' ext.assertjVersion= '2.3.0' +ext.hibernateVersion = '5.2.2.Final' ext.powerMockDependencies = [ "org.powermock:powermock-core:$powerMockVersion", diff --git a/test/integration-tests/build.gradle b/test/integration-tests/build.gradle index 199ab48f..069706fb 100644 --- a/test/integration-tests/build.gradle +++ b/test/integration-tests/build.gradle @@ -50,7 +50,7 @@ dependencies { testCompile "org.springframework:spring-test:$springVersion", "org.springframework:spring-aop:$springVersion", "org.springframework:spring-expression:$springVersion", - "org.hibernate:hibernate-core:3.3.2.GA", + "org.hibernate:hibernate-core:$hibernateVersion", "aspectj:aspectjrt:1.5.3", "aspectj:aspectjweaver:1.5.3", "hsqldb:hsqldb:1.8.0.7", diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java index 3bd1198b..92ab6313 100755 --- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java +++ b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java @@ -4,7 +4,7 @@ import org.springframework.ldap.core.DirContextAdapter; import org.springframework.ldap.core.DistinguishedName; import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.itest.transaction.compensating.manager.DummyException; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; +import org.springframework.orm.hibernate5.support.HibernateDaoSupport; import org.springframework.transaction.annotation.Transactional; /** @@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional; public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements OrgPersonDao { private LdapTemplate ldapTemplate; - + public void create(OrgPerson person) { DistinguishedName dn = new DistinguishedName(); dn.add("ou", person.getCountry()); @@ -28,14 +28,14 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements ctx.setAttributeValue("description", person.getDescription()); ldapTemplate.bind(dn, ctx, null); this.getHibernateTemplate().saveOrUpdate(person); - - + + } public void createWithException(OrgPerson person) { this.create(person); throw new DummyException("This method failed"); - + } public void modifyAttributes(String dn, String lastName, String description) { @@ -45,7 +45,7 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements ldapTemplate.modifyAttributes(dn, ctx.getModificationItems()); } - + public void modifyAttributesWithException(String dn, String lastName, String description) { modifyAttributes(dn, lastName, description); @@ -56,7 +56,7 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements String dn = prepareDn(person); ldapTemplate.unbind(dn); this.getHibernateTemplate().delete(person); - + } public void unbindWithException(OrgPerson person) { @@ -72,22 +72,22 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements ldapTemplate.modifyAttributes(ctx); this.getHibernateTemplate().saveOrUpdate(person); - + } public void updateWithException(OrgPerson person) { this.update(person); throw new DummyException("This method failed"); } - + public void updateAndRename(String dn, String newDn, String updatedDescription) { - + DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); ctx.setAttributeValue("description", updatedDescription); ldapTemplate.modifyAttributes(ctx); ldapTemplate.rename(dn, newDn); - + } public void updateAndRenameWithException(String dn, String newDn, String updatedDescription) { @@ -95,12 +95,12 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements throw new DummyException("This method failed"); } - + public void setLdapTemplate(LdapTemplate ldapTemplate) { this.ldapTemplate = ldapTemplate; } - + private String prepareDn(OrgPerson person){ return "cn=" + person.getFullname() + ",ou=" + person.getCompany() + ",ou=" + person.getCountry(); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/LdapConditionallyFilteredTestRunner.java b/test/integration-tests/src/test/java/org/springframework/ldap/LdapConditionallyFilteredTestRunner.java index 97d0349c..9e246131 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/LdapConditionallyFilteredTestRunner.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/LdapConditionallyFilteredTestRunner.java @@ -40,7 +40,7 @@ public class LdapConditionallyFilteredTestRunner extends SpringJUnit4ClassRunner String noadtest = System.getProperty("adtest"); if (noadtest != null) { try { - filter(new Categories.CategoryFilter(null, NoAdTest.class)); + filter(Categories.CategoryFilter.exclude(NoAdTest.class)); } catch (NoTestsRemainException e) { // Nothing to do here. } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/ldap321/Ldap321Test.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/ldap321/Ldap321Test.java index 281f2fe4..f59b11ec 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/ldap321/Ldap321Test.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/ldap321/Ldap321Test.java @@ -22,9 +22,9 @@ import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; /** @@ -32,8 +32,8 @@ import org.springframework.transaction.annotation.Transactional; */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:ldap321.xml") -@TransactionConfiguration(transactionManager = "txManager",defaultRollback = true) @Transactional +@Rollback public class Ldap321Test{ @Autowired private RoleRepo roleRepo; diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTest.java index f8d3a766..ae2e7654 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTest.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTest.java @@ -34,7 +34,7 @@ import org.springframework.ldap.itest.transaction.compensating.manager.DummyExce import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson; import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao; import org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager; -import org.springframework.orm.hibernate3.HibernateTemplate; +import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.fail; /** * Integration tests for {@link ContextSourceAndHibernateTransactionManager}. - * + * * @author Hans Westerbeek */ @ContextConfiguration(locations = {"/conf/ldapAndHibernateTransactionTestContext.xml"}) diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITest.java index c279d060..590a05c2 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITest.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITest.java @@ -33,7 +33,7 @@ import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest; import org.springframework.ldap.itest.transaction.compensating.manager.DummyException; import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson; import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao; -import org.springframework.orm.hibernate3.HibernateTemplate; +import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.transaction.support.TransactionSynchronizationManager; diff --git a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml index f3cf0afc..3832978a 100755 --- a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml +++ b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml @@ -22,11 +22,11 @@ - + - + diff --git a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml index 3cbcb283..73788925 100755 --- a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml +++ b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml @@ -25,11 +25,11 @@ - + - + diff --git a/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml index 289e4427..3d922840 100755 --- a/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml +++ b/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml @@ -32,11 +32,11 @@ - + - +