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

duanzhengqiang 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 f61fa6e  fix testcases overrided with the same filename.xml (#15723)
f61fa6e is described below

commit f61fa6ec8ad805e90b5a1f341b87642401bab337
Author: cheese8 <[email protected]>
AuthorDate: Wed Mar 2 20:37:14 2022 +0800

    fix testcases overrided with the same filename.xml (#15723)
    
    * Update SQLRewriteEngineTestParametersBuilder.java
    
    fix testcases overrided with the same filename.xml
    
    * Update SQLRewriteEngineTestParametersBuilder.java
    
    * Update SQLRewriteEngineTestParametersBuilder.java
    
    impove fileNameKey with path
    
    * retrigger ci
---
 .../SQLRewriteEngineTestParametersBuilder.java        | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
index 6ae6ddb..b92b917 100644
--- 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
+++ 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
@@ -56,38 +56,39 @@ public final class SQLRewriteEngineTestParametersBuilder {
      */
     public static Collection<Object[]> loadTestParameters(final String type, 
final String path, final Class<?> targetClass) {
         Collection<Object[]> result = new LinkedList<>();
-        for (Entry<String, RewriteAssertionsRootEntity> entry : 
loadAllRewriteAssertionsRootEntities(path, targetClass).entrySet()) {
+        for (Entry<String, RewriteAssertionsRootEntity> entry : 
loadAllRewriteAssertionsRootEntities(type, path, targetClass).entrySet()) {
             result.addAll(createTestParameters(type, entry.getKey(), 
entry.getValue()));
         }
         return result;
     }
     
-    private static Map<String, RewriteAssertionsRootEntity> 
loadAllRewriteAssertionsRootEntities(final String path, final Class<?> 
targetClass) {
+    private static Map<String, RewriteAssertionsRootEntity> 
loadAllRewriteAssertionsRootEntities(final String type, final String path, 
final Class<?> targetClass) {
         Map<String, RewriteAssertionsRootEntity> result = new 
LinkedHashMap<>();
         File file = new 
File(targetClass.getProtectionDomain().getCodeSource().getLocation().getPath() 
+ "/" + path);
         for (File each : Objects.requireNonNull(file.listFiles())) {
             if (each.isFile()) {
-                appendFromFile(each, path, result);
+                appendFromFile(type, each, path, result);
             } else {
-                appendFromDirectory(each, path + "/" + each.getName(), result);
+                appendFromDirectory(type, each, path + "/" + each.getName(), 
result);
             }
         }
         return result;
     }
     
-    private static void appendFromDirectory(final File directory, final String 
path, final Map<String, RewriteAssertionsRootEntity> result) {
+    private static void appendFromDirectory(final String type, final File 
directory, final String path, final Map<String, RewriteAssertionsRootEntity> 
result) {
         for (File each : Objects.requireNonNull(directory.listFiles())) {
             if (each.isFile()) {
-                appendFromFile(each, path, result);
+                appendFromFile(type, each, path, result);
             } else {
-                appendFromDirectory(each, path + "/" + each.getName(), result);
+                appendFromDirectory(type, each, path + "/" + each.getName(), 
result);
             }
         }
     }
     
-    private static void appendFromFile(final File file, final String path, 
final Map<String, RewriteAssertionsRootEntity> result) {
+    private static void appendFromFile(final String type, final File file, 
final String path, final Map<String, RewriteAssertionsRootEntity> result) {
         if (file.getName().endsWith(".xml")) {
-            result.put(file.getName(), new 
RewriteAssertionsRootEntityLoader().load(path + "/" + file.getName()));
+            String key = path.toLowerCase().replace(type.toLowerCase() + "/", 
"") + file.getName();
+            result.put(key, new RewriteAssertionsRootEntityLoader().load(path 
+ "/" + file.getName()));
         }
     }
     

Reply via email to