From b6b4158fad40356f61c108de8e1f4b201b049dda Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 14:07:58 -0600
Subject: [PATCH 01/67] Prepare for 4.0 Development
---
.../main/resources/META-INF/spring.schemas | 2 +-
.../ldap/config/spring-ldap-4.0.xsd | 685 ++++++++++++++++++
gradle.properties | 2 +-
3 files changed, 687 insertions(+), 2 deletions(-)
create mode 100644 core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd
diff --git a/core/src/main/resources/META-INF/spring.schemas b/core/src/main/resources/META-INF/spring.schemas
index 752edee1d9..7377496dd1 100644
--- a/core/src/main/resources/META-INF/spring.schemas
+++ b/core/src/main/resources/META-INF/spring.schemas
@@ -1,4 +1,4 @@
-http\://www.springframework.org/schema/ldap/spring-ldap.xsd=org/springframework/ldap/config/spring-ldap-2.2.xsd
+http\://www.springframework.org/schema/ldap/spring-ldap.xsd=org/springframework/ldap/config/spring-ldap-4.0.xsd
http\://www.springframework.org/schema/ldap/spring-ldap-2.0.xsd=org/springframework/ldap/config/spring-ldap-2.0.xsd
http\://www.springframework.org/schema/ldap/spring-ldap-2.1.xsd=org/springframework/ldap/config/spring-ldap-2.1.xsd
http\://www.springframework.org/schema/ldap/spring-ldap-2.2.xsd=org/springframework/ldap/config/spring-ldap-2.2.xsd
\ No newline at end of file
diff --git a/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd b/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd
new file mode 100644
index 0000000000..142b29b65a
--- /dev/null
+++ b/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd
@@ -0,0 +1,685 @@
+
+
+
+
+
+
+
+
+
+ A bean identifier, used for referring to the bean elsewhere in the context.
+ "contextSource".
+
+
+
+
+
+
+ Defines whether read-only operations will be performed using an anonymous (unauthenticated) context.
+
+
+
+
+
+
+ Id of the AuthenticationSource instance to use. If not specified, a SimpleAuthenticationSource will
+ be used.
+
+
+
+
+
+
+ Id of the DirContextAuthenticationStrategy instance to use. If not specified, a SimpleDirContextAuthenticationStrategy
+ will be used.
+
+
+
+
+
+
+ The base DN. If configured, all LDAP operations on contexts retrieved from this ContextSource will
+ be relative to this DN. Default is an empty distinguished name (i.e. all operations will be
+ relative to the directory root).
+
+
+
+
+
+
+ The password to use for authentication.
+
+
+
+
+
+
+ Specify whether native Java LDAP connection pooling should be used. Default is false.
+
+
+
+
+
+
+ Defines the strategy to handle referrals, as described on https://docs.oracle.com/javase/jndi/tutorial/ldap/referral/jndi.html.
+ Default is null.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ URL of the LDAP server to use. If fail-over functionality is desired, more than one URL can
+ be specified, separated using comma (,).
+
+
+
+
+
+
+ The username (principal) to use for authentication. This will normally be the distinguished name
+ of an admin user.
+
+
+
+
+
+
+ Reference to a Map of custom environment properties that should supplied with the environment
+ sent to the DirContext on construction.
+
+
+
+
+
+
+
+
+
+ The maximum number of active connections of each type (read-only|read-write)
+ that can be allocated from the pool at the same time, or non-positive for no limit.
+ Default is 8.
+
+
+
+
+
+
+ The overall maximum number of active connections (for all types) that can be allocated from
+ this pool at the same time, or non-positive for no limit. Default is -1 (no limit).
+
+
+
+
+
+
+ The maximum number of active connections of each type (read-only|read-write) that can remain idle in the pool,
+ without extra ones being released, or non-positive for no limit. Default is 8.
+
+
+
+
+
+
+ The minimum number of active connections of each type (read-only|read-write) that can remain
+ idle in the pool, without extra ones being created, or zero to create none. Default is 0.
+
+
+
+
+
+
+ The maximum number of milliseconds that the pool will wait (when there are no available connections)
+ for a connection to be returned before throwing an exception, or non-positive to wait indefinitely.
+ Default is -1.
+
+
+
+
+
+
+ Specifies the behaviour when the pool is exhausted.
+
+
+
+
+
+
+
+ Throw a NoSuchElementException when the pool is exhausted
+
+
+
+
+
+
+ Wait until a new object is available. If max-wait is positive a NoSuchElementException
+ is thrown if no new object is available after the maxWait time expires.
+
+
+
+
+
+
+ Create and return a new object (essentially making maxActive meaningless).
+
+
+
+
+
+
+
+
+
+ The indication of whether objects will be validated before being borrowed from the pool.
+ If the object fails to validate, it will be dropped from the pool, and an attempt to borrow another will be made.
+ Default is false.
+
+
+
+
+
+
+ The indication of whether objects will be validated before being returned to the pool.
+ Default is false.
+
+
+
+
+
+
+ The indication of whether objects will be validated by the idle object evictor (if any).
+ If an object fails to validate, it will be dropped from the pool.
+ Default is false.
+
+
+
+
+
+
+ The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive,
+ no idle object evictor thread will be run. Default is -1.
+
+
+
+
+
+
+ The number of objects to examine during each run of the idle object evictor thread (if any).
+ Default is 3.
+
+
+
+
+
+
+ The minimum amount of time an object may sit idle in the pool before it is eligible
+ for eviction by the idle object evictor (if any). Default is 1000 * 60 * 30.
+
+
+
+
+
+
+ The base dn to use for validation searches. Default is LdapUtils.emptyPath().
+
+
+
+
+
+
+ The filter to use for validation queries. Default is (objectclass=*).
+
+
+
+
+
+
+ Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE;
+ countLimit: 1; timeLimit: 500; returningAttributes: [objectclass].
+
+
+
+
+
+
+ Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE;
+ countLimit: 1; timeLimit: 500; returningAttributes: [objectclass].
+
+
+
+
+
+
+
+
+
+ The overall maximum number of active connections (for all types) that can be allocated from
+ this pool at the same time, or non-positive for no limit. Default is -1 (no limit).
+
+
+
+
+
+
+ The limit on the number of object instances allocated by the pool (checked out or idle),
+ per key. When the limit is reached, the sub-pool is said to be exhausted. A negative value
+ indicates no limit. Default is 8.
+
+
+
+
+
+
+ The maximum number of active connections per type (read-only|read-write) that can remain idle in the pool,
+ without extra ones being released, or non-positive for no limit. Default is 8.
+
+
+
+
+
+
+ The minimum number of active connections per type (read-only|read-write) that can remain
+ idle in the pool, without extra ones being created, or zero to create none. Default is 0.
+
+
+
+
+
+
+ The maximum number of milliseconds that the pool will wait (when there are no available connections)
+ for a connection to be returned before throwing an exception, or non-positive to wait indefinitely.
+ Default is -1.
+
+
+
+
+
+
+ Sets to wait until a new object is available. If max-wait is positive a NoSuchElementException
+ is thrown if no new object is available after the maxWait time expires. Default is true.
+
+
+
+
+
+
+ Sets whether objects created for the pool will be validated before borrowing. If the object
+ fails to validate, then borrowing will fail. Default is false.
+
+
+
+
+
+
+ The indication of whether objects will be validated before being borrowed from the pool.
+ If the object fails to validate, it will be dropped from the pool, and an attempt to borrow another will be made.
+ Default is false.
+
+
+
+
+
+
+ The indication of whether objects will be validated before being returned to the pool.
+ Default is false.
+
+
+
+
+
+
+ The indication of whether objects will be validated by the idle object evictor (if any).
+ If an object fails to validate, it will be dropped from the pool.
+ Default is false.
+
+
+
+
+
+
+ The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive,
+ no idle object evictor thread will be run. Default is -1.
+
+
+
+
+
+
+ The number of objects to examine during each run of the idle object evictor thread (if any).
+ Default is 3.
+
+
+
+
+
+
+ The minimum amount of time an object may sit idle in the pool before it is eligible
+ for eviction by the idle object evictor (if any). Default is 1000 * 60 * 30.
+
+
+
+
+
+
+ The minimum amount of time an object may sit idle in the pool before it is eligible for
+ eviction by the idle object evictor, with the extra condition that at least minimum number
+ of object instances per key remain in the pool. This settings is overridden by min-evictable-time-millis if
+ it is set to a positive value. Default is -1.
+
+
+
+
+
+
+ The name of the eviction policy implementation that is used by this pool. The Pool will
+ attempt to load the class using the thread context class loader. If that fails, the Pool
+ will attempt to load the class using the class loader that loaded this class. Default is
+ org.apache.commons.pool2.impl.DefaultEvictionPolicy.
+
+
+
+
+
+
+ Sets whether or not the pool serves threads waiting to borrow connections fairly.
+ True means that waiting threads are served as if waiting in a FIFO queue. Default is false.
+
+
+
+
+
+
+ Sets whether JMX will be enabled with the platform MBean server for the pool. Default
+ is true.
+
+
+
+
+
+
+ The value of the JMX name base that will be used as part of the name assigned
+ to JMX enabled pools. Default is null.
+
+
+
+
+
+
+ The value of the JMX name prefix that will be used as part of the name assigned
+ to JMX enabled pools. Default value is pool.
+
+
+
+
+
+
+ Sets whether the pool has LIFO (last in, first out) behaviour with
+ respect to idle objects - always returning the most recently used object
+ from the pool, or as a FIFO (first in, first out) queue, where the pool
+ always returns the oldest object in the idle object pool. Default is true.
+
+
+
+
+
+
+ The base dn to use for validation searches. Default is LdapUtils.emptyPath().
+
+
+
+
+
+
+ The filter to use for validation queries. Default is (objectclass=*).
+
+
+
+
+
+
+ Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE;
+ countLimit: 1; timeLimit: 500; returningAttributes: [objectclass].
+
+
+
+
+
+
+ Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE;
+ countLimit: 1; timeLimit: 500; returningAttributes: [objectclass].
+
+
+
+
+
+
+
+
+ Creates a ContextSource instance to be used to get LdapContexts for communicating with an LDAP server.
+
+
+
+
+
+
+
+
+ Defines the settings to use for the Spring LDAP connection pooling support.
+
+
+
+
+
+
+
+
+
+
+
+ Defines the settings to use for the Spring LDAP connection pooling support based on commons-pool2 library.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A bean identifier, used for referring to the bean elsewhere in the context.
+ Default is "ldapTemplate".
+
+
+
+
+
+
+ Id of the ContextSource instance to use. Default is "contextSource".
+
+
+
+
+
+
+ The default count limit for searches. Default is 0 (no limit).
+
+
+
+
+
+
+ The default time limit for searches. Default is 0 (no limit).
+
+
+
+
+
+
+ The default search scope for searches. Default is SUBTREE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Specifies whether NameNotFoundException should be ignored in searches. Setting this
+ attribute to true will cause errors caused by invalid search base to be silently swallowed.
+ Default is false.
+
+
+
+
+
+
+ Specifies whether PartialResultException should be ignored in searches. Some LDAP servers
+ have problems with referrals; these should normally be followed automatically, but if this
+ doesn't work it will manifest itself with a PartialResultException. Setting this attribute
+ to true presents a work-around to this problem. Default is false.
+
+
+
+
+
+
+ Id of the ObjectDirectoryMapper instance to use. Default is a default-configured DefaultObjectDirectoryMapper.
+
+
+
+
+
+
+
+
+ Creates an LdapTemplate instance.
+
+
+
+
+
+
+
+
+
+
+
+ Id of this instance. Default is "transactionManager".
+
+
+
+
+
+
+ Id of the ContextSource instance to use. "contextSource".
+
+
+
+
+
+
+ Id of the DataSource instance to use.
+
+
+
+
+
+
+ Id of the Hibernate SessionFactory instance to use.
+
+
+
+
+
+
+
+
+ Creates an ContextSourceTransactionManager. If data-source-ref or session-factory-ref is specified,
+ a DataSourceAndContextSourceTransactionManager/HibernateAndContextSourceTransactionManager will be
+ created.
+
+
+
+
+
+
+
+ The default (simplistic) TempEntryRenamingStrategy. Please note that this
+ strategy will not work for more advanced scenarios. See reference documentation
+ for details.
+
+
+
+
+
+
+ The default suffix that will be added to modified entries.
+ Default is "_temp".
+
+
+
+
+
+
+
+
+ TempEntryRenamingStrategy that moves the entry to a different subtree than
+ the original entry.
+
+
+
+
+
+
+ The subtree base where changed entries should be moved.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The reference to an LdapTemplate. Will default to 'ldapTemplate'.
+
+
+
+
+
+
+
+
diff --git a/gradle.properties b/gradle.properties
index b1981b323d..5dc9e988d9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,3 @@
-version=3.3.1
+version=4.0.0-SNAPSHOT
springJavaformatVersion=0.0.38
org.gradle.caching=true
From 32a866f86844c61e0c64be412d229bf3638684fd Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 14:06:38 -0600
Subject: [PATCH 02/67] Remove LDAP + Data Source Transaction Wrappers
Closes gh-1109
---
.../ldap/config/TransactionManagerParser.java | 21 +-
...SourceAndDataSourceTransactionManager.java | 218 ----------
...tSourceAndHibernateTransactionManager.java | 221 ----------
.../ldap/config/spring-ldap-4.0.xsd | 18 +-
.../LdapTemplateNamespaceHandlerTests.java | 9 +-
.../ContextSourceTransactionManagerTests.java | 3 +-
modules/ROOT/pages/transaction-support.adoc | 29 +-
.../DummyDaoLdapAndHibernateImpl.java | 120 ------
...rceTransactionManagerIntegrationTests.java | 358 -----------------
...sactionManagerLdap179IntegrationTests.java | 96 -----
...urceTransactionManagerNamespaceITests.java | 359 -----------------
...ateTransactionManagerIntegrationTests.java | 375 -----------------
...sactionManagerLdap179IntegrationTests.java | 89 -----
...nateTransactionManagerNamespaceITests.java | 376 ------------------
.../src/test/resources/conf/OrgPerson.hbm.xml | 16 -
...bernateTransactionNamespaceTestContext.xml | 51 ---
...ldapAndHibernateTransactionTestContext.xml | 63 ---
...AndJdbcTransactionNamespaceTestContext.xml | 52 ---
.../ldapAndJdbcTransactionTestContext.xml | 49 ---
...LdapAndHibernateTransactionTestContext.xml | 80 ----
...ssingLdapAndJdbcTransactionTestContext.xml | 66 ---
21 files changed, 11 insertions(+), 2658 deletions(-)
delete mode 100644 core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java
delete mode 100755 core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java
delete mode 100755 test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java
delete mode 100644 test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java
delete mode 100644 test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java
delete mode 100644 test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java
delete mode 100644 test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java
delete mode 100644 test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java
delete mode 100644 test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java
delete mode 100755 test/integration-tests/src/test/resources/conf/OrgPerson.hbm.xml
delete mode 100755 test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml
delete mode 100755 test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml
delete mode 100644 test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionNamespaceTestContext.xml
delete mode 100644 test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml
delete mode 100755 test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml
delete mode 100644 test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml
diff --git a/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java b/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java
index 550a2904ae..37078544da 100644
--- a/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java
+++ b/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java
@@ -24,8 +24,6 @@
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager;
-import org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager;
import org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager;
import org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy;
import org.springframework.ldap.transaction.compensating.support.DifferentSubtreeTempEntryRenamingStrategy;
@@ -58,24 +56,13 @@ public BeanDefinition parse(Element element, ParserContext parserContext) {
String dataSourceRef = element.getAttribute(ATT_DATA_SOURCE_REF);
String sessionFactoryRef = element.getAttribute(ATT_SESSION_FACTORY_REF);
- if (StringUtils.hasText(dataSourceRef) && StringUtils.hasText(sessionFactoryRef)) {
- throw new IllegalArgumentException(String.format("Only one of %s and %s can be specified",
+ if (StringUtils.hasText(dataSourceRef) || StringUtils.hasText(sessionFactoryRef)) {
+ throw new IllegalArgumentException(String.format(
+ "ContextSourceAndHibernateTransactionManager and ContextSourceAndDataSourceTransactionManager are removed in Spring LDAP 4.0. Please remove your usage of data-source-ref and session-factory-ref.",
ATT_DATA_SOURCE_REF, ATT_SESSION_FACTORY_REF));
}
- BeanDefinitionBuilder builder;
- if (StringUtils.hasText(dataSourceRef)) {
- builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceAndDataSourceTransactionManager.class);
- builder.addPropertyReference("dataSource", dataSourceRef);
- }
- else if (StringUtils.hasText(sessionFactoryRef)) {
- builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceAndHibernateTransactionManager.class);
- builder.addPropertyReference("sessionFactory", sessionFactoryRef);
- }
- else {
- // Standard transaction manager
- builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceTransactionManager.class);
- }
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceTransactionManager.class);
builder.addPropertyReference("contextSource", contextSourceRef);
diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java
deleted file mode 100644
index 37562b4bef..0000000000
--- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2005-2013 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
- *
- * https://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.transaction.compensating.manager;
-
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.ldap.core.ContextSource;
-import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionException;
-import org.springframework.transaction.TransactionSuspensionNotSupportedException;
-import org.springframework.transaction.support.DefaultTransactionStatus;
-
-/**
- * A Transaction Manager to manage LDAP and JDBC operations within the same 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.
- *
- * Note that nested transactions are not supported.
- *
- * @author Mattias Hellborg Arthursson
- * @since 1.2
- * @deprecated The idea of wrapping two transaction managers without actual XA support is
- * probably not such a good idea after all. AbstractPlatformTransactionManager is not
- * designed for this usage.
- */
-@Deprecated
-public class ContextSourceAndDataSourceTransactionManager extends DataSourceTransactionManager {
-
- private static final long serialVersionUID = 6832868697460384648L;
-
- private ContextSourceTransactionManagerDelegate ldapManagerDelegate = new ContextSourceTransactionManagerDelegate();
-
- public ContextSourceAndDataSourceTransactionManager() {
- super();
- // Override the default behaviour.
- setNestedTransactionAllowed(false);
- }
-
- /*
- * @see org.springframework.jdbc.datasource.DataSourceTransactionManager#
- * isExistingTransaction(java.lang.Object)
- */
- @Override
- protected boolean isExistingTransaction(Object transaction) {
- // We don't support nested transactions here
- return false;
- }
-
- /*
- * @see
- * org.springframework.jdbc.datasource.DataSourceTransactionManager#doGetTransaction()
- */
- @Override
- protected Object doGetTransaction() {
- Object dataSourceTransactionObject = super.doGetTransaction();
- Object contextSourceTransactionObject = this.ldapManagerDelegate.doGetTransaction();
-
- return new ContextSourceAndDataSourceTransactionObject(contextSourceTransactionObject,
- dataSourceTransactionObject);
- }
-
- /*
- * @see
- * org.springframework.jdbc.datasource.DataSourceTransactionManager#doBegin(java.lang.
- * Object, org.springframework.transaction.TransactionDefinition)
- */
- @Override
- protected void doBegin(Object transaction, TransactionDefinition definition) {
- ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) transaction;
-
- super.doBegin(actualTransactionObject.getDataSourceTransactionObject(), definition);
- try {
- this.ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition);
- }
- catch (TransactionException ex) {
- // Failed to start LDAP transaction - make sure we clean up properly
- super.doCleanupAfterCompletion(actualTransactionObject.getDataSourceTransactionObject());
- throw ex;
- }
- }
-
- /*
- * @see org.springframework.jdbc.datasource.DataSourceTransactionManager#
- * doCleanupAfterCompletion(java.lang.Object)
- */
- @Override
- protected void doCleanupAfterCompletion(Object transaction) {
- ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) transaction;
-
- super.doCleanupAfterCompletion(actualTransactionObject.getDataSourceTransactionObject());
- this.ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject());
- }
-
- /*
- * @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doCommit(org.
- * springframework.transaction.support.DefaultTransactionStatus)
- */
- @Override
- protected void doCommit(DefaultTransactionStatus status) {
-
- ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
- .getTransaction();
-
- try {
- super.doCommit(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(),
- status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
- status.getSuspendedResources()));
- }
- catch (TransactionException ex) {
- if (isRollbackOnCommitFailure()) {
- logger.debug("Failed to commit db resource, rethrowing", ex);
- // If we are to rollback on commit failure, just rethrow the
- // exception - this will cause a rollback to be performed on
- // both resources.
- throw ex;
- }
- else {
- logger.warn("Failed to commit and resource is rollbackOnCommit not set -"
- + " proceeding to commit ldap resource.");
- }
- }
- this.ldapManagerDelegate.doCommit(new DefaultTransactionStatus(
- actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
- status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
- }
-
- /*
- * @see
- * org.springframework.jdbc.datasource.DataSourceTransactionManager#doRollback(org.
- * springframework.transaction.support.DefaultTransactionStatus)
- */
- @Override
- protected void doRollback(DefaultTransactionStatus status) {
- ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
- .getTransaction();
-
- super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(),
- status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
- status.getSuspendedResources()));
- this.ldapManagerDelegate.doRollback(new DefaultTransactionStatus(
- actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
- status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
- }
-
- public ContextSource getContextSource() {
- return this.ldapManagerDelegate.getContextSource();
- }
-
- public void setContextSource(ContextSource contextSource) {
- this.ldapManagerDelegate.setContextSource(contextSource);
- }
-
- public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
- this.ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
- }
-
- /*
- * @see
- * org.springframework.jdbc.datasource.DataSourceTransactionManager#doSuspend(java.
- * lang.Object)
- */
- protected Object doSuspend(Object transaction) {
- throw new TransactionSuspensionNotSupportedException(
- "Transaction manager [" + getClass().getName() + "] does not support transaction suspension");
- }
-
- /*
- * @see
- * org.springframework.jdbc.datasource.DataSourceTransactionManager#doResume(java.lang
- * .Object, java.lang.Object)
- */
- protected void doResume(Object transaction, Object suspendedResources) {
- throw new TransactionSuspensionNotSupportedException(
- "Transaction manager [" + getClass().getName() + "] does not support transaction suspension");
- }
-
- public void afterPropertiesSet() {
- super.afterPropertiesSet();
- this.ldapManagerDelegate.checkRenamingStrategy();
- }
-
- private static final class ContextSourceAndDataSourceTransactionObject {
-
- private Object ldapTransactionObject;
-
- private Object dataSourceTransactionObject;
-
- ContextSourceAndDataSourceTransactionObject(Object ldapTransactionObject, Object dataSourceTransactionObject) {
- this.ldapTransactionObject = ldapTransactionObject;
- this.dataSourceTransactionObject = dataSourceTransactionObject;
- }
-
- Object getDataSourceTransactionObject() {
- return this.dataSourceTransactionObject;
- }
-
- Object getLdapTransactionObject() {
- return this.ldapTransactionObject;
- }
-
- }
-
-}
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
deleted file mode 100755
index 3d32dc72cb..0000000000
--- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2005-2013 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
- *
- * https://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.transaction.compensating.manager;
-
-import org.springframework.ldap.core.ContextSource;
-import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy;
-import org.springframework.orm.hibernate5.HibernateTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionException;
-import org.springframework.transaction.TransactionSuspensionNotSupportedException;
-import org.springframework.transaction.support.DefaultTransactionStatus;
-
-/**
- * A Transaction Manager to manage LDAP and Hibernate 3 operations within the same
- * 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
- * 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
- * @deprecated The idea of wrapping two transaction managers without actual XA support is
- * probably not such a good idea after all. AbstractPlatformTransactionManager is not
- * designed for this usage.
- */
-@Deprecated
-public class ContextSourceAndHibernateTransactionManager extends HibernateTransactionManager {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private ContextSourceTransactionManagerDelegate ldapManagerDelegate = new ContextSourceTransactionManagerDelegate();
-
- /*
- * @see org.springframework.orm.hibernate5.HibernateTransactionManager#
- * isExistingTransaction(java.lang.Object)
- */
- @Override
- protected boolean isExistingTransaction(Object transaction) {
- ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction;
-
- return super.isExistingTransaction(actualTransactionObject.getHibernateTransactionObject());
- }
-
- /*
- * @see
- * org.springframework.orm.hibernate5.HibernateTransactionManager#doGetTransaction()
- */
- @Override
- protected Object doGetTransaction() {
- Object dataSourceTransactionObject = super.doGetTransaction();
- Object contextSourceTransactionObject = this.ldapManagerDelegate.doGetTransaction();
-
- return new ContextSourceAndHibernateTransactionObject(contextSourceTransactionObject,
- dataSourceTransactionObject);
- }
-
- /*
- * @see
- * org.springframework.orm.hibernate5.HibernateTransactionManager#doBegin(java.lang.
- * Object, org.springframework.transaction.TransactionDefinition)
- */
- @Override
- protected void doBegin(Object transaction, TransactionDefinition definition) {
- ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction;
-
- super.doBegin(actualTransactionObject.getHibernateTransactionObject(), definition);
- try {
- this.ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition);
- }
- catch (TransactionException ex) {
- // Failed to start LDAP transaction - make sure we clean up properly
- super.doCleanupAfterCompletion(actualTransactionObject.getHibernateTransactionObject());
- throw ex;
- }
- }
-
- /*
- * @see org.springframework.orm.hibernate5.HibernateTransactionManager#
- * doCleanupAfterCompletion(java.lang.Object)
- */
- @Override
- protected void doCleanupAfterCompletion(Object transaction) {
- ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction;
-
- super.doCleanupAfterCompletion(actualTransactionObject.getHibernateTransactionObject());
- this.ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject());
- }
-
- /*
- * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doCommit(org.
- * springframework.transaction.support.DefaultTransactionStatus)
- */
- @Override
- protected void doCommit(DefaultTransactionStatus status) {
-
- ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
- .getTransaction();
-
- try {
- super.doCommit(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(),
- status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
- status.getSuspendedResources()));
- }
- catch (TransactionException ex) {
- if (isRollbackOnCommitFailure()) {
- logger.debug("Failed to commit db resource, rethrowing", ex);
- // If we are to rollback on commit failure, just rethrow the
- // exception - this will cause a rollback to be performed on
- // both resources.
- throw ex;
- }
- else {
- logger.warn("Failed to commit and resource is rollbackOnCommit not set -"
- + " proceeding to commit ldap resource.");
- }
- }
- this.ldapManagerDelegate.doCommit(new DefaultTransactionStatus(
- actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
- status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
- }
-
- /*
- * @see org.springframework.orm.hibernate5.HibernateTransactionManager#doRollback(org.
- * springframework.transaction.support.DefaultTransactionStatus)
- */
- @Override
- protected void doRollback(DefaultTransactionStatus status) {
- ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
- .getTransaction();
-
- super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(),
- status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
- status.getSuspendedResources()));
- this.ldapManagerDelegate.doRollback(new DefaultTransactionStatus(
- actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
- status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
- }
-
- public ContextSource getContextSource() {
- return this.ldapManagerDelegate.getContextSource();
- }
-
- public void setContextSource(ContextSource contextSource) {
- this.ldapManagerDelegate.setContextSource(contextSource);
- }
-
- public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
- this.ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
- }
-
- /*
- * @see
- * org.springframework.orm.hibernate5.HibernateTransactionManager#doSuspend(java.lang.
- * Object)
- */
- @Override
- protected Object doSuspend(Object transaction) {
- throw new TransactionSuspensionNotSupportedException(
- "Transaction manager [" + getClass().getName() + "] does not support transaction suspension");
- }
-
- /*
- * @see
- * org.springframework.orm.hibernate5.HibernateTransactionManager#doResume(java.lang.
- * Object, java.lang.Object)
- */
- @Override
- protected void doResume(Object transaction, Object suspendedResources) {
- throw new TransactionSuspensionNotSupportedException(
- "Transaction manager [" + getClass().getName() + "] does not support transaction suspension");
- }
-
- @Override
- public void afterPropertiesSet() {
- super.afterPropertiesSet();
- this.ldapManagerDelegate.checkRenamingStrategy();
- }
-
- private static final class ContextSourceAndHibernateTransactionObject {
-
- private Object ldapTransactionObject;
-
- private Object hibernateTransactionObject;
-
- ContextSourceAndHibernateTransactionObject(Object ldapTransactionObject, Object hibernateTransactionObject) {
- this.ldapTransactionObject = ldapTransactionObject;
- this.hibernateTransactionObject = hibernateTransactionObject;
- }
-
- Object getHibernateTransactionObject() {
- return this.hibernateTransactionObject;
- }
-
- Object getLdapTransactionObject() {
- return this.ldapTransactionObject;
- }
-
- }
-
-}
diff --git a/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd b/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd
index 142b29b65a..16919e283e 100644
--- a/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd
+++ b/core/src/main/resources/org/springframework/ldap/config/spring-ldap-4.0.xsd
@@ -600,28 +600,12 @@
-
-
-
- Id of the DataSource instance to use.
-
-
-
-
-
-
- Id of the Hibernate SessionFactory instance to use.
-
-
-
- Creates an ContextSourceTransactionManager. If data-source-ref or session-factory-ref is specified,
- a DataSourceAndContextSourceTransactionManager/HibernateAndContextSourceTransactionManager will be
- created.
+ Creates an ContextSourceTransactionManager
diff --git a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java
index a645098dce..a528d91e02 100644
--- a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java
+++ b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java
@@ -42,7 +42,6 @@
import org.springframework.ldap.pool2.factory.PooledContextSource;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy;
-import org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager;
import org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager;
import org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy;
import org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy;
@@ -51,6 +50,7 @@
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Mattias Hellborg Arthursson
@@ -238,11 +238,8 @@ public void verifyParseWithDefaultTransactions() {
@Test
public void verifyParseTransactionWithDataSource() {
- ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
- "/ldap-namespace-config-transactional-datasource.xml");
- PlatformTransactionManager transactionManager = ctx.getBean(PlatformTransactionManager.class);
-
- assertThat(transactionManager instanceof ContextSourceAndDataSourceTransactionManager).isTrue();
+ assertThatExceptionOfType(BeansException.class).isThrownBy(
+ () -> new ClassPathXmlApplicationContext("/ldap-namespace-config-transactional-datasource.xml"));
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java
index f977107193..c6b9ae774d 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java
@@ -114,7 +114,8 @@ public void testDoRollback() {
CompensatingTransactionObject transactionObject = new CompensatingTransactionObject(null);
transactionObject.setHolder(expectedContextHolder);
- this.tested.doRollback(new DefaultTransactionStatus(transactionObject, false, false, false, false, null));
+ this.tested.doRollback(
+ new DefaultTransactionStatus("name", transactionObject, false, false, false, false, false, null));
verify(this.transactionDataManagerMock).rollback();
}
diff --git a/modules/ROOT/pages/transaction-support.adoc b/modules/ROOT/pages/transaction-support.adoc
index cfe27a0b5c..f847ce5785 100644
--- a/modules/ROOT/pages/transaction-support.adoc
+++ b/modules/ROOT/pages/transaction-support.adoc
@@ -62,34 +62,7 @@ In a real-world situation, you would probably apply the transactions on the serv
[[spring-ldap-jdbc-transaction-integration]]
== JDBC Transaction Integration
-A common use case when working against LDAP is that some of the data is stored in the LDAP tree but other data is stored in a relational database. In this case, transaction support becomes even more important, since the update of the different resources should be synchronized.
-
-While actual XA transactions is not supported, support is provided to conceptually wrap JDBC and LDAP access within the same transaction by supplying a `data-source-ref` attribute to the `` element. This creates a `ContextSourceAndDataSourceTransactionManager`, which then manages the two transactions virtually as if they were one. When performing a commit, the LDAP part of the operation is always performed first, letting both transactions be rolled back should the LDAP commit fail. The JDBC part of the transaction is managed exactly as in `DataSourceTransactionManager`, except that nested transactions are not supported. The following example shows an `ldap:transaction-manager` element with a `data-source-ref` attribute:
-
-====
-[source,java]
-[subs="verbatim,quotes"]
-----
-
-
-
-----
-====
-
-NOTE: The provided support is all client-side.
-The wrapped transaction is not an XA transaction. No two-phase commit is performed, as the LDAP server cannot vote on its outcome.
-
-You can accomplish the same thing for Hibernate integration by supplying a `session-factory-ref` attribute to the `` element, as follows:
-
-====
-[source,xml]
-[subs="verbatim,quotes"]
-----
-
-
-
-----
-====
+This support was removed in Spring LDAP 4.0.
[[ldap-compensating-transactions-explained]]
== LDAP Compensating Transactions Explained
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
deleted file mode 100755
index 3b263add01..0000000000
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2005-2023 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
- *
- * https://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.itest.transaction.compensating.manager.hibernate;
-
-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.hibernate5.support.HibernateDaoSupport;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * @author Hans Westerbeek
- */
-@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());
- dn.add("ou", person.getCompany());
- dn.add("cn", person.getFullname());
-
- DirContextAdapter ctx = new DirContextAdapter();
- ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
- ctx.setAttributeValue("cn", person.getFullname());
- ctx.setAttributeValue("sn", person.getLastname());
- ctx.setAttributeValue("description", person.getDescription());
- this.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) {
- DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
- ctx.setAttributeValue("sn", lastName);
- ctx.setAttributeValue("description", description);
-
- this.ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
- }
-
- public void modifyAttributesWithException(String dn, String lastName, String description) {
- modifyAttributes(dn, lastName, description);
- throw new DummyException("This method failed.");
- }
-
- public void unbind(OrgPerson person) {
- String dn = prepareDn(person);
- this.ldapTemplate.unbind(dn);
- this.getHibernateTemplate().delete(person);
-
- }
-
- public void unbindWithException(OrgPerson person) {
- this.unbind(person);
- throw new DummyException("This method failed");
- }
-
- public void update(OrgPerson person) {
- String dn = prepareDn(person);
- DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
- ctx.setAttributeValue("sn", person.getLastname());
- ctx.setAttributeValue("description", person.getDescription());
-
- this.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) this.ldapTemplate.lookup(dn);
- ctx.setAttributeValue("description", updatedDescription);
-
- this.ldapTemplate.modifyAttributes(ctx);
- this.ldapTemplate.rename(dn, newDn);
-
- }
-
- public void updateAndRenameWithException(String dn, String newDn, String updatedDescription) {
- this.updateAndRename(dn, newDn, updatedDescription);
- 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/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java
deleted file mode 100644
index 83b8561d1b..0000000000
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright 2005-2016 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
- *
- * https://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.itest.manager;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.ldap.NameNotFoundException;
-import org.springframework.ldap.core.AttributesMapper;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
-import org.springframework.ldap.itest.transaction.compensating.manager.DummyDao;
-import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-/**
- * Integration tests for
- * {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
- *
- * @author Mattias Hellborg Arthursson
- */
-@ContextConfiguration(locations = { "/conf/ldapAndJdbcTransactionTestContext.xml" })
-public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
-
- private static Logger log = LoggerFactory
- .getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class);
-
- @Autowired
- @Qualifier("dummyDao")
- private DummyDao dummyDao;
-
- @Autowired
- private LdapTemplate ldapTemplate;
-
- @Autowired
- private JdbcTemplate jdbcTemplate;
-
- @Before
- public void prepareTestedInstance() throws Exception {
- if (TransactionSynchronizationManager.isSynchronizationActive()) {
- TransactionSynchronizationManager.clearSynchronization();
- }
-
- this.jdbcTemplate.execute("drop table PERSON if exists");
- this.jdbcTemplate
- .execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
- this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
- new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
- }
-
- @After
- public void cleanup() throws Exception {
- this.jdbcTemplate.execute("drop table PERSON if exists");
- }
-
- @Test
- public void testCreateWithException() {
- try {
- this.dummyDao.createWithException("Sweden", "company1", "some testperson", "testperson",
- "some description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- // Verify that no entry was created
- try {
- this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- try {
- this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'", new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- return null;
- }
- });
- fail("EmptyResultDataAccessException expected");
- }
- catch (EmptyResultDataAccessException expected) {
- assertThat(true).isTrue();
- }
- }
-
- @Test
- public void testCreate() {
- this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
-
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- Object dbResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'",
- new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- return new Object();
- }
- });
- assertThat(ldapResult).isNotNull();
- assertThat(dbResult).isNotNull();
-
- this.ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
- }
-
- @Test
- public void testUpdateWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- this.dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Person");
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
- new Object[] { "Some Person" }, new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- assertThat(rs.getString("lastname")).isEqualTo("Person");
- assertThat(rs.getString("description")).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- assertThat(ldapResult).isNotNull();
- assertThat(jdbcResult).isNotNull();
- }
-
- @Test
- public void testUpdate() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- this.dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
-
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
- new Object[] { "Some Person" }, new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- assertThat(rs.getString("lastname")).isEqualTo("Updated Person");
- assertThat(rs.getString("description")).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(ldapResult).isNotNull();
- assertThat(jdbcResult).isNotNull();
- this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
- }
-
- @Test
- public void testUpdateAndRenameWithException() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that entry was not moved.
- try {
- this.ldapTemplate.lookup(newDn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that original entry was not updated.
- Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
- return new Object();
- }
- });
- assertThat(object).isNotNull();
- }
-
- @Test
- public void testUpdateAndRename() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- // Perform test
- this.dummyDao.updateAndRename(dn, newDn, "Updated description");
-
- // Verify that entry was moved and updated.
- Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(object).isNotNull();
- this.dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
- }
-
- @Test
- public void testModifyAttributesWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify result - check that the operation was properly rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Person");
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- }
-
- @Test
- public void testModifyAttributes() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
-
- // Verify result - check that the operation was not rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
- }
-
- @Test
- public void testUnbindWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.unbindWithException(dn, "Some Person");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify result - check that the operation was properly rolled back
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- // Just verify that the entry still exists.
- return new Object();
- }
- });
-
- Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
- new Object[] { "Some Person" }, new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- // Just verify that the entry still exists.
- return new Object();
- }
- });
-
- assertThat(ldapResult).isNotNull();
- assertThat(jdbcResult).isNotNull();
- }
-
- @Test
- public void testUnbind() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- this.dummyDao.unbind(dn, "Some Person");
-
- try {
- // Verify result - check that the operation was not rolled back
- this.ldapTemplate.lookup(dn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- try {
- this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?", new Object[] { "Some Person" },
- new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- return null;
- }
- });
- fail("EmptyResultDataAccessException expected");
- }
- catch (EmptyResultDataAccessException expected) {
- assertThat(true).isTrue();
- }
- }
-
-}
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java
deleted file mode 100644
index ba76a91468..0000000000
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2005-2016 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
- *
- * https://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.itest.manager;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.ldap.CommunicationException;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.itest.transaction.compensating.manager.DummyDao;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import org.springframework.transaction.CannotCreateTransactionException;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-/**
- * Integration tests for
- * {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
- *
- * @author Mattias Hellborg Arthursson
- */
-@ContextConfiguration(locations = { "/conf/missingLdapAndJdbcTransactionTestContext.xml" })
-public class ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests
- extends AbstractJUnit4SpringContextTests {
-
- private static Logger log = LoggerFactory
- .getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class);
-
- @Autowired
- @Qualifier("dummyDao")
- private DummyDao dummyDao;
-
- @Autowired
- private LdapTemplate ldapTemplate;
-
- @Autowired
- private JdbcTemplate jdbcTemplate;
-
- @Before
- public void prepareTestedInstance() throws Exception {
- if (TransactionSynchronizationManager.isSynchronizationActive()) {
- TransactionSynchronizationManager.clearSynchronization();
- }
- }
-
- @After
- public void cleanup() throws Exception {
- this.jdbcTemplate.execute("drop table PERSON if exists");
- }
-
- @Test
- public void verifyThatJdbcTransactionIsClosedIfLdapServerUnavailable_ldap179() {
- try {
- this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
- fail("CannotCreateTransactionException expected");
- }
- catch (CannotCreateTransactionException expected) {
- assertThat(expected.getCause() instanceof CommunicationException).isTrue();
- }
-
- // Make sure there is no transaction synchronization
- assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
-
- try {
- this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
- fail("CannotCreateTransactionException expected");
- }
- catch (CannotCreateTransactionException expected) {
- assertThat(expected.getCause() instanceof CommunicationException).isTrue();
- }
- }
-
-}
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java
deleted file mode 100644
index e83cedbaf2..0000000000
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright 2005-2016 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
- *
- * https://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.itest.manager;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.ldap.NameNotFoundException;
-import org.springframework.ldap.core.AttributesMapper;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
-import org.springframework.ldap.itest.transaction.compensating.manager.DummyDao;
-import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-/**
- * Integration tests for
- * {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}
- * with namespace configuration.
- *
- * @author Mattias Hellborg Arthursson
- */
-@ContextConfiguration(locations = { "/conf/ldapAndJdbcTransactionNamespaceTestContext.xml" })
-public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
-
- private static Logger log = LoggerFactory
- .getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class);
-
- @Autowired
- @Qualifier("dummyDao")
- private DummyDao dummyDao;
-
- @Autowired
- private LdapTemplate ldapTemplate;
-
- @Autowired
- private JdbcTemplate jdbcTemplate;
-
- @Before
- public void prepareTestedInstance() throws Exception {
- if (TransactionSynchronizationManager.isSynchronizationActive()) {
- TransactionSynchronizationManager.clearSynchronization();
- }
-
- this.jdbcTemplate.execute("drop table PERSON if exists");
- this.jdbcTemplate
- .execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
- this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
- new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
- }
-
- @After
- public void cleanup() throws Exception {
- this.jdbcTemplate.execute("drop table PERSON if exists");
- }
-
- @Test
- public void testCreateWithException() {
- try {
- this.dummyDao.createWithException("Sweden", "company1", "some testperson", "testperson",
- "some description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- // Verify that no entry was created
- try {
- this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- try {
- this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'", new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- return null;
- }
- });
- fail("EmptyResultDataAccessException expected");
- }
- catch (EmptyResultDataAccessException expected) {
- assertThat(true).isTrue();
- }
- }
-
- @Test
- public void testCreate() {
- this.dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
-
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- Object dbResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'",
- new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- return new Object();
- }
- });
- assertThat(ldapResult).isNotNull();
- assertThat(dbResult).isNotNull();
-
- this.ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
- }
-
- @Test
- public void testUpdateWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- this.dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Person");
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
- new Object[] { "Some Person" }, new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- assertThat(rs.getString("lastname")).isEqualTo("Person");
- assertThat(rs.getString("description")).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- assertThat(ldapResult).isNotNull();
- assertThat(jdbcResult).isNotNull();
- }
-
- @Test
- public void testUpdate() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- this.dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
-
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
- new Object[] { "Some Person" }, new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- assertThat(rs.getString("lastname")).isEqualTo("Updated Person");
- assertThat(rs.getString("description")).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(ldapResult).isNotNull();
- assertThat(jdbcResult).isNotNull();
- this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
- }
-
- @Test
- public void testUpdateAndRenameWithException() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that entry was not moved.
- try {
- this.ldapTemplate.lookup(newDn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that original entry was not updated.
- Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
- return new Object();
- }
- });
- assertThat(object).isNotNull();
- }
-
- @Test
- public void testUpdateAndRename() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- // Perform test
- this.dummyDao.updateAndRename(dn, newDn, "Updated description");
-
- // Verify that entry was moved and updated.
- Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(object).isNotNull();
- this.dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
- }
-
- @Test
- public void testModifyAttributesWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify result - check that the operation was properly rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Person");
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- }
-
- @Test
- public void testModifyAttributes() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
-
- // Verify result - check that the operation was not rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- this.dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
- }
-
- @Test
- public void testUnbindWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.unbindWithException(dn, "Some Person");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify result - check that the operation was properly rolled back
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- // Just verify that the entry still exists.
- return new Object();
- }
- });
-
- Object jdbcResult = this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
- new Object[] { "Some Person" }, new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- // Just verify that the entry still exists.
- return new Object();
- }
- });
-
- assertThat(ldapResult).isNotNull();
- assertThat(jdbcResult).isNotNull();
- }
-
- @Test
- public void testUnbind() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- this.dummyDao.unbind(dn, "Some Person");
-
- try {
- // Verify result - check that the operation was not rolled back
- this.ldapTemplate.lookup(dn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- try {
- this.jdbcTemplate.queryForObject("select * from PERSON where fullname=?", new Object[] { "Some Person" },
- new RowMapper() {
- public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
- return null;
- }
- });
- fail("EmptyResultDataAccessException expected");
- }
- catch (EmptyResultDataAccessException expected) {
- assertThat(true).isTrue();
- }
- }
-
-}
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java
deleted file mode 100644
index bb844578ba..0000000000
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright 2005-2016 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
- *
- * https://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.itest.manager.hibernate;
-
-import java.util.List;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.ldap.NameNotFoundException;
-import org.springframework.ldap.core.AttributesMapper;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
-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.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager;
-import org.springframework.orm.hibernate5.HibernateTemplate;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-/**
- * Integration tests for {@link ContextSourceAndHibernateTransactionManager}.
- *
- * @author Hans Westerbeek
- */
-@ContextConfiguration(locations = { "/conf/ldapAndHibernateTransactionTestContext.xml" })
-public class ContextSourceAndHibernateTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
-
- private static Logger log = LoggerFactory
- .getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class);
-
- @Autowired
- @Qualifier("dummyDao")
- private OrgPersonDao dummyDao;
-
- @Autowired
- private LdapTemplate ldapTemplate;
-
- @Autowired
- private HibernateTemplate hibernateTemplate;
-
- @Autowired
- private SessionFactory sessionFactory;
-
- @Before
- public void prepareTest() throws Exception {
- if (TransactionSynchronizationManager.isSynchronizationActive()) {
- TransactionSynchronizationManager.clearSynchronization();
- }
-
- OrgPerson person = new OrgPerson();
- person.setId(1);
- person.setLastname("Person");
- person.setFullname("Some Person");
- person.setDescription("Sweden, Company1, Some Person");
- person.setCountry("Sweden");
- person.setCompany("Company1");
- // "Some Person", "Person", "Sweden, Company1, Some Person"
- // avoid the transaction manager we have configured, do it manually
- Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.saveOrUpdate(person);
- tx.commit();
- session.close();
-
- }
-
- @After
- public void cleanup() throws Exception {
- // probably the wrong idea, this will use the thing i am trying to
- // test..
-
- Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- Query query = session.createQuery("delete from OrgPerson");
- query.executeUpdate();
- tx.commit();
- session.close();
- }
-
- @Test
- public void testCreateWithException() {
- OrgPerson person = new OrgPerson();
-
- person.setId(2);
- person.setDescription("some description");
- person.setFullname("Some testperson");
- person.setLastname("testperson");
- person.setCountry("Sweden");
- person.setCompany("company1");
-
- try {
- this.dummyDao.createWithException(person);
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- // Verify that no entry was created in ldap or hibernate db
- try {
- this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- List result = this.hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname",
- "lastname", person.getLastname());
- assertThat(result.size() == 0).isTrue();
-
- }
-
- @Test
- public void testCreate() {
- OrgPerson person = new OrgPerson();
-
- person.setId(2);
- person.setDescription("some description");
- person.setFullname("Some testperson");
- person.setLastname("testperson");
- person.setCountry("Sweden");
- person.setCompany("company1");
- // dummyDao.create("Sweden", "company1", "some testperson",
- // "testperson", "some description");
-
- this.dummyDao.create(person);
- person = null;
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 2);
- assertThat(ldapResult).isNotNull();
- assertThat(fromDb).isNotNull();
- }
-
- @Test
- public void testUpdateWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- OrgPerson originalPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- originalPerson.setLastname("fooo");
- try {
- this.dummyDao.updateWithException(originalPerson);
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).as("Person").isNotNull();
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- OrgPerson notUpdatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- assertThat(notUpdatedPerson.getLastname()).isEqualTo("Person");
- assertThat(notUpdatedPerson.getDescription()).isEqualTo("Sweden, Company1, Some Person");
-
- assertThat(ldapResult).isNotNull();
- // no need to assert if notUpdatedPerson exists
- }
-
- @Test
- public void testUpdate() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- person.setLastname("Updated Person");
- person.setDescription("Updated description");
-
- this.dummyDao.update(person);
-
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
- assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
- assertThat(ldapResult).isNotNull();
- }
-
- @Test
- public void testUpdateAndRenameWithException() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- person.setLastname("Updated Person");
- person.setDescription("Updated description");
-
- try {
- // Perform test
- this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that entry was not moved.
- try {
- this.ldapTemplate.lookup(newDn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that original entry was not updated.
- Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
- return new Object();
- }
- });
- assertThat(object).isNotNull();
- }
-
- @Test
- public void testUpdateAndRename() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- // Perform test
- this.dummyDao.updateAndRename(dn, newDn, "Updated description");
-
- // Verify that entry was moved and updated.
- Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(object).isNotNull();
- }
-
- @Test
- public void testModifyAttributesWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify result - check that the operation was properly rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Person");
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- }
-
- @Test
- public void testModifyAttributes() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
-
- // Verify result - check that the operation was not rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- }
-
- @Test
- public void testUnbindWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
-
- try {
- // Perform test
- this.dummyDao.unbindWithException(person);
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- person = null;
- // Verify result - check that the operation was properly rolled back
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- // Just verify that the entry still exists.
- return new Object();
- }
- });
-
- person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1); // will
- // throw
- // exception
- // of
- // person
- // does
- // not
- // exist
-
- assertThat(ldapResult).isNotNull();
- }
-
- @Test
- public void testUnbind() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- this.dummyDao.unbind(person);
-
- try {
- // Verify result - check that the operation was not rolled back
- this.ldapTemplate.lookup(dn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- person = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 1);
- assertThat(person).isNull();
- }
-
-}
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java
deleted file mode 100644
index 0f73056b8e..0000000000
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2005-2016 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
- *
- * https://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.itest.manager.hibernate;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.ldap.CommunicationException;
-import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson;
-import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import org.springframework.transaction.CannotCreateTransactionException;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Integration tests for
- * {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager}.
- *
- * @author Hans Westerbeek
- */
-@ContextConfiguration(locations = { "/conf/missingLdapAndHibernateTransactionTestContext.xml" })
-public class ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests
- extends AbstractJUnit4SpringContextTests {
-
- private static Logger log = LoggerFactory
- .getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class);
-
- @Autowired
- @Qualifier("dummyDao")
- private OrgPersonDao dummyDao;
-
- @Before
- public void prepareTest() throws Exception {
- if (TransactionSynchronizationManager.isSynchronizationActive()) {
- TransactionSynchronizationManager.clearSynchronization();
- }
- }
-
- @Test
- public void testCreate() {
- OrgPerson person = new OrgPerson();
-
- person.setId(2);
- person.setDescription("some description");
- person.setFullname("Some testperson");
- person.setLastname("testperson");
- person.setCountry("Sweden");
- person.setCompany("company1");
-
- try {
- this.dummyDao.create(person);
- }
- catch (CannotCreateTransactionException expected) {
- assertThat(expected.getCause() instanceof CommunicationException).isTrue();
- }
-
- // Make sure there is no transaction synchronization
- assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
-
- try {
- this.dummyDao.create(person);
- }
- catch (CannotCreateTransactionException expected) {
- assertThat(expected.getCause() instanceof CommunicationException).isTrue();
- }
- }
-
-}
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java
deleted file mode 100644
index 97f4bf254c..0000000000
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright 2005-2016 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
- *
- * https://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.itest.manager.hibernate;
-
-import java.util.List;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.ldap.NameNotFoundException;
-import org.springframework.ldap.core.AttributesMapper;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTests;
-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.hibernate5.HibernateTemplate;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-/**
- * Integration tests for
- * {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager}
- * with namespace configuration.
- *
- * @author Hans Westerbeek
- */
-@ContextConfiguration(locations = { "/conf/ldapAndHibernateTransactionNamespaceTestContext.xml" })
-public class ContextSourceAndHibernateTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
-
- private static Logger log = LoggerFactory
- .getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class);
-
- @Autowired
- @Qualifier("dummyDao")
- private OrgPersonDao dummyDao;
-
- @Autowired
- private LdapTemplate ldapTemplate;
-
- @Autowired
- private HibernateTemplate hibernateTemplate;
-
- @Autowired
- private SessionFactory sessionFactory;
-
- @Before
- public void prepareTest() throws Exception {
- if (TransactionSynchronizationManager.isSynchronizationActive()) {
- TransactionSynchronizationManager.clearSynchronization();
- }
-
- OrgPerson person = new OrgPerson();
- person.setId(1);
- person.setLastname("Person");
- person.setFullname("Some Person");
- person.setDescription("Sweden, Company1, Some Person");
- person.setCountry("Sweden");
- person.setCompany("Company1");
- // "Some Person", "Person", "Sweden, Company1, Some Person"
- // avoid the transaction manager we have configured, do it manually
- Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.saveOrUpdate(person);
- tx.commit();
- session.close();
-
- }
-
- @After
- public void cleanup() throws Exception {
- // probably the wrong idea, this will use the thing i am trying to
- // test..
-
- Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- Query query = session.createQuery("delete from OrgPerson");
- query.executeUpdate();
- tx.commit();
- session.close();
- }
-
- @Test
- public void testCreateWithException() {
- OrgPerson person = new OrgPerson();
-
- person.setId(2);
- person.setDescription("some description");
- person.setFullname("Some testperson");
- person.setLastname("testperson");
- person.setCountry("Sweden");
- person.setCompany("company1");
-
- try {
- this.dummyDao.createWithException(person);
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- // Verify that no entry was created in ldap or hibernate db
- try {
- this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- List result = this.hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname",
- "lastname", person.getLastname());
- assertThat(result.size() == 0).isTrue();
-
- }
-
- @Test
- public void testCreate() {
- OrgPerson person = new OrgPerson();
-
- person.setId(2);
- person.setDescription("some description");
- person.setFullname("Some testperson");
- person.setLastname("testperson");
- person.setCountry("Sweden");
- person.setCompany("company1");
- // dummyDao.create("Sweden", "company1", "some testperson",
- // "testperson", "some description");
-
- this.dummyDao.create(person);
- person = null;
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
- OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 2);
- assertThat(ldapResult).isNotNull();
- assertThat(fromDb).isNotNull();
- }
-
- @Test
- public void testUpdateWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- OrgPerson originalPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- originalPerson.setLastname("fooo");
- try {
- this.dummyDao.updateWithException(originalPerson);
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- log.debug("Verifying result");
-
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).as("Person").isNotNull();
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- OrgPerson notUpdatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- assertThat(notUpdatedPerson.getLastname()).isEqualTo("Person");
- assertThat(notUpdatedPerson.getDescription()).isEqualTo("Sweden, Company1, Some Person");
-
- assertThat(ldapResult).isNotNull();
- // no need to assert if notUpdatedPerson exists
- }
-
- @Test
- public void testUpdate() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- person.setLastname("Updated Person");
- person.setDescription("Updated description");
-
- this.dummyDao.update(person);
-
- log.debug("Verifying result");
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
- assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
- assertThat(ldapResult).isNotNull();
- }
-
- @Test
- public void testUpdateAndRenameWithException() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- person.setLastname("Updated Person");
- person.setDescription("Updated description");
-
- try {
- // Perform test
- this.dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that entry was not moved.
- try {
- this.ldapTemplate.lookup(newDn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify that original entry was not updated.
- Object object = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
- return new Object();
- }
- });
- assertThat(object).isNotNull();
- }
-
- @Test
- public void testUpdateAndRename() {
- String dn = "cn=Some Person2,ou=company1,ou=Sweden";
- String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
- // Perform test
- this.dummyDao.updateAndRename(dn, newDn, "Updated description");
-
- // Verify that entry was moved and updated.
- Object object = this.ldapTemplate.lookup(newDn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(object).isNotNull();
- }
-
- @Test
- public void testModifyAttributesWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- try {
- // Perform test
- this.dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- // Verify result - check that the operation was properly rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Person");
- assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- }
-
- @Test
- public void testModifyAttributes() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- this.dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
-
- // Verify result - check that the operation was not rolled back
- Object result = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
- assertThat(attributes.get("description").get()).isEqualTo("Updated description");
- return new Object();
- }
- });
-
- assertThat(result).isNotNull();
- }
-
- @Test
- public void testUnbindWithException() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
-
- try {
- // Perform test
- this.dummyDao.unbindWithException(person);
- fail("DummyException expected");
- }
- catch (DummyException expected) {
- assertThat(true).isTrue();
- }
-
- person = null;
- // Verify result - check that the operation was properly rolled back
- Object ldapResult = this.ldapTemplate.lookup(dn, new AttributesMapper() {
- public Object mapFromAttributes(Attributes attributes) throws NamingException {
- // Just verify that the entry still exists.
- return new Object();
- }
- });
-
- person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1); // will
- // throw
- // exception
- // of
- // person
- // does
- // not
- // exist
-
- assertThat(ldapResult).isNotNull();
- }
-
- @Test
- public void testUnbind() {
- String dn = "cn=Some Person,ou=company1,ou=Sweden";
- // Perform test
- OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, 1);
- this.dummyDao.unbind(person);
-
- try {
- // Verify result - check that the operation was not rolled back
- this.ldapTemplate.lookup(dn);
- fail("NameNotFoundException expected");
- }
- catch (NameNotFoundException expected) {
- assertThat(true).isTrue();
- }
-
- person = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, 1);
- assertThat(person).isNull();
- }
-
-}
diff --git a/test/integration-tests/src/test/resources/conf/OrgPerson.hbm.xml b/test/integration-tests/src/test/resources/conf/OrgPerson.hbm.xml
deleted file mode 100755
index 543841471f..0000000000
--- a/test/integration-tests/src/test/resources/conf/OrgPerson.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml
deleted file mode 100755
index b7c100cbac..0000000000
--- a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionNamespaceTestContext.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- conf/OrgPerson.hbm.xml
-
-
-
-
- hibernate.dialect=org.hibernate.dialect.HSQLDialect
- hibernate.hbm2ddl.auto=create
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml
deleted file mode 100755
index 4b0546ed6d..0000000000
--- a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- conf/OrgPerson.hbm.xml
-
-
-
-
- hibernate.dialect=org.hibernate.dialect.HSQLDialect
- hibernate.hbm2ddl.auto=create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionNamespaceTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionNamespaceTestContext.xml
deleted file mode 100644
index 4957f3e27f..0000000000
--- a/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionNamespaceTestContext.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml
deleted file mode 100644
index 80f105c43c..0000000000
--- a/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml
deleted file mode 100755
index 3d04bcdb40..0000000000
--- a/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- conf/OrgPerson.hbm.xml
-
-
-
-
- hibernate.dialect=org.hibernate.dialect.HSQLDialect
- hibernate.hbm2ddl.auto=create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PROPAGATION_REQUIRES_NEW
-
-
-
-
diff --git a/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml
deleted file mode 100644
index deee2666f9..0000000000
--- a/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PROPAGATION_REQUIRES_NEW
-
-
-
-
From d1a7944579ba3f737c1937ca80819baa80bd58df Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 14:08:13 -0600
Subject: [PATCH 03/67] Update to Spring Framework 7
Closes gh-1110
---
dependencies/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 31015d08d3..2cdf3de625 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -20,7 +20,7 @@ dependencies {
api platform("org.springframework:spring-framework-bom:$springFrameworkVersion")
api platform("org.springframework.data:spring-data-bom:$springDataVersion")
} else {
- api platform("org.springframework:spring-framework-bom:6.2.7")
+ api platform("org.springframework:spring-framework-bom:7.0.0-M6")
api platform("org.springframework.data:spring-data-bom:2021.2.18")
}
api platform("org.springframework.security:spring-security-bom:6.4.5")
From a2bc78bcf5910d00fa6d216785d89fb9dcc801ef Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 14:37:20 -0600
Subject: [PATCH 04/67] Use DefaultConversionService
This commit changes DefaultObjectDirectoryMapper to use
DefaultConversionService, preserving standard converters
that were there previous to deprecating ConverterManager.
Closes gh-1101
---
.../core/impl/DefaultObjectDirectoryMapper.java | 4 ++--
.../impl/DefaultObjectDirectoryMapperTests.java | 16 +++++++++++++++-
.../UnitTestPersonWithIndexedDnAttributes.java | 14 +++++++++++++-
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java
index cd69fabc17..b65bbd8efb 100644
--- a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java
+++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java
@@ -39,7 +39,7 @@
import org.springframework.LdapDataEntry;
import org.springframework.core.convert.ConversionService;
-import org.springframework.core.convert.support.GenericConversionService;
+import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.ldap.convert.ConverterUtils;
import org.springframework.ldap.filter.AndFilter;
import org.springframework.ldap.filter.EqualsFilter;
@@ -78,7 +78,7 @@ public DefaultObjectDirectoryMapper() {
}
private static ConverterManager createDefaultConverterManager() {
- GenericConversionService conversionService = new GenericConversionService();
+ DefaultConversionService conversionService = new DefaultConversionService();
ConverterUtils.addDefaultConverters(conversionService);
return new ConversionServiceConverterManager(conversionService);
}
diff --git a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java
index f2ea363b42..595b48c2b0 100644
--- a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java
+++ b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2023 the original author or authors.
+ * Copyright 2005-2025 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.
@@ -143,6 +143,20 @@ public void mapToLdapDataEntryWhenCustomConversionServiceThenUses() {
verify(conversionService).convert(any(), any(Class.class));
}
+ // gh-1101
+ @Test
+ public void managerWhenEntityMapsLongThenConverts() {
+ this.tested.manageClass(UnitTestPersonWithIndexedDnAttributes.class);
+ UnitTestPersonWithIndexedDnAttributes testPerson = new UnitTestPersonWithIndexedDnAttributes();
+ testPerson.setFullName("Some Person");
+ testPerson.setAge(34L);
+ DirContextAdapter adapter = new DirContextAdapter("cn=Some Person, ou=Some Company, c=Sweden");
+ this.tested.mapToLdapDataEntry(testPerson, adapter);
+ assertThat(adapter.getStringAttribute("age")).isEqualTo("34");
+ testPerson = this.tested.mapFromLdapDataEntry(adapter, UnitTestPersonWithIndexedDnAttributes.class);
+ assertThat(testPerson.getAge()).isEqualTo(34L);
+ }
+
private void assertField(DefaultObjectDirectoryMapper.EntityData entityData, String fieldName,
String expectedAttributeName, String expectedDnAttributeName, boolean expectedBinary,
boolean expectedTransient, boolean expectedList, boolean expectedReadOnly) {
diff --git a/core/src/test/java/org/springframework/ldap/odm/core/impl/UnitTestPersonWithIndexedDnAttributes.java b/core/src/test/java/org/springframework/ldap/odm/core/impl/UnitTestPersonWithIndexedDnAttributes.java
index 4e82f0b869..370bc0af16 100644
--- a/core/src/test/java/org/springframework/ldap/odm/core/impl/UnitTestPersonWithIndexedDnAttributes.java
+++ b/core/src/test/java/org/springframework/ldap/odm/core/impl/UnitTestPersonWithIndexedDnAttributes.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2013 the original author or authors.
+ * Copyright 2005-2025 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.
@@ -18,6 +18,7 @@
import javax.naming.Name;
+import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.DnAttribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
@@ -40,6 +41,9 @@ public class UnitTestPersonWithIndexedDnAttributes {
@DnAttribute(value = "c", index = 0)
private String country;
+ @Attribute(name = "age")
+ private Long age;
+
public void setFullName(String fullName) {
this.fullName = fullName;
}
@@ -52,4 +56,12 @@ public void setCountry(String country) {
this.country = country;
}
+ public Long getAge() {
+ return this.age;
+ }
+
+ public void setAge(Long age) {
+ this.age = age;
+ }
+
}
From 56f5854c1e6948f33de77a18e6df8fedbedb789c Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 14:48:51 -0600
Subject: [PATCH 05/67] Remove Unused Files
Issue gh-1109
---
.../manager/LdapAndJdbcDummyDaoImpl.java | 199 ------------------
.../manager/hibernate/OrgPerson.java | 152 -------------
.../manager/hibernate/OrgPersonDao.java | 41 ----
3 files changed, 392 deletions(-)
delete mode 100644 test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java
delete mode 100755 test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPerson.java
delete mode 100755 test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPersonDao.java
diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java
deleted file mode 100644
index 1893fb6f96..0000000000
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2005-2013 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
- *
- * https://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.itest.transaction.compensating.manager;
-
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.ldap.core.DirContextAdapter;
-import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class LdapAndJdbcDummyDaoImpl implements DummyDao {
-
- private LdapTemplate ldapTemplate;
-
- private JdbcTemplate jdbcTemplate;
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- public void setLdapTemplate(LdapTemplate ldapTemplate) {
- this.ldapTemplate = ldapTemplate;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#createWithException(java.lang
- * .String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void createWithException(String country, String company, String fullname, String lastname,
- String description) {
- create(country, company, fullname, lastname, description);
- throw new DummyException("This method failed");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.ldap.transaction.support.DummyDao#create(java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void create(String country, String company, String fullname, String lastname, String description) {
- DistinguishedName dn = new DistinguishedName();
- dn.add("ou", country);
- dn.add("ou", company);
- dn.add("cn", fullname);
-
- DirContextAdapter ctx = new DirContextAdapter();
- ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
- ctx.setAttributeValue("cn", fullname);
- ctx.setAttributeValue("sn", lastname);
- ctx.setAttributeValue("description", description);
- this.ldapTemplate.bind(dn, ctx, null);
- this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
- new Object[] { fullname, lastname, description });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.ldap.transaction.support.DummyDao#update(java.lang.String,
- * java.lang.String, java.lang.String)
- */
- public void update(String dn, String fullname, String lastname, String description) {
- DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
- ctx.setAttributeValue("sn", lastname);
- ctx.setAttributeValue("description", description);
-
- this.ldapTemplate.modifyAttributes(ctx);
- this.jdbcTemplate.update("update PERSON set lastname=?, description = ? where fullname = ?",
- new Object[] { lastname, description, fullname });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#updateWithException(java.lang
- * .String, java.lang.String, java.lang.String)
- */
- public void updateWithException(String dn, String fullname, String lastname, String description) {
- update(dn, fullname, lastname, description);
- throw new DummyException("This method failed.");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#updateAndRename(java.lang.
- * String, java.lang.String, java.lang.String)
- */
- public void updateAndRename(String dn, String newDn, String description) {
- DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
- ctx.setAttributeValue("description", description);
-
- this.ldapTemplate.modifyAttributes(ctx);
- this.ldapTemplate.rename(dn, newDn);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#updateAndRenameWithException(
- * java.lang.String, java.lang.String, java.lang.String)
- */
- public void updateAndRenameWithException(String dn, String newDn, String description) {
- updateAndRename(dn, newDn, description);
- throw new DummyException("This method failed.");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#modifyAttributes(java.lang.
- * String, java.lang.String, java.lang.String)
- */
- public void modifyAttributes(String dn, String lastName, String description) {
- DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
- ctx.setAttributeValue("sn", lastName);
- ctx.setAttributeValue("description", description);
-
- this.ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#modifyAttributesWithException
- * (java.lang.String, java.lang.String, java.lang.String)
- */
- public void modifyAttributesWithException(String dn, String lastName, String description) {
- modifyAttributes(dn, lastName, description);
- throw new DummyException("This method failed.");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.ldap.transaction.support.DummyDao#unbind(java.lang.String)
- */
- public void unbind(String dn, String fullname) {
- this.ldapTemplate.unbind(dn);
- this.jdbcTemplate.update("delete from PERSON where fullname=?", new Object[] { fullname });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.ldap.transaction.support.DummyDao#unbindWithException(java.lang
- * .String)
- */
- public void unbindWithException(String dn, String fullname) {
- unbind(dn, fullname);
- throw new DummyException("This operation failed.");
- }
-
- @Override
- public void deleteRecursively(String dn) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void deleteRecursivelyWithException(String dn) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void createRecursivelyAndUnbindSubnode() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void createRecursivelyAndUnbindSubnodeWithException() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPerson.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPerson.java
deleted file mode 100755
index 130734c961..0000000000
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPerson.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2005-2023 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
- *
- * https://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.itest.transaction.compensating.manager.hibernate;
-
-/**
- * Pojo for use with the ContextSourceAndHibernateTransactionManager integration tests
- *
- * @author Hans Westerbeek
- *
- */
-public class OrgPerson {
-
- private Integer id;
-
- private String fullname;
-
- private String lastname;
-
- private String company;
-
- private String country;
-
- private String description;
-
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getFullname() {
- return this.fullname;
- }
-
- public void setFullname(String fullname) {
- this.fullname = fullname;
- }
-
- public String getLastname() {
- return this.lastname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public String getCountry() {
- return this.country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getCompany() {
- return this.company;
- }
-
- public void setCompany(String company) {
- this.company = company;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final OrgPerson other = (OrgPerson) obj;
- if (this.company == null) {
- if (other.company != null) {
- return false;
- }
- }
- else if (!this.company.equals(other.company)) {
- return false;
- }
- if (this.country == null) {
- if (other.country != null) {
- return false;
- }
- }
- else if (!this.country.equals(other.country)) {
- return false;
- }
- if (this.description == null) {
- if (other.description != null) {
- return false;
- }
- }
- else if (!this.description.equals(other.description)) {
- return false;
- }
- if (this.fullname == null) {
- if (other.fullname != null) {
- return false;
- }
- }
- else if (!this.fullname.equals(other.fullname)) {
- return false;
- }
- if (this.lastname == null) {
- if (other.lastname != null) {
- return false;
- }
- }
- else if (!this.lastname.equals(other.lastname)) {
- return false;
- }
- return true;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.company == null) ? 0 : this.company.hashCode());
- result = prime * result + ((this.country == null) ? 0 : this.country.hashCode());
- result = prime * result + ((this.description == null) ? 0 : this.description.hashCode());
- result = prime * result + ((this.fullname == null) ? 0 : this.fullname.hashCode());
- result = prime * result + ((this.lastname == null) ? 0 : this.lastname.hashCode());
- return result;
- }
-
-}
diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPersonDao.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPersonDao.java
deleted file mode 100755
index ddbdec7f76..0000000000
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/OrgPersonDao.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2005-2023 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
- *
- * https://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.itest.transaction.compensating.manager.hibernate;
-
-public interface OrgPersonDao {
-
- void createWithException(OrgPerson person);
-
- void create(OrgPerson person);
-
- void update(OrgPerson person);
-
- void updateWithException(OrgPerson person);
-
- void updateAndRename(String dn, String newDn, String updatedDescription);
-
- void updateAndRenameWithException(String dn, String newDn, String updatedDescription);
-
- void modifyAttributes(String dn, String lastName, String description);
-
- void modifyAttributesWithException(String dn, String lastName, String description);
-
- void unbind(OrgPerson person);
-
- void unbindWithException(OrgPerson person);
-
-}
From 9d0c616cd14fd3b2d45a54e2bac39fa29df47c12 Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 15:48:04 -0600
Subject: [PATCH 06/67] Update Dependabot for 4.x
---
.github/dependabot.yml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 3235155f83..a592f7610b 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -2,6 +2,20 @@ version: 2
updates:
- package-ecosystem: gradle
target-branch: main
+ milestone: 97 # 4.0.x
+ directory: /
+ schedule:
+ interval: daily
+ time: '03:40'
+ timezone: Etc/UTC
+ labels:
+ - 'type: dependency-upgrade'
+ - 'in: build'
+ ignore:
+ - dependency-name: org.apache.directory.server:*
+ - dependency-name: org.apache.directory.shared:*
+ - package-ecosystem: gradle
+ target-branch: 3.3.x
milestone: 79 # 3.3.x
directory: /
schedule:
From 19205f46ded3a123ff27d3657e0b441fecc5745a Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Mon, 16 Jun 2025 15:49:40 -0600
Subject: [PATCH 07/67] Update to Gradle 8.14.2
Closes gh-1111
---
gradle/wrapper/gradle-wrapper.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1e2fbf0d45..0b55a3bd94 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
From cdc05aa3ada4d18ae16ec5f5eec78d134f7319d3 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 3 Jun 2025 03:32:31 +0000
Subject: [PATCH 08/67] Bump
io.spring.javaformat:spring-javaformat-gradle-plugin
Bumps [io.spring.javaformat:spring-javaformat-gradle-plugin](https://github.com/spring-io/spring-javaformat) from 0.0.44 to 0.0.46.
- [Release notes](https://github.com/spring-io/spring-javaformat/releases)
- [Commits](https://github.com/spring-io/spring-javaformat/compare/v0.0.44...v0.0.46)
---
updated-dependencies:
- dependency-name: io.spring.javaformat:spring-javaformat-gradle-plugin
dependency-version: 0.0.46
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
buildSrc/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index c17b2d54eb..ad5ea6e725 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -89,7 +89,7 @@ dependencies {
implementation 'com.apollographql.apollo:apollo-runtime:2.5.14'
implementation 'com.github.ben-manes:gradle-versions-plugin:0.52.0'
implementation 'com.github.spullara.mustache.java:compiler:0.9.14'
- implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.44'
+ implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.46'
implementation 'io.spring.gradle:spring-security-release-plugin:1.0.6'
implementation 'io.spring.nohttp:nohttp-gradle:0.0.11'
implementation 'net.sourceforge.htmlunit:htmlunit:2.70.0'
From c34960196f59f81ae409055d701c9471a9b7ccdc Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed, 4 Jun 2025 03:49:00 +0000
Subject: [PATCH 09/67] Bump io.spring.develocity.conventions from 0.0.22 to
0.0.23
Bumps [io.spring.develocity.conventions](https://github.com/spring-io/develocity-conventions) from 0.0.22 to 0.0.23.
- [Release notes](https://github.com/spring-io/develocity-conventions/releases)
- [Commits](https://github.com/spring-io/develocity-conventions/compare/v0.0.22...v0.0.23)
---
updated-dependencies:
- dependency-name: io.spring.develocity.conventions
dependency-version: 0.0.23
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
settings.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/settings.gradle b/settings.gradle
index 760c470ffa..61d487f8ee 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -9,7 +9,7 @@ pluginManagement {
}
plugins {
- id "io.spring.develocity.conventions" version "0.0.22"
+ id "io.spring.develocity.conventions" version "0.0.23"
}
dependencyResolutionManagement {
From 001750c504d5f805c88010a397027a57c4e3771b Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 10 Jun 2025 03:10:09 +0000
Subject: [PATCH 10/67] Bump io.micrometer:micrometer-bom from 1.14.7 to 1.14.8
Bumps [io.micrometer:micrometer-bom](https://github.com/micrometer-metrics/micrometer) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/micrometer-metrics/micrometer/releases)
- [Commits](https://github.com/micrometer-metrics/micrometer/compare/v1.14.7...v1.14.8)
---
updated-dependencies:
- dependency-name: io.micrometer:micrometer-bom
dependency-version: 1.14.8
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
dependencies/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 2cdf3de625..0346944094 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -25,7 +25,7 @@ dependencies {
}
api platform("org.springframework.security:spring-security-bom:6.4.5")
api platform('com.fasterxml.jackson:jackson-bom:2.18.4')
- api platform("io.micrometer:micrometer-bom:1.14.7")
+ api platform("io.micrometer:micrometer-bom:1.14.8")
api platform("io.micrometer:micrometer-tracing-bom:1.4.6")
api platform("org.junit:junit-bom:5.12.2")
constraints {
From 063567258ee9756d742b842cabd325d4efaf3437 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 20 May 2025 03:34:40 +0000
Subject: [PATCH 11/67] Bump org.springframework.security:spring-security-bom
Bumps [org.springframework.security:spring-security-bom](https://github.com/spring-projects/spring-security) from 6.4.5 to 6.4.6.
- [Release notes](https://github.com/spring-projects/spring-security/releases)
- [Changelog](https://github.com/spring-projects/spring-security/blob/main/RELEASE.adoc)
- [Commits](https://github.com/spring-projects/spring-security/compare/6.4.5...6.4.6)
---
updated-dependencies:
- dependency-name: org.springframework.security:spring-security-bom
dependency-version: 6.4.6
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
dependencies/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 0346944094..51f00678ae 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -23,7 +23,7 @@ dependencies {
api platform("org.springframework:spring-framework-bom:7.0.0-M6")
api platform("org.springframework.data:spring-data-bom:2021.2.18")
}
- api platform("org.springframework.security:spring-security-bom:6.4.5")
+ api platform("org.springframework.security:spring-security-bom:6.4.6")
api platform('com.fasterxml.jackson:jackson-bom:2.18.4')
api platform("io.micrometer:micrometer-bom:1.14.8")
api platform("io.micrometer:micrometer-tracing-bom:1.4.6")
From cb88ed8b03522a8c1bc5909eb9c30aa6f7720f89 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 10 Jun 2025 03:10:29 +0000
Subject: [PATCH 12/67] Bump io.micrometer:micrometer-tracing-bom from 1.4.6 to
1.4.7
Bumps [io.micrometer:micrometer-tracing-bom](https://github.com/micrometer-metrics/tracing) from 1.4.6 to 1.4.7.
- [Release notes](https://github.com/micrometer-metrics/tracing/releases)
- [Commits](https://github.com/micrometer-metrics/tracing/compare/v1.4.6...v1.4.7)
---
updated-dependencies:
- dependency-name: io.micrometer:micrometer-tracing-bom
dependency-version: 1.4.7
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
dependencies/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 51f00678ae..01b95bb5ff 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -26,7 +26,7 @@ dependencies {
api platform("org.springframework.security:spring-security-bom:6.4.6")
api platform('com.fasterxml.jackson:jackson-bom:2.18.4')
api platform("io.micrometer:micrometer-bom:1.14.8")
- api platform("io.micrometer:micrometer-tracing-bom:1.4.6")
+ api platform("io.micrometer:micrometer-tracing-bom:1.4.7")
api platform("org.junit:junit-bom:5.12.2")
constraints {
api "com.querydsl:querydsl-core:$queryDslVersion"
From 2cab480a761c7356762a55488258c4b17959ae08 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 16 Jun 2025 22:11:48 +0000
Subject: [PATCH 13/67] Bump com.fasterxml.jackson:jackson-bom from 2.18.4 to
2.19.1
Bumps [com.fasterxml.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 2.18.4 to 2.19.1.
- [Commits](https://github.com/FasterXML/jackson-bom/compare/jackson-bom-2.18.4...jackson-bom-2.19.1)
---
updated-dependencies:
- dependency-name: com.fasterxml.jackson:jackson-bom
dependency-version: 2.19.1
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
---
dependencies/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 01b95bb5ff..60bb03592e 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -24,7 +24,7 @@ dependencies {
api platform("org.springframework.data:spring-data-bom:2021.2.18")
}
api platform("org.springframework.security:spring-security-bom:6.4.6")
- api platform('com.fasterxml.jackson:jackson-bom:2.18.4')
+ api platform('com.fasterxml.jackson:jackson-bom:2.19.1')
api platform("io.micrometer:micrometer-bom:1.14.8")
api platform("io.micrometer:micrometer-tracing-bom:1.4.7")
api platform("org.junit:junit-bom:5.12.2")
From 14e63a537480d17382f3167b977aaca69eee3aec Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Thu, 17 Jul 2025 11:02:38 -0600
Subject: [PATCH 14/67] Fix Comment Typos
See gh-998
Co-Authored-By: kibeom lee <46297213+lkb85@users.noreply.github.com>
---
.../ldap/odm/typeconversion/impl/ConverterManagerImpl.java | 2 +-
.../apache/directory/server/core/avltree/ArrayMarshaller.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
mode change 100755 => 100644 core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java
diff --git a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java
old mode 100755
new mode 100644
index 3df19e20eb..c6a8dace79
--- a/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java
+++ b/core/src/main/java/org/springframework/ldap/odm/typeconversion/impl/ConverterManagerImpl.java
@@ -127,7 +127,7 @@ public boolean canConvert(Class> fromClass, String syntax, Class> toClass) {
public T convert(Object source, String syntax, Class toClass) {
Object result = null;
- // What are we converting form
+ // What are we converting from
Class> fromClass = source.getClass();
// Deal with primitives
diff --git a/test/integration-tests/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java b/test/integration-tests/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
index cdaa9d5fcb..42f05560b3 100644
--- a/test/integration-tests/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
+++ b/test/integration-tests/src/test/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
@@ -61,7 +61,7 @@ public ArrayMarshaller(Comparator comparator, Marshaller keyMarshaller) {
/**
* Creates a new instance of AvlTreeMarshaller with the default key Marshaller which
* uses Java Serialization.
- * @param comparator Comparator to be used for key comparision
+ * @param comparator Comparator to be used for key comparison
*/
public ArrayMarshaller(Comparator comparator) {
this.comparator = comparator;
From b5908cee7e06669af6211d1562f46eafd4c14f0d Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 16 Jun 2025 22:11:51 +0000
Subject: [PATCH 15/67] Bump org.slf4j:log4j-over-slf4j from 1.7.36 to 2.0.17
Bumps org.slf4j:log4j-over-slf4j from 1.7.36 to 2.0.17.
---
updated-dependencies:
- dependency-name: org.slf4j:log4j-over-slf4j
dependency-version: 2.0.17
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
---
dependencies/build.gradle | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 60bb03592e..40326cb695 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -57,10 +57,10 @@ dependencies {
api "junit:junit:4.13.2"
api "org.mockito:mockito-core:5.14.1"
api "org.mockito:mockito-junit-jupiter:5.14.1"
- api "org.slf4j:jcl-over-slf4j:1.7.36"
- api "org.slf4j:log4j-over-slf4j:1.7.36"
- api "org.slf4j:slf4j-api:1.7.36"
- api "org.slf4j:slf4j-log4j12:1.7.36"
+ api "org.slf4j:jcl-over-slf4j:2.0.17"
+ api "org.slf4j:log4j-over-slf4j:2.0.17"
+ api "org.slf4j:slf4j-api:2.0.17"
+ api "org.slf4j:slf4j-log4j12:2.0.17"
api "org.springframework.security:spring-security-config"
api "org.springframework.security:spring-security-core"
api "org.springframework.security:spring-security-ldap"
From 77ef6526ca89bd2131314c0b748cdb67673266c1 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 19 Jun 2025 03:18:48 +0000
Subject: [PATCH 16/67] Bump com.apollographql.apollo from 2.5.14 to 4.3.1
Bumps com.apollographql.apollo from 2.5.14 to 4.3.1.
---
updated-dependencies:
- dependency-name: com.apollographql.apollo
dependency-version: 4.3.1
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
---
buildSrc/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index ad5ea6e725..f90d10b39a 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -2,7 +2,7 @@ plugins {
id "java-gradle-plugin"
id "java"
id "groovy"
- id 'com.apollographql.apollo' version '2.5.14'
+ id 'com.apollographql.apollo' version '4.3.1'
}
sourceCompatibility = JavaVersion.VERSION_17
From 8734656d73edfd7ee3180d6c0a43afa54cba1c14 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 17 Jul 2025 16:57:02 +0000
Subject: [PATCH 17/67] Bump io.micrometer:micrometer-tracing-bom from 1.4.6 to
1.5.2
---
updated-dependencies:
- dependency-name: io.micrometer:micrometer-tracing-bom
dependency-version: 1.5.2
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
---
dependencies/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies/build.gradle b/dependencies/build.gradle
index 40326cb695..402fd5aaa3 100644
--- a/dependencies/build.gradle
+++ b/dependencies/build.gradle
@@ -26,7 +26,7 @@ dependencies {
api platform("org.springframework.security:spring-security-bom:6.4.6")
api platform('com.fasterxml.jackson:jackson-bom:2.19.1')
api platform("io.micrometer:micrometer-bom:1.14.8")
- api platform("io.micrometer:micrometer-tracing-bom:1.4.7")
+ api platform("io.micrometer:micrometer-tracing-bom:1.5.2")
api platform("org.junit:junit-bom:5.12.2")
constraints {
api "com.querydsl:querydsl-core:$queryDslVersion"
From 3d4f74aa3f0ede290c9edeb0e32955b4750fcb0b Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Thu, 17 Jul 2025 11:50:22 -0600
Subject: [PATCH 18/67] Update Core Tests to JUnit 5
Issue gh-1058
---
core/build.gradle | 7 +-
.../ldap/NamingExceptionTests.java | 2 +-
.../aot/hint/LdapCoreRuntimeHintsTests.java | 6 +-
...uesAuthenticationSourceDecoratorTests.java | 6 +-
.../LdapTemplateNamespaceHandlerTests.java | 32 ++++----
.../ldap/control/PagedResultTests.java | 2 +-
.../ldap/control/PagedResultsCookieTests.java | 2 +-
.../PagedResultsDirContextProcessorTests.java | 10 +--
...equestControlDirContextProcessorTests.java | 18 +++--
.../SortControlDirContextProcessorTests.java | 6 +-
...tingNameClassPairCallbackHandlerTests.java | 6 +-
.../ContextMapperCallbackHandlerTests.java | 22 +++---
.../ldap/core/DefaultLdapClientListTests.java | 6 +-
.../core/DefaultLdapClientLookupTests.java | 6 +-
.../core/DefaultLdapClientRenameTests.java | 6 +-
.../ldap/core/DefaultLdapClientTests.java | 6 +-
.../ldap/core/DirContextAdapterBugTests.java | 2 +-
.../ldap/core/DirContextAdapterTests.java | 6 +-
.../core/DistinguishedNameEditorTests.java | 6 +-
.../ldap/core/DistinguishedNameTests.java | 74 +++++++++++--------
.../ldap/core/LdapRdnComponentTests.java | 2 +-
.../ldap/core/LdapRdnTests.java | 31 ++++----
.../ldap/core/LdapTemplateListTests.java | 6 +-
.../ldap/core/LdapTemplateLookupTests.java | 6 +-
.../ldap/core/LdapTemplateOdmTests.java | 6 +-
.../ldap/core/LdapTemplateRenameTests.java | 6 +-
.../ldap/core/LdapTemplateTests.java | 6 +-
.../ldap/core/NameAwareAttributeTests.java | 2 +-
.../ldap/core/NameAwareAttributesTests.java | 2 +-
.../support/AbstractContextSourceTests.java | 2 +-
.../AggregateDirContextProcessorTests.java | 6 +-
.../BaseLdapPathBeanPostProcessorTests.java | 27 ++++---
...apperCallbackHandlerWithControlsTests.java | 22 +++---
...meClassPairResultCallbackHandlerTests.java | 6 +-
.../support/DefaultDirObjectFactoryTests.java | 6 +-
...faultIncrementalAttributesMapperTests.java | 6 +-
...DirContextAuthenticationStrategyTests.java | 11 ++-
.../core/support/LdapContextSourceTests.java | 25 ++++---
.../ldap/core/support/RangeOptionTests.java | 2 +-
...DirContextAuthenticationStrategyTests.java | 6 +-
.../support/SingleContextSourceTests.java | 6 +-
.../core/support/ldap294/Ldap294Tests.java | 2 +-
.../ldap/filter/AbstractFilterTests.java | 2 +-
.../ldap/filter/AndFilterTests.java | 2 +-
.../ldap/filter/EqualsFilterTests.java | 2 +-
.../GreaterThanOrEqualsFilterTests.java | 2 +-
.../ldap/filter/HardcodedFilterTests.java | 2 +-
.../filter/LessThanOrEqualsFilterTests.java | 2 +-
.../ldap/filter/LikeFilterTests.java | 2 +-
.../ldap/filter/NotFilterTests.java | 2 +-
.../ldap/filter/NotPresentFilterTests.java | 2 +-
.../ldap/filter/OrFilterTests.java | 2 +-
.../ldap/filter/PresentFilterTests.java | 2 +-
.../ldap/filter/ProximityFilterTests.java | 2 +-
.../WhitespaceWildcardsFilterTests.java | 2 +-
.../DefaultObjectDirectoryMapperTests.java | 21 ++++--
.../ldap/pool/AbstractPoolTestCase.java | 4 +-
.../ldap/pool/DelegatingContextTests.java | 2 +-
.../ldap/pool/DelegatingDirContextTests.java | 2 +-
.../ldap/pool/DelegatingLdapContextTests.java | 2 +-
.../MutableDelegatingLdapContextTests.java | 2 +-
.../DirContextPoolableObjectFactoryTests.java | 2 +-
.../MutablePoolingContextSourceTests.java | 2 +-
.../factory/PoolingContextSourceTests.java | 2 +-
.../DefaultDirContextValidatorTests.java | 6 +-
.../ldap/pool2/AbstractPoolTestCase.java | 4 +-
.../ldap/pool2/DelegatingContextTests.java | 2 +-
.../ldap/pool2/DelegatingDirContextTests.java | 2 +-
.../pool2/DelegatingLdapContextTests.java | 2 +-
.../MutableDelegatingLdapContextTests.java | 2 +-
.../DirContextPooledObjectFactoryTests.java | 2 +-
.../MutablePooledContextSourceTests.java | 2 +-
.../ldap/pool2/factory/PoolConfigTests.java | 2 +-
.../factory/PooledContextSourceTests.java | 2 +-
.../ldap/query/LdapQueryBuilderTests.java | 57 ++++++++------
.../ldap/support/LdapEncoderTests.java | 7 +-
.../ldap/support/LdapNameBuilderTests.java | 2 +-
.../ldap/support/LdapUtilsTests.java | 6 +-
.../BindOperationExecutorTests.java | 6 +-
.../BindOperationRecorderTests.java | 19 +++--
...atingTransactionOperationFactoryTests.java | 6 +-
.../LdapTransactionUtilsTests.java | 6 +-
...odifyAttributesOperationExecutorTests.java | 6 +-
...odifyAttributesOperationRecorderTests.java | 6 +-
.../RebindOperationExecutorTests.java | 6 +-
.../RebindOperationRecorderTests.java | 6 +-
.../RenameOperationExecutorTests.java | 6 +-
.../RenameOperationRecorderTests.java | 6 +-
.../UnbindOperationExecutorTests.java | 6 +-
.../UnbindOperationRecorderTests.java | 6 +-
.../CompensatingTransactionUtilsTests.java | 6 +-
.../ContextSourceTransactionManagerTests.java | 6 +-
...ansactionAwareContextSourceProxyTests.java | 6 +-
...AwareDirContextInvocationHandlerTests.java | 6 +-
...DefaultTempEntryRenamingStrategyTests.java | 2 +-
...SubtreeTempEntryRenamingStrategyTests.java | 2 +-
.../ldap/util/ListComparatorTests.java | 6 +-
...atingTransactionOperationManagerTests.java | 35 +++++----
98 files changed, 409 insertions(+), 333 deletions(-)
diff --git a/core/build.gradle b/core/build.gradle
index 5b5b03d0e4..17dcc002ce 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -38,13 +38,13 @@ dependencies {
exclude group: 'org.assertj'
}
testImplementation platform('org.junit:junit-bom')
- testImplementation "org.junit.vintage:junit-vintage-engine"
+ testImplementation "org.junit.jupiter:junit-jupiter-api"
+ testImplementation "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
-
- testImplementation "junit:junit"
testImplementation "commons-lang:commons-lang"
testImplementation "gsbase:gsbase"
testImplementation "org.mockito:mockito-core"
+ testImplementation "org.mockito:mockito-junit-jupiter:4.11.0"
testImplementation "org.springframework:spring-test"
testImplementation "org.assertj:assertj-core"
testImplementation "com.unboundid:unboundid-ldapsdk"
@@ -60,6 +60,7 @@ compileTestJava {
test {
jvmArgs '--add-exports', 'java.naming/com.sun.jndi.ldap=ALL-UNNAMED'
+ useJUnitPlatform()
}
checkFormatMain {
diff --git a/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java b/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java
index ff231a1b35..fba3e0dd3a 100644
--- a/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java
+++ b/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java
@@ -24,7 +24,7 @@
import javax.naming.directory.InitialDirContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java b/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java
index 4ebbf12f28..05072cbc69 100644
--- a/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java
+++ b/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java
@@ -22,8 +22,8 @@
import javax.naming.ldap.SortResponseControl;
import javax.net.ssl.SSLSocketFactory;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
@@ -44,7 +44,7 @@ public class LdapCoreRuntimeHintsTests {
private final RuntimeHints hints = new RuntimeHints();
- @Before
+ @BeforeEach
public void setup() {
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
.load(RuntimeHintsRegistrar.class)
diff --git a/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTests.java b/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTests.java
index a462368155..5e5f54b874 100644
--- a/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTests.java
+++ b/core/src/test/java/org/springframework/ldap/authentication/DefaultValuesAuthenticationSourceDecoratorTests.java
@@ -16,8 +16,8 @@
package org.springframework.ldap.authentication;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.AuthenticationSource;
@@ -36,7 +36,7 @@ public class DefaultValuesAuthenticationSourceDecoratorTests {
private AuthenticationSource authenticationSourceMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.authenticationSourceMock = mock(AuthenticationSource.class);
this.tested = new DefaultValuesAuthenticationSourceDecorator();
diff --git a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java
index a528d91e02..10dd308ef5 100644
--- a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java
+++ b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java
@@ -28,7 +28,7 @@
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -97,19 +97,22 @@ public void verifyThatAnonymousReadOnlyContextWillNotBeWrappedInProxy() {
assertThat(Boolean.TRUE).isEqualTo(getInternalState(contextSource, "anonymousReadOnly"));
}
- @Test(expected = BeansException.class)
+ @Test
public void verifyThatAnonymousReadOnlyAndTransactionalThrowsException() {
- new ClassPathXmlApplicationContext("/ldap-namespace-config-anonymous-read-only-and-transactions.xml");
+ assertThatExceptionOfType(BeansException.class).isThrownBy(() -> new ClassPathXmlApplicationContext(
+ "/ldap-namespace-config-anonymous-read-only-and-transactions.xml"));
}
- @Test(expected = BeansException.class)
+ @Test
public void verifyThatMissingUsernameThrowsException() {
- new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-username.xml");
+ assertThatExceptionOfType(BeansException.class)
+ .isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-username.xml"));
}
- @Test(expected = BeansException.class)
+ @Test
public void verifyThatMissingPasswordThrowsException() {
- new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-password.xml");
+ assertThatExceptionOfType(BeansException.class)
+ .isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-password.xml"));
}
@Test
@@ -366,9 +369,10 @@ public void verifyParsePoolingValidationSet() {
assertThat(nonTransientExceptions.contains(CannotProceedException.class)).isTrue();
}
- @Test(expected = BeansException.class)
+ @Test
public void verifyParseWithPoolingAndNativePoolingWillFail() {
- new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-with-native.xml");
+ assertThatExceptionOfType(BeansException.class)
+ .isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-with-native.xml"));
}
@Test
@@ -494,14 +498,16 @@ public void verifyParsePool2ValidationSet() {
assertThat(nonTransientExceptions.contains(CannotProceedException.class)).isTrue();
}
- @Test(expected = BeansException.class)
+ @Test
public void verifyParseWithPool2AndNativePoolingWillFail() {
- new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-native.xml");
+ assertThatExceptionOfType(BeansException.class)
+ .isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-native.xml"));
}
- @Test(expected = BeansException.class)
+ @Test
public void verifyParseWithPool1AndPool2WillFail() {
- new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-pool1.xml");
+ assertThatExceptionOfType(BeansException.class)
+ .isThrownBy(() -> new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-pool1.xml"));
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/control/PagedResultTests.java b/core/src/test/java/org/springframework/ldap/control/PagedResultTests.java
index 86766f4ac1..811f68f878 100644
--- a/core/src/test/java/org/springframework/ldap/control/PagedResultTests.java
+++ b/core/src/test/java/org/springframework/ldap/control/PagedResultTests.java
@@ -22,7 +22,7 @@
import javax.naming.ldap.PagedResultsControl;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for the PagedResult class. {@link PagedResultsControl}
diff --git a/core/src/test/java/org/springframework/ldap/control/PagedResultsCookieTests.java b/core/src/test/java/org/springframework/ldap/control/PagedResultsCookieTests.java
index ef9b19cde6..03f4cc8228 100644
--- a/core/src/test/java/org/springframework/ldap/control/PagedResultsCookieTests.java
+++ b/core/src/test/java/org/springframework/ldap/control/PagedResultsCookieTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.control;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class PagedResultsCookieTests {
diff --git a/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTests.java b/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTests.java
index 7bad249f85..74fe5857d3 100644
--- a/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTests.java
+++ b/core/src/test/java/org/springframework/ldap/control/PagedResultsDirContextProcessorTests.java
@@ -27,9 +27,9 @@
import com.sun.jndi.ldap.BerDecoder;
import com.sun.jndi.ldap.BerEncoder;
import com.sun.jndi.ldap.ctl.DirSyncResponseControl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -41,7 +41,7 @@ public class PagedResultsDirContextProcessorTests {
private PagedResultsDirContextProcessor tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new PagedResultsDirContextProcessor(20);
@@ -50,7 +50,7 @@ public void setUp() throws Exception {
this.ldapContextMock = mock(LdapContext.class);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
this.tested = null;
diff --git a/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java b/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java
index d4c6a1b833..de245284f5 100644
--- a/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java
+++ b/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java
@@ -22,10 +22,11 @@
import javax.naming.ldap.LdapContext;
import javax.naming.ldap.SortControl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.verify;
@@ -42,7 +43,7 @@ public class RequestControlDirContextProcessorTests {
private DirContext dirContextMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Create requestControl mock
this.requestControlMock = mock(Control.class);
@@ -68,7 +69,7 @@ public void postProcess(DirContext ctx) throws NamingException {
};
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
this.requestControlMock = null;
this.requestControl2Mock = null;
@@ -125,9 +126,10 @@ public void testPreProcessWithNullControlsShouldAdd() throws NamingException {
verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock });
}
- @Test(expected = IllegalArgumentException.class)
- public void testPreProcessWhenNotLdapContextShouldFail() throws Exception {
- this.tested.preProcess(this.dirContextMock);
+ @Test
+ public void testPreProcessWhenNotLdapContextShouldFail() {
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> this.tested.preProcess(this.dirContextMock));
}
}
diff --git a/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTests.java b/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTests.java
index 9c6ae6ae8e..b83816b961 100644
--- a/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTests.java
+++ b/core/src/test/java/org/springframework/ldap/control/SortControlDirContextProcessorTests.java
@@ -27,8 +27,8 @@
import com.sun.jndi.ldap.BerDecoder;
import com.sun.jndi.ldap.BerEncoder;
import com.sun.jndi.ldap.ctl.DirSyncResponseControl;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -45,7 +45,7 @@ public class SortControlDirContextProcessorTests {
private SortControlDirContextProcessor tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new SortControlDirContextProcessor("key");
diff --git a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java
index f999df231e..38f038b3e9 100644
--- a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java
@@ -21,8 +21,8 @@
import javax.naming.NameClassPair;
import javax.naming.NamingException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class CollectingNameClassPairCallbackHandlerTests {
private NameClassPair expectedNameClassPair;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.expectedResult = new Object();
this.expectedNameClassPair = new NameClassPair(null, null);
diff --git a/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTests.java b/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTests.java
index 598b081ff4..f436fed404 100644
--- a/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTests.java
@@ -19,10 +19,11 @@
import javax.naming.Binding;
import javax.naming.NamingException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
@@ -32,15 +33,16 @@ public class ContextMapperCallbackHandlerTests {
private ContextMapperCallbackHandler tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.mapperMock = mock(ContextMapper.class);
this.tested = new ContextMapperCallbackHandler(this.mapperMock);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testConstructorWithEmptyArgument() {
- new ContextMapperCallbackHandler(null);
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> new ContextMapperCallbackHandler(null));
}
@Test
@@ -54,10 +56,12 @@ public void testGetObjectFromNameClassPair() throws NamingException {
assertThat(actualResult).isEqualTo(expectedResult);
}
- @Test(expected = ObjectRetrievalException.class)
- public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException {
- Binding expectedBinding = new Binding("some name", null);
- this.tested.getObjectFromNameClassPair(expectedBinding);
+ @Test
+ public void testGetObjectFromNameClassPairObjectRetrievalException() {
+ assertThatExceptionOfType(ObjectRetrievalException.class).isThrownBy(() -> {
+ Binding expectedBinding = new Binding("some name", null);
+ this.tested.getObjectFromNameClassPair(expectedBinding);
+ });
}
}
diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java
index 5d82e7e28c..da3e6ff92e 100644
--- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java
@@ -28,8 +28,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.LimitExceededException;
import org.springframework.ldap.PartialResultException;
@@ -64,7 +64,7 @@ public class DefaultLdapClientListTests {
private DefaultLdapClient tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java
index 5108dff5de..4bddd0e8de 100644
--- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java
@@ -27,8 +27,8 @@
import javax.naming.directory.SearchResult;
import javax.naming.ldap.LdapContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.BDDMockito;
import org.springframework.LdapDataEntry;
@@ -56,7 +56,7 @@ public class DefaultLdapClientLookupTests {
private LdapClient tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.contextSourceMock = mock(ContextSource.class);
this.dirContextMock = mock(LdapContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTests.java
index 678061a724..2de2d22ea9 100644
--- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientRenameTests.java
@@ -20,8 +20,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.NameAlreadyBoundException;
import org.springframework.ldap.UncategorizedLdapException;
@@ -51,7 +51,7 @@ public class DefaultLdapClientRenameTests {
private LdapClient tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java
index 82d8b52bd3..0638699849 100644
--- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java
@@ -30,8 +30,8 @@
import javax.naming.ldap.LdapContext;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatcher;
import org.springframework.dao.EmptyResultDataAccessException;
@@ -102,7 +102,7 @@ public class DefaultLdapClientTests {
private AuthenticatedLdapEntryContextMapper authContextMapperMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
diff --git a/core/src/test/java/org/springframework/ldap/core/DirContextAdapterBugTests.java b/core/src/test/java/org/springframework/ldap/core/DirContextAdapterBugTests.java
index 32e7423fac..71ab412bd3 100644
--- a/core/src/test/java/org/springframework/ldap/core/DirContextAdapterBugTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DirContextAdapterBugTests.java
@@ -20,7 +20,7 @@
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
diff --git a/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTests.java b/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTests.java
index f8ab26f3e8..a73a2830a2 100644
--- a/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DirContextAdapterTests.java
@@ -30,8 +30,8 @@
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
@@ -53,7 +53,7 @@ public class DirContextAdapterTests {
private DirContextAdapter tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new DirContextAdapter();
}
diff --git a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTests.java b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTests.java
index 74532b5d06..5816ad564e 100644
--- a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameEditorTests.java
@@ -16,8 +16,8 @@
package org.springframework.ldap.core;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
@@ -31,7 +31,7 @@ public class DistinguishedNameEditorTests {
private DistinguishedNameEditor tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new DistinguishedNameEditor();
}
diff --git a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTests.java b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTests.java
index 6bc526d316..d62b8a213c 100644
--- a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTests.java
@@ -23,11 +23,12 @@
import javax.naming.Name;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.BadLdapGrammarException;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
/**
@@ -469,10 +470,12 @@ public void testGetLdapRdnForKey() throws Exception {
assertThat(ldapRdn).isEqualTo(new LdapRdn("ou=Some company"));
}
- @Test(expected = IllegalArgumentException.class)
- public void testGetLdapRdnForKeyNoMatchingKeyThrowsException() throws Exception {
- DistinguishedName dn = new DistinguishedName("cn=john doe, ou=Some company, c=SE");
- dn.getLdapRdn("nosuchkey");
+ @Test
+ public void testGetLdapRdnForKeyNoMatchingKeyThrowsException() {
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ DistinguishedName dn = new DistinguishedName("cn=john doe, ou=Some company, c=SE");
+ dn.getLdapRdn("nosuchkey");
+ });
}
@Test
@@ -482,10 +485,12 @@ public void testGetValue() throws Exception {
assertThat(value).isEqualTo("Some company");
}
- @Test(expected = IllegalArgumentException.class)
- public void testGetValueNoMatchingKeyThrowsException() throws Exception {
- DistinguishedName dn = new DistinguishedName("cn=john doe, ou=Some company, c=SE");
- dn.getValue("nosuchkey");
+ @Test
+ public void testGetValueNoMatchingKeyThrowsException() {
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ DistinguishedName dn = new DistinguishedName("cn=john doe, ou=Some company, c=SE");
+ dn.getValue("nosuchkey");
+ });
}
@Test
@@ -515,9 +520,10 @@ public void testParseAtSign2() {
/**
* Test case to verify correct parsing for issue on forums.
*/
- @Test(expected = BadLdapGrammarException.class)
+ @Test
public void testParseInvalidPlus() {
- new DistinguishedName("cn=te+stname@example.com");
+ assertThatExceptionOfType(BadLdapGrammarException.class)
+ .isThrownBy(() -> new DistinguishedName("cn=te+stname@example.com"));
}
/**
@@ -537,34 +543,42 @@ public void testAppendChained() {
assertThat(tested.toString()).isEqualTo("cn=john doe,ou=company1,dc=mycompany,dc=com");
}
- @Test(expected = UnsupportedOperationException.class)
- public void testUnmodifiableDistinguishedNameFailsToAddRdn() throws Exception {
- DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
- result.add(new LdapRdn("somekey", "somevalue"));
+ @Test
+ public void testUnmodifiableDistinguishedNameFailsToAddRdn() {
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
+ result.add(new LdapRdn("somekey", "somevalue"));
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void testUnmodifiableDistinguishedNameFailsToModifyRdn() throws Exception {
- DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
- LdapRdn ldapRdn = result.getLdapRdn(0);
+ @Test
+ public void testUnmodifiableDistinguishedNameFailsToModifyRdn() {
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
+ LdapRdn ldapRdn = result.getLdapRdn(0);
- ldapRdn.addComponent(new LdapRdnComponent("somekey", "somevalue"));
+ ldapRdn.addComponent(new LdapRdnComponent("somekey", "somevalue"));
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void testUnmodifiableDistinguishedNameFailsToModifyRdnComponentKey() throws Exception {
- DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
- LdapRdnComponent component = result.getLdapRdn(0).getComponent();
+ @Test
+ public void testUnmodifiableDistinguishedNameFailsToModifyRdnComponentKey() {
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
+ LdapRdnComponent component = result.getLdapRdn(0).getComponent();
- component.setKey("somekey");
+ component.setKey("somekey");
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void testUnmodifiableDistinguishedNameFailsToModifyRdnComponentValue() throws Exception {
- DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
- LdapRdnComponent component = result.getLdapRdn(0).getComponent();
+ @Test
+ public void testUnmodifiableDistinguishedNameFailsToModifyRdnComponentValue() {
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ DistinguishedName result = DistinguishedName.immutableDistinguishedName("cn=john doe");
+ LdapRdnComponent component = result.getLdapRdn(0).getComponent();
- component.setValue("somevalue");
+ component.setValue("somevalue");
+ });
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapRdnComponentTests.java b/core/src/test/java/org/springframework/ldap/core/LdapRdnComponentTests.java
index b1b2fc2533..69bc72cc02 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapRdnComponentTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapRdnComponentTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapRdnTests.java b/core/src/test/java/org/springframework/ldap/core/LdapRdnTests.java
index 30beaf0d80..da2a138623 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapRdnTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapRdnTests.java
@@ -17,11 +17,12 @@
package org.springframework.ldap.core;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.BadLdapGrammarException;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Unit test for the LdapRdn class.
@@ -72,9 +73,9 @@ public void testLdapRdn_parse_hexEscape() {
assertThat(rdn.getComponent().getLdapEncoded()).isEqualTo("foo=bar\\0Dfum");
}
- @Test(expected = BadLdapGrammarException.class)
+ @Test
public void testLdapRdn_parse_trailingBackslash() {
- new LdapRdn("foo=bar\\");
+ assertThatExceptionOfType(BadLdapGrammarException.class).isThrownBy(() -> new LdapRdn("foo=bar\\"));
}
@Test
@@ -86,9 +87,9 @@ public void testLdapRdn_parse_spaces_escape() {
assertThat(rdn.getComponent().getLdapEncoded()).isEqualTo("foo=\\ bar \\ ");
}
- @Test(expected = BadLdapGrammarException.class)
+ @Test
public void testLdapRdn_parse_tooMuchTrim() {
- new LdapRdn("foo=bar\\");
+ assertThatExceptionOfType(BadLdapGrammarException.class).isThrownBy(() -> new LdapRdn("foo=bar\\"));
}
@Test
@@ -100,9 +101,9 @@ public void testLdapRdn_parse_slash() {
assertThat(rdn.getComponent().getLdapEncoded()).isEqualTo("ou=Clerical / Secretarial Staff");
}
- @Test(expected = BadLdapGrammarException.class)
+ @Test
public void testLdapRdn_parse_quoteInKey() {
- new LdapRdn("\"umanroleid=2583");
+ assertThatExceptionOfType(BadLdapGrammarException.class).isThrownBy(() -> new LdapRdn("\"umanroleid=2583"));
}
@Test
@@ -147,16 +148,20 @@ public void testLdapRdn_Parse_MultipleComponents() {
assertThat(rdn.getValue("sn")).isEqualTo("Doe");
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetValueNoKeyWithCorrectValue() {
- LdapRdn tested = new LdapRdn("cn=john doe");
- tested.getValue("sn");
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ LdapRdn tested = new LdapRdn("cn=john doe");
+ tested.getValue("sn");
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetValueNoComponents() {
- LdapRdn tested = new LdapRdn();
- tested.getValue("sn");
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ LdapRdn tested = new LdapRdn();
+ tested.getValue("sn");
+ });
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTests.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTests.java
index 374954796b..123507c275 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateListTests.java
@@ -26,8 +26,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.LimitExceededException;
import org.springframework.ldap.PartialResultException;
@@ -63,7 +63,7 @@ public class LdapTemplateListTests {
private LdapTemplate tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTests.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTests.java
index 63528d6453..1d3ea4879d 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateLookupTests.java
@@ -25,8 +25,8 @@
import javax.naming.ldap.LdapContext;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.NameNotFoundException;
import org.springframework.ldap.odm.core.ObjectDirectoryMapper;
@@ -56,7 +56,7 @@ public class LdapTemplateLookupTests {
private ObjectDirectoryMapper odmMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTests.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTests.java
index 2e3a7071ff..d7c6804d5e 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateOdmTests.java
@@ -16,8 +16,8 @@
package org.springframework.ldap.core;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.odm.core.ObjectDirectoryMapper;
@@ -34,7 +34,7 @@ public class LdapTemplateOdmTests {
private ObjectDirectoryMapper odmMock;
- @Before
+ @BeforeEach
public void prepareTestedClass() {
this.tested = mock(LdapTemplate.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTests.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTests.java
index bff64add03..1aa9a218a4 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateRenameTests.java
@@ -20,8 +20,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.NameAlreadyBoundException;
import org.springframework.ldap.UncategorizedLdapException;
@@ -50,7 +50,7 @@ public class LdapTemplateRenameTests {
private LdapTemplate tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java
index 213b497fcd..f22fc8cd6e 100644
--- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java
@@ -32,8 +32,8 @@
import javax.naming.ldap.LdapContext;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
@@ -109,7 +109,7 @@ public class LdapTemplateTests {
private AuthenticatedLdapEntryContextMapper authContextMapperMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Setup ContextSource mock
diff --git a/core/src/test/java/org/springframework/ldap/core/NameAwareAttributeTests.java b/core/src/test/java/org/springframework/ldap/core/NameAwareAttributeTests.java
index 192b01a4cc..2b45af34d6 100644
--- a/core/src/test/java/org/springframework/ldap/core/NameAwareAttributeTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/NameAwareAttributeTests.java
@@ -21,7 +21,7 @@
import javax.naming.NamingException;
import javax.naming.ldap.LdapName;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
diff --git a/core/src/test/java/org/springframework/ldap/core/NameAwareAttributesTests.java b/core/src/test/java/org/springframework/ldap/core/NameAwareAttributesTests.java
index a682cc1d6c..e9094ad00f 100644
--- a/core/src/test/java/org/springframework/ldap/core/NameAwareAttributesTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/NameAwareAttributesTests.java
@@ -19,7 +19,7 @@
import java.util.List;
import java.util.stream.StreamSupport;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/core/support/AbstractContextSourceTests.java b/core/src/test/java/org/springframework/ldap/core/support/AbstractContextSourceTests.java
index d1988a4705..597ba8e4e0 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/AbstractContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/AbstractContextSourceTests.java
@@ -19,7 +19,7 @@
import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTests.java b/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTests.java
index bc5d86decc..33933a2988 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/AggregateDirContextProcessorTests.java
@@ -18,8 +18,8 @@
import javax.naming.NamingException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.DirContextProcessor;
@@ -34,7 +34,7 @@ public class AggregateDirContextProcessorTests {
private AggregateDirContextProcessor tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// Create processor1 mock
this.processor1Mock = mock(DirContextProcessor.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java b/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java
index 3009ae4471..550c2813c1 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java
@@ -18,8 +18,8 @@
import java.util.HashMap;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
@@ -27,6 +27,7 @@
import org.springframework.ldap.support.LdapUtils;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.verify;
@@ -46,7 +47,7 @@ public class BaseLdapPathBeanPostProcessorTests {
private BaseLdapNameAware ldapNameAwareMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new BaseLdapPathBeanPostProcessor();
@@ -138,18 +139,22 @@ public void testGetAbstractContextSourceFromApplicationContext() throws Exceptio
assertThat(result).isSameAs(expectedContextSource);
}
- @Test(expected = NoSuchBeanDefinitionException.class)
- public void testGetAbstractContextSourceFromApplicationContextNoContextSource() throws Exception {
- given(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).willReturn(new String[0]);
+ @Test
+ public void testGetAbstractContextSourceFromApplicationContextNoContextSource() {
+ assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> {
+ given(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).willReturn(new String[0]);
- this.tested.getBaseLdapPathSourceFromApplicationContext();
+ this.tested.getBaseLdapPathSourceFromApplicationContext();
+ });
}
- @Test(expected = NoSuchBeanDefinitionException.class)
- public void testGetAbstractContextSourceFromApplicationContextTwoContextSources() throws Exception {
- given(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).willReturn(new String[2]);
+ @Test
+ public void testGetAbstractContextSourceFromApplicationContextTwoContextSources() {
+ assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> {
+ given(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class)).willReturn(new String[2]);
- this.tested.getBaseLdapPathSourceFromApplicationContext();
+ this.tested.getBaseLdapPathSourceFromApplicationContext();
+ });
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTests.java b/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTests.java
index 606755dec8..b8f87ba096 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/ContextMapperCallbackHandlerWithControlsTests.java
@@ -21,12 +21,13 @@
import javax.naming.ldap.Control;
import javax.naming.ldap.HasControls;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.ObjectRetrievalException;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
@@ -41,15 +42,16 @@ public class ContextMapperCallbackHandlerWithControlsTests {
private ContextMapperCallbackHandlerWithControls tested;
@SuppressWarnings("unchecked")
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.mapperMock = mock(ContextMapperWithControls.class);
this.tested = new ContextMapperCallbackHandlerWithControls(this.mapperMock);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testConstructorWithEmptyArgument() {
- new ContextMapperCallbackHandlerWithControls<>(null);
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> new ContextMapperCallbackHandlerWithControls<>(null));
}
@Test
@@ -78,11 +80,13 @@ public void testGetObjectFromNameClassPairImplementingHasControls() throws Namin
assertThat(actualResult).isEqualTo(expectedResult);
}
- @Test(expected = ObjectRetrievalException.class)
- public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException {
- Binding expectedBinding = new Binding("some name", null);
+ @Test
+ public void testGetObjectFromNameClassPairObjectRetrievalException() {
+ assertThatExceptionOfType(ObjectRetrievalException.class).isThrownBy(() -> {
+ Binding expectedBinding = new Binding("some name", null);
- this.tested.getObjectFromNameClassPair(expectedBinding);
+ this.tested.getObjectFromNameClassPair(expectedBinding);
+ });
}
private static class MyBindingThatHasControls extends Binding implements HasControls {
diff --git a/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTests.java b/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTests.java
index aef8fbcf77..af7ca0cd2b 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/CountNameClassPairResultCallbackHandlerTests.java
@@ -18,8 +18,8 @@
import javax.naming.directory.SearchResult;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -27,7 +27,7 @@ public class CountNameClassPairResultCallbackHandlerTests {
private CountNameClassPairCallbackHandler tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new CountNameClassPairCallbackHandler();
}
diff --git a/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTests.java b/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTests.java
index a0ea20bfbc..1b7c661f93 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/DefaultDirObjectFactoryTests.java
@@ -25,8 +25,8 @@
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.NameAwareAttributes;
@@ -49,7 +49,7 @@ public class DefaultDirObjectFactoryTests {
private Context contextMock2;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.contextMock = mock(Context.class);
this.contextMock2 = mock(Context.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTests.java b/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTests.java
index 56b27cb8b0..d1de42fc48 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapperTests.java
@@ -21,8 +21,8 @@
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,7 +36,7 @@ public class DefaultIncrementalAttributesMapperTests {
private DefaultIncrementalAttributesMapper tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new DefaultIncrementalAttributesMapper("member");
}
diff --git a/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java b/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java
index a8928f0ac2..534b7acf39 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java
@@ -18,10 +18,12 @@
import javax.naming.ldap.LdapContext;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
import static org.mockito.Mockito.verify;
@@ -29,7 +31,8 @@
* @author Rob Winch
* @since 5.0
*/
-@RunWith(MockitoJUnitRunner.class)
+@MockitoSettings(strictness = Strictness.WARN)
+@ExtendWith(MockitoExtension.class)
public class DefaultTlsDirContextAuthenticationStrategyTests {
@Mock
diff --git a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java
index 51382623a2..c4cccf6adb 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java
@@ -21,12 +21,13 @@
import javax.naming.Context;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Unit tests for the LdapContextSource class.
@@ -38,23 +39,25 @@ public class LdapContextSourceTests {
private LdapContextSource tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new LdapContextSource();
}
- @Test(expected = IllegalArgumentException.class)
- public void testAfterPropertiesSet_NoUrl() throws Exception {
- this.tested.afterPropertiesSet();
+ @Test
+ public void testAfterPropertiesSet_NoUrl() {
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> this.tested.afterPropertiesSet());
}
// gh-538
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAfterPropertiesSet_NullPassword() {
- this.tested.setUrl("ldap://ldap.example.com:389");
- this.tested.setUserDn("value");
- this.tested.setPassword(null);
- this.tested.afterPropertiesSet();
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ this.tested.setUrl("ldap://ldap.example.com:389");
+ this.tested.setUserDn("value");
+ this.tested.setPassword(null);
+ this.tested.afterPropertiesSet();
+ });
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/core/support/RangeOptionTests.java b/core/src/test/java/org/springframework/ldap/core/support/RangeOptionTests.java
index 35295f3f48..aa2c36bd7e 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/RangeOptionTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/RangeOptionTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.core.support;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTests.java b/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTests.java
index db3ac0eee0..670df7c8e7 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/SimpleDirContextAuthenticationStrategyTests.java
@@ -20,8 +20,8 @@
import javax.naming.Context;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -29,7 +29,7 @@ public class SimpleDirContextAuthenticationStrategyTests {
private SimpleDirContextAuthenticationStrategy tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new SimpleDirContextAuthenticationStrategy();
}
diff --git a/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTests.java b/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTests.java
index 71c4082430..8e2c2280f7 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/SingleContextSourceTests.java
@@ -22,8 +22,8 @@
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.ContextExecutor;
import org.springframework.ldap.core.ContextSource;
@@ -44,7 +44,7 @@ public class SingleContextSourceTests {
private DirContext dirContextMock;
- @Before
+ @BeforeEach
public void prepareMocks() {
this.contextSourceMock = mock(ContextSource.class);
this.dirContextMock = mock(DirContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/core/support/ldap294/Ldap294Tests.java b/core/src/test/java/org/springframework/ldap/core/support/ldap294/Ldap294Tests.java
index 6c14ccf835..878b59cc2c 100644
--- a/core/src/test/java/org/springframework/ldap/core/support/ldap294/Ldap294Tests.java
+++ b/core/src/test/java/org/springframework/ldap/core/support/ldap294/Ldap294Tests.java
@@ -21,7 +21,7 @@
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.support.AbstractContextSource;
diff --git a/core/src/test/java/org/springframework/ldap/filter/AbstractFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/AbstractFilterTests.java
index 2c074d21c7..30e4d020af 100644
--- a/core/src/test/java/org/springframework/ldap/filter/AbstractFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/AbstractFilterTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java
index 357a485b44..66ee9938d9 100644
--- a/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/EqualsFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/EqualsFilterTests.java
index 41283a11fc..a16970c3be 100644
--- a/core/src/test/java/org/springframework/ldap/filter/EqualsFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/EqualsFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilterTests.java
index d84d7f145e..9960faba14 100644
--- a/core/src/test/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/GreaterThanOrEqualsFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/HardcodedFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/HardcodedFilterTests.java
index 4aa178df31..8051c93042 100644
--- a/core/src/test/java/org/springframework/ldap/filter/HardcodedFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/HardcodedFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/LessThanOrEqualsFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/LessThanOrEqualsFilterTests.java
index 2273f304fd..8762ae3ccd 100644
--- a/core/src/test/java/org/springframework/ldap/filter/LessThanOrEqualsFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/LessThanOrEqualsFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/LikeFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/LikeFilterTests.java
index caf82f6327..a1f88d1563 100644
--- a/core/src/test/java/org/springframework/ldap/filter/LikeFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/LikeFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/NotFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/NotFilterTests.java
index e1af3b176b..7feacce9af 100644
--- a/core/src/test/java/org/springframework/ldap/filter/NotFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/NotFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/NotPresentFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/NotPresentFilterTests.java
index d7929ceed6..05d1fdf9ac 100644
--- a/core/src/test/java/org/springframework/ldap/filter/NotPresentFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/NotPresentFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java
index c5b8442194..7897498fed 100644
--- a/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/PresentFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/PresentFilterTests.java
index e7e22cc934..4dea47fa70 100644
--- a/core/src/test/java/org/springframework/ldap/filter/PresentFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/PresentFilterTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.filter;
import com.gargoylesoftware.base.testing.EqualsTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/ProximityFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/ProximityFilterTests.java
index b1842f76e1..ceadbc23b9 100644
--- a/core/src/test/java/org/springframework/ldap/filter/ProximityFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/ProximityFilterTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/filter/WhitespaceWildcardsFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/WhitespaceWildcardsFilterTests.java
index 8f7ec813c1..636f12f972 100644
--- a/core/src/test/java/org/springframework/ldap/filter/WhitespaceWildcardsFilterTests.java
+++ b/core/src/test/java/org/springframework/ldap/filter/WhitespaceWildcardsFilterTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java
index 595b48c2b0..a0a632d0b6 100644
--- a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java
+++ b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java
@@ -21,12 +21,14 @@
import javax.naming.Name;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
import org.springframework.core.SpringVersion;
import org.springframework.core.convert.ConversionService;
@@ -38,6 +40,7 @@
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -45,12 +48,13 @@
/**
* @author Mattias Hellborg Arthursson
*/
-@RunWith(MockitoJUnitRunner.class)
+@MockitoSettings(strictness = Strictness.WARN)
+@ExtendWith(MockitoExtension.class)
public class DefaultObjectDirectoryMapperTests {
private DefaultObjectDirectoryMapper tested;
- @Before
+ @BeforeEach
public void prepareTestedInstance() {
this.tested = new DefaultObjectDirectoryMapper();
}
@@ -127,9 +131,10 @@ public void testIndexedDnAttributes() {
assertThat(calculatedId).isEqualTo(LdapUtils.newLdapName("cn=Some Person, ou=Some Company, c=Sweden"));
}
- @Test(expected = MetaDataException.class)
+ @Test
public void testIndexedDnAttributesRequiresThatAllAreIndexed() {
- this.tested.manageClass(UnitTestPersonWithIndexedAndUnindexedDnAttributes.class);
+ assertThatExceptionOfType(MetaDataException.class)
+ .isThrownBy(() -> this.tested.manageClass(UnitTestPersonWithIndexedAndUnindexedDnAttributes.class));
}
@Test
diff --git a/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java b/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java
index 1239adbe86..9e3a42205d 100644
--- a/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java
+++ b/core/src/test/java/org/springframework/ldap/pool/AbstractPoolTestCase.java
@@ -21,7 +21,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.commons.pool.KeyedObjectPool;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.pool.validation.DirContextValidator;
@@ -47,7 +47,7 @@ public abstract class AbstractPoolTestCase {
protected DirContextValidator dirContextValidatorMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.contextMock = mock(Context.class);
this.dirContextMock = mock(DirContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java b/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java
index ff22a6f075..ed33b6e9a7 100644
--- a/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java
@@ -21,7 +21,7 @@
import javax.naming.NamingException;
import org.apache.commons.pool.KeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/pool/DelegatingDirContextTests.java b/core/src/test/java/org/springframework/ldap/pool/DelegatingDirContextTests.java
index f174f78e22..8569dcb743 100644
--- a/core/src/test/java/org/springframework/ldap/pool/DelegatingDirContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/DelegatingDirContextTests.java
@@ -23,7 +23,7 @@
import javax.naming.directory.DirContext;
import org.apache.commons.pool.KeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/pool/DelegatingLdapContextTests.java b/core/src/test/java/org/springframework/ldap/pool/DelegatingLdapContextTests.java
index 028de096cf..1a518b4e4a 100644
--- a/core/src/test/java/org/springframework/ldap/pool/DelegatingLdapContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/DelegatingLdapContextTests.java
@@ -21,7 +21,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.commons.pool.KeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/pool/MutableDelegatingLdapContextTests.java b/core/src/test/java/org/springframework/ldap/pool/MutableDelegatingLdapContextTests.java
index 30da15d5de..99f7784cd1 100644
--- a/core/src/test/java/org/springframework/ldap/pool/MutableDelegatingLdapContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/MutableDelegatingLdapContextTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.pool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.verify;
diff --git a/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java b/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java
index 6ebc9474f5..3d17236264 100644
--- a/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java
@@ -22,7 +22,7 @@
import javax.naming.directory.DirContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.ldap.core.ContextSource;
diff --git a/core/src/test/java/org/springframework/ldap/pool/factory/MutablePoolingContextSourceTests.java b/core/src/test/java/org/springframework/ldap/pool/factory/MutablePoolingContextSourceTests.java
index 7f82c0a700..251224a01b 100644
--- a/core/src/test/java/org/springframework/ldap/pool/factory/MutablePoolingContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/factory/MutablePoolingContextSourceTests.java
@@ -18,7 +18,7 @@
import javax.naming.directory.DirContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.pool.AbstractPoolTestCase;
import org.springframework.ldap.pool.MutableDelegatingLdapContext;
diff --git a/core/src/test/java/org/springframework/ldap/pool/factory/PoolingContextSourceTests.java b/core/src/test/java/org/springframework/ldap/pool/factory/PoolingContextSourceTests.java
index 4babbe585f..efc448f4a8 100644
--- a/core/src/test/java/org/springframework/ldap/pool/factory/PoolingContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/factory/PoolingContextSourceTests.java
@@ -20,7 +20,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.ldap.core.ContextSource;
diff --git a/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java b/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java
index 02979b085f..a6dbaaaa09 100644
--- a/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java
@@ -21,8 +21,8 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.pool.DirContextType;
@@ -41,7 +41,7 @@ public class DefaultDirContextValidatorTests {
private DirContext dirContextMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.namingEnumerationMock = mock(NamingEnumeration.class);
this.dirContextMock = mock(DirContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java b/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java
index 1d71aa5457..23c8329aa2 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/AbstractPoolTestCase.java
@@ -21,7 +21,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.commons.pool2.KeyedObjectPool;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.pool2.validation.DirContextValidator;
@@ -47,7 +47,7 @@ public abstract class AbstractPoolTestCase {
protected DirContextValidator dirContextValidatorMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.contextMock = mock(Context.class);
this.dirContextMock = mock(DirContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java b/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java
index 3833422c96..2d1860db3e 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java
@@ -21,7 +21,7 @@
import javax.naming.NamingException;
import org.apache.commons.pool2.KeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/DelegatingDirContextTests.java b/core/src/test/java/org/springframework/ldap/pool2/DelegatingDirContextTests.java
index b6a9b442fa..b82e0a80ce 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/DelegatingDirContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/DelegatingDirContextTests.java
@@ -23,7 +23,7 @@
import javax.naming.directory.DirContext;
import org.apache.commons.pool2.KeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/DelegatingLdapContextTests.java b/core/src/test/java/org/springframework/ldap/pool2/DelegatingLdapContextTests.java
index 247795384c..c8e80f906b 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/DelegatingLdapContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/DelegatingLdapContextTests.java
@@ -21,7 +21,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.commons.pool2.KeyedObjectPool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/MutableDelegatingLdapContextTests.java b/core/src/test/java/org/springframework/ldap/pool2/MutableDelegatingLdapContextTests.java
index 4db7475e0c..03a5e55d27 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/MutableDelegatingLdapContextTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/MutableDelegatingLdapContextTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.pool2;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.verify;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java b/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java
index 072a7a1423..317b2ebd56 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java
@@ -24,7 +24,7 @@
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.pool2.AbstractPoolTestCase;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/factory/MutablePooledContextSourceTests.java b/core/src/test/java/org/springframework/ldap/pool2/factory/MutablePooledContextSourceTests.java
index 2db1153983..08f9b6e126 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/factory/MutablePooledContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/factory/MutablePooledContextSourceTests.java
@@ -18,7 +18,7 @@
import javax.naming.directory.DirContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.pool2.AbstractPoolTestCase;
import org.springframework.ldap.pool2.MutableDelegatingLdapContext;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/factory/PoolConfigTests.java b/core/src/test/java/org/springframework/ldap/pool2/factory/PoolConfigTests.java
index 579d980225..e7e33e3d46 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/factory/PoolConfigTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/factory/PoolConfigTests.java
@@ -17,7 +17,7 @@
package org.springframework.ldap.pool2.factory;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.pool2.AbstractPoolTestCase;
diff --git a/core/src/test/java/org/springframework/ldap/pool2/factory/PooledContextSourceTests.java b/core/src/test/java/org/springframework/ldap/pool2/factory/PooledContextSourceTests.java
index 185ddc7d68..a8a23ff92b 100644
--- a/core/src/test/java/org/springframework/ldap/pool2/factory/PooledContextSourceTests.java
+++ b/core/src/test/java/org/springframework/ldap/pool2/factory/PooledContextSourceTests.java
@@ -19,7 +19,7 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.ldap.core.ContextSource;
diff --git a/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java b/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java
index ce4f076e39..b43e2963cb 100644
--- a/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java
+++ b/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java
@@ -16,12 +16,13 @@
package org.springframework.ldap.query;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.filter.ProximityFilter;
import org.springframework.ldap.support.LdapUtils;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Mattias Hellborg Arthursson
@@ -88,18 +89,22 @@ public void buildHardcodedFilter() {
assertThat(result.filter().encode()).isEqualTo("(cn=Person*)");
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyThatHardcodedFilterFailsIfFilterAlreadySpecified() {
- LdapQueryBuilder query = LdapQueryBuilder.query();
- query.where("sn").is("Doe");
- query.filter("(cn=Person*)");
+ assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ LdapQueryBuilder query = LdapQueryBuilder.query();
+ query.where("sn").is("Doe");
+ query.filter("(cn=Person*)");
+ });
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyThatFilterFormatFailsIfFilterAlreadySpecified() {
- LdapQueryBuilder query = LdapQueryBuilder.query();
- query.where("sn").is("Doe");
- query.filter("(|(cn={0})(cn={1}))", "Person*", "Parson*");
+ assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ LdapQueryBuilder query = LdapQueryBuilder.query();
+ query.where("sn").is("Doe");
+ query.filter("(|(cn={0})(cn={1}))", "Person*", "Parson*");
+ });
}
@Test
@@ -162,28 +167,38 @@ public void buildNestedAnd() {
assertThat(result.filter().encode()).isEqualTo("(&(objectclass=person)(|(sn=Doe)(sn=Die)))");
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyEmptyFilterThrowsIllegalState() {
- LdapQueryBuilder.query().filter();
+ assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> LdapQueryBuilder.query().filter());
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyThatNewAttemptToStartSpecifyingFilterThrowsIllegalState() {
- LdapQueryBuilder query = LdapQueryBuilder.query();
- query.where("sn").is("Doe");
- query.where("cn").is("John Doe");
+ assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ LdapQueryBuilder query = LdapQueryBuilder.query();
+ query.where("sn").is("Doe");
+ query.where("cn").is("John Doe");
+ });
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyThatAttemptToStartSpecifyingBasePropertiesThrowsIllegalStateWhenFilterStarted() {
- LdapQueryBuilder query = LdapQueryBuilder.query();
- query.where("sn").is("Doe");
- query.base("dc=261consulting,dc=com");
+ assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
+ LdapQueryBuilder query = LdapQueryBuilder.query();
+ query.where("sn").is("Doe");
+ query.base("dc=261consulting,dc=com");
+ });
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void verifyThatOperatorChangeIsIllegal() {
- LdapQueryBuilder.query().where("cn").is("John Doe").and("sn").is("Doe").or("objectclass").is("person");
+ assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> LdapQueryBuilder.query()
+ .where("cn")
+ .is("John Doe")
+ .and("sn")
+ .is("Doe")
+ .or("objectclass")
+ .is("person"));
}
}
diff --git a/core/src/test/java/org/springframework/ldap/support/LdapEncoderTests.java b/core/src/test/java/org/springframework/ldap/support/LdapEncoderTests.java
index abcd2e6f38..1217e921bb 100644
--- a/core/src/test/java/org/springframework/ldap/support/LdapEncoderTests.java
+++ b/core/src/test/java/org/springframework/ldap/support/LdapEncoderTests.java
@@ -16,11 +16,12 @@
package org.springframework.ldap.support;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.BadLdapGrammarException;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Unit test for the LdapEncode class.
@@ -52,9 +53,9 @@ public void testNameDecode() {
assertThat(res).isEqualTo("# foo ,+\"\\<>; ");
}
- @Test(expected = BadLdapGrammarException.class)
+ @Test
public void testNameDecode_slashlast() {
- LdapEncoder.nameDecode("\\");
+ assertThatExceptionOfType(BadLdapGrammarException.class).isThrownBy(() -> LdapEncoder.nameDecode("\\"));
}
// gh-413
diff --git a/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java b/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java
index dde503da9c..cb938ec96a 100644
--- a/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java
+++ b/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java
@@ -16,7 +16,7 @@
package org.springframework.ldap.support;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java b/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java
index 0037d70a34..a05a55e65f 100644
--- a/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java
+++ b/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java
@@ -25,8 +25,8 @@
import javax.naming.ldap.LdapName;
import org.apache.commons.lang.ArrayUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.NoSuchAttributeException;
@@ -43,7 +43,7 @@ public class LdapUtilsTests {
private AttributeValueCallbackHandler handlerMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.handlerMock = mock(AttributeValueCallbackHandler.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTests.java
index b183b08afd..8edeb45857 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationExecutorTests.java
@@ -19,8 +19,8 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -33,7 +33,7 @@ public class BindOperationExecutorTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java
index b42e9c6be6..a9f8538364 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java
@@ -19,21 +19,22 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.transaction.compensating.CompensatingTransactionOperationExecutor;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
public class BindOperationRecorderTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
@@ -75,13 +76,15 @@ public void testPerformOperation_String() {
assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testPerformOperation_Invalid() {
- BindOperationRecorder tested = new BindOperationRecorder(this.ldapOperationsMock);
- Object expectedDn = new Object();
+ assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
+ BindOperationRecorder tested = new BindOperationRecorder(this.ldapOperationsMock);
+ Object expectedDn = new Object();
- // Perform test.
- tested.recordOperation(new Object[] { expectedDn });
+ // Perform test.
+ tested.recordOperation(new Object[] { expectedDn });
+ });
}
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTests.java
index f82e1becd8..15eab75c3d 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapCompensatingTransactionOperationFactoryTests.java
@@ -18,8 +18,8 @@
import javax.naming.directory.DirContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.transaction.compensating.CompensatingTransactionOperationRecorder;
@@ -37,7 +37,7 @@ public class LdapCompensatingTransactionOperationFactoryTests {
private LdapCompensatingTransactionOperationFactory tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
this.renamingStrategyMock = mock(TempEntryRenamingStrategy.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTests.java
index dcb396cc25..fba3a56ea2 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtilsTests.java
@@ -19,8 +19,8 @@
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -33,7 +33,7 @@ public class LdapTransactionUtilsTests {
private DirContext dirContextMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.dirContextMock = mock(DirContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTests.java
index 18c2254893..4d6b491b54 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationExecutorTests.java
@@ -19,8 +19,8 @@
import javax.naming.Name;
import javax.naming.directory.ModificationItem;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -33,7 +33,7 @@ public class ModifyAttributesOperationExecutorTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java
index 7e886309a4..4f0bf1dbc0 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java
@@ -25,8 +25,8 @@
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.IncrementalAttributesMapper;
import org.springframework.ldap.core.LdapOperations;
@@ -45,7 +45,7 @@ public class ModifyAttributesOperationRecorderTests {
private ModifyAttributesOperationRecorder tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
this.attributesMapperMock = mock(IncrementalAttributesMapper.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTests.java
index bfab43c9b3..1eed6cd396 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationExecutorTests.java
@@ -19,8 +19,8 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -32,7 +32,7 @@ public class RebindOperationExecutorTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java
index 6424e5f141..ac7bcff4da 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java
@@ -19,8 +19,8 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -36,7 +36,7 @@ public class RebindOperationRecorderTests {
private TempEntryRenamingStrategy renamingStrategyMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
this.renamingStrategyMock = mock(TempEntryRenamingStrategy.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTests.java
index d2118053b3..e6441037f7 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationExecutorTests.java
@@ -18,8 +18,8 @@
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -32,7 +32,7 @@ public class RenameOperationExecutorTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java
index a89abf7bbc..2f6b2fffb8 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java
@@ -16,8 +16,8 @@
package org.springframework.ldap.transaction.compensating;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.transaction.compensating.CompensatingTransactionOperationExecutor;
@@ -29,7 +29,7 @@ public class RenameOperationRecorderTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTests.java
index 2dc956ca1a..ff0a4e0aa5 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationExecutorTests.java
@@ -18,8 +18,8 @@
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -31,7 +31,7 @@ public class UnbindOperationExecutorTests {
private LdapOperations ldapOperationsMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
}
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTests.java
index ef42f7a126..9b9b5cb000 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/UnbindOperationRecorderTests.java
@@ -18,8 +18,8 @@
import javax.naming.ldap.LdapName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.support.LdapUtils;
@@ -35,7 +35,7 @@ public class UnbindOperationRecorderTests {
private TempEntryRenamingStrategy renamingStrategyMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.ldapOperationsMock = mock(LdapOperations.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTests.java
index e1443ae4ca..da991871c6 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/CompensatingTransactionUtilsTests.java
@@ -20,8 +20,8 @@
import javax.naming.directory.DirContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.ContextSource;
import org.springframework.transaction.compensating.CompensatingTransactionOperationManager;
@@ -40,7 +40,7 @@ public class CompensatingTransactionUtilsTests {
private CompensatingTransactionOperationManager operationManagerMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.dirContextMock = mock(DirContext.class);
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java
index c6b9ae774d..fcf5d3d817 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java
@@ -21,8 +21,8 @@
import javax.naming.directory.DirContext;
import javax.sql.DataSource;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.ldap.UncategorizedLdapException;
@@ -59,7 +59,7 @@ public class ContextSourceTransactionManagerTests {
private TempEntryRenamingStrategy renamingStrategyMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.clearSynchronization();
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTests.java
index d0033a7b54..031b9d4851 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareContextSourceProxyTests.java
@@ -19,8 +19,8 @@
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.DirContextProxy;
@@ -44,7 +44,7 @@ public class TransactionAwareContextSourceProxyTests {
private DirContext dirContextMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.contextSourceMock = mock(ContextSource.class);
this.ldapContextMock = mock(LdapContext.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTests.java
index 4c3b472d69..dceb5a3df0 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandlerTests.java
@@ -19,8 +19,8 @@
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.core.ContextSource;
import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -39,7 +39,7 @@ public class TransactionAwareDirContextInvocationHandlerTests {
private DirContextHolder holder;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.dirContextMock = mock(DirContext.class);
this.contextSourceMock = mock(ContextSource.class);
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategyTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategyTests.java
index 3f85065cce..6a1689f41d 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategyTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DefaultTempEntryRenamingStrategyTests.java
@@ -19,7 +19,7 @@
import javax.naming.Name;
import javax.naming.ldap.LdapName;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategyTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategyTests.java
index f71da758ba..026b4f3720 100644
--- a/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategyTests.java
+++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/support/DifferentSubtreeTempEntryRenamingStrategyTests.java
@@ -19,7 +19,7 @@
import javax.naming.Name;
import javax.naming.ldap.LdapName;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.LdapUtils;
diff --git a/core/src/test/java/org/springframework/ldap/util/ListComparatorTests.java b/core/src/test/java/org/springframework/ldap/util/ListComparatorTests.java
index c53d2fc24b..11fc002b80 100644
--- a/core/src/test/java/org/springframework/ldap/util/ListComparatorTests.java
+++ b/core/src/test/java/org/springframework/ldap/util/ListComparatorTests.java
@@ -19,8 +19,8 @@
import java.util.Arrays;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.ldap.support.ListComparator;
@@ -35,7 +35,7 @@ public class ListComparatorTests {
private ListComparator tested;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.tested = new ListComparator();
}
diff --git a/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java b/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java
index c89f0f93df..ee2e1948b7 100644
--- a/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java
+++ b/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java
@@ -18,8 +18,8 @@
import java.util.Stack;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.compensating.CompensatingTransactionOperationExecutor;
@@ -27,6 +27,7 @@
import org.springframework.transaction.compensating.CompensatingTransactionOperationRecorder;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.verify;
@@ -40,7 +41,7 @@ public class DefaultCompensatingTransactionOperationManagerTests {
private CompensatingTransactionOperationRecorder operationRecorderMock;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.operationExecutorMock = mock(CompensatingTransactionOperationExecutor.class);
this.operationFactoryMock = mock(CompensatingTransactionOperationFactory.class);
@@ -77,15 +78,17 @@ public void testRollback() {
verify(this.operationExecutorMock).rollback();
}
- @Test(expected = TransactionSystemException.class)
+ @Test
public void testRollback_Exception() {
- DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager(
- this.operationFactoryMock);
- tested.getOperationExecutors().push(this.operationExecutorMock);
+ assertThatExceptionOfType(TransactionSystemException.class).isThrownBy(() -> {
+ DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager(
+ this.operationFactoryMock);
+ tested.getOperationExecutors().push(this.operationExecutorMock);
- willThrow(new RuntimeException()).given(this.operationExecutorMock).rollback();
+ willThrow(new RuntimeException()).given(this.operationExecutorMock).rollback();
- tested.rollback();
+ tested.rollback();
+ });
}
@Test
@@ -98,15 +101,17 @@ public void testCommit() {
verify(this.operationExecutorMock).commit();
}
- @Test(expected = TransactionSystemException.class)
+ @Test
public void testCommit_Exception() {
- DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager(
- this.operationFactoryMock);
- tested.getOperationExecutors().push(this.operationExecutorMock);
+ assertThatExceptionOfType(TransactionSystemException.class).isThrownBy(() -> {
+ DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager(
+ this.operationFactoryMock);
+ tested.getOperationExecutors().push(this.operationExecutorMock);
- willThrow(new RuntimeException()).given(this.operationExecutorMock).commit();
+ willThrow(new RuntimeException()).given(this.operationExecutorMock).commit();
- tested.commit();
+ tested.commit();
+ });
}
}
From 9cb2ba6f3b5fe769a67dc13088987b42f8cf65b2 Mon Sep 17 00:00:00 2001
From: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
Date: Thu, 17 Jul 2025 11:54:59 -0600
Subject: [PATCH 19/67] Update Ldif Tests to JUnit 5
Issue gh-1058
---
ldif/ldif-core/build.gradle | 11 +++++++++--
.../DefaultAttributeValidationPolicyTests.java | 16 +++++++---------
.../ldap/ldif/Ldap233LdifParserTests.java | 2 +-
.../ldap/ldif/LdifParserTests.java | 10 +++++-----
4 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/ldif/ldif-core/build.gradle b/ldif/ldif-core/build.gradle
index b0aed199c5..86ef8518a9 100644
--- a/ldif/ldif-core/build.gradle
+++ b/ldif/ldif-core/build.gradle
@@ -6,13 +6,20 @@ dependencies {
management platform(project(":spring-ldap-dependencies"))
api project(":spring-ldap-core")
+
testImplementation platform('org.junit:junit-bom')
- testImplementation "org.junit.vintage:junit-vintage-engine"
- testImplementation "junit:junit"
testImplementation "org.assertj:assertj-core"
+ testImplementation "org.junit.jupiter:junit-jupiter-api"
+ testImplementation "org.junit.jupiter:junit-jupiter-engine"
+ testImplementation "org.junit.jupiter:junit-jupiter-params"
+ testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation ("log4j:log4j:1.2.17") {
exclude group: 'javax.jms'
exclude group: 'com.sun.jdmk'
exclude group: 'com.sun.jmx'
}
}
+
+tasks.withType(Test).configureEach {
+ useJUnitPlatform()
+}
diff --git a/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java b/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java
index ce42b737be..5aa797413d 100644
--- a/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java
+++ b/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java
@@ -21,10 +21,8 @@
import java.util.Collection;
import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,7 +42,6 @@
* @author Keith Barlow
*
*/
-@RunWith(Parameterized.class)
public class DefaultAttributeValidationPolicyTests {
private static Logger log = LoggerFactory.getLogger(DefaultAttributeValidationPolicyTests.class);
@@ -75,7 +72,6 @@ private enum AttributeType {
* The data set to parse.
* @return
*/
- @Parameters
public static Collection