You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/11/12 14:14:48 UTC

[shardingsphere] branch master updated: Refactor SQLCaseLoader (#22121)

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

panjuan 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 8d336479096 Refactor SQLCaseLoader (#22121)
8d336479096 is described below

commit 8d336479096eae95f0a080fa38b7086e187534c1
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Nov 12 22:14:41 2022 +0800

    Refactor SQLCaseLoader (#22121)
---
 .../DynamicLoadingSQLParserParameterizedIT.java    | 192 ---------------------
 .../sql/parser/env/IntegrationTestEnvironment.java |   6 +-
 .../sql/parser/loader/SQLCaseLoadStrategy.java     |  14 +-
 .../sql/parser/loader/SQLCaseLoader.java           | 132 ++++++++++++++
 .../loader/impl/GitHubSQLCaseLoadStrategy.java     |  70 ++++++--
 .../loader/impl/LocalFileSQLCaseLoadStrategy.java  |  24 ++-
 .../DynamicLoadingMySQLParserParameterizedIT.java  |  12 +-
 ...amicLoadingPostgreSQLParserParameterizedIT.java |  12 +-
 8 files changed, 213 insertions(+), 249 deletions(-)

diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedIT.java
deleted file mode 100644
index c8fcfbde2e8..00000000000
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/base/DynamicLoadingSQLParserParameterizedIT.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sql.parser.base;
-
-import com.google.common.collect.ImmutableMap;
-import com.jayway.jsonpath.JsonPath;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.infra.util.exception.external.ShardingSphereExternalException;
-import org.apache.shardingsphere.sql.parser.api.CacheOption;
-import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
-import org.apache.shardingsphere.sql.parser.api.SQLVisitorEngine;
-import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
-import org.apache.shardingsphere.sql.parser.result.SQLParserResultProcessor;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-@RequiredArgsConstructor
-@Slf4j
-public abstract class DynamicLoadingSQLParserParameterizedIT {
-    
-    private final String sqlCaseId;
-    
-    private final String sql;
-    
-    private final String databaseType;
-    
-    // TODO this will refactor as an abstract
-    private final SQLParserResultProcessor resultGenerator;
-    
-    protected static Collection<Object[]> getTestParameters(final String sqlCaseAPI, final URI sqlCaseTestURI, final URI sqlCaseResultURI) {
-        Collection<Object[]> result = new LinkedList<>();
-        if (sqlCaseAPI.isEmpty()) {
-            result.addAll(getSQLCases("localFile", getContent(sqlCaseTestURI), ""));
-        } else {
-            Map<String, String> resultResponse = getResultResponse(sqlCaseAPI, sqlCaseResultURI);
-            for (Map<String, String> each : getResponse(sqlCaseAPI, sqlCaseTestURI)) {
-                String sqlCaseFileName = each.get("name").split("\\.")[0];
-                String sqlCaseTestFileContent = getContent(URI.create(each.get("download_url")));
-                String sqlCaseResultDownloadURL = resultResponse.get(sqlCaseFileName);
-                String sqlCaseResultFileContent = null == sqlCaseResultDownloadURL ? "" : getContent(URI.create(sqlCaseResultDownloadURL));
-                result.addAll(getSQLCases(sqlCaseFileName, sqlCaseTestFileContent, sqlCaseResultFileContent));
-            }
-        }
-        if (result.isEmpty()) {
-            result.add(new Object[]{"", ""});
-        }
-        return result;
-    }
-    
-    protected static Map<String, String> getResultResponse(final String sqlCaseAPI, final URI sqlCaseURI) {
-        Map<String, String> result = new HashMap<>();
-        for (Map<String, String> each : getResponse(sqlCaseAPI, sqlCaseURI)) {
-            result.put(each.get("name").split("\\.")[0], each.get("download_url"));
-        }
-        return result;
-    }
-    
-    protected static Collection<Map<String, String>> getResponse(final String sqlCaseAPI, final URI sqlCaseURI) {
-        Collection<Map<String, String>> result = new LinkedList<>();
-        URI casesAPI = getAPI(sqlCaseAPI, sqlCaseURI);
-        String caseContent = getContent(casesAPI);
-        if (caseContent.isEmpty()) {
-            return result;
-        }
-        List<String> casesName = JsonPath.parse(caseContent).read("$..name");
-        List<String> casesDownloadURL = JsonPath.parse(caseContent).read("$..download_url");
-        List<String> casesHtmlURL = JsonPath.parse(caseContent).read("$..html_url");
-        List<String> casesType = JsonPath.parse(caseContent).read("$..type");
-        IntStream.range(0, JsonPath.parse(caseContent).read("$.length()"))
-                .forEach(each -> {
-                    if ("file".equals(casesType.get(each))) {
-                        result.add(ImmutableMap.of("name", casesName.get(each), "download_url", casesDownloadURL.get(each)));
-                    } else if ("dir".equals(casesType.get(each))) {
-                        result.addAll(getResponse(sqlCaseAPI, URI.create(casesHtmlURL.get(each))));
-                    }
-                });
-        return result;
-    }
-    
-    private static URI getAPI(final String sqlCaseAPI, final URI sqlCaseURI) {
-        String[] patches = sqlCaseURI.toString().split("/", 8);
-        String casesOwner = patches[3];
-        String casesRepo = patches[4];
-        String casesDirectory = patches[7];
-        return URI.create(sqlCaseAPI + casesOwner + "/" + casesRepo + "/contents/" + casesDirectory);
-    }
-    
-    protected static String getContent(final URI casesURI) {
-        String result = "";
-        try {
-            InputStreamReader in = new InputStreamReader(casesURI.toURL().openStream());
-            result = new BufferedReader(in).lines().collect(Collectors.joining(System.lineSeparator()));
-        } catch (IOException ignore) {
-            log.warn("Error: GitHub API rate limit exceeded");
-        }
-        return result;
-    }
-    
-    protected static Collection<Object[]> getSQLCases(final String sqlCaseFileName, final String sqlCaseTestFileContent, final String sqlCaseResultFileContent) {
-        Collection<Object[]> result = new LinkedList<>();
-        String[] testLines = sqlCaseTestFileContent.split("\n");
-        String[] resultLines = sqlCaseResultFileContent.split("\n");
-        String completedSQL = "";
-        int sqlCaseEnum = 1;
-        int statementLines = 0;
-        int resultIndex = 0;
-        boolean inProcedure = false;
-        for (String testLine : testLines) {
-            inProcedure = isInProcedure(inProcedure, testLine.trim());
-            completedSQL = getStatement(completedSQL, testLine.trim(), inProcedure);
-            statementLines = completedSQL.isEmpty() ? 0 : statementLines + 1;
-            if (completedSQL.contains(";") && !inProcedure) {
-                resultIndex = searchResult(resultIndex, resultLines, completedSQL, statementLines);
-                if (resultIndex >= resultLines.length || !resultLines[resultIndex].contains("ERROR")) {
-                    String sqlCaseId = sqlCaseFileName + sqlCaseEnum;
-                    result.add(new Object[]{sqlCaseId, completedSQL});
-                    sqlCaseEnum++;
-                }
-                completedSQL = "";
-                statementLines = 0;
-            }
-        }
-        return result;
-    }
-    
-    private static boolean isInProcedure(final boolean inProcedure, final String statementLines) {
-        if (statementLines.contains("{") && statementLines.contains("}")) {
-            return inProcedure;
-        }
-        return statementLines.contains("{") || statementLines.contains("}") || statementLines.contains("$$") ? !inProcedure : inProcedure;
-    }
-    
-    private static int searchResult(final int resultIndex, final String[] resultLines, final String completedSQL, final int statementLines) {
-        int index = resultIndex;
-        while (index < resultLines.length && !completedSQL.startsWith(resultLines[index].trim())) {
-            index++;
-        }
-        if (index != resultLines.length) {
-            return index + statementLines;
-        }
-        return resultIndex;
-    }
-    
-    private static String getStatement(final String completedSQL, final String statementTest, final boolean inProcedure) {
-        return (statementTest.isEmpty() || isComment(statementTest)) && !inProcedure ? "" : completedSQL + statementTest + " ";
-    }
-    
-    private static boolean isComment(final String statement) {
-        return statement.startsWith("#") || statement.startsWith("/") || statement.startsWith("--") || statement.startsWith(":") || statement.startsWith("\\");
-    }
-    
-    @Test
-    public final void assertParseSQL() {
-        String result = "success";
-        try {
-            ParseASTNode parseASTNode = new SQLParserEngine(databaseType, new CacheOption(128, 1024L)).parse(sql, false);
-            new SQLVisitorEngine(databaseType, "STATEMENT", true, new Properties()).visit(parseASTNode);
-        } catch (final ShardingSphereExternalException | ClassCastException | NullPointerException | IllegalArgumentException | IndexOutOfBoundsException ignore) {
-            result = "failed";
-            log.warn("ParserError: " + sqlCaseId + " value: " + sql + " db-type: " + databaseType);
-        }
-        resultGenerator.processResult(sqlCaseId, databaseType, result, sql);
-    }
-}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java
index 58acde28de1..b5d86fdab5d 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java
@@ -24,6 +24,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 
+/**
+ * Integration test environment.
+ */
 @Getter
 public final class IntegrationTestEnvironment {
     
@@ -39,8 +42,7 @@ public final class IntegrationTestEnvironment {
     
     private IntegrationTestEnvironment() {
         props = loadProperties();
-        String sqlParserITEnabledStr = null == System.getProperty("sql.parser.it.enabled") ? props.get("sql.parser.it.enabled").toString() : System.getProperty("sql.parser.it.enabled");
-        sqlParserITEnabled = null == sqlParserITEnabledStr ? false : Boolean.parseBoolean(sqlParserITEnabledStr);
+        sqlParserITEnabled = Boolean.parseBoolean(null == System.getProperty("sql.parser.it.enabled") ? props.get("sql.parser.it.enabled").toString() : System.getProperty("sql.parser.it.enabled"));
         resultPath = props.getOrDefault("sql.parser.it.report.path", "/tmp/").toString();
         resultProcessorType = props.getOrDefault("sql.parser.it.report.type", "LOG").toString();
     }
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoadStrategy.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoadStrategy.java
index b4302d8784d..eb65aafdac4 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoadStrategy.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoadStrategy.java
@@ -19,20 +19,14 @@ package org.apache.shardingsphere.sql.parser.loader;
 
 import java.net.URI;
 import java.util.Collection;
+import java.util.Map;
 
 /**
  * SQL case load strategy.
  */
 public interface SQLCaseLoadStrategy {
     
-    /**
-     * Get test parameters.
-     *
-     * @param sqlCaseTestURI the URI of sql test case
-     *
-     * @param sqlCaseResultURI the URI of sql result case
-     *
-     * @return Test cases from with strategy
-     */
-    Collection<Object[]> getTestParameters(URI sqlCaseTestURI, URI sqlCaseResultURI);
+    Collection<Map<String, String>> loadSQLCaseFiles(final URI uri);
+    
+    Map<String, String> loadSQLCaseResultFiles(final URI uri);
 }
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoader.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoader.java
new file mode 100644
index 00000000000..35dea8aa921
--- /dev/null
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/SQLCaseLoader.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.loader;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.sql.parser.env.IntegrationTestEnvironment;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * SQL case loader.
+ */
+@RequiredArgsConstructor
+@Slf4j
+public final class SQLCaseLoader {
+    
+    private final SQLCaseLoadStrategy loadStrategy;
+    
+    /**
+     * Load SQL cases.
+     *
+     * @param sqlCaseURI SQL case URI
+     * @param sqlCaseResultURI SQL case result case URI
+     *
+     * @return Test cases from with strategy
+     */
+    public Collection<Object[]> load(URI sqlCaseURI, URI sqlCaseResultURI) {
+        if (!IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()) {
+            return Collections.emptyList();
+        }
+        Collection<Object[]> result = new LinkedList<>();
+        Collection<Map<String, String>> sqlCases = loadStrategy.loadSQLCaseFiles(sqlCaseURI);
+        Map<String, String> resultResponse = loadStrategy.loadSQLCaseResultFiles(sqlCaseResultURI);
+        for (Map<String, String> each : sqlCases) {
+            String sqlCaseFileName = each.get("name").split("\\.")[0];
+            String sqlCaseTestFileContent = loadContent(URI.create(each.get("download_url")));
+            String sqlCaseResultFileContent = resultResponse.containsKey(sqlCaseFileName) ? loadContent(URI.create(resultResponse.get(sqlCaseFileName))) : "";
+            result.addAll(createSQLCases(sqlCaseFileName, sqlCaseTestFileContent, sqlCaseResultFileContent));
+        }
+        if (result.isEmpty()) {
+            result.add(new Object[]{"", ""});
+        }
+        return result;
+    }
+    
+    private String loadContent(final URI uri) {
+        try {
+            InputStreamReader in = new InputStreamReader(uri.toURL().openStream());
+            return new BufferedReader(in).lines().collect(Collectors.joining(System.lineSeparator()));
+        } catch (final IOException ex) {
+            log.warn("Load SQL cases failed, reason is: ", ex);
+            return "";
+        }
+    }
+    
+    private Collection<Object[]> createSQLCases(final String sqlCaseFileName, final String sqlCaseFileContent, final String sqlCaseResultFileContent) {
+        Collection<Object[]> result = new LinkedList<>();
+        String[] caseCaseLines = sqlCaseFileContent.split("\n");
+        String[] caseCaseResultLines = sqlCaseResultFileContent.split("\n");
+        String completedSQL = "";
+        int sqlCaseEnum = 1;
+        int statementLines = 0;
+        int resultIndex = 0;
+        boolean inProcedure = false;
+        for (String each : caseCaseLines) {
+            inProcedure = isInProcedure(inProcedure, each.trim());
+            completedSQL = getStatement(completedSQL, each.trim(), inProcedure);
+            statementLines = completedSQL.isEmpty() ? 0 : statementLines + 1;
+            if (completedSQL.contains(";") && !inProcedure) {
+                resultIndex = searchResult(resultIndex, caseCaseResultLines, completedSQL, statementLines);
+                if (resultIndex >= caseCaseResultLines.length || !caseCaseResultLines[resultIndex].contains("ERROR")) {
+                    String sqlCaseId = sqlCaseFileName + sqlCaseEnum;
+                    result.add(new Object[]{sqlCaseId, completedSQL});
+                    sqlCaseEnum++;
+                }
+                completedSQL = "";
+                statementLines = 0;
+            }
+        }
+        return result;
+    }
+    
+    private static boolean isInProcedure(final boolean inProcedure, final String statementLines) {
+        if (statementLines.contains("{") && statementLines.contains("}")) {
+            return inProcedure;
+        }
+        return (statementLines.contains("{") || statementLines.contains("}") || statementLines.contains("$$")) != inProcedure;
+    }
+    
+    private static String getStatement(final String completedSQL, final String sqlLine, final boolean inProcedure) {
+        return (sqlLine.isEmpty() || isComment(sqlLine)) && !inProcedure ? "" : completedSQL + sqlLine + " ";
+    }
+    
+    private static boolean isComment(final String statement) {
+        return statement.startsWith("#") || statement.startsWith("/") || statement.startsWith("--") || statement.startsWith(":") || statement.startsWith("\\");
+    }
+    
+    private static int searchResult(final int resultIndex, final String[] resultLines, final String completedSQL, final int statementLines) {
+        int index = resultIndex;
+        while (index < resultLines.length && !completedSQL.startsWith(resultLines[index].trim())) {
+            index++;
+        }
+        if (index != resultLines.length) {
+            return index + statementLines;
+        }
+        return resultIndex;
+    }
+}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/GitHubSQLCaseLoadStrategy.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/GitHubSQLCaseLoadStrategy.java
index 669236ebe7e..58467884a1c 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/GitHubSQLCaseLoadStrategy.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/GitHubSQLCaseLoadStrategy.java
@@ -17,36 +17,74 @@
 
 package org.apache.shardingsphere.sql.parser.loader.impl;
 
-import org.apache.shardingsphere.sql.parser.base.DynamicLoadingSQLParserParameterizedIT;
+import com.google.common.collect.ImmutableMap;
+import com.jayway.jsonpath.JsonPath;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.sql.parser.loader.SQLCaseLoadStrategy;
-import org.apache.shardingsphere.sql.parser.result.SQLParserCSVResultProcessor;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.net.URI;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * SQL case loader with GitHub.
  */
-public final class GitHubSQLCaseLoadStrategy extends DynamicLoadingSQLParserParameterizedIT implements SQLCaseLoadStrategy {
+@Slf4j
+public final class GitHubSQLCaseLoadStrategy implements SQLCaseLoadStrategy {
     
-    public GitHubSQLCaseLoadStrategy() {
-        super("", "", "", new SQLParserCSVResultProcessor(""));
+    @Override
+    public Collection<Map<String, String>> loadSQLCaseFiles(final URI uri) {
+        String caseContent = loadContent(getGitHubApiUri(uri));
+        if (caseContent.isEmpty()) {
+            return Collections.emptyList();
+        }
+        Collection<Map<String, String>> result = new LinkedList<>();
+        List<String> casesName = JsonPath.parse(caseContent).read("$..name");
+        List<String> casesDownloadURL = JsonPath.parse(caseContent).read("$..download_url");
+        List<String> casesHtmlURL = JsonPath.parse(caseContent).read("$..html_url");
+        List<String> casesType = JsonPath.parse(caseContent).read("$..type");
+        int bound = JsonPath.parse(caseContent).read("$.length()");
+        for (int each = 0; each < bound; each++) {
+            if ("file".equals(casesType.get(each))) {
+                result.add(ImmutableMap.of("name", casesName.get(each), "download_url", casesDownloadURL.get(each)));
+            } else if ("dir".equals(casesType.get(each))) {
+                result.addAll(loadSQLCaseFiles(URI.create(casesHtmlURL.get(each))));
+            }
+        }
+        return result;
     }
     
-    @Override
-    public Collection<Object[]> getTestParameters(final URI sqlCaseTestURI, final URI sqlCaseResultURI) {
-        Collection<Object[]> result = new LinkedList<>();
-        Map<String, String> resultResponse = getResultResponse("https://api.github.com/repos/", sqlCaseResultURI);
-        for (Map<String, String> each : getResponse("https://api.github.com/repos/", sqlCaseTestURI)) {
-            String sqlCaseFileName = each.get("name").split("\\.")[0];
-            String sqlCaseTestFileContent = getContent(URI.create(each.get("download_url")));
-            String sqlCaseResultFileContent = getContent(URI.create(resultResponse.get(each.get("name"))));
-            result.addAll(getSQLCases(sqlCaseFileName, sqlCaseTestFileContent, sqlCaseResultFileContent));
+    private URI getGitHubApiUri(final URI sqlCaseURI) {
+        String[] patches = sqlCaseURI.toString().split("/", 8);
+        String casesOwner = patches[3];
+        String casesRepo = patches[4];
+        String casesDirectory = patches[7];
+        return URI.create(String.join("/", "https://api.github.com/repos", casesOwner, casesRepo, "contents", casesDirectory));
+    }
+    
+    private String loadContent(final URI casesURI) {
+        try {
+            InputStreamReader in = new InputStreamReader(casesURI.toURL().openStream());
+            return new BufferedReader(in).lines().collect(Collectors.joining(System.lineSeparator()));
+        } catch (final IOException ex) {
+            log.warn("Load SQL cases failed, reason is: ", ex);
+            return "";
         }
-        if (result.isEmpty()) {
-            result.add(new Object[]{"", ""});
+    }
+    
+    @Override
+    public Map<String, String> loadSQLCaseResultFiles(final URI uri) {
+        Map<String, String> result = new HashMap<>();
+        for (Map<String, String> each : loadSQLCaseFiles(uri)) {
+            result.put(each.get("name").split("\\.")[0], each.get("download_url"));
         }
         return result;
     }
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/LocalFileSQLCaseLoadStrategy.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/LocalFileSQLCaseLoadStrategy.java
index 84a09c8c021..9b3a2565dec 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/LocalFileSQLCaseLoadStrategy.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/loader/impl/LocalFileSQLCaseLoadStrategy.java
@@ -17,29 +17,27 @@
 
 package org.apache.shardingsphere.sql.parser.loader.impl;
 
-import org.apache.shardingsphere.sql.parser.base.DynamicLoadingSQLParserParameterizedIT;
 import org.apache.shardingsphere.sql.parser.loader.SQLCaseLoadStrategy;
-import org.apache.shardingsphere.sql.parser.result.SQLParserCSVResultProcessor;
 
 import java.net.URI;
 import java.util.Collection;
-import java.util.LinkedList;
+import java.util.Collections;
+import java.util.Map;
 
 /**
- * Dynamic SQL case loader with local file.
+ * SQL case loader with local file.
  */
-public final class LocalFileSQLCaseLoadStrategy extends DynamicLoadingSQLParserParameterizedIT implements SQLCaseLoadStrategy {
+public final class LocalFileSQLCaseLoadStrategy implements SQLCaseLoadStrategy {
     
-    public LocalFileSQLCaseLoadStrategy() {
-        super("", "", "", new SQLParserCSVResultProcessor(""));
+    @Override
+    public Collection<Map<String, String>> loadSQLCaseFiles(final URI uri) {
+        // TODO
+        return Collections.emptyList();
     }
     
     @Override
-    public Collection<Object[]> getTestParameters(final URI sqlCaseTestURI, final URI sqlCaseResultURI) {
-        Collection<Object[]> result = new LinkedList<>(getSQLCases("localFile", getContent(sqlCaseTestURI), getContent(sqlCaseResultURI)));
-        if (result.isEmpty()) {
-            result.add(new Object[]{"", ""});
-        }
-        return result;
+    public Map<String, String> loadSQLCaseResultFiles(final URI uri) {
+        // TODO
+        return Collections.emptyMap();
     }
 }
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 98ab4c02d0d..f2fcdc1e6fd 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
@@ -18,7 +18,8 @@
 package org.apache.shardingsphere.sql.parser.mysql;
 
 import org.apache.shardingsphere.sql.parser.base.DynamicLoadingSQLParserParameterizedIT;
-import org.apache.shardingsphere.sql.parser.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.sql.parser.loader.SQLCaseLoader;
+import org.apache.shardingsphere.sql.parser.loader.impl.GitHubSQLCaseLoadStrategy;
 import org.apache.shardingsphere.sql.parser.result.SQLParserResultProcessorManager;
 import org.apache.shardingsphere.test.runner.ShardingSphereParallelTestParameterized;
 import org.junit.runner.RunWith;
@@ -26,7 +27,6 @@ import org.junit.runners.Parameterized.Parameters;
 
 import java.net.URI;
 import java.util.Collection;
-import java.util.Collections;
 
 @RunWith(ShardingSphereParallelTestParameterized.class)
 public final class DynamicLoadingMySQLParserParameterizedIT extends DynamicLoadingSQLParserParameterizedIT {
@@ -42,11 +42,7 @@ public final class DynamicLoadingMySQLParserParameterizedIT extends DynamicLoadi
      */
     @Parameters(name = "{0} (MySQL) -> {1}")
     public static Collection<Object[]> getTestParameters() {
-        return IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()
-                ? DynamicLoadingSQLParserParameterizedIT.getTestParameters(
-                        "https://api.github.com/repos/",
-                        URI.create("https://github.com/mysql/mysql-server/tree/8.0/mysql-test/t"),
-                        URI.create("https://github.com/mysql/mysql-server/tree/8.0/mysql-test/r"))
-                : Collections.emptyList();
+        return new SQLCaseLoader(new GitHubSQLCaseLoadStrategy()).load(
+                URI.create("https://github.com/mysql/mysql-server/tree/8.0/mysql-test/t"), URI.create("https://github.com/mysql/mysql-server/tree/8.0/mysql-test/r"));
     }
 }
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 8ae3936b713..c3458e5dfc3 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
@@ -18,7 +18,8 @@
 package org.apache.shardingsphere.sql.parser.postgresql;
 
 import org.apache.shardingsphere.sql.parser.base.DynamicLoadingSQLParserParameterizedIT;
-import org.apache.shardingsphere.sql.parser.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.sql.parser.loader.SQLCaseLoader;
+import org.apache.shardingsphere.sql.parser.loader.impl.GitHubSQLCaseLoadStrategy;
 import org.apache.shardingsphere.sql.parser.result.SQLParserCSVResultProcessor;
 import org.apache.shardingsphere.test.runner.ShardingSphereParallelTestParameterized;
 import org.junit.runner.RunWith;
@@ -26,7 +27,6 @@ import org.junit.runners.Parameterized.Parameters;
 
 import java.net.URI;
 import java.util.Collection;
-import java.util.Collections;
 
 @RunWith(ShardingSphereParallelTestParameterized.class)
 public final class DynamicLoadingPostgreSQLParserParameterizedIT extends DynamicLoadingSQLParserParameterizedIT {
@@ -42,11 +42,7 @@ public final class DynamicLoadingPostgreSQLParserParameterizedIT extends Dynamic
      **/
     @Parameters(name = "{0} (PostgreSQL) -> {1}")
     public static Collection<Object[]> getTestParameters() {
-        return IntegrationTestEnvironment.getInstance().isSqlParserITEnabled()
-                ? DynamicLoadingSQLParserParameterizedIT.getTestParameters(
-                        "https://api.github.com/repos/",
-                        URI.create("https://github.com/postgres/postgres/tree/master/src/test/regress/sql"),
-                        URI.create("https://github.com/postgres/postgres/tree/master/src/test/regress/expected"))
-                : Collections.emptyList();
+        return new SQLCaseLoader(new GitHubSQLCaseLoadStrategy()).load(
+                URI.create("https://github.com/postgres/postgres/tree/master/src/test/regress/sql"), URI.create("https://github.com/postgres/postgres/tree/master/src/test/regress/expected"));
     }
 }