diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java index dc12cc374bf35..a0958acdcc3bd 100644 --- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java +++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.transaction.xa.jta.connection.dialect; -import com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection; +import com.mysql.cj.jdbc.MysqlXAConnection; import com.zaxxer.hikari.HikariDataSource; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader; +import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils; import org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper; @@ -34,8 +34,9 @@ import java.sql.Connection; import java.sql.SQLException; -import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -46,7 +47,7 @@ class MySQLXAConnectionWrapperTest { @Test void assertWrap() throws SQLException { XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection()); - assertThat(actual.getXAResource(), instanceOf(JDBC4MysqlXAConnection.class)); + assertThat(actual.getXAResource().getClass(), is(MysqlXAConnection.class)); } private XADataSource createXADataSource() { @@ -56,7 +57,7 @@ private XADataSource createXADataSource() { private Connection mockConnection() throws SQLException { Connection result = mock(Connection.class); - when(result.unwrap(com.mysql.jdbc.Connection.class)).thenReturn(mock(com.mysql.jdbc.Connection.class)); + when(result.unwrap(com.mysql.cj.jdbc.JdbcConnection.class)).thenReturn(mock(com.mysql.cj.jdbc.JdbcConnection.class, RETURNS_DEEP_STUBS)); return result; } }