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 0d03d32c9f6 Use AgentE2ETestCasesLoader instead of E2ETestCasesLoader 
in each module (#32195)
0d03d32c9f6 is described below

commit 0d03d32c9f6ff7f6886f1e84886f64dcf640bc4a
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jul 20 13:36:51 2024 +0800

    Use AgentE2ETestCasesLoader instead of E2ETestCasesLoader in each module 
(#32195)
    
    * Add AgentE2ETestCases
    
    * Use AgentE2ETestCasesLoader instead of E2ETestCasesLoader in each module
    
    * Use AgentE2ETestCasesLoader instead of E2ETestCasesLoader in each module
---
 .../e2e/agent/common/cases/AgentE2ETestCases.java} |  23 +++--
 .../common/cases/AgentE2ETestCasesLoader.java}     |  41 +++------
 .../test/e2e/agent/file/FilePluginE2EIT.java       |   5 +-
 .../test/e2e/agent/file/cases/E2ETestCases.java    |   3 +-
 .../test/e2e/agent/metrics/MetricsPluginE2EIT.java |   5 +-
 .../test/e2e/agent/metrics/cases/E2ETestCases.java |   3 +-
 .../agent/metrics/cases/E2ETestCasesLoader.java    | 102 ---------------------
 .../test/e2e/agent/jaeger/JaegerPluginE2EIT.java   |   5 +-
 .../test/e2e/agent/jaeger/cases/E2ETestCases.java  |   3 +-
 .../e2e/agent/jaeger/cases/E2ETestCasesLoader.java | 102 ---------------------
 .../test/e2e/agent/zipkin/ZipkinPluginE2EIT.java   |   5 +-
 .../test/e2e/agent/zipkin/cases/E2ETestCases.java  |   3 +-
 .../e2e/agent/zipkin/cases/E2ETestCasesLoader.java | 102 ---------------------
 13 files changed, 44 insertions(+), 358 deletions(-)

diff --git 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
 
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/cases/AgentE2ETestCases.java
similarity index 67%
copy from 
test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
copy to 
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/cases/AgentE2ETestCases.java
index b26dac9c2f8..e7273d693da 100644
--- 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
+++ 
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/cases/AgentE2ETestCases.java
@@ -15,22 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.test.e2e.agent.file.cases;
+package org.apache.shardingsphere.test.e2e.agent.common.cases;
 
-import lombok.Getter;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
 import java.util.Collection;
-import java.util.LinkedList;
 
 /**
- * E2E test cases.
+ * Agent E2E test cases.
+ * 
+ * @param <T> type of agent E2E test case
  */
