Skip to content

Commit b14e415

Browse files
committed
Centralize FileUtils usage into ItUtils
1 parent e7693ab commit b14e415

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

its/core-it-suite/src/test/java/org/apache/maven/it/ItUtils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static String calcHash(Path file, String algo) throws Exception {
5959
}
6060

6161
public static void assertCanonicalFileEquals(Path expected, Path actual) throws IOException {
62-
assertEquals(expected.toFile().getCanonicalFile(), actual.toFile().getCanonicalFile());
62+
assertEquals(canonicalPath(expected), canonicalPath(actual));
6363
}
6464

6565
public static void createFile(Path path) throws IOException {
@@ -77,4 +77,12 @@ public static void lastModified(Path path, long millis) throws IOException {
7777
public static void deleteDirectory(Path path) throws IOException {
7878
FileUtils.deleteDirectory(path.toFile());
7979
}
80+
81+
public static void copyDirectoryStructure(Path src, Path dest) throws IOException {
82+
FileUtils.copyDirectory(src.toFile(), dest.toFile());
83+
}
84+
85+
public static String canonicalPath(Path path) throws IOException {
86+
return path.toFile().getCanonicalPath();
87+
}
8088
}

its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.Reader;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25-
import org.codehaus.plexus.util.FileUtils;
2625
import org.codehaus.plexus.util.xml.Xpp3Dom;
2726
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
2827
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -43,7 +42,7 @@ public void testitMNG3441() throws Exception {
4342

4443
Path targetRepository = testDir.resolve("target-repo");
4544
ItUtils.deleteDirectory(targetRepository);
46-
FileUtils.copyDirectoryStructure(testDir.resolve("deploy-repo").toFile(), targetRepository.toFile());
45+
ItUtils.copyDirectoryStructure(testDir.resolve("deploy-repo"), targetRepository);
4746

4847
Verifier verifier;
4948

its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4309StrictChecksumValidationForMetadataTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.maven.it;
2020

2121
import java.nio.file.Path;
22-
import org.codehaus.plexus.util.FileUtils;
2322
import org.junit.jupiter.api.Test;
2423

2524
/**
@@ -43,7 +42,7 @@ public void testit() throws Exception {
4342
verifier.setAutoclean(false);
4443
verifier.deleteDirectory("target");
4544
verifier.deleteArtifacts("org.apache.maven.its.mng4309");
46-
FileUtils.copyDirectoryStructure(testDir.resolve("repo").toFile(), testDir.resolve("target/repo").toFile());
45+
ItUtils.copyDirectoryStructure(testDir.resolve("repo"), testDir.resolve("target/repo"));
4746
verifier.addCliArgument("--strict-checksums");
4847
try {
4948
verifier.addCliArgument("validate");

its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4554PluginPrefixMappingUpdateTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Map;
2828
import javax.servlet.http.HttpServletRequest;
2929
import javax.servlet.http.HttpServletResponse;
30-
import org.codehaus.plexus.util.FileUtils;
3130
import org.eclipse.jetty.server.NetworkConnector;
3231
import org.eclipse.jetty.server.Request;
3332
import org.eclipse.jetty.server.Server;
@@ -262,7 +261,7 @@ public void handle(
262261
verifier.addCliArgument("-s");
263262
verifier.addCliArgument("settings.xml");
264263

265-
FileUtils.copyDirectoryStructure(testDir.resolve("repo-1").toFile(), testDir.resolve("repo-it").toFile());
264+
ItUtils.copyDirectoryStructure(testDir.resolve("repo-1"), testDir.resolve("repo-it"));
266265

267266
verifier.setLogFileName("log-refetched-1.txt");
268267
verifier.addCliArgument("a:touch");
@@ -275,7 +274,7 @@ public void handle(
275274
requestedUris.clear();
276275

277276
// simulate deployment of new plugin which updates the prefix mapping in the remote repo
278-
FileUtils.copyDirectoryStructure(testDir.resolve("repo-2").toFile(), testDir.resolve("repo-it").toFile());
277+
ItUtils.copyDirectoryStructure(testDir.resolve("repo-2"), testDir.resolve("repo-it"));
279278

280279
verifier.setLogFileName("log-refetched-2.txt");
281280
verifier.addCliArgument("b:touch");

its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5868NoDuplicateAttachedArtifacts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void testNoDeployNotDuplicate() throws Exception {
106106
verifier.setAutoclean(false);
107107
verifier.deleteDirectory("target");
108108
verifier.deleteArtifacts("org.apache.maven.its.mng5868");
109-
verifier.addCliArgument("-Dartifact.attachedFile=" + tmp.toFile().getCanonicalPath());
109+
verifier.addCliArgument("-Dartifact.attachedFile=" + ItUtils.canonicalPath(tmp));
110110
verifier.addCliArgument("-DdeploymentPort=" + port);
111111
verifier.addCliArguments("org.apache.maven.its.plugins:maven-it-plugin-artifact:2.1-SNAPSHOT:attach", "deploy");
112112
verifier.execute();

0 commit comments

Comments
 (0)