This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git


The following commit(s) were added to refs/heads/master by this push:
     new a4ddadd0 Share regression tests across embedded and Docker databases
a4ddadd0 is described below

commit a4ddadd0206d7447bca24242d09e5a62c03b2a65
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Nov 27 23:07:29 2026 -0500

    Share regression tests across embedded and Docker databases
    
    Run the same test classes with H2 and HSQLDB through Surefire and
    PostgreSQL, MySQL, MariaDB, Oracle XE, and SQL Server through Failsafe.
    
    Centralize database selection and initialization, isolate test accounts
    and tables, and adapt SQL and JDBC assertions for each driver. Keep
    mock-only tests in Surefire and update the testing documentation.
---
 pom.xml                                            |  29 +++-
 src/site/xdoc/testing.xml                          |  24 +++-
 .../dbcp2/AbstractDatabaseConnectionTest.java      |   6 +-
 ...DatabaseTest.java => AbstractDatabaseTest.java} |  31 ++++-
 .../commons/dbcp2/DatabaseArgumentsProvider.java   |  60 +++++++++
 .../dbcp2/DatabaseArgumentsProviderTest.java       |  63 +++++++++
 ...tabaseTest.java => DatabaseConnectionTest.java} |   9 +-
 .../java/org/apache/commons/dbcp2/DatabaseIT.java  |  91 -------------
 .../org/apache/commons/dbcp2/DatabaseTestUser.java | 120 +++++++++++++++++
 .../org/apache/commons/dbcp2/Jdbc41BridgeTest.java | 147 +++++++++++----------
 .../dbcp2/TestBasicDataSourceInvalidation.java     |   4 +-
 .../dbcp2/TestConcurrentConnectionClose.java       |   8 +-
 .../TestConcurrentManagedConnectionClose.java      |   2 +-
 .../dbcp2/TestConcurrentStatementClose.java        |  11 +-
 .../apache/commons/dbcp2/TestDataSourceClose.java  |  69 +++++-----
 .../org/apache/commons/dbcp2/TestDatabase.java     | 135 ++++++++++++++++++-
 .../commons/dbcp2/TestDelegatingConnection.java    |  99 +++++++++++---
 .../dbcp2/TestDelegatingConnectionCachedState.java |  95 +++++++------
 .../dbcp2/TestUnderlyingConnectionAccess.java      |  50 ++++---
 .../dbcp2/managed/TestBasicManagedDataSource.java  |  77 -----------
 .../TestBasicManagedDataSourceDatabase.java        | 101 ++++++++++++++
 .../dbcp2/managed/TestConnectionWithNarayana.java  |  22 +--
 22 files changed, 857 insertions(+), 396 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6212fbbe..aea66911 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,7 +162,20 @@
     <dependency>
       <groupId>com.oracle.database.jdbc</groupId>
       <artifactId>ojdbc8</artifactId>
