You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/22 11:32:57 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

strongduanmu opened a new issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918


   Hi community,
   
   This issue is for #10887.
   
   # Background
   
   Currently `FederateStatementTest` and `FederatePrepareStatementTest` use JUNIT to test SQL statements. In order to improve test coverage and code elegance, we need to migrate the test scenarios of FederateStatementTest and FederatePrepareStatementTest to `shardingsphere-integration-test`. 
   
   # Target
   
   The goal of this issue is to migrate the `SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT` statement to the `shardingsphere-integration-test` module. 
   
   You can search for the `SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT` keyword, and then you will find the test cases in `FederateStatementTest` and `FederatePrepareStatementTest`.
   
   FederateStatementTest:
   
   ```java
       private static final String SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT =
               "select t_user_encrypt_federate.user_id, t_user_encrypt_federate.pwd, t_user_info.information from t_user_encrypt_federate, t_user_info "
               + "where t_user_encrypt_federate.user_id = t_user_info.user_id ";
   
       @Test
       public void assertQueryWithFederateInSingleTablesWithEncryptRuleByExecuteQuery() throws SQLException {
           assertQueryWithFederateInSingleTablesWithEncryptRule(true);
       }
       
       @Test
       public void assertQueryWithFederateInSingleTablesWithEncryptRuleByExecute() throws SQLException {
           assertQueryWithFederateInSingleTablesWithEncryptRule(false);
       }
       
       private void assertQueryWithFederateInSingleTablesWithEncryptRule(final boolean executeQuery) throws SQLException {
           ShardingSphereStatement statement = (ShardingSphereStatement) getShardingSphereDataSource().getConnection().createStatement();
           ResultSet resultSet = getResultSet(statement, SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT, executeQuery);
           assertNotNull(resultSet);
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(0));
           assertThat(resultSet.getString(2), is("decryptValue"));
           assertThat(resultSet.getString(3), is("description0"));
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(1));
           assertThat(resultSet.getString(2), is("decryptValue"));
           assertThat(resultSet.getString(3), is("description1"));
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(2));
           assertThat(resultSet.getString(2), is("decryptValue"));
           assertThat(resultSet.getString(3), is("description2"));
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(3));
           assertThat(resultSet.getString(2), is("decryptValue"));
           assertThat(resultSet.getString(3), is("description3"));
           assertFalse(resultSet.next());
       }
   ```
   
   FederatePrepareStatementTest:
   
   ```java
       private static final String SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT =
               "select t_user_encrypt_federate.user_id, t_user_encrypt_federate.pwd, t_user_info.information from t_user_encrypt_federate, t_user_info "
                       + "where t_user_encrypt_federate.user_id = t_user_info.user_id and t_user_encrypt_federate.user_id > ? ";
   
       @Test
       public void assertQueryWithFederateInSingleTablesWithEncryptRuleByExecuteQuery() throws SQLException {
           assertQueryWithFederateInSingleTablesWithEncryptRule(true);
       }
       
       @Test
       public void assertQueryWithFederateInSingleTablesWithEncryptRuleByExecute() throws SQLException {
           assertQueryWithFederateInSingleTablesWithEncryptRule(false);
       }
       
       private void assertQueryWithFederateInSingleTablesWithEncryptRule(final boolean executeQuery) throws SQLException {
           ShardingSpherePreparedStatement preparedStatement = (ShardingSpherePreparedStatement) getShardingSphereDataSource()
                   .getConnection().prepareStatement(SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT);
           preparedStatement.setInt(1, 1);
           ResultSet resultSet = getResultSet(preparedStatement, executeQuery);
           assertNotNull(resultSet);
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(2));
           assertThat(resultSet.getString(2), is("decryptValue"));
           assertThat(resultSet.getString(3), is("description2"));
           assertTrue(resultSet.next());
           assertThat(resultSet.getInt(1), is(3));
           assertThat(resultSet.getString(2), is("decryptValue"));
           assertThat(resultSet.getString(3), is("description3"));
           assertFalse(resultSet.next());
       }
   ```
   
   # How to
   In order to finish this task, you need to understand the [documentation](https://shardingsphere.apache.org/document/current/en/features/test-engine/integration-test/) of the integration test first, and PR #10913 also provides an example, which you can refer to. BTW, if you have any questions, please leave a comment.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] LeeGuoPing commented on issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
LeeGuoPing commented on issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918#issuecomment-908948180


   @strongduanmu I have finished this issue


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] LeeGuoPing commented on issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
LeeGuoPing commented on issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918#issuecomment-908948180


   @strongduanmu I have finished this issue


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] LeeGuoPing commented on issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
LeeGuoPing commented on issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918#issuecomment-905980402


   Please assign it to me


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #10918: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_TABLES_WITH_ENCRYPT statement with shardingsphere-integration-test

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #10918:
URL: https://github.com/apache/shardingsphere/issues/10918


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org