You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/11/22 09:16:21 UTC

[dubbo] branch 1122_fix_seperator created (now 192cfa0008)

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

albumenj pushed a change to branch 1122_fix_seperator
in repository https://gitbox.apache.org/repos/asf/dubbo.git


      at 192cfa0008 Fix FileTest seperator in Win

This branch includes the following new commits:

     new 192cfa0008 Fix FileTest seperator in Win

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[dubbo] 01/01: Fix FileTest seperator in Win

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 1122_fix_seperator
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 192cfa00081a8390c68c194f4838965e14a658e7
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Tue Nov 22 17:15:27 2022 +0800

    Fix FileTest seperator in Win
---
 .../java/org/apache/dubbo/dependency/FileTest.java | 64 +++++++++++-----------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java b/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java
index e7f7ba606b..85775ae2c5 100644
--- a/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java
+++ b/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java
@@ -80,7 +80,7 @@ class FileTest {
             .sorted()
             .collect(Collectors.toList());
 
-        String dubboBomPath = "dubbo-distribution/dubbo-bom/pom.xml";
+        String dubboBomPath = "dubbo-distribution" + File.separator + "dubbo-bom" + File.separator + "pom.xml";
         Document dubboBom = reader.read(new File(getBaseFile(), dubboBomPath));
         List<String> artifactIdsInDubboBom = dubboBom.getRootElement()
             .element("dependencyManagement")
@@ -120,7 +120,7 @@ class FileTest {
             .sorted()
             .collect(Collectors.toList());
 
-        String dubboDependenciesAllPath = "dubbo-test/dubbo-dependencies-all/pom.xml";
+        String dubboDependenciesAllPath = "dubbo-test" + File.separator + "dubbo-dependencies-all" + File.separator + "pom.xml";
         Document dubboDependenciesAll = reader.read(new File(getBaseFile(), dubboDependenciesAllPath));
         List<String> artifactIdsInDubboDependenciesAll = dubboDependenciesAll.getRootElement()
             .element("dependencies")
@@ -177,7 +177,7 @@ class FileTest {
             .sorted()
             .collect(Collectors.toList());
 
-        String dubboAllPath = "dubbo-distribution/dubbo-all/pom.xml";
+        String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml";
         Document dubboAll = reader.read(new File(getBaseFile(), dubboAllPath));
         List<String> artifactIdsInDubboAll = dubboAll.getRootElement()
             .element("dependencies")
@@ -191,12 +191,12 @@ class FileTest {
         expectedArtifactIds.removeIf(artifactId -> ignoredModules.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
         expectedArtifactIds.removeIf(artifactId -> ignoredModulesInDubboAll.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
 
-        Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml). Found modules: " + expectedArtifactIds);
+        Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml). Found modules: " + expectedArtifactIds);
 
         List<String> unexpectedArtifactIds = new LinkedList<>(artifactIdsInDubboAll);
         unexpectedArtifactIds.removeIf(artifactId -> !artifactIds.contains(artifactId));
         unexpectedArtifactIds.removeAll(deployedArtifactIds);
-        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml). Found modules: " + unexpectedArtifactIds);
+        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml). Found modules: " + unexpectedArtifactIds);
 
         unexpectedArtifactIds = new LinkedList<>();
         for (String artifactId : artifactIdsInDubboAll) {
@@ -210,7 +210,7 @@ class FileTest {
                 unexpectedArtifactIds.add(artifactId);
             }
         }
-        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml). Found modules: " + unexpectedArtifactIds);
+        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml). Found modules: " + unexpectedArtifactIds);
     }
 
     @Test
