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

zhangliang 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 2ebcc08821f Refactor SQLRewriteEntryTest (#31884)
2ebcc08821f is described below

commit 2ebcc08821fe9ad2b44236afe47172fbad7937c9
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jun 27 10:00:46 2024 +0800

    Refactor SQLRewriteEntryTest (#31884)
    
    * Remove useless static on ShardingSphereSQLParserEngine
    
    * Refactor SQLRewriteEntryTest
---
 .../apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java    | 6 ++----
 .../infra/util/directory/ClasspathResourceDirectoryReader.java      | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git 
a/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
 
b/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
index 8001f873535..d1edb97db4d 100644
--- 
a/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
+++ 
b/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
@@ -49,7 +49,6 @@ import java.util.Properties;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -84,8 +83,7 @@ class SQLRewriteEntryTest {
                 mock(RuleMetaData.class), Collections.singletonMap("test", 
mock(ShardingSphereSchema.class)));
         SQLTranslatorRule sqlTranslatorRule = mock(SQLTranslatorRule.class);
         when(sqlTranslatorRule.translate(any(), any(), any(), any(), any(), 
any())).thenReturn(new SQLTranslatorContext("", Collections.emptyList()));
-        SQLRewriteEntry sqlRewriteEntry = new SQLRewriteEntry(
-                database, new 
RuleMetaData(Collections.singleton(sqlTranslatorRule)), new 
ConfigurationProperties(new Properties()));
+        SQLRewriteEntry sqlRewriteEntry = new SQLRewriteEntry(database, new 
RuleMetaData(Collections.singleton(sqlTranslatorRule)), new 
ConfigurationProperties(new Properties()));
         RouteContext routeContext = new RouteContext();
         RouteUnit firstRouteUnit = mock(RouteUnit.class);
         when(firstRouteUnit.getDataSourceMapper()).thenReturn(new 
RouteMapper("ds", "ds_0"));
@@ -104,7 +102,7 @@ class SQLRewriteEntryTest {
         
when(storageUnit2.getStorageType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
 "MySQL"));
         storageUnits.put("ds_0", storageUnit1);
         storageUnits.put("ds_1", storageUnit2);
-        ResourceMetaData result = mock(ResourceMetaData.class, 
RETURNS_DEEP_STUBS);
+        ResourceMetaData result = mock(ResourceMetaData.class);
         when(result.getStorageUnits()).thenReturn(storageUnits);
         return result;
     }
diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/directory/ClasspathResourceDirectoryReader.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/directory/ClasspathResourceDirectoryReader.java
index 3cc69afdafe..4bc15177972 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/directory/ClasspathResourceDirectoryReader.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/directory/ClasspathResourceDirectoryReader.java
@@ -201,9 +201,9 @@ public final class ClasspathResourceDirectoryReader {
         }
     }
     
+    @SuppressWarnings("resource")
     private static Stream<String> loadFromDirectory(final String directory, 
final URL directoryUrl) throws URISyntaxException, IOException {
         Path directoryPath = Paths.get(directoryUrl.toURI());
-        // noinspection resource
         Stream<Path> walkStream = Files.find(directoryPath, Integer.MAX_VALUE, 
(path, basicFileAttributes) -> !basicFileAttributes.isDirectory(), 
FileVisitOption.FOLLOW_LINKS);
         return walkStream.map(path -> {
             StringBuilder stringBuilder = new StringBuilder();

Reply via email to