You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/11/08 12:28:52 UTC
[shardingsphere] branch master updated: Revise #22011 (#22017)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 cb27c814321 Revise #22011 (#22017)
cb27c814321 is described below
commit cb27c8143215f15ef399d91f7c88ce7f505a37b2
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Nov 8 20:28:45 2022 +0800
Revise #22011 (#22017)
* Revise #22011
---
.../DynamicLoadingSQLParserParameterizedTest.java | 8 +++----
.../DynamicLoadingMySQLParserParameterizedIT.java | 7 +++---
...amicLoadingPostgreSQLParserParameterizedIT.java | 9 ++++---
.../sql/parser/result/CSVResultGenerator.java | 28 +++++++++-------------
.../src/test/resources/env/it-env.properties | 3 +--
5 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedTest.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedTest.java
index de1dd184904..b0de2a2f262 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedTest.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedTest.java
@@ -42,8 +42,8 @@ import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-@Slf4j
@RequiredArgsConstructor
+@Slf4j
public abstract class DynamicLoadingSQLParserParameterizedTest {
private final String sqlCaseId;
@@ -55,12 +55,12 @@ public abstract class DynamicLoadingSQLParserParameterizedTest {
// TODO this will refactor as an abstract
private final CSVResultGenerator resultGenerator;
- protected static Collection<Object[]> getTestParameters(final String sqlCaseApi, final URI sqlCaseURI, final String databaseType) {
+ protected static Collection<Object[]> getTestParameters(final String sqlCaseAPI, final URI sqlCaseURI, final String databaseType) {
Collection<Object[]> result = new LinkedList<>();
- if (sqlCaseApi.isEmpty()) {
+ if (sqlCaseAPI.isEmpty()) {
result.addAll(getSQLCases("localFile", getContent(sqlCaseURI), databaseType));
} else {
- for (Map<String, String> each : getResponse(sqlCaseApi, sqlCaseURI)) {
+ for (Map<String, String> each : getResponse(sqlCaseAPI, sqlCaseURI)) {
String sqlCaseFileName = each.get("name").split("\\.")[0];
String sqlCaseFileContent = getContent(URI.create(each.get("download_url")));
result.addAll(getSQLCases(sqlCaseFileName, sqlCaseFileContent, databaseType));
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/mysql/DynamicLoadingMySQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/mysql/DynamicLoadingMySQLParserParameterizedIT.java
index 778581997b3..ef8d1f35cfe 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/mysql/DynamicLoadingMySQLParserParameterizedIT.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/mysql/DynamicLoadingMySQLParserParameterizedIT.java
@@ -42,9 +42,8 @@ public final class DynamicLoadingMySQLParserParameterizedIT extends DynamicLoadi
*/
@Parameters(name = "{0} ({2}) -> {1}")
public static Collection<Object[]> getTestParameters() {
- if (IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()) {
- return DynamicLoadingSQLParserParameterizedTest.getTestParameters("https://api.github.com/repos/", URI.create("https://github.com/mysql/mysql-server/tree/8.0/mysql-test/t"), "MySQL");
- }
- return Collections.emptyList();
+ return IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()
+ ? DynamicLoadingSQLParserParameterizedTest.getTestParameters("https://api.github.com/repos/", URI.create("https://github.com/mysql/mysql-server/tree/8.0/mysql-test/t"), "MySQL")
+ : Collections.emptyList();
}
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/postgresql/DynamicLoadingPostgreSQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/postgresql/DynamicLoadingPostgreSQLParserParameterizedIT.java
index 9d1f29595d8..b7f9c2c0385 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/postgresql/DynamicLoadingPostgreSQLParserParameterizedIT.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/postgresql/DynamicLoadingPostgreSQLParserParameterizedIT.java
@@ -42,10 +42,9 @@ public final class DynamicLoadingPostgreSQLParserParameterizedIT extends Dynamic
**/
@Parameters(name = "{0} ({2}) -> {1}")
public static Collection<Object[]> getTestParameters() {
- if (IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()) {
- return DynamicLoadingSQLParserParameterizedTest.getTestParameters("https://api.github.com/repos/", URI.create("https://github.com/postgres/postgres/tree/master/src/test/regress/sql"),
- "PostgreSQL");
- }
- return Collections.emptyList();
+ return IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()
+ ? DynamicLoadingSQLParserParameterizedTest.getTestParameters(
+ "https://api.github.com/repos/", URI.create("https://github.com/postgres/postgres/tree/master/src/test/regress/sql"), "PostgreSQL")
+ : Collections.emptyList();
}
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/result/CSVResultGenerator.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/result/CSVResultGenerator.java
index 43b2d72d628..e8a6292702e 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/result/CSVResultGenerator.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/result/CSVResultGenerator.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.sql.parser.result;
-import lombok.extern.slf4j.Slf4j;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
@@ -26,38 +25,33 @@ import java.io.IOException;
import java.io.Writer;
/**
- * CSV format result generator.
+ * CSV result generator.
*/
-@Slf4j
-public class CSVResultGenerator {
+public final class CSVResultGenerator {
private final CSVPrinter printer;
public CSVResultGenerator(final String databaseType) {
- CSVFormat csvFormat = CSVFormat.DEFAULT.builder()
- .setHeader("SQLCaseId", "DatabaseType", "Result", "SQL").setSkipHeaderRecord(false).build();
- try {
- Writer out = new FileWriter(databaseType + "-result.csv", true);
+ CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setHeader("SQLCaseId", "DatabaseType", "Result", "SQL").setSkipHeaderRecord(false).build();
+ try (Writer out = new FileWriter(databaseType + "-result.csv", true)) {
printer = new CSVPrinter(out, csvFormat);
- } catch (IOException e) {
- log.error("create sql parser csv file failed");
- throw new RuntimeException("create sql parser csv file failed", e);
+ } catch (final IOException ex) {
+ throw new RuntimeException("Create CSV file failed.", ex);
}
}
/**
* Process the result.
*
- * @param param the content for a row of CSV record
+ * @param params the content for a row of CSV record
*/
- public void processResult(final Object... param) {
+ public void processResult(final Object... params) {
try {
- printer.printRecord(param);
+ printer.printRecord(params);
// TODO this may be optimized in next step.
printer.flush();
- } catch (IOException e) {
- log.error("write sql parser csv file failed");
- throw new RuntimeException("write sql parser csv file failed", e);
+ } catch (final IOException ex) {
+ throw new RuntimeException("Write CSV file failed.", ex);
}
}
}
diff --git a/test/integration-test/sql-parser/src/test/resources/env/it-env.properties b/test/integration-test/sql-parser/src/test/resources/env/it-env.properties
index cf74c29c267..1a78fd77a4b 100644
--- a/test/integration-test/sql-parser/src/test/resources/env/it-env.properties
+++ b/test/integration-test/sql-parser/src/test/resources/env/it-env.properties
@@ -14,6 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# sql.parser.it.enabled=true,false
-sql.parser.it.enabled=false
+sql.parser.it.enabled=false