-@XmlRootElement(name = "e2e-test-cases")
-@Getter
-public final class E2ETestCases {
+public interface AgentE2ETestCases<T extends AgentE2ETestCase> {
     
-    @XmlElement(name = "test-case")
-    private final Collection<LogTestCase> testCases = new LinkedList<>();
+    /**
+     * Get test cases.
+     *
+     * @return test cases
+     */
+    Collection<T> getTestCases();
 }
diff --git 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/cases/AgentE2ETestCasesLoader.java
similarity index 66%
rename from 
test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
rename to 
test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/cases/AgentE2ETestCasesLoader.java
index 3e678f4cedc..6c530a6e6a3 100644
--- 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
+++ 
b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/cases/AgentE2ETestCasesLoader.java
@@ -15,12 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.test.e2e.agent.file.cases;
+package org.apache.shardingsphere.test.e2e.agent.common.cases;
 
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
-import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCase;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
@@ -42,23 +40,12 @@ import java.util.Objects;
 /**
  * E2E test cases loader.
  */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class E2ETestCasesLoader {
+@RequiredArgsConstructor
+public final class AgentE2ETestCasesLoader {
     
     private static final String FILE_EXTENSION = ".xml";
     
-    private static final E2ETestCasesLoader INSTANCE = new 
E2ETestCasesLoader();
-    
-    private Collection<AgentE2ETestCase> testCases;
-    
-    /**
-     * Get singleton instance.
-     *
-     * @return singleton instance
-     */
-    public static E2ETestCasesLoader getInstance() {
-        return INSTANCE;
-    }
+    private final Class<? extends AgentE2ETestCases<?>> agentE2ETestCasesClass;
     
     /**
      * Load test cases.
@@ -66,20 +53,17 @@ public final class E2ETestCasesLoader {
      * @param adapter adapter
      * @return test cases
      */
-    @SneakyThrows({IOException.class, URISyntaxException.class, 
JAXBException.class})
     public Collection<AgentE2ETestCase> loadTestCases(final String adapter) {
-        if (null != testCases) {
-            return testCases;
-        }
-        testCases = new LinkedList<>();
+        Collection<AgentE2ETestCase> result = new LinkedList<>();
         URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
         for (File each : getFiles(url)) {
-            testCases.addAll(unmarshal(each.getPath()).getTestCases());
+            result.addAll(unmarshal(each.getPath()).getTestCases());
         }
-        return testCases;
+        return result;
     }
     
-    private Collection<File> getFiles(final URL url) throws IOException, 
URISyntaxException {
+    @SneakyThrows({IOException.class, URISyntaxException.class})
+    private Collection<File> getFiles(final URL url) {
         Collection<File> result = new LinkedList<>();
         Files.walkFileTree(Paths.get(url.toURI()), new 
SimpleFileVisitor<Path>() {
             
@@ -94,9 +78,10 @@ public final class E2ETestCasesLoader {
         return result;
     }
     
-    private E2ETestCases unmarshal(final String e2eCasesFile) throws 
IOException, JAXBException {
+    @SneakyThrows({IOException.class, JAXBException.class})
+    private AgentE2ETestCases<?> unmarshal(final String e2eCasesFile) {
         try (FileReader reader = new FileReader(e2eCasesFile)) {
-            return (E2ETestCases) 
JAXBContext.newInstance(E2ETestCases.class).createUnmarshaller().unmarshal(reader);
+            return (AgentE2ETestCases<?>) 
JAXBContext.newInstance(agentE2ETestCasesClass).createUnmarshaller().unmarshal(reader);
         }
     }
 }
diff --git 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
 
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
index 234884efeab..841850493e3 100644
--- 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
+++ 
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
@@ -18,9 +18,10 @@
 package org.apache.shardingsphere.test.e2e.agent.file;
 
 import 
org.apache.shardingsphere.test.e2e.agent.common.AgentTestActionExtension;
+import 
org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCasesLoader;
 import org.apache.shardingsphere.test.e2e.agent.common.env.E2ETestEnvironment;
 import org.apache.shardingsphere.test.e2e.agent.file.asserts.ContentAssert;
-import org.apache.shardingsphere.test.e2e.agent.file.cases.E2ETestCasesLoader;
+import org.apache.shardingsphere.test.e2e.agent.file.cases.E2ETestCases;
 import org.apache.shardingsphere.test.e2e.agent.file.cases.LogTestCase;
 import org.junit.jupiter.api.condition.EnabledIf;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -53,7 +54,7 @@ class FilePluginE2EIT {
         
         @Override
         public Stream<? extends Arguments> provideArguments(final 
ExtensionContext extensionContext) {
-            return 
E2ETestCasesLoader.getInstance().loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
+            return new 
AgentE2ETestCasesLoader(E2ETestCases.class).loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
         }
     }
 }
diff --git 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
 
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
index b26dac9c2f8..6c7fc1e01e2 100644
--- 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
+++ 
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCases.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.test.e2e.agent.file.cases;
 
 import lombok.Getter;
+import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCases;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -29,7 +30,7 @@ import java.util.LinkedList;
  */
 @XmlRootElement(name = "e2e-test-cases")
 @Getter
-public final class E2ETestCases {
+public final class E2ETestCases implements AgentE2ETestCases<LogTestCase> {
     
     @XmlElement(name = "test-case")
     private final Collection<LogTestCase> testCases = new LinkedList<>();
diff --git 
a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/MetricsPluginE2EIT.java
 
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/MetricsPluginE2EIT.java
index 70b92fac068..dc483b34c0a 100644
--- 
a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/MetricsPluginE2EIT.java
+++ 
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/MetricsPluginE2EIT.java
@@ -19,11 +19,12 @@ package org.apache.shardingsphere.test.e2e.agent.metrics;
 
 import lombok.extern.slf4j.Slf4j;
 import 
org.apache.shardingsphere.test.e2e.agent.common.AgentTestActionExtension;
+import 
org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCasesLoader;
 import org.apache.shardingsphere.test.e2e.agent.common.env.E2ETestEnvironment;
 import org.apache.shardingsphere.test.e2e.agent.common.util.OkHttpUtils;
 import 
org.apache.shardingsphere.test.e2e.agent.metrics.asserts.MetricMetadataAssert;
 import 
org.apache.shardingsphere.test.e2e.agent.metrics.asserts.MetricQueryAssert;
-import 
org.apache.shardingsphere.test.e2e.agent.metrics.cases.E2ETestCasesLoader;
+import org.apache.shardingsphere.test.e2e.agent.metrics.cases.E2ETestCases;
 import 
org.apache.shardingsphere.test.e2e.agent.metrics.cases.MetricQueryAssertion;
 import org.apache.shardingsphere.test.e2e.agent.metrics.cases.MetricTestCase;
 import 
org.apache.shardingsphere.test.e2e.agent.metrics.result.MetricsMetaDataResult;
@@ -85,7 +86,7 @@ class MetricsPluginE2EIT {
         
         @Override
         public Stream<? extends Arguments> provideArguments(final 
ExtensionContext extensionContext) {
-            return 
E2ETestCasesLoader.getInstance().loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
+            return new 
AgentE2ETestCasesLoader(E2ETestCases.class).loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
         }
     }
 }
diff --git 
a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCases.java
 
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCases.java
index ec0c96168c6..7ed5be27bde 100644
--- 
a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCases.java
+++ 
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCases.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.test.e2e.agent.metrics.cases;
 
 import lombok.Getter;
+import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCases;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -29,7 +30,7 @@ import java.util.LinkedList;
  */
 @XmlRootElement(name = "e2e-test-cases")
 @Getter
-public final class E2ETestCases {
+public final class E2ETestCases implements AgentE2ETestCases<MetricTestCase> {
     
     @XmlElement(name = "test-case")
     private final Collection<MetricTestCase> testCases = new LinkedList<>();
diff --git 
a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCasesLoader.java
deleted file mode 100644
index 831ce963e05..00000000000
--- 
a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/E2ETestCasesLoader.java
+++ /dev/null
@@ -1,102 +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.test.e2e.agent.metrics.cases;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCase;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Objects;
-
-/**
- * E2E test cases loader.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class E2ETestCasesLoader {
-    
-    private static final String FILE_EXTENSION = ".xml";
-    
-    private static final E2ETestCasesLoader INSTANCE = new 
E2ETestCasesLoader();
-    
-    private Collection<AgentE2ETestCase> testCases;
-    
-    /**
-     * Get singleton instance.
-     *
-     * @return singleton instance
-     */
-    public static E2ETestCasesLoader getInstance() {
-        return INSTANCE;
-    }
-    
-    /**
-     * Load test cases.
-     *
-     * @param adapter adapter
-     * @return test cases
-     */
-    @SneakyThrows({IOException.class, URISyntaxException.class, 
JAXBException.class})
-    public Collection<AgentE2ETestCase> loadTestCases(final String adapter) {
-        if (null != testCases) {
-            return testCases;
-        }
-        testCases = new LinkedList<>();
-        URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
-        for (File each : getFiles(url)) {
-            testCases.addAll(unmarshal(each.getPath()).getTestCases());
-        }
-        return testCases;
-    }
-    
-    private Collection<File> getFiles(final URL url) throws IOException, 
URISyntaxException {
-        Collection<File> result = new LinkedList<>();
-        Files.walkFileTree(Paths.get(url.toURI()), new 
SimpleFileVisitor<Path>() {
-            
-            @Override
-            public FileVisitResult visitFile(final Path file, final 
BasicFileAttributes basicFileAttributes) {
-                if (file.getFileName().toString().endsWith(FILE_EXTENSION)) {
-                    result.add(file.toFile());
-                }
-                return FileVisitResult.CONTINUE;
-            }
-        });
-        return result;
-    }
-    
-    private E2ETestCases unmarshal(final String e2eCasesFile) throws 
IOException, JAXBException {
-        try (FileReader reader = new FileReader(e2eCasesFile)) {
-            return (E2ETestCases) 
JAXBContext.newInstance(E2ETestCases.class).createUnmarshaller().unmarshal(reader);
-        }
-    }
-}
diff --git 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/JaegerPluginE2EIT.java
 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/JaegerPluginE2EIT.java
index 394db850ac2..44117ab8a78 100644
--- 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/JaegerPluginE2EIT.java
+++ 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/JaegerPluginE2EIT.java
@@ -18,9 +18,10 @@
 package org.apache.shardingsphere.test.e2e.agent.jaeger;
 
 import 
org.apache.shardingsphere.test.e2e.agent.common.AgentTestActionExtension;
+import 
org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCasesLoader;
 import org.apache.shardingsphere.test.e2e.agent.common.env.E2ETestEnvironment;
 import org.apache.shardingsphere.test.e2e.agent.jaeger.asserts.SpanAssert;
-import 
org.apache.shardingsphere.test.e2e.agent.jaeger.cases.E2ETestCasesLoader;
+import org.apache.shardingsphere.test.e2e.agent.jaeger.cases.E2ETestCases;
 import org.apache.shardingsphere.test.e2e.agent.jaeger.cases.SpanTestCase;
 import org.junit.jupiter.api.condition.EnabledIf;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -50,7 +51,7 @@ class JaegerPluginE2EIT {
         
         @Override
         public Stream<? extends Arguments> provideArguments(final 
ExtensionContext extensionContext) {
-            return 
E2ETestCasesLoader.getInstance().loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
+            return new 
AgentE2ETestCasesLoader(E2ETestCases.class).loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
         }
     }
 }
diff --git 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCases.java
 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCases.java
index 191ad73ee97..a957a99563c 100644
--- 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCases.java
+++ 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCases.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.test.e2e.agent.jaeger.cases;
 
 import lombok.Getter;
+import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCases;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -29,7 +30,7 @@ import java.util.LinkedList;
  */
 @XmlRootElement(name = "e2e-test-cases")
 @Getter
-public final class E2ETestCases {
+public final class E2ETestCases implements AgentE2ETestCases<SpanTestCase> {
     
     @XmlElement(name = "test-case")
     private final Collection<SpanTestCase> testCases = new LinkedList<>();
diff --git 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
deleted file mode 100644
index 343f8a3a61e..00000000000
--- 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
+++ /dev/null
@@ -1,102 +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.test.e2e.agent.jaeger.cases;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCase;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Objects;
-
-/**
- * E2E test cases loader.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class E2ETestCasesLoader {
-    
-    private static final String FILE_EXTENSION = ".xml";
-    
-    private static final E2ETestCasesLoader INSTANCE = new 
E2ETestCasesLoader();
-    
-    private Collection<AgentE2ETestCase> testCases;
-    
-    /**
-     * Get singleton instance.
-     *
-     * @return singleton instance
-     */
-    public static E2ETestCasesLoader getInstance() {
-        return INSTANCE;
-    }
-    
-    /**
-     * Load test cases.
-     *
-     * @param adapter adapter
-     * @return test cases
-     */
-    @SneakyThrows({IOException.class, URISyntaxException.class, 
JAXBException.class})
-    public Collection<AgentE2ETestCase> loadTestCases(final String adapter) {
-        if (null != testCases) {
-            return testCases;
-        }
-        testCases = new LinkedList<>();
-        URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
-        for (File each : getFiles(url)) {
-            testCases.addAll(unmarshal(each.getPath()).getTestCases());
-        }
-        return testCases;
-    }
-    
-    private Collection<File> getFiles(final URL url) throws IOException, 
URISyntaxException {
-        Collection<File> result = new LinkedList<>();
-        Files.walkFileTree(Paths.get(url.toURI()), new 
SimpleFileVisitor<Path>() {
-            
-            @Override
-            public FileVisitResult visitFile(final Path file, final 
BasicFileAttributes basicFileAttributes) {
-                if (file.getFileName().toString().endsWith(FILE_EXTENSION)) {
-                    result.add(file.toFile());
-                }
-                return FileVisitResult.CONTINUE;
-            }
-        });
-        return result;
-    }
-    
-    private E2ETestCases unmarshal(final String e2eCasesFile) throws 
IOException, JAXBException {
-        try (FileReader reader = new FileReader(e2eCasesFile)) {
-            return (E2ETestCases) 
JAXBContext.newInstance(E2ETestCases.class).createUnmarshaller().unmarshal(reader);
-        }
-    }
-}
diff --git 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/ZipkinPluginE2EIT.java
 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/ZipkinPluginE2EIT.java
index 411b22d560d..239be973a23 100644
--- 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/ZipkinPluginE2EIT.java
+++ 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/ZipkinPluginE2EIT.java
@@ -18,9 +18,10 @@
 package org.apache.shardingsphere.test.e2e.agent.zipkin;
 
 import 
org.apache.shardingsphere.test.e2e.agent.common.AgentTestActionExtension;
+import 
org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCasesLoader;
 import org.apache.shardingsphere.test.e2e.agent.common.env.E2ETestEnvironment;
 import org.apache.shardingsphere.test.e2e.agent.zipkin.asserts.SpanAssert;
-import 
org.apache.shardingsphere.test.e2e.agent.zipkin.cases.E2ETestCasesLoader;
+import org.apache.shardingsphere.test.e2e.agent.zipkin.cases.E2ETestCases;
 import org.apache.shardingsphere.test.e2e.agent.zipkin.cases.SpanTestCase;
 import org.junit.jupiter.api.condition.EnabledIf;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -50,7 +51,7 @@ class ZipkinPluginE2EIT {
         
         @Override
         public Stream<? extends Arguments> provideArguments(final 
ExtensionContext extensionContext) {
-            return 
E2ETestCasesLoader.getInstance().loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
+            return new 
AgentE2ETestCasesLoader(E2ETestCases.class).loadTestCases(E2ETestEnvironment.getInstance().getAdapter()).stream().map(Arguments::of);
         }
     }
 }
diff --git 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCases.java
 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCases.java
index 81db141d5f7..76af0320a97 100644
--- 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCases.java
+++ 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCases.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.test.e2e.agent.zipkin.cases;
 
 import lombok.Getter;
+import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCases;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -29,7 +30,7 @@ import java.util.LinkedList;
  */
 @XmlRootElement(name = "e2e-test-cases")
 @Getter
-public final class E2ETestCases {
+public final class E2ETestCases implements AgentE2ETestCases<SpanTestCase> {
     
     @XmlElement(name = "test-case")
     private final Collection<SpanTestCase> testCases = new LinkedList<>();
diff --git 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
deleted file mode 100644
index 67f93d8e2f6..00000000000
--- 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
+++ /dev/null
@@ -1,102 +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.test.e2e.agent.zipkin.cases;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.test.e2e.agent.common.cases.AgentE2ETestCase;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Objects;
-
-/**
- * E2E test cases loader.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class E2ETestCasesLoader {
-    
-    private static final String FILE_EXTENSION = ".xml";
-    
-    private static final E2ETestCasesLoader INSTANCE = new 
E2ETestCasesLoader();
-    
-    private Collection<AgentE2ETestCase> testCases;
-    
-    /**
-     * Get singleton instance.
-     *
-     * @return singleton instance
-     */
-    public static E2ETestCasesLoader getInstance() {
-        return INSTANCE;
-    }
-    
-    /**
-     * Load test cases.
-     *
-     * @param adapter adapter
-     * @return test cases
-     */
-    @SneakyThrows({IOException.class, URISyntaxException.class, 
JAXBException.class})
-    public Collection<AgentE2ETestCase> loadTestCases(final String adapter) {
-        if (null != testCases) {
-            return testCases;
-        }
-        testCases = new LinkedList<>();
-        URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
-        for (File each : getFiles(url)) {
-            testCases.addAll(unmarshal(each.getPath()).getTestCases());
-        }
-        return testCases;
-    }
-    
-    private Collection<File> getFiles(final URL url) throws IOException, 
URISyntaxException {
-        Collection<File> result = new LinkedList<>();
-        Files.walkFileTree(Paths.get(url.toURI()), new 
SimpleFileVisitor<Path>() {
-            
-            @Override
-            public FileVisitResult visitFile(final Path file, final 
BasicFileAttributes basicFileAttributes) {
-                if (file.getFileName().toString().endsWith(FILE_EXTENSION)) {
-                    result.add(file.toFile());
-                }
-                return FileVisitResult.CONTINUE;
-            }
-        });
-        return result;
-    }
-    
-    private E2ETestCases unmarshal(final String e2eCasesFile) throws 
IOException, JAXBException {
-        try (FileReader reader = new FileReader(e2eCasesFile)) {
-            return (E2ETestCases) 
JAXBContext.newInstance(E2ETestCases.class).createUnmarshaller().unmarshal(reader);
-        }
-    }
-}

Reply via email to