@@ -254,7 +254,7 @@ class FileTest {
             .sorted()
             .collect(Collectors.toList());
 
-        String dubboAllPath = "dubbo-distribution/dubbo-all/pom.xml";
+        String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml";
         Document dubboAll = reader.read(new File(getBaseFile(), dubboAllPath));
         List<String> artifactIdsInDubboAll = dubboAll.getRootElement()
             .element("build")
@@ -281,12 +281,12 @@ class FileTest {
         expectedArtifactIds.removeIf(artifactId -> ignoredModules.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
         expectedArtifactIds.removeIf(artifactId -> ignoredModulesInDubboAll.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
 
-        Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all (dubbo-distribution/dubbo-all/pom.xml in shade plugin). Found modules: " + expectedArtifactIds);
+        Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all (dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin). Found modules: " + expectedArtifactIds);
 
         List<String> unexpectedArtifactIds = new LinkedList<>(artifactIdsInDubboAll);
         unexpectedArtifactIds.removeIf(artifactId -> !artifactIds.contains(artifactId));
         unexpectedArtifactIds.removeAll(deployedArtifactIds);
-        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all (dubbo-distribution/dubbo-all/pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
+        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all (dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
 
         unexpectedArtifactIds = new LinkedList<>();
         for (String artifactId : artifactIdsInDubboAll) {
@@ -300,7 +300,7 @@ class FileTest {
                 unexpectedArtifactIds.add(artifactId);
             }
         }
-        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all (dubbo-distribution/dubbo-all/pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
+        Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all (dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
     }
 
     @Test
@@ -309,7 +309,7 @@ class FileTest {
         List<String> spis = new LinkedList<>();
         readSPI(baseFile, spis);
 
-        String dubboAllPath = "dubbo-distribution/dubbo-all/pom.xml";
+        String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml";
 
         SAXReader reader = new SAXReader();
         Document dubboAll = reader.read(new File(baseFile, dubboAllPath));
@@ -335,11 +335,11 @@ class FileTest {
 
         List<String> expectedSpis = new LinkedList<>(spis);
         expectedSpis.removeAll(transformsInDubboAll);
-        Assertions.assertTrue(expectedSpis.isEmpty(), "Newly created SPI interface must be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml in shade plugin) to being transformed. Found spis: " + expectedSpis);
+        Assertions.assertTrue(expectedSpis.isEmpty(), "Newly created SPI interface must be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin) to being transformed. Found spis: " + expectedSpis);
 
         List<String> unexpectedSpis = new LinkedList<>(transformsInDubboAll);
         unexpectedSpis.removeAll(spis);
-        Assertions.assertTrue(unexpectedSpis.isEmpty(), "Class without `@SPI` declaration should not be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml in shade plugin) to being transformed. Found spis: " + unexpectedSpis);
+        Assertions.assertTrue(unexpectedSpis.isEmpty(), "Class without `@SPI` declaration should not be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin) to being transformed. Found spis: " + unexpectedSpis);
     }
 
     @Test
@@ -356,8 +356,8 @@ class FileTest {
 
         List<File> unexpectedSpis = new LinkedList<>();
         readSPIUnexpectedResource(baseFile, unexpectedSpis);
-        unexpectedSpis.removeIf(file -> file.getAbsolutePath().contains("dubbo-common/src/main/resources/META-INF/services/org.apache.dubbo.common.extension.LoadingStrategy"));
-        Assertions.assertTrue(unexpectedSpis.isEmpty(), "Dubbo native provided spi profiles must filed in `META-INF/dubbo/internal`. Please move to proper folder . Found spis: " + unexpectedSpis);
+        unexpectedSpis.removeIf(file -> file.getAbsolutePath().contains("dubbo-common" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "services" + File.separator + "org.apache.dubbo.common.extension.LoadingStrategy"));
+        Assertions.assertTrue(unexpectedSpis.isEmpty(), "Dubbo native provided spi profiles must filed in `META-INF" + File.separator + "dubbo" + File.separator + "internal`. Please move to proper folder . Found spis: " + unexpectedSpis);
     }
 
     private static File getBaseFile() {
@@ -404,7 +404,7 @@ class FileTest {
             if (path.getAbsolutePath().contains("target")) {
                 return;
             }
-            if (path.getAbsolutePath().contains("src/main/java")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "java")) {
                 String content;
                 try {
                     content = FileUtils.readFileToString(path, StandardCharsets.UTF_8);
@@ -413,9 +413,10 @@ class FileTest {
                 }
                 if (content != null && content.contains("@SPI")) {
                     String absolutePath = path.getAbsolutePath();
-                    absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src/main/java/") + "src/main/java/".length());
+                    absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src" + File.separator + "main" + File.separator + "java" + File.separator)
+                        + ("src" + File.separator + "main" + File.separator + "java" + File.separator).length());
                     absolutePath = absolutePath.substring(0, absolutePath.lastIndexOf(".java"));
-                    absolutePath = absolutePath.replaceAll("/", ".");
+                    absolutePath = absolutePath.replaceAll(File.separator, ".");
                     spis.add(absolutePath);
                 }
             }
@@ -434,10 +435,11 @@ class FileTest {
             if (path.getAbsolutePath().contains("target")) {
                 return;
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF/dubbo/internal/")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "internal" + File.separator)) {
                 String absolutePath = path.getAbsolutePath();
-                absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src/main/resources/META-INF/dubbo/internal/") + "src/main/resources/META-INF/dubbo/internal/".length());
-                absolutePath = absolutePath.replaceAll("/", ".");
+                absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "internal" + File.separator)
+                    + ("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "internal" + File.separator).length());
+                absolutePath = absolutePath.replaceAll( File.separator, ".");
                 spis.put(path, absolutePath);
             }
         }
@@ -455,35 +457,35 @@ class FileTest {
             if (path.getAbsolutePath().contains("target")) {
                 return;
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF/dubbo/org.apache.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "org.apache.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF/dubbo/com.alibaba.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "com.alibaba.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF/services/org.apache.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "services" + File.separator + "org.apache.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF/services/com.alibaba.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "services" + File.separator + "com.alibaba.dubbo")) {
                 spis.add(path);
             }
 
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo/org.apache.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo" + File.separator + "org.apache.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo/com.alibaba.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo" + File.separator + "com.alibaba.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF.services/org.apache.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.services" + File.separator + "org.apache.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF.services/com.alibaba.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.services" + File.separator + "com.alibaba.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo.internal/org.apache.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo.internal" + File.separator + "org.apache.dubbo")) {
                 spis.add(path);
             }
-            if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo.internal/com.alibaba.dubbo")) {
+            if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo.internal" + File.separator + "com.alibaba.dubbo")) {
                 spis.add(path);
             }
         }