You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/02/22 15:20:17 UTC

[shardingsphere] branch master updated: Auto verify meta data in DQL (#15573)

This is an automated email from the ASF dual-hosted git repository.

menghaoran 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 ffa7412  Auto verify meta data in DQL (#15573)
ffa7412 is described below

commit ffa741280aa1eeb3d6d4adc9f73b6f15b09cfe3a
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Feb 22 23:15:07 2022 +0800

    Auto verify meta data in DQL (#15573)
    
    * Minor changes
    
    * Auto verify meta data in DQL
---
 .../test/integration/engine/dql/BaseDQLIT.java     | 30 +---------------------
 .../test/integration/engine/ral/BaseRALIT.java     |  4 +--
 .../test/integration/engine/rdl/BaseRDLIT.java     |  2 +-
 3 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java
index eaf395e..0b26626 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java
@@ -17,8 +17,6 @@
 
 package org.apache.shardingsphere.test.integration.engine.dql;
 
-import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
-import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetaData;
 import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
 import org.apache.shardingsphere.test.integration.engine.SingleITCase;
 import org.apache.shardingsphere.test.integration.env.scenario.ScenarioPath;
@@ -37,7 +35,6 @@ import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.LinkedList;
 import java.util.List;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -72,11 +69,7 @@ public abstract class BaseDQLIT extends SingleITCase {
     }
     
     protected final void assertResultSet(final ResultSet actualResultSet, final ResultSet verificationResultSet) throws SQLException {
-        if (isAssertMetaDataByByDataSetFile()) {
-            assertMetaDataByDataSetFile(actualResultSet.getMetaData(), getExpectedColumns());
-        } else {
-            assertMetaData(actualResultSet.getMetaData(), verificationResultSet.getMetaData());
-        }
+        assertMetaData(actualResultSet.getMetaData(), verificationResultSet.getMetaData());
         if (getDataSet().isIgnoreRowOrder()) {
             assertRowsIgnoreOrder(actualResultSet, getDataSet().getRows());
         } else {
@@ -101,27 +94,6 @@ public abstract class BaseDQLIT extends SingleITCase {
         }
     }
     
-    // TODO should assert it with verification data source for all finally
-    private boolean isAssertMetaDataByByDataSetFile() {
-        return getScenario().equals("encrypt") || getScenario().equals("dbtbl_with_readwrite_splitting_and_encrypt") || getScenario().equals("shadow");
-    }
-    
-    private Collection<DataSetColumn> getExpectedColumns() {
-        Collection<DataSetColumn> result = new LinkedList<>();
-        for (DataSetMetaData each : getDataSet().getMetaDataList()) {
-            result.addAll(each.getColumns());
-        }
-        return result;
-    }
-    
-    private void assertMetaDataByDataSetFile(final ResultSetMetaData actual, final Collection<DataSetColumn> expected) throws SQLException {
-        assertThat(actual.getColumnCount(), is(expected.size()));
-        int index = 1;
-        for (DataSetColumn each : expected) {
-            assertThat(actual.getColumnLabel(index++).toLowerCase(), is(each.getName().toLowerCase()));
-        }
-    }
-    
     private void assertRows(final ResultSet actual, final List<DataSetRow> expected) throws SQLException {
         int rowCount = 0;
         ResultSetMetaData actualMetaData = actual.getMetaData();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/BaseRALIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/BaseRALIT.java
index d2cb488..e1eefc0 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/BaseRALIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ral/BaseRALIT.java
@@ -47,7 +47,7 @@ public abstract class BaseRALIT extends SingleITCase {
     
     @Before
     public final void init() throws Exception {
-        if (getAssertion().getInitialSQL() != null) {
+        if (null != getAssertion().getInitialSQL()) {
             try (Connection connection = getTargetDataSource().getConnection()) {
                 executeInitSQLs(connection);
             }
@@ -56,7 +56,7 @@ public abstract class BaseRALIT extends SingleITCase {
     
     @After
     public final void tearDown() throws Exception {
-        if (getAssertion().getDestroySQL() != null) {
+        if (null != getAssertion().getDestroySQL()) {
             try (Connection connection = getTargetDataSource().getConnection()) {
                 executeDestroySQLs(connection);
             }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/BaseRDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/BaseRDLIT.java
index 71335a0..5cc10d9 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/BaseRDLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/rdl/BaseRDLIT.java
@@ -56,7 +56,7 @@ public abstract class BaseRDLIT extends SingleITCase {
     
     @After
     public final void tearDown() throws Exception {
-        if (getAssertion().getDestroySQL() != null) {
+        if (null != getAssertion().getDestroySQL()) {
             try (Connection connection = getTargetDataSource().getConnection()) {
                 executeDestroySQLs(connection);
             }