use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.
the class ConnectionAdapterTest method assertSetReadOnly.
@Test
public void assertSetReadOnly() throws SQLException {
try (ShardingConnection actual = getShardingDataSource().getConnection()) {
assertTrue(actual.isReadOnly());
actual.setReadOnly(false);
actual.createStatement().executeQuery(sql);
assertReadOnly(actual, false);
if (DatabaseType.SQLServer != getCurrentDatabaseType()) {
actual.setReadOnly(true);
assertReadOnly(actual, true);
}
}
}
use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.
the class ConnectionAdapterTest method assertTransactionIsolation.
private void assertTransactionIsolation(final ShardingConnection actual, final int transactionIsolation) throws SQLException {
assertThat(actual.getTransactionIsolation(), is(transactionIsolation));
assertThat(actual.getCachedConnections().size(), is(2));
for (Connection each : actual.getCachedConnections().values()) {
assertThat(each.getTransactionIsolation(), is(transactionIsolation));
}
}
use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.
the class ConnectionAdapterTest method assertAutoCommit.
private void assertAutoCommit(final ShardingConnection actual, final boolean autoCommit) throws SQLException {
assertThat(actual.getAutoCommit(), is(autoCommit));
assertThat(actual.getCachedConnections().size(), is(2));
for (Connection each : actual.getCachedConnections().values()) {
assertThat(each.getAutoCommit(), is(autoCommit));
}
}
use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.
the class ConnectionAdapterTest method assertRollback.
@Test
public // TODO 缺少断言,做柔性事务时补充
void assertRollback() throws SQLException {
try (ShardingConnection actual = getShardingDataSource().getConnection()) {
actual.setAutoCommit(false);
actual.createStatement().executeQuery(sql);
actual.rollback();
}
}
use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.
the class ConnectionAdapterTest method assertReadOnly.
private void assertReadOnly(final ShardingConnection actual, final boolean readOnly) throws SQLException {
assertThat(actual.isReadOnly(), is(readOnly));
assertThat(actual.getCachedConnections().size(), is(2));
for (Connection each : actual.getCachedConnections().values()) {
assertThat(each.isReadOnly(), is(readOnly));
}
}
Aggregations