gemmellr commented on code in PR #4615:
URL: https://github.com/apache/activemq-artemis/pull/4615#discussion_r1327171247


##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java:
##########
@@ -72,4 +82,27 @@ public static final boolean deleteDirectory(final File 
directory) {
       return directory.delete();
    }
 
+   public static final void copyDirectory(final File directorySource, final 
File directoryTarget) throws Exception {
+      Path sourcePath = directorySource.toPath();
+      Path targetPath = directoryTarget.toPath();
+
+      try {
+         Files.walkFileTree(sourcePath, new SimpleFileVisitor<>() {
+            @Override
+            public FileVisitResult preVisitDirectory(Path dir, 
BasicFileAttributes attrs) throws IOException {
+               Path targetDir = targetPath.resolve(sourcePath.relativize(dir));
+               Files.createDirectories(targetDir);
+               return FileVisitResult.CONTINUE;
+            }
+
+            @Override
+            public FileVisitResult visitFile(Path file, BasicFileAttributes 
attrs) throws IOException {
+               Files.copy(file, 
targetPath.resolve(sourcePath.relativize(file)), 
StandardCopyOption.REPLACE_EXISTING);
+               return FileVisitResult.CONTINUE;
+            }
+         });
+      } catch (IOException e) {
+         e.printStackTrace();
+      }

Review Comment:
   Doesnt seem like this should be here, it could swallow failure to copy the 
dir properly?



##########
tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/upgradeTest/CompareUpgradeTest.java:
##########
@@ -137,30 +146,39 @@ private void compareDirectories(String expectedFolder, 
String upgradeFolder, Str
          if (f.getName().endsWith(".exe")) {
             Assert.assertArrayEquals(f.getName() + " is different after 
upgrade", Files.readAllBytes(f.toPath()), 
Files.readAllBytes(upgradeFile.toPath()));
          } else {
-            try (Stream<String> expectedStream = Files.lines(f.toPath());
-                 Stream<String> upgradeStream = 
Files.lines(upgradeFile.toPath())) {
+            compareFiles(allowExpectedWord, f, upgradeFile);
+         }
+      }
+   }
 
-               Iterator<String> expectedIterator = expectedStream.iterator();
-               Iterator<String> upgradeIterator = upgradeStream.iterator();
+   private static void compareFiles(boolean allowExpectedWord, File 
expectedFile, File upgradeFile) throws IOException {
+      logger.debug("comparing: {} to {}", upgradeFile, upgradeFile);
+      try (Stream<String> expectedStream = Files.lines(expectedFile.toPath());
+           Stream<String> upgradeStream = Files.lines(upgradeFile.toPath())) {
 
-               int line = 1;
+         Iterator<String> expectedIterator = expectedStream.iterator();
+         Iterator<String> upgradeIterator = upgradeStream.iterator();
 
-               while (expectedIterator.hasNext()) {
-                  Assert.assertTrue(upgradeIterator.hasNext());
+         int line = 1;
 
-                  String expectedString = 
expectedIterator.next().replace("Expected", "").trim();
-                  String upgradeString = upgradeIterator.next().trim();
-                  Assert.assertEquals("error on line " + line + " at " + 
upgradeFile, expectedString, upgradeString);
-                  line++;
-               }
+         while (expectedIterator.hasNext()) {
+            Assert.assertTrue(upgradeIterator.hasNext());
 
-               Assert.assertFalse(upgradeIterator.hasNext());
-            }
-         }
-      }
+            String expectedString = 
expectedIterator.next().replace("Expected", "").trim();
+            String upgradeString = upgradeIterator.next().trim();
 
+            // there's a test in this class that will use a different name ID. 
on that case we replace Expected by ""
+            // on the comparison
+            if (allowExpectedWord) {
+               expectedString = expectedString.replace("Expected", "");
+            }

Review Comment:
   This doesn't seem to be doing anything as the same replace is always already 
being done before it,  when creating expectedString initially. Did you mean to 
remove that one?



##########
tests/smoke-tests/pom.xml:
##########
@@ -1537,6 +1537,21 @@
                      <staticCluster>tcp://localhost:61616</staticCluster>
                   </configuration>
                </execution>
+               <execution>
+                  <phase>test-compile</phase>
+                  <id>upgrade-current-version-phrase1</id>

Review Comment:
   typo, phrase1 -> phase1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to