-      <version>21.24.0.0</version>
+      <version>${commons.oracle.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- Oracle SQLXML support used by the shared JDBC tests. -->
+    <dependency>
+      <groupId>com.oracle.database.xml</groupId>
+      <artifactId>xdb</artifactId>
+      <version>${commons.oracle.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.oracle.database.xml</groupId>
+      <artifactId>xmlparserv2</artifactId>
+      <version>${commons.oracle.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -220,6 +233,7 @@
     
<commons.scmPubCheckoutDirectory>site-content</commons.scmPubCheckoutDirectory>
     <commons.jira.id>DBCP</commons.jira.id>
     <commons.jira.pid>12310469</commons.jira.pid>
+    <commons.oracle.version>21.24.0.0</commons.oracle.version>
     <commons.pool.version>2.13.1</commons.pool.version>
     <!-- See DBCP-445 and DBCP-454 -->
     
<commons.osgi.import>javax.transaction;version="1.1.0",javax.transaction.xa;version="1.1.0";partial=true;mandatory:=partial,*</commons.osgi.import>
@@ -310,6 +324,9 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <argLine>@{dbcp.jacoco.argLine} ${argLine} 
${surefire.argline}</argLine>
+          <properties>
+            
<configurationParameters>dbcp.test.mode=embedded</configurationParameters>
+          </properties>
           <excludes>
             <!-- Integration tests are run only by Failsafe in the Docker 
profile. -->
             <exclude>**/*IT.java</exclude>
@@ -602,15 +619,25 @@
               <jvm>${commons.surefire.java}</jvm>
               <argLine>@{dbcp.jacoco.argLine} ${argLine} 
${surefire.argline}</argLine>
               <failIfNoTests>true</failIfNoTests>
+              <includes>
+                <include>**/Test*.java</include>
+                <include>**/*Test.java</include>
+              </includes>
+              <groups>database</groups>
+              <properties>
+                
<configurationParameters>dbcp.test.mode=docker</configurationParameters>
+              </properties>
               <systemPropertyVariables>
                 
<dbcp.test.databases>${dbcp.test.databases}</dbcp.test.databases>
                 
<dbcp.test.postgresql.url>jdbc:postgresql://${docker.host.address}:${dbcp.postgresql.port}/dbcp?connectTimeout=10&amp;socketTimeout=30</dbcp.test.postgresql.url>
                 <dbcp.test.postgresql.user>dbcp</dbcp.test.postgresql.user>
                 
<dbcp.test.postgresql.password>dbcp-test</dbcp.test.postgresql.password>
                 
<dbcp.test.mysql.url>jdbc:mysql://${docker.host.address}:${dbcp.mysql.port}/dbcp?sslMode=DISABLED&amp;allowPublicKeyRetrieval=true&amp;connectTimeout=10000&amp;socketTimeout=30000</dbcp.test.mysql.url>
+                
<dbcp.test.mysql.adminPassword>dbcp-root-test</dbcp.test.mysql.adminPassword>
                 <dbcp.test.mysql.user>dbcp</dbcp.test.mysql.user>
                 <dbcp.test.mysql.password>dbcp-test</dbcp.test.mysql.password>
                 
<dbcp.test.mariadb.url>jdbc:mariadb://${docker.host.address}:${dbcp.mariadb.port}/dbcp?connectTimeout=10000&amp;socketTimeout=30000</dbcp.test.mariadb.url>
+                
<dbcp.test.mariadb.adminPassword>dbcp-root-test</dbcp.test.mariadb.adminPassword>
                 <dbcp.test.mariadb.user>dbcp</dbcp.test.mariadb.user>
                 
<dbcp.test.mariadb.password>dbcp-test</dbcp.test.mariadb.password>
                 
<dbcp.test.oracle.url>jdbc:oracle:thin:@//${docker.host.address}:${dbcp.oracle.port}/XEPDB1?oracle.net.CONNECT_TIMEOUT=10000&amp;oracle.jdbc.ReadTimeout=30000</dbcp.test.oracle.url>
diff --git a/src/site/xdoc/testing.xml b/src/site/xdoc/testing.xml
index a484f45b..fe82799d 100644
--- a/src/site/xdoc/testing.xml
+++ b/src/site/xdoc/testing.xml
@@ -33,7 +33,7 @@
     <section name="Docker databases">
       <p>
         With a running Docker daemon, use <code>mvn -B -ntp -Pdocker-it 
verify</code> to also run the shared
-        connection-pool tests against PostgreSQL, MySQL, MariaDB, Oracle 
Database Express Edition (XE),
+        database regression tests against PostgreSQL, MySQL, MariaDB, Oracle 
Database Express Edition (XE),
         and Microsoft SQL Server. The
         <a href="https://dmp.fabric8.io/";>Docker Maven plugin</a> starts the 
databases, waits for the final
         server startup log after initialization, and passes dynamically 
allocated ports to Failsafe.
@@ -74,14 +74,34 @@ mvn -B -ntp -Pdocker-it 
"-Ddbcp.test.databases=oracle,sqlserver" verify]]></sour
         are disabled for this partial suite; the main CI build enforces the 
full-suite coverage thresholds.
       </p>
       <source><![CDATA[mvn -B -ntp -Pdocker-it -DskipTests 
"-Djacoco.skip=true" "-Ddbcp.test.databases=mariadb" verify]]></source>
+      <p>To select one shared test class for a Docker run:</p>
+      <source><![CDATA[mvn -B -ntp -Pdocker-it -DskipTests 
"-Djacoco.skip=true" "-Ddbcp.test.databases=postgresql" 
"-Dit.test=TestUnderlyingConnectionAccess" verify]]></source>
       <p>
         The shared tests cover pool reuse, validation, invalidation, state 
restoration, rollback on return,
         CPDS logical handles, prepared statements, generated keys, and managed 
local/XA transactions with
-        Geronimo and Narayana. XA commit tests enlist a second resource to 
exercise two-phase commit.
+        Geronimo and Narayana. They also cover concurrent connection and 
statement close, terminal data-source
+        shutdown, cached state, JDBC bridge methods, and access to underlying 
driver objects. The same test
+        classes and parameter combinations run against the embedded engines 
and the selected Docker databases.
+        Driver-specific unsupported operations are checked explicitly. XA 
commit tests enlist a second resource
+        to exercise two-phase commit.
         PostgreSQL enables <code>max_prepared_transactions</code> for these 
tests. Oracle grants the test
         user access to the XA recovery views and package. SQL Server installs 
the JDBC XA procedures
         and grants the test login membership in <code>SqlJDBCXAUser</code> 
before running the tests.
       </p>
+      <p>
+        Database tests inherit <code>AbstractDatabaseTest</code>, which 
provides the <code>database</code> JUnit tag
+        and a common argument provider. Surefire sets 
<code>dbcp.test.mode=embedded</code>; Failsafe sets
+        <code>dbcp.test.mode=docker</code> through JUnit configuration 
parameters and includes only the tagged
+        tests. Failsafe discovers these shared classes even though their names 
end in <code>Test</code> or
+        start with <code>Test</code>. Ordinary mock-based unit tests remain in 
Surefire. Selecting Docker
+        aliases does not change the embedded databases exercised by Surefire.
+      </p>
+      <p>
+        Tables and temporary accounts use unique names and are removed after 
their pools close. Password-change
+        tests use disposable accounts instead of modifying the common test 
user. MySQL and MariaDB initialize
+        a small stored procedure for callable-statement tests. Oracle SQLXML 
tests include the driver's XML
+        support libraries. All server initialization uses JDBC.
+      </p>
       <p>
         Image versions are pinned in <code>dbcp.docker.postgresql.image</code>,
         <code>dbcp.docker.mysql.image</code>, 
<code>dbcp.docker.mariadb.image</code>,
diff --git 
a/src/test/java/org/apache/commons/dbcp2/AbstractDatabaseConnectionTest.java 
b/src/test/java/org/apache/commons/dbcp2/AbstractDatabaseConnectionTest.java
index 9e97d5a8..126c4099 100644
--- a/src/test/java/org/apache/commons/dbcp2/AbstractDatabaseConnectionTest.java
+++ b/src/test/java/org/apache/commons/dbcp2/AbstractDatabaseConnectionTest.java
@@ -45,7 +45,6 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.params.Parameter;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
@@ -57,7 +56,7 @@ import com.arjuna.ats.jta.common.jtaPropertyManager;
  * Shared connection-pool behavior exercised against every supported test 
database.
  */
 @Timeout(30)
-abstract class AbstractDatabaseConnectionTest {
+abstract class AbstractDatabaseConnectionTest extends AbstractDatabaseTest {
 
     /** Forces the transaction manager to use two-phase commit with the real 
database resource. */
     private static final class AdditionalResource implements XAResource {
@@ -125,9 +124,6 @@ abstract class AbstractDatabaseConnectionTest {
         return Stream.of(false, true).flatMap(narayana -> Stream.of(false, 
true)
                 .flatMap(xa -> Stream.of(false, true).map(commit -> 
Arguments.of(narayana, xa, commit))));
     }
-    /** Database selected by the concrete test class. */
-    @Parameter
-    TestDatabase database;
     /** Keeps embedded state alive across physical connection replacement. */
     private Connection anchor;
     /** URL shared by this test's physical connections. */
diff --git 
a/src/test/java/org/apache/commons/dbcp2/AbstractEmbeddedDatabaseTest.java 
b/src/test/java/org/apache/commons/dbcp2/AbstractDatabaseTest.java
similarity index 55%
rename from 
src/test/java/org/apache/commons/dbcp2/AbstractEmbeddedDatabaseTest.java
rename to src/test/java/org/apache/commons/dbcp2/AbstractDatabaseTest.java
index 1fff0c15..3c2cc9fa 100644
--- a/src/test/java/org/apache/commons/dbcp2/AbstractEmbeddedDatabaseTest.java
+++ b/src/test/java/org/apache/commons/dbcp2/AbstractDatabaseTest.java
@@ -17,19 +17,42 @@
 
 package org.apache.commons.dbcp2;
 
+import java.sql.SQLException;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.BeforeParameterizedClassInvocation;
 import org.junit.jupiter.params.Parameter;
 import org.junit.jupiter.params.ParameterizedClass;
-import org.junit.jupiter.params.provider.EnumSource;
+import org.junit.jupiter.params.provider.ArgumentsSource;
 
 /**
- * Parameterizes tests over the supported embedded databases.
+ * Parameterizes tests over the databases selected for this Maven execution.
+ *
+ * @since 2.15.0
  */
 @ParameterizedClass(name = "{0}")
-@EnumSource(value = TestDatabase.class, names = {"H2", "HSQLDB"})
-public abstract class AbstractEmbeddedDatabaseTest {
+@ArgumentsSource(DatabaseArgumentsProvider.class)
+@Tag("database")
+public abstract class AbstractDatabaseTest {
+
+    /**
+     * Initializes server-side support before any database test executes.
+     *
+     * @param database the selected database.
+     * @throws SQLException if initialization fails.
+     * @since 2.15.0
+     */
+    @BeforeParameterizedClassInvocation
+    @Timeout(60)
+    protected static void initializeDatabase(final TestDatabase database) 
throws SQLException {
+        database.initialize();
+    }
 
     /**
      * Database used by this invocation.
+     *
+     * @since 2.15.0
      */
     @Parameter
     protected TestDatabase database;
diff --git 
a/src/test/java/org/apache/commons/dbcp2/DatabaseArgumentsProvider.java 
b/src/test/java/org/apache/commons/dbcp2/DatabaseArgumentsProvider.java
new file mode 100644
index 00000000..edf884a6
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbcp2/DatabaseArgumentsProvider.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.commons.dbcp2;
+
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.support.ParameterDeclarations;
+
+/**
+ * Selects databases independently for Surefire and Failsafe.
+ */
+class DatabaseArgumentsProvider implements ArgumentsProvider {
+
+    /**
+     * Selects databases, rejecting invalid modes and server selections.
+     */
+    static Stream<TestDatabase> select(final String mode, final String 
selection) {
+        if ("embedded".equals(mode)) {
+            return Stream.of(TestDatabase.H2, TestDatabase.HSQLDB);
+        }
+        if (!"docker".equals(mode)) {
+            throw new IllegalArgumentException("Unknown dbcp.test.mode: " + 
mode);
+        }
+        if (selection == null) {
+            throw new IllegalArgumentException("Missing dbcp.test.databases; 
run mvn -Pdocker-it verify");
+        }
+        return Arrays.stream(selection.split(",", -1)).map(String::trim)
+                .map(name -> 
TestDatabase.valueOf(name.toUpperCase(Locale.ROOT))).peek(database -> {
+                    if (database == TestDatabase.H2 || database == 
TestDatabase.HSQLDB) {
+                        throw new IllegalArgumentException("Not a Docker 
database: " + database);
+                    }
+                }).distinct();
+    }
+
+    @Override
+    public Stream<? extends Arguments> provideArguments(final 
ParameterDeclarations parameters, final ExtensionContext context) {
+        return 
select(context.getConfigurationParameter("dbcp.test.mode").orElse("embedded"),
+                System.getProperty("dbcp.test.databases")).map(Arguments::of);
+    }
+}
diff --git 
a/src/test/java/org/apache/commons/dbcp2/DatabaseArgumentsProviderTest.java 
b/src/test/java/org/apache/commons/dbcp2/DatabaseArgumentsProviderTest.java
new file mode 100644
index 00000000..58ce7eab
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbcp2/DatabaseArgumentsProviderTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.commons.dbcp2;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.NullAndEmptySource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+/**
+ * Tests execution isolation and strict database selection.
+ */
+class DatabaseArgumentsProviderTest {
+
+    @Test
+    void testDockerSelection() {
+        assertEquals(Arrays.asList(TestDatabase.POSTGRESQL, 
TestDatabase.MYSQL, TestDatabase.MARIADB, TestDatabase.ORACLE, 
TestDatabase.SQLSERVER),
+                DatabaseArgumentsProvider.select("docker", " 
PostgreSQL,mysql,mariadb,oracle,SQLSERVER,mysql 
").collect(Collectors.toList()));
+    }
+
+    @ParameterizedTest
+    @NullAndEmptySource
+    @ValueSource(strings = {"postgresql", "not-a-database"})
+    void testEmbeddedSelectionIsIndependent(final String selection) {
+        assertEquals(Arrays.asList(TestDatabase.H2, TestDatabase.HSQLDB),
+                DatabaseArgumentsProvider.select("embedded", 
selection).collect(Collectors.toList()));
+    }
+
+    @ParameterizedTest
+    @NullAndEmptySource
+    @ValueSource(strings = {"h2", "hsqldb", "postgresql,", " ,mysql", 
"unknown", "mysql,h2"})
+    void testRejectInvalidDockerSelection(final String selection) {
+        assertThrows(IllegalArgumentException.class, () -> 
DatabaseArgumentsProvider.select("docker", 
selection).collect(Collectors.toList()));
+    }
+
+    @ParameterizedTest
+    @NullAndEmptySource
+    @ValueSource(strings = {"server", "EMBEDDED"})
+    void testRejectUnknownMode(final String mode) {
+        assertThrows(IllegalArgumentException.class, () -> 
DatabaseArgumentsProvider.select(mode, "mysql").collect(Collectors.toList()));
+    }
+}
diff --git a/src/test/java/org/apache/commons/dbcp2/EmbeddedDatabaseTest.java 
b/src/test/java/org/apache/commons/dbcp2/DatabaseConnectionTest.java
similarity index 71%
rename from src/test/java/org/apache/commons/dbcp2/EmbeddedDatabaseTest.java
rename to src/test/java/org/apache/commons/dbcp2/DatabaseConnectionTest.java
index efbba34c..11592200 100644
--- a/src/test/java/org/apache/commons/dbcp2/EmbeddedDatabaseTest.java
+++ b/src/test/java/org/apache/commons/dbcp2/DatabaseConnectionTest.java
@@ -17,13 +17,8 @@
 
 package org.apache.commons.dbcp2;
 
-import org.junit.jupiter.params.ParameterizedClass;
-import org.junit.jupiter.params.provider.EnumSource;
-
 /**
- * Runs the common database contract against both embedded engines.
+ * Runs the common database contract against each selected database.
  */
-@ParameterizedClass(name = "{0}")
-@EnumSource(value = TestDatabase.class, names = {"H2", "HSQLDB"})
-class EmbeddedDatabaseTest extends AbstractDatabaseConnectionTest {
+class DatabaseConnectionTest extends AbstractDatabaseConnectionTest {
 }
diff --git a/src/test/java/org/apache/commons/dbcp2/DatabaseIT.java 
b/src/test/java/org/apache/commons/dbcp2/DatabaseIT.java
deleted file mode 100644
index e441878e..00000000
--- a/src/test/java/org/apache/commons/dbcp2/DatabaseIT.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.commons.dbcp2;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.stream.Stream;
-
-import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.params.BeforeParameterizedClassInvocation;
-import org.junit.jupiter.params.ParameterizedClass;
-import org.junit.jupiter.params.provider.MethodSource;
-
-/**
- * Runs the common database contract against the Maven-managed Docker 
databases.
- */
-@ParameterizedClass(name = "{0}")
-@MethodSource("databases")
-class DatabaseIT extends AbstractDatabaseConnectionTest {
-
-    /**
-     * Selects the same comma-separated database aliases used by the Docker 
Maven plugin.
-     *
-     * @return the selected server databases.
-     */
-    static Stream<TestDatabase> databases() {
-        return Arrays.stream(System.getProperty("dbcp.test.databases", 
"postgresql,mysql,mariadb,oracle,sqlserver").split(",", -1))
-                .map(String::trim).map(name -> 
TestDatabase.valueOf(name.toUpperCase(Locale.ROOT))).peek(database -> {
-                    if (database == TestDatabase.H2 || database == 
TestDatabase.HSQLDB) {
-                        throw new IllegalArgumentException("Use 
EmbeddedDatabaseTest for " + database);
-                    }
-                }).distinct();
-    }
-
-    /**
-     * Configures server-side XA support using JDBC, independently of the host 
operating system.
-     *
-     * @param database the selected database.
-     * @throws SQLException if database initialization fails.
-     */
-    @BeforeParameterizedClassInvocation
-    @Timeout(60)
-    static void initializeDatabase(final TestDatabase database) throws 
SQLException {
-        if (database == TestDatabase.ORACLE) {
-            final Properties properties = new Properties();
-            properties.setProperty("user", "sys");
-            properties.setProperty("password", 
System.getProperty("dbcp.test.oracle.adminPassword"));
-            properties.setProperty("internal_logon", "sysdba");
-            try (Connection connection = 
DriverManager.getConnection(database.newUrl(), properties);
-                    Statement statement = connection.createStatement()) {
-                statement.execute("GRANT SELECT ON 
SYS.DBA_PENDING_TRANSACTIONS TO dbcp");
-                statement.execute("GRANT SELECT ON SYS.PENDING_TRANS$ TO 
dbcp");
-                statement.execute("GRANT SELECT ON SYS.DBA_2PC_PENDING TO 
dbcp");
-                statement.execute("GRANT EXECUTE ON SYS.DBMS_XA TO dbcp");
-            }
-        } else if (database == TestDatabase.SQLSERVER) {
-            try (Connection connection = 
DriverManager.getConnection(System.getProperty("dbcp.test.sqlserver.adminUrl"), 
"sa", database.getPassword());
-                    Statement statement = connection.createStatement()) {
-                statement.execute("EXEC sp_sqljdbc_xa_install");
-                statement.execute("IF DB_ID('dbcp') IS NULL CREATE DATABASE 
dbcp");
-                statement.execute("IF SUSER_ID('dbcp') IS NULL CREATE LOGIN 
dbcp WITH PASSWORD = '"
-                        + database.getPassword().replace("'", "''") + "'");
-                statement.execute("IF DATABASE_PRINCIPAL_ID('dbcp') IS NULL 
CREATE USER dbcp FOR LOGIN dbcp");
-                statement.execute("ALTER ROLE SqlJDBCXAUser ADD MEMBER dbcp");
-                statement.execute("USE dbcp");
-                statement.execute("IF DATABASE_PRINCIPAL_ID('dbcp') IS NULL 
CREATE USER dbcp FOR LOGIN dbcp");
-                statement.execute("ALTER ROLE db_owner ADD MEMBER dbcp");
-            }
-        }
-    }
-}
diff --git a/src/test/java/org/apache/commons/dbcp2/DatabaseTestUser.java 
b/src/test/java/org/apache/commons/dbcp2/DatabaseTestUser.java
new file mode 100644
index 00000000..4864fdae
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbcp2/DatabaseTestUser.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.commons.dbcp2;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.UUID;
+
+/**
+ * An isolated database account, removed after its pools have closed.
+ */
+final class DatabaseTestUser implements AutoCloseable {
+    private final TestDatabase database;
+    private final String url;
+    private final String name = "DBCP_U_" + 
UUID.randomUUID().toString().replace("-", "").substring(0, 
16).toUpperCase(java.util.Locale.ROOT);
+    private String password;
+
+    /**
+     * Creates a disposable login with permission to connect to the test 
database.
+     */
+    DatabaseTestUser(final TestDatabase database, final String url, final 
String password) throws SQLException {
+        this.database = database;
+        this.url = url;
+        this.password = password;
+        try (Connection connection = database.adminConnection(url); Statement 
statement = connection.createStatement()) {
+            switch (database) {
+            case MYSQL:
+            case MARIADB:
+                statement.execute("CREATE USER '" + name + "'@'%' IDENTIFIED 
BY '" + password + "'");
+                statement.execute("GRANT ALL ON dbcp.* TO '" + name + "'@'%'");
+                break;
+            case ORACLE:
+                statement.execute("CREATE USER " + name + " IDENTIFIED BY \"" 
+ password + "\"");
+                statement.execute("GRANT CREATE SESSION TO " + name);
+                break;
+            case SQLSERVER:
+                statement.execute("CREATE LOGIN " + name + " WITH PASSWORD = 
'" + password + "'");
+                statement.execute("USE dbcp");
+                statement.execute("CREATE USER " + name + " FOR LOGIN " + 
name);
+                break;
+            default:
+                statement.execute("CREATE USER \"" + name + "\" " + (database 
== TestDatabase.POSTGRESQL ? "WITH " : "")
+                        + "PASSWORD '" + password + "'");
+            }
+        }
+    }
+
+    /**
+     * Changes this account's password without modifying the common database 
account.
+     */
+    void changePassword(final String value) throws SQLException {
+        try (Connection connection = database.adminConnection(url); Statement 
statement = connection.createStatement()) {
+            switch (database) {
+            case MYSQL:
+            case MARIADB:
+                statement.execute("ALTER USER '" + name + "'@'%' IDENTIFIED BY 
'" + value + "'");
+                break;
+            case ORACLE:
+                statement.execute("ALTER USER " + name + " IDENTIFIED BY \"" + 
value + "\"");
+                break;
+            case SQLSERVER:
+                statement.execute("ALTER LOGIN " + name + " WITH PASSWORD = '" 
+ value + "'");
+                break;
+            default:
+                statement.execute("ALTER USER \"" + name + "\" " + (database 
== TestDatabase.POSTGRESQL ? "WITH " : "SET ")
+                        + "PASSWORD '" + value + "'");
+            }
+            password = value;
+        }
+    }
+
+    @Override
+    public void close() throws SQLException {
+        try (Connection connection = database.adminConnection(url); Statement 
statement = connection.createStatement()) {
+            switch (database) {
+            case MYSQL:
+            case MARIADB:
+                statement.execute("DROP USER '" + name + "'@'%'");
+                break;
+            case SQLSERVER:
+                statement.execute("USE dbcp");
+                statement.execute("DROP USER " + name);
+                statement.execute("DROP LOGIN " + name);
+                break;
+            default:
+                statement.execute("DROP USER \"" + name + "\"");
+            }
+        }
+    }
+
+    /**
+     * Gets the login name.
+     */
+    String getName() {
+        return name;
+    }
+
+    /**
+     * Gets the current password.
+     */
+    String getPassword() {
+        return password;
+    }
+}
diff --git a/src/test/java/org/apache/commons/dbcp2/Jdbc41BridgeTest.java 
b/src/test/java/org/apache/commons/dbcp2/Jdbc41BridgeTest.java
index f0e308b2..ab875952 100644
--- a/src/test/java/org/apache/commons/dbcp2/Jdbc41BridgeTest.java
+++ b/src/test/java/org/apache/commons/dbcp2/Jdbc41BridgeTest.java
@@ -19,9 +19,9 @@ package org.apache.commons.dbcp2;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.math.BigDecimal;
@@ -29,9 +29,8 @@ import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLSyntaxErrorException;
 import java.sql.Statement;
-import java.sql.Types;
+import java.util.concurrent.Executor;
 
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
@@ -39,7 +38,7 @@ import org.mockito.Mockito;
 /**
  * Tests {@link Jdbc41Bridge}.
  */
-class Jdbc41BridgeTest extends AbstractEmbeddedDatabaseTest {
+class Jdbc41BridgeTest extends AbstractDatabaseTest {
 
     private Connection getConnection() throws SQLException {
         return database.connect();
@@ -49,20 +48,21 @@ class Jdbc41BridgeTest extends AbstractEmbeddedDatabaseTest 
{
     @Test
     void testAbort() throws SQLException {
         // Normal
-        try (Connection conn = getConnection()) {
-            Jdbc41Bridge.abort(conn, r -> {
-                // empty for now
-            });
+        try (Connection conn = getConnection(); Connection physical = 
getConnection()) {
+            physical.abort(Runnable::run);
+            Jdbc41Bridge.abort(conn, Runnable::run);
+            assertEquals(physical.isClosed(), conn.isClosed());
         }
         // Force AbstractMethodError
         try (Connection conn = getConnection()) {
-            final Connection spy = Mockito.spy(conn);
-            Mockito.doThrow(new AbstractMethodError()).when(spy).abort(r -> {
-                // empty for now
-            });
-            Jdbc41Bridge.abort(spy, r -> {
-                // empty for now
-            });
+            final Connection legacy = new 
DelegatingConnection<Connection>(conn) {
+                @Override
+                public void abort(final Executor executor) {
+                    throw new AbstractMethodError();
+                }
+            };
+            Jdbc41Bridge.abort(legacy, Runnable::run);
+            assertTrue(conn.isClosed());
         }
     }
 
@@ -88,7 +88,7 @@ class Jdbc41BridgeTest extends AbstractEmbeddedDatabaseTest {
     void testGeneratedKeyAlwaysReturned() throws SQLException {
         // Normal
         try (Connection conn = getConnection()) {
-            
assertTrue(Jdbc41Bridge.generatedKeyAlwaysReturned(conn.getMetaData()));
+            assertEquals(conn.getMetaData().generatedKeyAlwaysReturned(), 
Jdbc41Bridge.generatedKeyAlwaysReturned(conn.getMetaData()));
         }
         // Cannot mock a final class
         // Force AbstractMethodError
@@ -108,66 +108,70 @@ class Jdbc41BridgeTest extends 
AbstractEmbeddedDatabaseTest {
             } else {
                 Jdbc41Bridge.setNetworkTimeout(conn, Runnable::run, 30_000);
             }
-            // Embedded drivers do not use a network timeout.
-            assertEquals(0, Jdbc41Bridge.getNetworkTimeout(conn));
+            // Check the behavior reported by the selected driver.
+            assertEquals(conn.getNetworkTimeout(), 
Jdbc41Bridge.getNetworkTimeout(conn));
+        }
+    }
+
+    /**
+     * A typed ResultSet lookup.
+     */
+    @FunctionalInterface
+    private interface JdbcLookup {
+        Object get() throws SQLException;
+    }
+
+    /**
+     * Checks typed values and driver-specific conversion exceptions against 
the JDBC implementation.
+     */
+    private static void assertLookup(final JdbcLookup physical, final 
JdbcLookup bridge) throws SQLException {
+        final Object expected;
+        try {
+            expected = physical.get();
+        } catch (final SQLException e) {
+            final SQLException actual = assertThrowsExactly(e.getClass(), 
bridge::get);
+            assertEquals(e.getSQLState(), actual.getSQLState());
+            return;
+        }
+        assertEquals(expected, bridge.get());
+    }
+
+    /**
+     * Finds a metadata type whose JDBC code also fits in a byte.
+     */
+    private static void findType(final ResultSet rs) throws SQLException {
+        while (rs.next()) {
+            final int type = rs.getInt("DATA_TYPE");
+            if (type >= Byte.MIN_VALUE && type <= Byte.MAX_VALUE) {
+                return;
+            }
         }
+        org.junit.jupiter.api.Assertions.fail("No JDBC type with a byte-sized 
code");
     }
 
     @Test
     void testGetObjectIndex() throws SQLException {
-        // Normal
-        try (Connection conn = getConnection();
-                ResultSet rs = conn.getMetaData().getTypeInfo()) {
-            // Metadata ordering and the range of type codes differ between 
drivers.
-            while (rs.next() && rs.getInt("DATA_TYPE") != Types.INTEGER) {
-                // Find a type whose code also fits in a byte.
-            }
-            assertEquals(Types.INTEGER, rs.getInt("DATA_TYPE"));
-            assertNotNull(Jdbc41Bridge.getObject(rs, 1, String.class));
-            //
-            assertNotNull(Jdbc41Bridge.getObject(rs, 2, Integer.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, 2, Long.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, 2, Double.class));
-            if (database == TestDatabase.HSQLDB) {
-                // HyperSQL does not implement typed retrieval as Float.
-                assertThrows(SQLSyntaxErrorException.class, () -> 
Jdbc41Bridge.getObject(rs, 2, Float.class));
-            } else {
-                assertNotNull(Jdbc41Bridge.getObject(rs, 2, Float.class));
+        try (Connection conn = getConnection(); ResultSet rs = 
conn.getMetaData().getTypeInfo()) {
+            findType(rs);
+            assertLookup(() -> rs.getObject(1, String.class), () -> 
Jdbc41Bridge.getObject(rs, 1, String.class));
+            for (Class<?> type : new Class<?>[] {Integer.class, Long.class, 
Double.class, Float.class, Byte.class, BigDecimal.class}) {
+                assertLookup(() -> rs.getObject(2, type), () -> 
Jdbc41Bridge.getObject(rs, 2, type));
             }
-            assertNotNull(Jdbc41Bridge.getObject(rs, 2, Byte.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, 2, BigDecimal.class));
-            //
-            assertNotNull(Jdbc41Bridge.getObject(rs, 7, Short.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, 8, Boolean.class));
+            assertLookup(() -> rs.getObject(7, Short.class), () -> 
Jdbc41Bridge.getObject(rs, 7, Short.class));
+            assertLookup(() -> rs.getObject(8, Boolean.class), () -> 
Jdbc41Bridge.getObject(rs, 8, Boolean.class));
         }
     }
 
     @Test
     void testGetObjectName() throws SQLException {
-        // Normal
-        try (Connection conn = getConnection();
-                ResultSet rs = conn.getMetaData().getTypeInfo()) {
-            // Metadata ordering and the range of type codes differ between 
drivers.
-            while (rs.next() && rs.getInt("DATA_TYPE") != Types.INTEGER) {
-                // Find a type whose code also fits in a byte.
+        try (Connection conn = getConnection(); ResultSet rs = 
conn.getMetaData().getTypeInfo()) {
+            findType(rs);
+            assertLookup(() -> rs.getObject("TYPE_NAME", String.class), () -> 
Jdbc41Bridge.getObject(rs, "TYPE_NAME", String.class));
+            for (Class<?> type : new Class<?>[] {Integer.class, Long.class, 
Double.class, Float.class, Byte.class, BigDecimal.class}) {
+                assertLookup(() -> rs.getObject("DATA_TYPE", type), () -> 
Jdbc41Bridge.getObject(rs, "DATA_TYPE", type));
             }
-            assertEquals(Types.INTEGER, rs.getInt("DATA_TYPE"));
-            assertNotNull(Jdbc41Bridge.getObject(rs, "TYPE_NAME", 
String.class));
-            //
-            assertNotNull(Jdbc41Bridge.getObject(rs, "DATA_TYPE", 
Integer.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, "DATA_TYPE", Long.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, "DATA_TYPE", 
Double.class));
-            if (database == TestDatabase.HSQLDB) {
-                // HyperSQL does not implement typed retrieval as Float.
-                assertThrows(SQLSyntaxErrorException.class, () -> 
Jdbc41Bridge.getObject(rs, "DATA_TYPE", Float.class));
-            } else {
-                assertNotNull(Jdbc41Bridge.getObject(rs, "DATA_TYPE", 
Float.class));
-            }
-            assertNotNull(Jdbc41Bridge.getObject(rs, "DATA_TYPE", Byte.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, "DATA_TYPE", 
BigDecimal.class));
-            //
-            assertNotNull(Jdbc41Bridge.getObject(rs, "NULLABLE", Short.class));
-            assertNotNull(Jdbc41Bridge.getObject(rs, "CASE_SENSITIVE", 
Boolean.class));
+            assertLookup(() -> rs.getObject("NULLABLE", Short.class), () -> 
Jdbc41Bridge.getObject(rs, "NULLABLE", Short.class));
+            assertLookup(() -> rs.getObject("CASE_SENSITIVE", Boolean.class), 
() -> Jdbc41Bridge.getObject(rs, "CASE_SENSITIVE", Boolean.class));
         }
     }
 
@@ -180,7 +184,8 @@ class Jdbc41BridgeTest extends AbstractEmbeddedDatabaseTest 
{
             if (database == TestDatabase.HSQLDB) {
                 assertThrows(SQLFeatureNotSupportedException.class, () -> 
Jdbc41Bridge.getParentLogger(database.createDataSource(database.newUrl())));
             } else {
-                
assertNull(Jdbc41Bridge.getParentLogger(database.createDataSource(database.newUrl())));
+                final javax.sql.DataSource source = 
database.createDataSource(database.newUrl());
+                assertEquals(source.getParentLogger(), 
Jdbc41Bridge.getParentLogger(source));
             }
         }
     }
@@ -190,7 +195,7 @@ class Jdbc41BridgeTest extends AbstractEmbeddedDatabaseTest 
{
     void testGetSchema() throws SQLException {
         // Normal
         try (Connection conn = getConnection()) {
-            assertNotNull(Jdbc41Bridge.getSchema(conn));
+            assertEquals(conn.getSchema(), Jdbc41Bridge.getSchema(conn));
             final Connection spy = Mockito.spy(conn);
             Mockito.when(spy.getSchema()).thenThrow(AbstractMethodError.class);
             assertNull(Jdbc41Bridge.getSchema(spy));
@@ -211,13 +216,13 @@ class Jdbc41BridgeTest extends 
AbstractEmbeddedDatabaseTest {
         // Normal
         try (Connection conn = getConnection();
                 Statement stmt = conn.createStatement()) {
-            // Embedded drivers do not use a network timeout.
+            // Check the behavior reported by the selected driver.
             if (database == TestDatabase.HSQLDB) {
-                assertThrows(SQLFeatureNotSupportedException.class, () -> 
Jdbc41Bridge.setNetworkTimeout(conn, Runnable::run, 30_0000));
+                assertThrows(SQLFeatureNotSupportedException.class, () -> 
Jdbc41Bridge.setNetworkTimeout(conn, Runnable::run, 30_000));
             } else {
-                Jdbc41Bridge.setNetworkTimeout(conn, Runnable::run, 30_0000);
+                Jdbc41Bridge.setNetworkTimeout(conn, Runnable::run, 30_000);
             }
-            assertEquals(0, Jdbc41Bridge.getNetworkTimeout(conn));
+            assertEquals(conn.getNetworkTimeout(), 
Jdbc41Bridge.getNetworkTimeout(conn));
         }
     }
 
@@ -227,7 +232,7 @@ class Jdbc41BridgeTest extends AbstractEmbeddedDatabaseTest 
{
         try (Connection conn = getConnection();
                 Statement stmt = conn.createStatement()) {
             Jdbc41Bridge.setSchema(conn, Jdbc41Bridge.getSchema(conn));
-            final String expected = "PUBLIC";
+            final String expected = conn.getSchema();
             Jdbc41Bridge.setSchema(conn, expected);
             assertEquals(expected, Jdbc41Bridge.getSchema(conn));
         }
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceInvalidation.java 
b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceInvalidation.java
index d665b5a4..e19e2176 100644
--- 
a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceInvalidation.java
+++ 
b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceInvalidation.java
@@ -45,7 +45,7 @@ import org.junit.jupiter.params.provider.ValueSource;
 /**
  * Tests termination and identity-based traversal when invalidating wrapped 
connections.
  */
-class TestBasicDataSourceInvalidation extends AbstractEmbeddedDatabaseTest {
+class TestBasicDataSourceInvalidation extends AbstractDatabaseTest {
 
     /** Distinct instances compare equal, but must remain distinct nodes in a 
delegate chain. */
     private static final class EqualConnection extends 
DelegatingConnection<Connection> {
@@ -122,7 +122,7 @@ class TestBasicDataSourceInvalidation extends 
AbstractEmbeddedDatabaseTest {
     void setUp() throws SQLException {
         dataSource = new BasicDataSource();
         dataSource.setDriver(database.getDriver());
-        dataSource.setUrl(database.newUrl());
+        database.configure(dataSource, database.newUrl());
         pooledConnection = dataSource.getConnection();
     }
 
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestConcurrentConnectionClose.java 
b/src/test/java/org/apache/commons/dbcp2/TestConcurrentConnectionClose.java
index f295c978..55519a80 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestConcurrentConnectionClose.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestConcurrentConnectionClose.java
@@ -66,7 +66,7 @@ import org.junit.jupiter.params.provider.MethodSource;
 import org.junit.jupiter.params.provider.ValueSource;
 
 /** Tests overlapping closes, including reborrowing before the original close 
finishes. */
-class TestConcurrentConnectionClose extends AbstractEmbeddedDatabaseTest {
+class TestConcurrentConnectionClose extends AbstractDatabaseTest {
 
     /** A traced resource that pauses closing before the delegate is returned 
to its pool. */
     private static final class CleanupTrace extends AbandonedTrace {
@@ -276,8 +276,7 @@ class TestConcurrentConnectionClose extends 
AbstractEmbeddedDatabaseTest {
                 return connection;
             }
         };
-        cpds.setDriver(database.getDriverClassName());
-        cpds.setUrl(database.newUrl());
+        database.configure(cpds, database.newUrl());
         final InstanceKeyDataSource ds;
         final PoolFixture fixture;
         if (path == PoolPath.PER_USER) {
@@ -597,8 +596,7 @@ class TestConcurrentConnectionClose extends 
AbstractEmbeddedDatabaseTest {
     @Test
     void testCpdsCloseListenerCanCloseAndReborrow() throws Exception {
         final DriverAdapterCPDS cpds = new DriverAdapterCPDS();
-        cpds.setDriver(database.getDriverClassName());
-        cpds.setUrl(database.newUrl());
+        database.configure(cpds, database.newUrl());
         final PooledConnection pooled = cpds.getPooledConnection();
         try {
             final Connection first = pooled.getConnection();
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestConcurrentManagedConnectionClose.java
 
b/src/test/java/org/apache/commons/dbcp2/TestConcurrentManagedConnectionClose.java
index 92315d78..74252518 100644
--- 
a/src/test/java/org/apache/commons/dbcp2/TestConcurrentManagedConnectionClose.java
+++ 
b/src/test/java/org/apache/commons/dbcp2/TestConcurrentManagedConnectionClose.java
@@ -52,7 +52,7 @@ import org.junit.jupiter.params.provider.ValueSource;
 /**
  * Tests ownership of managed delegates when close overlaps a transaction 
callback.
  */
-class TestConcurrentManagedConnectionClose extends 
AbstractEmbeddedDatabaseTest {
+class TestConcurrentManagedConnectionClose extends AbstractDatabaseTest {
 
     /**
      * Failures during delegate inspection or close must not leave the 
delegate attached.
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestConcurrentStatementClose.java 
b/src/test/java/org/apache/commons/dbcp2/TestConcurrentStatementClose.java
index 36062c44..9eaf0d1d 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestConcurrentStatementClose.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestConcurrentStatementClose.java
@@ -43,7 +43,7 @@ import org.junit.jupiter.params.provider.MethodSource;
 /**
  * Tests concurrent explicit and connection-driven statement cleanup.
  */
-class TestConcurrentStatementClose extends AbstractEmbeddedDatabaseTest {
+class TestConcurrentStatementClose extends AbstractDatabaseTest {
 
     /**
      * Cleanup failures must still leave the wrapper closed and its delegate 
detached.
@@ -78,7 +78,7 @@ class TestConcurrentStatementClose extends 
AbstractEmbeddedDatabaseTest {
      * Prepares a statement that uses a single reusable pool entry.
      */
     private PreparedStatement prepare(final Connection connection, final 
boolean callable) throws SQLException {
-        return callable ? connection.prepareCall("CALL ABS(?)") : 
connection.prepareStatement(database.selectParameter());
+        return callable ? connection.prepareCall(database.callQuery()) : 
connection.prepareStatement(database.selectParameter());
     }
 
     @ParameterizedTest
@@ -216,7 +216,12 @@ class TestConcurrentStatementClose extends 
AbstractEmbeddedDatabaseTest {
                         assertEquals(0, pool.getNumIdle());
                         assertFalse(next.isClosed());
                         assertThrows(SQLException.class, () -> 
prepare(nextConnection, callable));
-                        next.setInt(1, 42);
+                        if (callable && database == TestDatabase.H2) {
+                            ((CallableStatement) next).registerOutParameter(1, 
java.sql.Types.INTEGER);
+                            next.setInt(2, 42);
+                        } else {
+                            next.setInt(1, 42);
+                        }
                         try (ResultSet result = next.executeQuery()) {
                             assertTrue(result.next());
                             assertEquals(42, result.getInt(1));
diff --git a/src/test/java/org/apache/commons/dbcp2/TestDataSourceClose.java 
b/src/test/java/org/apache/commons/dbcp2/TestDataSourceClose.java
index b243985a..578f767e 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestDataSourceClose.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestDataSourceClose.java
@@ -27,9 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.time.Duration;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -58,7 +56,7 @@ import org.junit.jupiter.params.provider.ValueSource;
 /**
  * Tests terminal data-source shutdown, including initialization and 
password-recovery races.
  */
-class TestDataSourceClose extends AbstractEmbeddedDatabaseTest {
+class TestDataSourceClose extends AbstractDatabaseTest {
 
     /**
      * Data-source lifecycle states in which shutdown must prevent new 
requests.
@@ -79,11 +77,10 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
         private volatile int failAt;
 
         /**
-         * Uses independent in-memory databases so tests do not share 
credentials or state.
+         * Uses the selected database and its configured credentials.
          */
         TrackingCPDS(final TestDatabase database) throws 
ClassNotFoundException {
-            setDriver(database.getDriverClassName());
-            setUrl(database.newUrl());
+            database.configure(this, database.newUrl());
         }
 
         /**
@@ -168,7 +165,7 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
     private void assertRejectsBorrowing(final InstanceKeyDataSource 
dataSource, final TrackingCPDS cpds) {
         final int attempts = cpds.attempts.get();
         assertThrows(SQLException.class, dataSource::getConnection);
-        assertThrows(SQLException.class, () -> 
dataSource.getConnection(database.getUser(), ""));
+        assertThrows(SQLException.class, () -> 
dataSource.getConnection(database.getUser(), database.getPassword()));
         assertEquals(attempts, cpds.attempts.get(), "A closed data source 
contacted its provider");
     }
 
@@ -214,18 +211,22 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
     void testCloseAllUserPools() throws Exception {
         final TrackingCPDS cpds = new TrackingCPDS(database);
         try (Connection anchor = 
database.createDataSource(cpds.getUrl()).getConnection();
-                Statement setup = anchor.createStatement(); 
PerUserPoolDataSource dataSource = new PerUserPoolDataSource()) {
-            for (String user : new String[] {"first", "second", "third"}) {
-                setup.execute("CREATE USER \"" + user + "\" PASSWORD ''");
-            }
+                DatabaseTestUser first = new DatabaseTestUser(database, 
cpds.getUrl(), "Before_dbcp123!");
+                DatabaseTestUser second = new DatabaseTestUser(database, 
cpds.getUrl(), "Before_dbcp123!");
+                DatabaseTestUser third = new DatabaseTestUser(database, 
cpds.getUrl(), "Before_dbcp123!");
+                PerUserPoolDataSource dataSource = new 
PerUserPoolDataSource()) {
             configure(dataSource, cpds);
-            dataSource.getConnection("first", "").close();
-            dataSource.getConnection("second", "").close();
-            try (Connection active = dataSource.getConnection("third", "")) {
+            dataSource.getConnection(first.getName(), 
first.getPassword()).close();
+            dataSource.getConnection(second.getName(), 
second.getPassword()).close();
+            try (Connection active = dataSource.getConnection(third.getName(), 
third.getPassword())) {
                 dataSource.close();
                 assertTrue(active.isValid(1));
-                assertThrows(SQLException.class, () -> 
dataSource.getConnection("first", ""));
-                assertThrows(SQLException.class, () -> 
dataSource.getConnection("fourth", ""));
+                final int attempts = cpds.attempts.get();
+                assertThrows(SQLException.class, () -> 
dataSource.getConnection(first.getName(), first.getPassword()));
+                assertThrows(SQLException.class, () -> 
dataSource.getConnection(second.getName(), second.getPassword()));
+                assertThrows(SQLException.class, () -> 
dataSource.getConnection(third.getName(), third.getPassword()));
+                assertThrows(SQLException.class, () -> 
dataSource.getConnection("unused", first.getPassword()));
+                assertEquals(attempts, cpds.attempts.get(), "A closed data 
source contacted its provider");
             }
             cpds.assertClosed();
         }
@@ -235,8 +236,7 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
     @MethodSource("serializationCases")
     void testClosedPoolIsNotRecreatedThroughDeserializedDataSource(final 
boolean shared, final boolean initialized, final boolean closeCopy) throws 
Exception {
         final DriverAdapterCPDS cpds = new DriverAdapterCPDS();
-        cpds.setDriver(database.getDriverClassName());
-        cpds.setUrl(database.newUrl());
+        database.configure(cpds, database.newUrl());
         try (InstanceKeyDataSource dataSource = create(shared)) {
             dataSource.setConnectionPoolDataSource(cpds);
             if (initialized) {
@@ -343,7 +343,7 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
                 configure(dataSource, cpds);
             }
             if (state == State.INITIALIZED) {
-                try (Connection connection = credentials ? 
dataSource.getConnection(database.getUser(), "") : dataSource.getConnection()) {
+                try (Connection connection = credentials ? 
dataSource.getConnection(database.getUser(), database.getPassword()) : 
dataSource.getConnection()) {
                     assertFalse(connection.isClosed());
                 }
             }
@@ -385,8 +385,7 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
     @ValueSource(booleans = {false, true})
     void testDeserializedDataSourceSharesInitializationMonitor(final boolean 
shared) throws Exception {
         final DriverAdapterCPDS cpds = new DriverAdapterCPDS();
-        cpds.setDriver(database.getDriverClassName());
-        cpds.setUrl(database.newUrl());
+        database.configure(cpds, database.newUrl());
         try (InstanceKeyDataSource dataSource = create(shared)) {
             dataSource.setConnectionPoolDataSource(cpds);
             try (InstanceKeyDataSource copy = 
SerializationUtils.clone(dataSource)) {
@@ -413,29 +412,28 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
     void testPasswordChangeThroughDeserializedDataSource(final boolean shared) 
throws Exception {
         final String url = database.newUrl();
         final DriverAdapterCPDS cpds = new DriverAdapterCPDS();
-        cpds.setDriver(database.getDriverClassName());
-        cpds.setUrl(url);
+        database.configure(cpds, url);
         // Keep the database alive while password recovery replaces its pooled 
connections.
-        try (Connection anchor = DriverManager.getConnection(url, 
database.getUser(), "before"); InstanceKeyDataSource dataSource = 
create(shared)) {
+        try (Connection anchor = 
database.createDataSource(url).getConnection();
+                DatabaseTestUser user = new DatabaseTestUser(database, url, 
"Before_dbcp123!");
+                InstanceKeyDataSource dataSource = create(shared)) {
             dataSource.setConnectionPoolDataSource(cpds);
             dataSource.setDefaultMaxTotal(1);
             dataSource.setDefaultBlockWhenExhausted(false);
-            dataSource.getConnection(database.getUser(), "before").close();
+            dataSource.getConnection(user.getName(), 
"Before_dbcp123!").close();
             try (InstanceKeyDataSource copy = 
SerializationUtils.clone(dataSource)) {
-                try (Statement statement = anchor.createStatement()) {
-                    statement.execute("ALTER USER SA SET PASSWORD 'after'");
-                }
-                try (Connection connection = 
copy.getConnection(database.getUser(), "after")) {
+                user.changePassword("After_dbcp123!");
+                try (Connection connection = 
copy.getConnection(user.getName(), "After_dbcp123!")) {
                     assertTrue(connection.isValid(1));
-                    assertEquals(1, shared ? ((SharedPoolDataSource) 
dataSource).getNumActive() : ((PerUserPoolDataSource) 
dataSource).getNumActive(database.getUser()));
-                    assertEquals(1, shared ? ((SharedPoolDataSource) 
copy).getNumActive() : ((PerUserPoolDataSource) 
copy).getNumActive(database.getUser()));
+                    assertEquals(1, shared ? ((SharedPoolDataSource) 
dataSource).getNumActive() : ((PerUserPoolDataSource) 
dataSource).getNumActive(user.getName()));
+                    assertEquals(1, shared ? ((SharedPoolDataSource) 
copy).getNumActive() : ((PerUserPoolDataSource) 
copy).getNumActive(user.getName()));
                 }
-                try (Connection connection = 
dataSource.getConnection(database.getUser(), "after")) {
+                try (Connection connection = 
dataSource.getConnection(user.getName(), "After_dbcp123!")) {
                     assertTrue(connection.isValid(1));
                 }
-                assertThrows(SQLException.class, () -> 
copy.getConnection(database.getUser(), "before"));
+                assertThrows(SQLException.class, () -> 
copy.getConnection(user.getName(), "Before_dbcp123!"));
                 copy.close();
-                assertThrows(SQLException.class, () -> 
dataSource.getConnection(database.getUser(), "after"));
+                assertThrows(SQLException.class, () -> 
dataSource.getConnection(user.getName(), "After_dbcp123!"));
             }
         }
     }
@@ -460,8 +458,7 @@ class TestDataSourceClose extends 
AbstractEmbeddedDatabaseTest {
     @MethodSource("serializationCases")
     void testRepeatedClosePreservesNewRegistration(final boolean shared, final 
boolean initialized, final boolean closeCopy) throws Exception {
         final DriverAdapterCPDS cpds = new DriverAdapterCPDS();
-        cpds.setDriver(database.getDriverClassName());
-        cpds.setUrl(database.newUrl());
+        database.configure(cpds, database.newUrl());
         final ObjectFactory factory = shared ? new 
SharedPoolDataSourceFactory() : new PerUserPoolDataSourceFactory();
         try (InstanceKeyDataSource first = create(shared)) {
             first.setConnectionPoolDataSource(cpds);
diff --git a/src/test/java/org/apache/commons/dbcp2/TestDatabase.java 
b/src/test/java/org/apache/commons/dbcp2/TestDatabase.java
index c990642e..66afe565 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestDatabase.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestDatabase.java
@@ -24,6 +24,7 @@ import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Locale;
+import java.util.Properties;
 import java.util.UUID;
 
 import javax.sql.DataSource;
@@ -83,6 +84,11 @@ public enum TestDatabase {
      */
     SQLSERVER("com.microsoft.sqlserver.jdbc.SQLServerDriver");
 
+    /**
+     * Whether server initialization has completed in this test JVM.
+     */
+    private boolean initialized;
+
     /** JDBC driver class name. */
     private final String driverClassName;
 
@@ -91,6 +97,26 @@ public enum TestDatabase {
         this.driverClassName = driverClassName;
     }
 
+    /**
+     * Opens an administrative connection for isolated test accounts.
+     */
+    Connection adminConnection(final String url) throws SQLException {
+        if (this == ORACLE) {
+            final Properties properties = new Properties();
+            properties.setProperty("user", "sys");
+            properties.setProperty("password", property("adminPassword"));
+            properties.setProperty("internal_logon", "sysdba");
+            return DriverManager.getConnection(url, properties);
+        }
+        if (this == SQLSERVER) {
+            return DriverManager.getConnection(property("adminUrl"), "sa", 
getPassword());
+        }
+        if (this == MYSQL || this == MARIADB) {
+            return DriverManager.getConnection(url, "root", 
property("adminPassword"));
+        }
+        return DriverManager.getConnection(url, getUser(), getPassword());
+    }
+
     /**
      * Configures a DBCP data source for the supplied database URL.
      *
@@ -231,6 +257,47 @@ public enum TestDatabase {
         }
     }
 
+    /**
+     * Initializes XA support and the test account once per database and test 
JVM.
+     */
+    synchronized void initialize() throws SQLException {
+        if (initialized) {
+            return;
+        }
+        if (this == TestDatabase.ORACLE) {
+            final Properties properties = new Properties();
+            properties.setProperty("user", "sys");
+            properties.setProperty("password", 
System.getProperty("dbcp.test.oracle.adminPassword"));
+            properties.setProperty("internal_logon", "sysdba");
+            try (Connection connection = DriverManager.getConnection(newUrl(), 
properties);
+                    Statement statement = connection.createStatement()) {
+                statement.execute("GRANT SELECT ON 
SYS.DBA_PENDING_TRANSACTIONS TO dbcp");
+                statement.execute("GRANT SELECT ON SYS.PENDING_TRANS$ TO 
dbcp");
+                statement.execute("GRANT SELECT ON SYS.DBA_2PC_PENDING TO 
dbcp");
+                statement.execute("GRANT EXECUTE ON SYS.DBMS_XA TO dbcp");
+            }
+        } else if (this == TestDatabase.SQLSERVER) {
+            try (Connection connection = 
DriverManager.getConnection(System.getProperty("dbcp.test.sqlserver.adminUrl"), 
"sa", getPassword());
+                    Statement statement = connection.createStatement()) {
+                statement.execute("EXEC sp_sqljdbc_xa_install");
+                statement.execute("IF DB_ID('dbcp') IS NULL CREATE DATABASE 
dbcp");
+                statement.execute("IF SUSER_ID('dbcp') IS NULL CREATE LOGIN 
dbcp WITH PASSWORD = '"
+                        + getPassword().replace("'", "''") + "'");
+                statement.execute("IF DATABASE_PRINCIPAL_ID('dbcp') IS NULL 
CREATE USER dbcp FOR LOGIN dbcp");
+                statement.execute("ALTER ROLE SqlJDBCXAUser ADD MEMBER dbcp");
+                statement.execute("USE dbcp");
+                statement.execute("IF DATABASE_PRINCIPAL_ID('dbcp') IS NULL 
CREATE USER dbcp FOR LOGIN dbcp");
+                statement.execute("ALTER ROLE db_owner ADD MEMBER dbcp");
+            }
+        }
+        if (this == MYSQL || this == MARIADB) {
+            try (Connection connection = connect(); Statement statement = 
connection.createStatement()) {
+                statement.execute("CREATE PROCEDURE IF NOT EXISTS 
DBCP_QUERY(IN VALUE_ARG INT) SELECT VALUE_ARG AS ID");
+            }
+        }
+        initialized = true;
+    }
+
     /**
      * Gets the registered JDBC driver.
      *
@@ -268,7 +335,7 @@ public enum TestDatabase {
     }
 
     /**
-     * Gets the expected concrete JDBC class for an embedded driver.
+     * Gets the vendor JDBC type used by unwrapping assertions.
      *
      * @param jdbcType the standard JDBC interface.
      * @return the vendor implementation class.
@@ -279,11 +346,35 @@ public enum TestDatabase {
             prefix = "org.h2.jdbc.Jdbc";
         } else if (this == HSQLDB) {
             prefix = "org.hsqldb.jdbc.JDBC";
+        } else if (this == POSTGRESQL) {
+            prefix = "org.postgresql.jdbc.Pg";
+        } else if (this == SQLSERVER) {
+            prefix = "com.microsoft.sqlserver.jdbc.SQLServer";
+        } else if (this == ORACLE) {
+            prefix = jdbcType == java.sql.DatabaseMetaData.class ? 
"oracle.jdbc.driver.Oracle" : "oracle.jdbc.Oracle";
+        } else if (this == MARIADB) {
+            prefix = "org.mariadb.jdbc.";
         } else {
-            throw new IllegalStateException("Concrete class assertions are for 
embedded drivers: " + this);
+            prefix = "com.mysql.cj.jdbc.";
+        }
+        String type = jdbcType.getSimpleName();
+        if (this == MYSQL) {
+            if (jdbcType == java.sql.ResultSet.class) {
+                type = "result.ResultSetImpl";
+            } else if (jdbcType == java.sql.Connection.class || jdbcType == 
java.sql.Statement.class) {
+                type += "Impl";
+            } else if (jdbcType == java.sql.PreparedStatement.class) {
+                type = "ClientPreparedStatement";
+            }
+        } else if (this == MARIADB && jdbcType == java.sql.ResultSet.class) {
+            type = "client.result.Result";
+        } else if (this == MARIADB && jdbcType == 
java.sql.PreparedStatement.class) {
+            type = "BasePreparedStatement";
+        } else if (this == MARIADB && jdbcType == 
java.sql.CallableStatement.class) {
+            type = "BaseCallableStatement";
         }
         try {
-            return Class.forName(prefix + jdbcType.getSimpleName());
+            return Class.forName(prefix + type);
         } catch (final ClassNotFoundException e) {
             throw new IllegalStateException(e);
         }
@@ -346,6 +437,44 @@ public enum TestDatabase {
         return value;
     }
 
+    /**
+     * Gets a query that can be prepared as a callable statement.
+     */
+    String callQuery() {
+        return this == H2 ? "{? = call ABS(?)}" : this == HSQLDB ? "CALL 
ABS(?)"
+                : this == MYSQL || this == MARIADB ? "{call DBCP_QUERY(?)}" : 
selectParameter();
+    }
+
+    /**
+     * Gets the SQL type for a large text payload.
+     *
+     * @return the type.
+     * @since 2.15.0
+     */
+    public String getLargeTextType() {
+        switch (this) {
+        case MYSQL:
+        case MARIADB:
+            return "LONGTEXT";
+        case ORACLE:
+            return "CLOB";
+        case SQLSERVER:
+            return "VARCHAR(MAX)";
+        default:
+            return "VARCHAR(100000)";
+        }
+    }
+
+    /**
+     * Gets the SQL type for a timestamp value.
+     *
+     * @return the type.
+     * @since 2.15.0
+     */
+    public String getTimestampType() {
+        return this == SQLSERVER ? "DATETIME2" : "TIMESTAMP";
+    }
+
     /**
      * Gets SQL selecting a single integer.
      *
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java 
b/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
index 76da9f7b..9b3abd73 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
@@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.sql.Connection;
@@ -39,7 +40,7 @@ import org.junit.jupiter.api.Test;
 /**
  * Tests {@link DelegatingConnection}.
  */
-public class TestDelegatingConnection extends AbstractEmbeddedDatabaseTest {
+public class TestDelegatingConnection extends AbstractDatabaseTest {
 
     /**
      * Delegate that will throw RTE on toString Used to validate fix for 
DBCP-241
@@ -86,10 +87,60 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
         databaseConnection = new DelegatingConnection<>(database.connect());
     }
 
+    /**
+     * A JDBC object factory that may report an unsupported feature.
+     */
+    @FunctionalInterface
+    private interface JdbcFactory {
+        Object create() throws SQLException;
+    }
+
+    /**
+     * Checks successful delegation or propagation of the driver's 
unsupported-feature exception.
+     */
+    private static void assertCreation(final JdbcFactory physical, final 
JdbcFactory wrapped) throws SQLException {
+        final Object expected;
+        try {
+            expected = physical.create();
+        } catch (final SQLException e) {
+            if (!(e instanceof SQLFeatureNotSupportedException) && 
!"0A000".equals(e.getSQLState())) {
+                throw e;
+            }
+            final SQLException actual = assertThrowsExactly(e.getClass(), 
wrapped::create);
+            assertEquals(e.getSQLState(), actual.getSQLState());
+            return;
+        }
+        try {
+            final Object actual = wrapped.create();
+            try {
+                assertNotNull(actual);
+                assertEquals(expected.getClass(), actual.getClass());
+            } finally {
+                free(actual);
+            }
+        } finally {
+            free(expected);
+        }
+    }
+
+    /**
+     * Frees the temporary JDBC values allocated by the factory checks.
+     */
+    private static void free(final Object value) throws SQLException {
+        if (value instanceof java.sql.Blob) {
+            ((java.sql.Blob) value).free();
+        } else if (value instanceof java.sql.Clob) {
+            ((java.sql.Clob) value).free();
+        } else if (value instanceof java.sql.Array) {
+            ((java.sql.Array) value).free();
+        } else if (value instanceof java.sql.SQLXML) {
+            ((java.sql.SQLXML) value).free();
+        }
+    }
+
     @Test
     void testAbort() throws Exception {
-        databaseConnection.abort(r -> {
-        });
+        databaseConnection.abort(Runnable::run);
     }
 
     @Test
@@ -159,6 +210,7 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
 
     @Test
     void testCommit() throws Exception {
+        databaseConnection.setAutoCommit(false);
         databaseConnection.commit();
     }
 
@@ -171,32 +223,38 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
 
     @Test
     void testCreateArrayOf() throws Exception {
-        assertNotNull(databaseConnection.createArrayOf("CHARACTER", new 
Object[] { "A", "B" }));
+        if (database == TestDatabase.SQLSERVER) {
+            // SQL Server reports unsupported array creation as a generic 
SQLException.
+            assertThrows(SQLException.class, () -> 
databaseConnection.createArrayOf("VARCHAR", new Object[] {"A", "B"}));
+            return;
+        }
+        assertCreation(() -> 
databaseConnection.getDelegate().createArrayOf("VARCHAR", new Object[] {"A", 
"B"}),
+                () -> databaseConnection.createArrayOf("VARCHAR", new Object[] 
{"A", "B"}));
     }
 
     @Test
     void testCreateBlob() throws Exception {
-        assertNotNull(databaseConnection.createBlob());
+        assertCreation(() -> databaseConnection.getDelegate().createBlob(), 
databaseConnection::createBlob);
     }
 
     @Test
     void testCreateClob() throws Exception {
-        assertNotNull(databaseConnection.createClob());
+        assertCreation(() -> databaseConnection.getDelegate().createClob(), 
databaseConnection::createClob);
     }
 
     @Test
     void testCreateNClob() throws Exception {
-        assertNotNull(databaseConnection.createNClob());
+        assertCreation(() -> databaseConnection.getDelegate().createNClob(), 
databaseConnection::createNClob);
     }
 
     @Test
     void testCreateSQLXML() throws Exception {
-        assertNotNull(databaseConnection.createSQLXML());
+        assertCreation(() -> databaseConnection.getDelegate().createSQLXML(), 
databaseConnection::createSQLXML);
     }
 
     @Test
     void testCreateStruct() throws Exception {
-        // Neither embedded driver supports SQL structured types.
+        // CHARACTER is not a user-defined SQL structured type.
         assertThrows(SQLException.class, () -> 
databaseConnection.createStruct("CHARACTER", new Object[] { "A", "B" }));
     }
 
@@ -216,7 +274,11 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
 
     @Test
     void testGetClientInfoString() throws Exception {
-        assertNull(databaseConnection.getClientInfo("xyz"));
+        if (database == TestDatabase.ORACLE) {
+            assertThrows(java.sql.SQLClientInfoException.class, () -> 
databaseConnection.getClientInfo("xyz"));
+        } else {
+            assertNull(databaseConnection.getClientInfo("xyz"));
+        }
     }
 
     @Test
@@ -236,12 +298,12 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
 
     @Test
     void testGetHoldability() throws Exception {
-        assertEquals(1, databaseConnection.getHoldability());
+        assertEquals(databaseConnection.getDelegate().getHoldability(), 
databaseConnection.getHoldability());
     }
 
     @Test
     void testGetNetworkTimeout() throws Exception {
-        assertEquals(0, databaseConnection.getNetworkTimeout());
+        assertEquals(databaseConnection.getDelegate().getNetworkTimeout(), 
databaseConnection.getNetworkTimeout());
     }
 
     @Test
@@ -311,11 +373,16 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
     void testReleaseSavepoint() throws Exception {
         databaseConnection.setAutoCommit(false);
         final Savepoint s = databaseConnection.setSavepoint();
-        databaseConnection.releaseSavepoint(s);
+        if (database == TestDatabase.ORACLE || database == 
TestDatabase.SQLSERVER) {
+            assertThrows(SQLFeatureNotSupportedException.class, () -> 
databaseConnection.releaseSavepoint(s));
+        } else {
+            databaseConnection.releaseSavepoint(s);
+        }
     }
 
     @Test
     void testRollback() throws Exception {
+        databaseConnection.setAutoCommit(false);
         databaseConnection.rollback();
     }
 
@@ -352,11 +419,11 @@ public class TestDelegatingConnection extends 
AbstractEmbeddedDatabaseTest {
     @Test
     void testSetNetworkTimeout() throws Exception {
         if (database == TestDatabase.HSQLDB) {
-            assertThrows(SQLFeatureNotSupportedException.class, () -> 
databaseConnection.setNetworkTimeout(Runnable::run, 1));
+            assertThrows(SQLFeatureNotSupportedException.class, () -> 
databaseConnection.setNetworkTimeout(Runnable::run, 30_000));
         } else {
-            databaseConnection.setNetworkTimeout(Runnable::run, 1);
+            databaseConnection.setNetworkTimeout(Runnable::run, 30_000);
         }
-        assertEquals(0, databaseConnection.getNetworkTimeout());
+        assertEquals(databaseConnection.getDelegate().getNetworkTimeout(), 
databaseConnection.getNetworkTimeout());
     }
 
     @Test
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnectionCachedState.java
 
b/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnectionCachedState.java
index 5df54611..47ec1660 100644
--- 
a/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnectionCachedState.java
+++ 
b/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnectionCachedState.java
@@ -27,11 +27,14 @@ import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Supplier;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
+import javax.sql.DataSource;
+
 import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
@@ -42,7 +45,7 @@ import org.junit.jupiter.params.provider.MethodSource;
 /**
  * Tests cached connection properties across successful writes and driver 
failures.
  */
-class TestDelegatingConnectionCachedState extends AbstractEmbeddedDatabaseTest 
{
+class TestDelegatingConnectionCachedState extends AbstractDatabaseTest {
 
     private static final class CacheConfig {
         private final boolean enabled;
@@ -495,56 +498,62 @@ class TestDelegatingConnectionCachedState extends 
AbstractEmbeddedDatabaseTest {
 
     @Test
     void testReturnAfterAutoCommitErrorRollsBackAndRestoresState() throws 
Exception {
-        try (Connection physical = database.connect()) {
-            try (Statement statement = physical.createStatement()) {
-                statement.execute("CREATE TABLE items (id INT)");
-            }
-            final AssertionError failure = new AssertionError("setAutoCommit 
failed");
-            final Connection faulty = new 
DelegatingConnection<Connection>(physical) {
-                private boolean failedOnce;
-
-                @Override
-                public void setAutoCommit(final boolean autoCommit) throws 
SQLException {
-                    super.setAutoCommit(autoCommit);
-                    if (!autoCommit && !failedOnce) {
-                        failedOnce = true;
-                        throw failure;
+        final String table = "DBCP_" + 
UUID.randomUUID().toString().replace("-", "").substring(0, 20);
+        final DataSource dataSource = 
database.createDataSource(database.newUrl());
+        // Keep an independent connection for cleanup after closing the pool's 
physical connection.
+        try (Connection anchor = dataSource.getConnection(); Statement setup = 
anchor.createStatement()) {
+            setup.execute("CREATE TABLE " + table + " (id INT)");
+            try (Connection physical = dataSource.getConnection()) {
+                final AssertionError failure = new 
AssertionError("setAutoCommit failed");
+                final Connection faulty = new 
DelegatingConnection<Connection>(physical) {
+                    private boolean failedOnce;
+
+                    @Override
+                    public void setAutoCommit(final boolean autoCommit) throws 
SQLException {
+                        super.setAutoCommit(autoCommit);
+                        if (!autoCommit && !failedOnce) {
+                            failedOnce = true;
+                            throw failure;
+                        }
                     }
-                }
-            };
-            final PoolableConnectionFactory factory = new 
PoolableConnectionFactory(() -> faulty, null);
-            factory.setCacheState(true);
-            factory.setDefaultAutoCommit(Boolean.TRUE);
-            factory.setRollbackOnReturn(true);
-            factory.setAutoCommitOnReturn(true);
-            try (GenericObjectPool<PoolableConnection> connectionPool = new 
GenericObjectPool<>(factory)) {
-                factory.setPool(connectionPool);
-                connectionPool.setMaxTotal(1);
-                final PoolableConnection first = connectionPool.borrowObject();
-                try (Connection connection = first) {
-                    assertTrue(connection.getAutoCommit());
-                    assertSame(failure, assertThrows(AssertionError.class, () 
-> connection.setAutoCommit(false)));
-                    assertFalse(physical.getAutoCommit());
-                    // DBCP-522: An application may catch the Error and 
continue using the connection.
-                    try (Statement statement = connection.createStatement()) {
-                        statement.executeUpdate("INSERT INTO items VALUES 
(1)");
+                };
+                final PoolableConnectionFactory factory = new 
PoolableConnectionFactory(() -> faulty, null);
+                factory.setCacheState(true);
+                factory.setDefaultAutoCommit(Boolean.TRUE);
+                factory.setRollbackOnReturn(true);
+                factory.setAutoCommitOnReturn(true);
+                try (GenericObjectPool<PoolableConnection> connectionPool = 
new GenericObjectPool<>(factory)) {
+                    factory.setPool(connectionPool);
+                    connectionPool.setMaxTotal(1);
+                    final PoolableConnection first = 
connectionPool.borrowObject();
+                    try (Connection connection = first) {
+                        assertTrue(connection.getAutoCommit());
+                        assertSame(failure, assertThrows(AssertionError.class, 
() -> connection.setAutoCommit(false)));
+                        assertFalse(physical.getAutoCommit());
+                        // DBCP-522: An application may catch the Error and 
continue using the connection.
+                        try (Statement statement = 
connection.createStatement()) {
+                            statement.executeUpdate("INSERT INTO " + table + " 
VALUES (1)");
+                        }
                     }
-                }
 
-                assertEquals(0, connectionPool.getNumActive());
-                assertEquals(1, connectionPool.getNumIdle());
-                assertTrue(physical.getAutoCommit(), "Returning the connection 
should restore auto-commit");
-                try (PoolableConnection second = 
connectionPool.borrowObject()) {
-                    assertSame(first, second, "The test must reuse the same 
pooled connection");
-                    assertTrue(second.getAutoCommit());
-                    try (Statement statement = second.createStatement(); 
ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM items")) {
-                        assertTrue(resultSet.next());
-                        assertEquals(0, resultSet.getInt(1), "Returning the 
connection should roll back the previous borrower's transaction");
+                    assertEquals(0, connectionPool.getNumActive());
+                    assertEquals(1, connectionPool.getNumIdle());
+                    assertTrue(physical.getAutoCommit(), "Returning the 
connection should restore auto-commit");
+                    try (PoolableConnection second = 
connectionPool.borrowObject()) {
+                        assertSame(first, second, "The test must reuse the 
same pooled connection");
+                        assertTrue(second.getAutoCommit());
+                        try (Statement statement = second.createStatement(); 
ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM " + table)) {
+                            assertTrue(resultSet.next());
+                            assertEquals(0, resultSet.getInt(1), "Returning 
the connection should roll back the previous borrower's transaction");
+                        }
                     }
                 }
+            } finally {
+                setup.execute("DROP TABLE " + table);
             }
         }
     }
+
     @Test
     void testSchemaGetterCompatibilityFallbackDoesNotRetainOldCache() throws 
SQLException {
         try (StateConnection physical = new StateConnection(); 
TrackingConnection wrapper = new TrackingConnection(physical)) {
diff --git 
a/src/test/java/org/apache/commons/dbcp2/TestUnderlyingConnectionAccess.java 
b/src/test/java/org/apache/commons/dbcp2/TestUnderlyingConnectionAccess.java
index 2aa65003..c66d50da 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestUnderlyingConnectionAccess.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestUnderlyingConnectionAccess.java
@@ -61,7 +61,7 @@ import org.junitpioneer.jupiter.ReadsSystemProperty;
  * Exercises delegate access through every pool guard and JDBC wrapper, with 
and without statement pooling and nested wrappers.
  */
 @ReadsSystemProperty
-class TestUnderlyingConnectionAccess extends AbstractEmbeddedDatabaseTest {
+class TestUnderlyingConnectionAccess extends AbstractDatabaseTest {
 
     private enum CloseWith {
         RESULT_SET, STATEMENT, CONNECTION
@@ -116,11 +116,11 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
             case PREPARED_NAMES:
                 return connection.prepareStatement(database.selectParameter(), 
new String[] {"ID"});
             case CALLABLE:
-                return connection.prepareCall(database == TestDatabase.HSQLDB 
? "CALL ABS(?)" : CALL_SQL);
+                return connection.prepareCall(database.callQuery());
             case CALLABLE_TYPE:
-                return connection.prepareCall(database == TestDatabase.HSQLDB 
? "CALL ABS(?)" : CALL_SQL, ResultSet.TYPE_FORWARD_ONLY, 
ResultSet.CONCUR_READ_ONLY);
+                return connection.prepareCall(database.callQuery(), 
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
             case CALLABLE_HOLDABILITY:
-                return connection.prepareCall(database == TestDatabase.HSQLDB 
? "CALL ABS(?)" : CALL_SQL, ResultSet.TYPE_FORWARD_ONLY, 
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+                return connection.prepareCall(database.callQuery(), 
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, 
ResultSet.HOLD_CURSORS_OVER_COMMIT);
             default:
                 throw new IllegalStateException(name());
             }
@@ -128,7 +128,6 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
     }
 
     private static final AtomicInteger IDS = new AtomicInteger();
-    private static final String CALL_SQL = "{? = call ABS(?)}";
 
     private static void assertAccess(final Wrapper wrapper, final Class<?> 
standardType, final Class<?> driverType, final boolean allowed)
             throws SQLException {
@@ -209,7 +208,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
         dataSource.setDriver(database.getDriver());
         dataSource.setUrl(newUrl());
         dataSource.setUsername(database.getUser());
-        dataSource.setPassword("");
+        dataSource.setPassword(database.getPassword());
         dataSource.setAccessToUnderlyingConnectionAllowed(allowed);
         dataSource.setPoolPreparedStatements(poolStatements);
     }
@@ -233,7 +232,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
             dataSource.setUrl(newUrl());
             dataSource.setAccessToUnderlyingConnectionAllowed(allowed);
             dataSource.setPoolPreparedStatements(poolStatements);
-            final PooledConnection pooledConnection = 
dataSource.getPooledConnection(database.getUser(), "");
+            final PooledConnection pooledConnection = 
dataSource.getPooledConnection(database.getUser(), database.getPassword());
             return new Fixture(pooledConnection.getConnection(), 
pooledConnection::close, nested);
         }
         final GenericObjectPool<PoolableConnection> pool = 
newPool(poolStatements);
@@ -251,12 +250,11 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
     private ResultSet execute(final Statement statement) throws SQLException {
         if (statement instanceof CallableStatement) {
             final CallableStatement callable = (CallableStatement) statement;
-            if (database == TestDatabase.HSQLDB) {
-                // HyperSQL exposes this scalar function through its result 
set.
-                callable.setInt(1, -7);
-            } else {
+            if (database == TestDatabase.H2) {
                 callable.registerOutParameter(1, Types.INTEGER);
                 callable.setInt(2, -7);
+            } else {
+                callable.setInt(1, 7);
             }
             assertTrue(callable.execute());
             return callable.getResultSet();
@@ -272,6 +270,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
     private GenericObjectPool<PoolableConnection> newPool(final boolean 
poolStatements) throws SQLException {
         final Properties properties = new Properties();
         properties.setProperty("user", database.getUser());
+        properties.setProperty("password", database.getPassword());
         final PoolableConnectionFactory factory = new 
PoolableConnectionFactory(new DriverConnectionFactory(database.getDriver(), 
newUrl(), properties), null);
         factory.setPoolStatements(poolStatements);
         final GenericObjectPoolConfig<PoolableConnection> config = new 
GenericObjectPoolConfig<>();
@@ -375,8 +374,18 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
         try (Fixture fixture = createFixture(source, allowed, poolStatements, 
nested)) {
             final Connection connection = fixture.connection;
             assertConnectionAccess(connection, allowed);
-            assertFalse(connection.isWrapperFor(String.class));
+            if (database == TestDatabase.ORACLE && allowed) {
+                // Oracle rejects non-interface arguments to isWrapperFor 
rather than returning false.
+                assertThrows(SQLException.class, () -> 
connection.isWrapperFor(String.class));
+            } else {
+                assertFalse(connection.isWrapperFor(String.class));
+            }
             assertThrows(SQLException.class, () -> 
connection.unwrap(String.class));
+            if (database == TestDatabase.POSTGRESQL && kind == 
StatementKind.PREPARED_INDEXES) {
+                // PostgreSQL supports generated-key column names, but not 
column indexes.
+                assertThrows(SQLException.class, () -> kind.create(connection, 
database));
+                return;
+            }
             try (Statement statement = kind.create(connection, database)) {
                 assertSame(connection, statement.getConnection());
                 assertStatementAccess(statement, allowed);
@@ -404,7 +413,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
             if (!allowed && !nested) {
                 assertNull(((DelegatingDatabaseMetaData) 
metadata).getDelegate());
             }
-            final ResultSet tables = metadata.getTables(null, null, null, 
null);
+            final ResultSet tables = 
metadata.getTables(connection.getCatalog(), connection.getSchema(), "DBCP_%", 
new String[] {"TABLE"});
             try (ResultSet ignored = tables) {
                 assertResultSetAccess(tables, allowed);
                 assertNull(tables.getStatement());
@@ -418,8 +427,9 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
     void testGeneratedKeys(final boolean allowed) throws Exception {
         try (Fixture fixture = createFixture(Source.BASIC, allowed, true, 
true);
                 Statement setup = fixture.connection.createStatement()) {
-            setup.execute("CREATE TABLE T (ID BIGINT GENERATED ALWAYS AS 
IDENTITY (START WITH 1), VALUE_COLUMN INT)");
-            try (PreparedStatement statement = 
fixture.connection.prepareStatement("INSERT INTO T (VALUE_COLUMN) VALUES (?)", 
Statement.RETURN_GENERATED_KEYS)) {
+            final String table = "DBCP_" + 
java.util.UUID.randomUUID().toString().replace("-", "").substring(0, 20);
+            setup.execute("CREATE TABLE " + table + " (ID " + 
database.getIdentityColumnDefinition() + " PRIMARY KEY, VALUE_COLUMN INT)");
+            try (PreparedStatement statement = 
database.prepareInsertWithGeneratedKeys(fixture.connection, "INSERT INTO " + 
table + " (VALUE_COLUMN) VALUES (?)")) {
                 statement.setInt(1, 9);
                 assertEquals(1, statement.executeUpdate());
                 try (ResultSet keys = statement.getGeneratedKeys()) {
@@ -428,13 +438,15 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
                     assertSame(statement, keys.getStatement());
                     assertResultSetAccess(keys, allowed);
                 }
+            } finally {
+                setup.execute("DROP TABLE " + table);
             }
         }
     }
 
     @Test
     void testGuardHookAndInternalAccess() throws Exception {
-        try (Connection physical = database.getDriver().connect(newUrl(), new 
Properties());
+        try (Connection physical = database.connect();
                 DelegatingConnection<Connection> connection = new 
DelegatingConnection<Connection>(physical) {
                     @Override
                     protected boolean isAccessToUnderlyingConnectionAllowed() {
@@ -472,7 +484,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
                 assertTrue(connection.isClosed());
             }
             dataSource.invalidateConnection(null);
-            try (Connection foreign = database.getDriver().connect(newUrl(), 
new Properties())) {
+            try (Connection foreign = database.connect()) {
                 assertThrows(IllegalStateException.class, () -> 
dataSource.invalidateConnection(foreign));
             }
         }
@@ -533,7 +545,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
 
     @Test
     void testParentlessWrappers() throws Exception {
-        try (Connection physical = database.getDriver().connect(newUrl(), new 
Properties());
+        try (Connection physical = database.connect();
                 DelegatingStatement statement = new DelegatingStatement(null, 
physical.createStatement());
                 ResultSet resultSet = 
statement.executeQuery(database.select(7))) {
             assertStatementAccess(statement, true);
@@ -550,7 +562,7 @@ class TestUnderlyingConnectionAccess extends 
AbstractEmbeddedDatabaseTest {
     @ClearSystemProperty(key = 
PoolingDriver.ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED_SYSTEM_PROPERTY)
     void testPlainWrappersAndDriverDefault() throws Exception {
         assertTrue(new 
PoolingDriver().isAccessToUnderlyingConnectionAllowed());
-        try (Connection physical = database.getDriver().connect(newUrl(), new 
Properties());
+        try (Connection physical = database.connect();
                 DelegatingConnection<Connection> connection = new 
DelegatingConnection<>(physical);
                 Statement statement = connection.createStatement(); ResultSet 
resultSet = statement.executeQuery(database.select(7))) {
             assertConnectionAccess(connection, true);
diff --git 
a/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
 
b/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
index 64623d9c..519fa408 100644
--- 
a/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
+++ 
b/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
@@ -17,42 +17,28 @@
  */
 package org.apache.commons.dbcp2.managed;
 
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import javax.sql.XADataSource;
 import javax.transaction.TransactionManager;
-import javax.transaction.TransactionSynchronizationRegistry;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
 import org.apache.commons.dbcp2.BasicDataSource;
 import org.apache.commons.dbcp2.TestBasicDataSource;
-import org.apache.commons.dbcp2.TestDatabase;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.function.ThrowingSupplier;
-import org.junit.jupiter.params.Parameter;
-import org.junit.jupiter.params.ParameterizedClass;
-import org.junit.jupiter.params.provider.EnumSource;
-
-import 
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
-import 
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple;
 
 /**
  * TestSuite for BasicManagedDataSource
  */
-@ParameterizedClass(name = "{0}")
-@EnumSource(value = TestDatabase.class, names = {"H2", "HSQLDB"})
 public class TestBasicManagedDataSource extends TestBasicDataSource {
 
     /**
@@ -106,10 +92,6 @@ public class TestBasicManagedDataSource extends 
TestBasicDataSource {
         }
     }
 
-    /** Database used by this invocation. */
-    @Parameter
-    TestDatabase database;
-
     @Override
     protected BasicDataSource createDataSource() throws Exception {
         final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource();
@@ -119,16 +101,6 @@ public class TestBasicManagedDataSource extends 
TestBasicDataSource {
         return basicManagedDataSource;
     }
 
-    @Test
-    void testCreateXaDataSourceNewInstance() throws SQLException, XAException {
-        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
-            
basicManagedDataSource.setXADataSource(database.createXaDataSource(database.newUrl()).getClass().getName());
-            
basicManagedDataSource.setDriverClassName(database.getDriverClassName());
-            basicManagedDataSource.setTransactionManager(new 
TransactionManagerImpl());
-            assertNotNull(basicManagedDataSource.createConnectionFactory());
-        }
-    }
-
     @Test
     void testCreateXaDataSourceNoInstanceSetAndNoDataSource() throws 
SQLException, XAException {
         try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
@@ -261,20 +233,6 @@ public class TestBasicManagedDataSource extends 
TestBasicDataSource {
         assertEquals(1, ds.getNumIdle());
     }
 
-    @Test
-    void testSetXaDataSourceInstance() throws SQLException, XAException {
-        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
-            basicManagedDataSource.setTransactionManager(new 
TransactionManagerImpl());
-            
basicManagedDataSource.setDriverClassName("org.apache.commons.dbcp2.TesterDriver");
-            basicManagedDataSource.setUrl("jdbc:apache:commons:testdriver");
-            basicManagedDataSource.setUsername("userName");
-            basicManagedDataSource.setPassword("password");
-            basicManagedDataSource.setMaxIdle(1);
-            
basicManagedDataSource.setXaDataSourceInstance(database.createXaDataSource(database.newUrl()));
-            assertNotNull(basicManagedDataSource.createConnectionFactory());
-        }
-    }
-
     @Test
     void testTransactionManagerNotSet() throws SQLException {
         try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
@@ -282,32 +240,6 @@ public class TestBasicManagedDataSource extends 
TestBasicDataSource {
         }
     }
 
-    @Test
-    void testTransactionSynchronizationRegistry() throws Exception {
-        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
-            basicManagedDataSource.setTransactionManager(new 
TransactionManagerImple());
-            final TransactionSynchronizationRegistry tsr = new 
TransactionSynchronizationRegistryImple();
-            basicManagedDataSource.setTransactionSynchronizationRegistry(tsr);
-            final XADataSource xaDataSource = 
database.createXaDataSource(database.newUrl());
-            basicManagedDataSource.setXaDataSourceInstance(xaDataSource);
-            basicManagedDataSource.setMaxIdle(1);
-
-            final TransactionManager tm = 
basicManagedDataSource.getTransactionManager();
-            tm.begin();
-            tsr.registerInterposedSynchronization(new SynchronizationAdapter() 
{
-                @Override
-                public void beforeCompletion() {
-                    try (Connection connection = 
assertDoesNotThrow((ThrowingSupplier<Connection>) 
basicManagedDataSource::getConnection)) {
-                        assertNotNull(connection);
-                    } catch (final SQLException e) {
-                        fail(e);
-                    }
-                }
-            });
-            tm.commit();
-        }
-    }
-
     @Test
     void testXADataSource() throws SQLException {
         try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
@@ -315,13 +247,4 @@ public class TestBasicManagedDataSource extends 
TestBasicDataSource {
             assertEquals("anything", basicManagedDataSource.getXADataSource());
         }
     }
-
-    @Test
-    void testXaDataSourceInstance() throws SQLException {
-        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
-            final XADataSource ds = 
database.createXaDataSource(database.newUrl());
-            basicManagedDataSource.setXaDataSourceInstance(ds);
-            assertEquals(ds, basicManagedDataSource.getXaDataSourceInstance());
-        }
-    }
 }
diff --git 
a/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSourceDatabase.java
 
b/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSourceDatabase.java
new file mode 100644
index 00000000..579d6ac6
--- /dev/null
+++ 
b/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSourceDatabase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.commons.dbcp2.managed;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.XADataSource;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAException;
+
+import org.apache.commons.dbcp2.AbstractDatabaseTest;
+import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.function.ThrowingSupplier;
+
+import 
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+import 
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple;
+
+/**
+ * Tests managed data sources with real JDBC drivers.
+ */
+class TestBasicManagedDataSourceDatabase extends AbstractDatabaseTest {
+
+    @Test
+    void testCreateXaDataSourceNewInstance() throws SQLException, XAException {
+        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
+            
basicManagedDataSource.setXADataSource(database.createXaDataSource(database.newUrl()).getClass().getName());
+            
basicManagedDataSource.setDriverClassName(database.getDriverClassName());
+            basicManagedDataSource.setTransactionManager(new 
TransactionManagerImpl());
+            assertNotNull(basicManagedDataSource.createConnectionFactory());
+        }
+    }
+
+    @Test
+    void testSetXaDataSourceInstance() throws SQLException, XAException {
+        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
+            basicManagedDataSource.setTransactionManager(new 
TransactionManagerImpl());
+            database.configure(basicManagedDataSource, database.newUrl());
+            basicManagedDataSource.setMaxIdle(1);
+            
basicManagedDataSource.setXaDataSourceInstance(database.createXaDataSource(database.newUrl()));
+            assertNotNull(basicManagedDataSource.createConnectionFactory());
+        }
+    }
+
+    @Test
+    void testTransactionSynchronizationRegistry() throws Exception {
+        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
+            basicManagedDataSource.setTransactionManager(new 
TransactionManagerImple());
+            final TransactionSynchronizationRegistry tsr = new 
TransactionSynchronizationRegistryImple();
+            basicManagedDataSource.setTransactionSynchronizationRegistry(tsr);
+            final XADataSource xaDataSource = 
database.createXaDataSource(database.newUrl());
+            basicManagedDataSource.setXaDataSourceInstance(xaDataSource);
+            basicManagedDataSource.setMaxIdle(1);
+
+            final TransactionManager tm = 
basicManagedDataSource.getTransactionManager();
+            tm.begin();
+            tsr.registerInterposedSynchronization(new SynchronizationAdapter() 
{
+                @Override
+                public void beforeCompletion() {
+                    try (Connection connection = 
assertDoesNotThrow((ThrowingSupplier<Connection>) 
basicManagedDataSource::getConnection)) {
+                        assertNotNull(connection);
+                    } catch (final SQLException e) {
+                        fail(e);
+                    }
+                }
+            });
+            tm.commit();
+        }
+    }
+
+    @Test
+    void testXaDataSourceInstance() throws SQLException {
+        try (final BasicManagedDataSource basicManagedDataSource = new 
BasicManagedDataSource()) {
+            final XADataSource ds = 
database.createXaDataSource(database.newUrl());
+            basicManagedDataSource.setXaDataSourceInstance(ds);
+            assertEquals(ds, basicManagedDataSource.getXaDataSourceInstance());
+        }
+    }
+}
diff --git 
a/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
 
b/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
index 8831e458..9676a9e5 100644
--- 
a/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
+++ 
b/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
@@ -32,7 +32,7 @@ import java.time.Duration;
 import javax.transaction.RollbackException;
 import javax.transaction.Status;
 
-import org.apache.commons.dbcp2.AbstractEmbeddedDatabaseTest;
+import org.apache.commons.dbcp2.AbstractDatabaseTest;
 import org.apache.commons.dbcp2.Utils;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
@@ -46,13 +46,9 @@ import com.arjuna.ats.jta.common.jtaPropertyManager;
  * Requires Java 8 or above.
  */
 @Timeout(30)
-public class TestConnectionWithNarayana extends AbstractEmbeddedDatabaseTest {
+public class TestConnectionWithNarayana extends AbstractDatabaseTest {
 
-    private static final String CREATE_STMT = "CREATE TABLE TEST_DATA (KEY1 
VARCHAR(100), ID BIGINT, VALUE1 DOUBLE PRECISION, INFO VARCHAR(100000), TS 
TIMESTAMP)";
-    private static final String INSERT_STMT = "INSERT INTO TEST_DATA   (KEY1, 
ID, VALUE1, INFO, TS) VALUES (?,?,?,?,?)";
-    private static final String SELECT_STMT = "SELECT KEY1, ID, VALUE1, INFO, 
TS FROM TEST_DATA";
     private static final String PAYLOAD;
-    private static final String DROP_STMT = "DROP TABLE TEST_DATA";
 
     static {
         final StringBuilder sb = new StringBuilder();
@@ -69,6 +65,10 @@ public class TestConnectionWithNarayana extends 
AbstractEmbeddedDatabaseTest {
     }
 
     private BasicManagedDataSource mds;
+    /**
+     * Table isolated from other tests using the same server.
+     */
+    private String table;
     /** Keeps the database alive while timeout handling discards pooled 
connections. */
     private Connection databaseAnchor;
     /** Timeout inherited from the current test thread before this fixture 
changes it. */
@@ -78,6 +78,7 @@ public class TestConnectionWithNarayana extends 
AbstractEmbeddedDatabaseTest {
 
     @BeforeEach
     public void setUp() throws Exception {
+        table = "DBCP_" + java.util.UUID.randomUUID().toString().replace("-", 
"").substring(0, 20);
         jtaPropertyManager.getJTAEnvironmentBean()
                 
.setLastResourceOptimisationInterfaceClassName("org.apache.commons.dbcp2.managed.LocalXAConnectionFactory$LocalXAResource");
         final TransactionManagerImple transactionManager = new 
TransactionManagerImple();
@@ -102,7 +103,8 @@ public class TestConnectionWithNarayana extends 
AbstractEmbeddedDatabaseTest {
         mds.setLifo(false);
 
         try (final Connection conn = mds.getConnection()) {
-            try (final PreparedStatement ps = 
conn.prepareStatement(CREATE_STMT)) {
+            try (final PreparedStatement ps = conn.prepareStatement("CREATE 
TABLE " + table + " (KEY1 VARCHAR(100), ID INTEGER, VALUE1 DOUBLE PRECISION, 
INFO "
+                    + database.getLargeTextType() + ", TS " + 
database.getTimestampType() + ")")) {
                 ps.execute();
                 tableCreated = true;
             }
@@ -116,7 +118,7 @@ public class TestConnectionWithNarayana extends 
AbstractEmbeddedDatabaseTest {
                 mds.getTransactionManager().rollback();
             }
             if (tableCreated) {
-                try (PreparedStatement statement = 
connection.prepareStatement(DROP_STMT)) {
+                try (PreparedStatement statement = 
connection.prepareStatement("DROP TABLE " + table)) {
                     statement.execute();
                 }
             }
@@ -151,7 +153,7 @@ public class TestConnectionWithNarayana extends 
AbstractEmbeddedDatabaseTest {
             mds.getTransactionManager().setTransactionTimeout(1);
             mds.getTransactionManager().begin();
             try {
-                try (Connection conn = mds.getConnection(); PreparedStatement 
ps = conn.prepareStatement(INSERT_STMT)) {
+                try (Connection conn = mds.getConnection(); PreparedStatement 
ps = conn.prepareStatement("INSERT INTO " + table + " (KEY1, ID, VALUE1, INFO, 
TS) VALUES (?,?,?,?,?)")) {
                     ps.setString(1, Thread.currentThread().getName());
                     ps.setLong(2, i);
                     ps.setDouble(3, new java.util.Random().nextDouble());
@@ -165,7 +167,7 @@ public class TestConnectionWithNarayana extends 
AbstractEmbeddedDatabaseTest {
                             if 
(mds.getTransactionManager().getTransaction().getStatus() != 
Status.STATUS_ACTIVE) {
                                 n++;
                             }
-                            try (Connection c = mds.getConnection(); 
PreparedStatement ps2 = c.prepareStatement(SELECT_STMT);
+                            try (Connection c = mds.getConnection(); 
PreparedStatement ps2 = c.prepareStatement("SELECT KEY1, ID, VALUE1, INFO, TS 
FROM " + table);
                                     ResultSet rs = ps2.executeQuery()) {
                                 // Exercise borrowing while the reaper rolls 
back the transaction.
                             }

Reply via email to