You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/06/27 05:41:58 UTC
[shardingsphere] branch master updated: Refactor single table unit test (#18622)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 17dda5bc3da Refactor single table unit test (#18622)
17dda5bc3da is described below
commit 17dda5bc3da39a9230e47383be8090dcf651bf9e
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Mon Jun 27 13:41:52 2022 +0800
Refactor single table unit test (#18622)
* Refactor single table unit test
* Update
* Change it
* Change table name
---
.../jdbc/core/statement/ShardingSpherePreparedStatementTest.java | 7 +++----
.../driver/jdbc/core/statement/ShardingSphereStatementTest.java | 4 ++--
.../src/test/resources/sql/single_jdbc_init.sql | 4 ++--
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java
index e00ac6ebf7e..8305615aafd 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java
@@ -49,7 +49,7 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
private static final String INSERT_ON_DUPLICATE_KEY_SQL = "INSERT INTO t_order_item (item_id, order_id, user_id, status) VALUES (?, ?, ?, ?), (?, ?, ?, ?) ON DUPLICATE KEY UPDATE status = ?";
- private static final String INSERT_NO_SHARDING_SQL = "INSERT INTO t_sys_0 (param_key, param_value) VALUES (?, ?)";
+ private static final String INSERT_SINGLE_TABLE_SQL = "INSERT INTO t_role (user_name) VALUES (?)";
private static final String SELECT_SQL_WITHOUT_PARAMETER_MARKER = "SELECT item_id FROM t_order_item WHERE user_id = %d AND order_id= %s AND status = 'BATCH'";
@@ -368,9 +368,8 @@ public final class ShardingSpherePreparedStatementTest extends AbstractShardingS
public void assertAddGetGeneratedKeysForNoGeneratedValues() throws SQLException {
try (
Connection connection = getShardingSphereDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(INSERT_NO_SHARDING_SQL, Statement.RETURN_GENERATED_KEYS)) {
- preparedStatement.setString(1, "show");
- preparedStatement.setString(2, "yes");
+ PreparedStatement preparedStatement = connection.prepareStatement(INSERT_SINGLE_TABLE_SQL, Statement.RETURN_GENERATED_KEYS)) {
+ preparedStatement.setString(1, "admin");
preparedStatement.execute();
ResultSet generateKeyResultSet = preparedStatement.getGeneratedKeys();
assertTrue(generateKeyResultSet.next());
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java
index 1c2542f0ba5..f944ee4159e 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java
@@ -67,9 +67,9 @@ public final class ShardingSphereStatementTest extends AbstractShardingSphereDat
@Test
public void assertAddGetGeneratedKeysForNoGeneratedValues() throws SQLException {
- String sql = "INSERT INTO t_sys_1 (param_key, param_value) VALUES ('%s', '%s')";
+ String sql = "INSERT INTO t_product (product_name) VALUES ('%s')";
try (Statement statement = getShardingSphereDataSource().getConnection().createStatement()) {
- statement.execute(String.format(sql, "show", "yes"), Statement.RETURN_GENERATED_KEYS);
+ statement.execute(String.format(sql, "cup"), Statement.RETURN_GENERATED_KEYS);
ResultSet generatedKeysResultSet = statement.getGeneratedKeys();
assertTrue(generatedKeysResultSet.next());
assertThat(generatedKeysResultSet.getInt(1), is(1));
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/sql/single_jdbc_init.sql b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/sql/single_jdbc_init.sql
index cfd8d1baa5b..780b8c9ad0c 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/sql/single_jdbc_init.sql
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/resources/sql/single_jdbc_init.sql
@@ -15,5 +15,5 @@
* limitations under the License.
*/
-CREATE TABLE IF NOT EXISTS t_sys_0 (id INT NOT NULL AUTO_INCREMENT, param_key VARCHAR(45) NULL, param_value VARCHAR(45) NULL, PRIMARY KEY (id));
-CREATE TABLE IF NOT EXISTS t_sys_1 (id INT NOT NULL AUTO_INCREMENT, param_key VARCHAR(45) NULL, param_value VARCHAR(45) NULL, PRIMARY KEY (id));
+CREATE TABLE IF NOT EXISTS t_role (id INT NOT NULL AUTO_INCREMENT, user_name VARCHAR(45) NULL, PRIMARY KEY (id));
+CREATE TABLE IF NOT EXISTS t_product (id INT NOT NULL AUTO_INCREMENT, product_name VARCHAR(45) NULL, PRIMARY KEY (id));