use of io.shardingjdbc.core.constant.DatabaseType in project sharding-jdbc by shardingjdbc.
the class RoutingDatabaseOnlyWithHintForDMLTest method assertInsertWithAllPlaceholders.
@Test
public void assertInsertWithAllPlaceholders() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
for (int i = 1; i <= 10; i++) {
try (HintShardingValueHelper helper = new HintDatabaseShardingValueHelper(i);
Connection connection = each.getValue().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(DatabaseTestSQL.INSERT_ORDER_WITH_ALL_PLACEHOLDERS_SQL)) {
preparedStatement.setInt(1, i);
preparedStatement.setInt(2, i);
preparedStatement.setString(3, "insert");
preparedStatement.executeUpdate();
}
}
assertDataSet(each.getValue().getConnection(), each.getKey(), "insert", "insert");
}
}
use of io.shardingjdbc.core.constant.DatabaseType in project sharding-jdbc by shardingjdbc.
the class RoutingDatabaseOnlyWithHintForSelectTest method assertSelectEqualsWithSingleTable.
@Test
public void assertSelectEqualsWithSingleTable() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
String sql = SQLPlaceholderUtil.replacePreparedStatement(DatabaseTestSQL.SELECT_EQUALS_WITH_SINGLE_TABLE_SQL);
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectEqualsWithSingleTable_0.xml", new HintDatabaseShardingValueHelper(10), each.getValue().getConnection(), sql, each.getKey(), 10, 1000);
assertDataSet("integrate/dataset/sharding/db/expect/select/SelectEqualsWithSingleTable_1.xml", new HintDatabaseShardingValueHelper(12), each.getValue().getConnection(), sql, each.getKey(), 12, 1201);
assertDataSet("integrate/dataset/Empty.xml", new HintDatabaseShardingValueHelper(12), each.getValue().getConnection(), sql, each.getKey(), 12, 1000);
}
}
use of io.shardingjdbc.core.constant.DatabaseType in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForDMLTest method assertInsertWithoutPlaceholder.
@Test
public void assertInsertWithoutPlaceholder() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
for (int i = 1; i <= 10; i++) {
try (HintShardingValueHelper helper = new HintShardingValueHelper(i, i);
Connection connection = each.getValue().getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(String.format(DatabaseTestSQL.INSERT_WITHOUT_PLACEHOLDER_SQL, i, i));
preparedStatement.executeUpdate();
}
}
assertDataSet(each.getValue().getConnection(), each.getKey(), "insert", "insert");
}
}
use of io.shardingjdbc.core.constant.DatabaseType in project sharding-jdbc by shardingjdbc.
the class ShardingDatabaseOnlyWithHintForDMLTest method assertInsertWithAllPlaceholders.
@Test
public void assertInsertWithAllPlaceholders() throws SQLException, DatabaseUnitException {
for (Map.Entry<DatabaseType, ShardingDataSource> each : shardingDataSources.entrySet()) {
for (int i = 1; i <= 10; i++) {
try (HintShardingValueHelper helper = new HintShardingValueHelper(i, i);
Connection connection = each.getValue().getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(DatabaseTestSQL.INSERT_ORDER_WITH_ALL_PLACEHOLDERS_SQL);
preparedStatement.setInt(1, i);
preparedStatement.setInt(2, i);
preparedStatement.setString(3, "insert");
preparedStatement.executeUpdate();
}
}
assertDataSet(each.getValue().getConnection(), each.getKey(), "insert", "insert");
}
}
use of io.shardingjdbc.core.constant.DatabaseType in project sharding-jdbc by shardingjdbc.
the class AbstractSQLAssertTest method importAllDataSet.
protected static void importAllDataSet(final List<String> dataSetFiles) throws Exception {
for (DatabaseType databaseType : getDatabaseTypes()) {
DatabaseEnvironment dbEnv = new DatabaseEnvironment(databaseType);
for (String each : dataSetFiles) {
InputStream is = AbstractSQLTest.class.getClassLoader().getResourceAsStream(each);
IDataSet dataSet = new FlatXmlDataSetBuilder().build(new InputStreamReader(is));
IDatabaseTester databaseTester = new ShardingJdbcDatabaseTester(dbEnv.getDriverClassName(), dbEnv.getURL(getDatabaseName(each)), dbEnv.getUsername(), dbEnv.getPassword(), dbEnv.getSchema(getDatabaseName(each)));
databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
databaseTester.setDataSet(dataSet);
databaseTester.onSetup();
}
}
}
Aggregations