You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/11/26 04:03:08 UTC

[shardingsphere] branch master updated: Move CaseFileLoader's package (#22430)

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

yx9o 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 76addd0deb0 Move CaseFileLoader's package (#22430)
76addd0deb0 is described below

commit 76addd0deb0ea5dee2719afbdbaa74e9008c8571
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Nov 26 12:03:02 2022 +0800

    Move CaseFileLoader's package (#22430)
---
 .../SQLCaseFileLoader.java => CaseFileLoader.java}     |  6 +++---
 .../cases/parser/load/SQLParserTestCasesLoader.java    | 18 +++++++++---------
 .../internal/cases/sql/loader/SQLCasesLoader.java      | 17 +++++++++--------
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCaseFileLoader.java b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/CaseFileLoader.java
similarity index 96%
rename from test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCaseFileLoader.java
rename to test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/CaseFileLoader.java
index c32e722615f..4dd747df957 100644
--- a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCaseFileLoader.java
+++ b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/CaseFileLoader.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.test.sql.parser.internal.cases.sql.loader;
+package org.apache.shardingsphere.test.sql.parser.internal.cases;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
@@ -42,7 +42,7 @@ import java.util.jar.JarFile;
  * SQL case file loader.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class SQLCaseFileLoader {
+public final class CaseFileLoader {
     
     private static final String FILE_EXTENSION = ".xml";
     
@@ -76,7 +76,7 @@ public final class SQLCaseFileLoader {
      */
     @SneakyThrows({URISyntaxException.class, IOException.class})
     public static Collection<File> loadFilesFromDirectory(final String path) {
-        URL url = SQLCaseFileLoader.class.getClassLoader().getResource(path);
+        URL url = CaseFileLoader.class.getClassLoader().getResource(path);
         if (null == url) {
             return Collections.emptyList();
         }
diff --git a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/parser/load/SQLParserTestCasesLoader.java b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/parser/load/SQLParserTestCasesLoader.java
index bb8f97b04c4..cea505c36e3 100644
--- a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/parser/load/SQLParserTestCasesLoader.java
+++ b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/parser/load/SQLParserTestCasesLoader.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
 import lombok.SneakyThrows;
 import org.apache.shardingsphere.test.sql.parser.internal.cases.parser.jaxb.RootSQLParserTestCases;
 import org.apache.shardingsphere.test.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
-import org.apache.shardingsphere.test.sql.parser.internal.cases.sql.loader.SQLCaseFileLoader;
+import org.apache.shardingsphere.test.sql.parser.internal.cases.CaseFileLoader;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
@@ -42,18 +42,18 @@ public final class SQLParserTestCasesLoader {
     /**
      * Load SQL parser test cases.
      * 
-     * @param rootDirection SQL parser test cases root direction
-     * @return loaded SQL parser test cases
+     * @param rootDirectory root directory
+     * @return loaded cases
      */
     @SneakyThrows({JAXBException.class, IOException.class})
-    public Map<String, SQLParserTestCase> load(final String rootDirection) {
+    public Map<String, SQLParserTestCase> load(final String rootDirectory) {
         File file = new File(SQLParserTestCasesLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath());
-        return file.isFile() ? loadFromJar(rootDirection, file) : loadFromDirectory(rootDirection);
+        return file.isFile() ? loadFromJar(rootDirectory, file) : loadFromDirectory(rootDirectory);
     }
     
-    private Map<String, SQLParserTestCase> loadFromJar(final String directory, final File file) throws JAXBException {
+    private Map<String, SQLParserTestCase> loadFromJar(final String rootDirectory, final File file) throws JAXBException {
         Map<String, SQLParserTestCase> result = new HashMap<>(Short.MAX_VALUE, 1);
-        for (String each : SQLCaseFileLoader.loadFileNamesFromJar(file, directory)) {
+        for (String each : CaseFileLoader.loadFileNamesFromJar(file, rootDirectory)) {
             Map<String, SQLParserTestCase> sqlParserTestCases = createSQLParserTestCases(SQLParserTestCasesLoader.class.getClassLoader().getResourceAsStream(each));
             checkDuplicate(result, sqlParserTestCases);
             result.putAll(sqlParserTestCases);
@@ -61,9 +61,9 @@ public final class SQLParserTestCasesLoader {
         return result;
     }
     
-    private Map<String, SQLParserTestCase> loadFromDirectory(final String directory) throws IOException, JAXBException {
+    private Map<String, SQLParserTestCase> loadFromDirectory(final String rootDirectory) throws IOException, JAXBException {
         Map<String, SQLParserTestCase> result = new HashMap<>(Short.MAX_VALUE, 1);
-        for (File each : SQLCaseFileLoader.loadFilesFromDirectory(directory)) {
+        for (File each : CaseFileLoader.loadFilesFromDirectory(rootDirectory)) {
             try (FileInputStream fileInputStream = new FileInputStream(each)) {
                 Map<String, SQLParserTestCase> sqlParserTestCases = createSQLParserTestCases(fileInputStream);
                 checkDuplicate(result, sqlParserTestCases);
diff --git a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCasesLoader.java b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCasesLoader.java
index c4af7457f19..3b089603ba3 100644
--- a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCasesLoader.java
+++ b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/cases/sql/loader/SQLCasesLoader.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.test.sql.parser.internal.cases.sql.loader;
 
 import com.google.common.base.Preconditions;
 import lombok.SneakyThrows;
+import org.apache.shardingsphere.test.sql.parser.internal.cases.CaseFileLoader;
 import org.apache.shardingsphere.test.sql.parser.internal.cases.sql.jaxb.RootSQLCases;
 import org.apache.shardingsphere.test.sql.parser.internal.cases.sql.jaxb.SQLCase;
 
@@ -40,26 +41,26 @@ public final class SQLCasesLoader {
     /**
      * Load SQL cases.
      * 
-     * @param rootDirection SQL cases root direction
-     * @return loaded SQL cases
+     * @param rootDirectory root directory
+     * @return loaded cases
      */
     @SneakyThrows({JAXBException.class, IOException.class})
-    public Map<String, SQLCase> load(final String rootDirection) {
+    public Map<String, SQLCase> load(final String rootDirectory) {
         File file = new File(SQLCasesLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath());
-        return file.isFile() ? loadFromJar(file, rootDirection) : loadFromTargetDirectory(rootDirection);
+        return file.isFile() ? loadFromJar(rootDirectory, file) : loadFromDirectory(rootDirectory);
     }
     
-    private Map<String, SQLCase> loadFromJar(final File file, final String path) throws JAXBException {
+    private Map<String, SQLCase> loadFromJar(final String rootDirectory, final File file) throws JAXBException {
         Map<String, SQLCase> result = new TreeMap<>();
-        for (String each : SQLCaseFileLoader.loadFileNamesFromJar(file, path)) {
+        for (String each : CaseFileLoader.loadFileNamesFromJar(file, rootDirectory)) {
             buildCaseMap(result, SQLCasesLoader.class.getClassLoader().getResourceAsStream(each));
         }
         return result;
     }
     
-    private Map<String, SQLCase> loadFromTargetDirectory(final String path) throws JAXBException, FileNotFoundException {
+    private Map<String, SQLCase> loadFromDirectory(final String rootDirectory) throws JAXBException, FileNotFoundException {
         Map<String, SQLCase> result = new TreeMap<>();
-        for (File each : SQLCaseFileLoader.loadFilesFromDirectory(path)) {
+        for (File each : CaseFileLoader.loadFilesFromDirectory(rootDirectory)) {
             buildCaseMap(result, new FileInputStream(each));
         }
         return result;