diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 4aeba407..f358e073 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -82,10 +82,28 @@
maven-model
test
+
+ org.apache.commons
+ commons-compress
+ test
+
+
+ org.codehaus.mojo
+ mrm-maven-plugin
+ 1.2.0
+
+
+ process-test-classes
+
+ start
+
+
+
+
org.apache.maven.plugins
maven-surefire-plugin
@@ -93,6 +111,7 @@
${project.version}
${mvnd.home}
+ ${mrm.repository.url}
${os.detected.name}
${os.detected.arch}
@@ -119,6 +138,7 @@
${project.version}
${mvnd.home}
+ ${mrm.repository.url}
${os.detected.name}
${os.detected.arch}
diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/ModuleAndPluginNativeIT.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/ModuleAndPluginNativeIT.java
index ad307f5b..687fc173 100644
--- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/ModuleAndPluginNativeIT.java
+++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/ModuleAndPluginNativeIT.java
@@ -49,6 +49,7 @@ public class ModuleAndPluginNativeIT {
}
final Path localMavenRepo = layout.getLocalMavenRepository();
+ TestUtils.deleteDir(localMavenRepo);
final Path[] installedJars = {
localMavenRepo.resolve(
"org/jboss/fuse/mvnd/test/module-and-plugin/module-and-plugin-maven-plugin/0.0.1-SNAPSHOT/module-and-plugin-maven-plugin-0.0.1-SNAPSHOT.jar"),
diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/MultiModuleTest.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/MultiModuleTest.java
index 88987173..bf9d4424 100644
--- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/MultiModuleTest.java
+++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/MultiModuleTest.java
@@ -27,6 +27,7 @@ import org.jboss.fuse.mvnd.client.Client;
import org.jboss.fuse.mvnd.client.ClientLayout;
import org.jboss.fuse.mvnd.client.ClientOutput;
import org.jboss.fuse.mvnd.junit.MvndTest;
+import org.jboss.fuse.mvnd.junit.TestUtils;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -55,6 +56,7 @@ public class MultiModuleTest {
});
final Path localMavenRepo = layout.getLocalMavenRepository();
+ TestUtils.deleteDir(localMavenRepo);
final Path[] installedJars = {
localMavenRepo.resolve(
"org/jboss/fuse/mvnd/test/multi-module/multi-module-api/0.0.1-SNAPSHOT/multi-module-api-0.0.1-SNAPSHOT.jar"),
diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/SingleModuleNativeIT.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/SingleModuleNativeIT.java
index d0324199..14a3e71e 100644
--- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/SingleModuleNativeIT.java
+++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/it/SingleModuleNativeIT.java
@@ -25,6 +25,7 @@ import org.jboss.fuse.mvnd.client.Client;
import org.jboss.fuse.mvnd.client.ClientLayout;
import org.jboss.fuse.mvnd.client.ClientOutput;
import org.jboss.fuse.mvnd.junit.MvndNativeTest;
+import org.jboss.fuse.mvnd.junit.TestUtils;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;
@@ -45,7 +46,9 @@ public class SingleModuleNativeIT {
Files.delete(helloFilePath);
}
- final Path installedJar = layout.getLocalMavenRepository().resolve(
+ final Path localMavenRepo = layout.getLocalMavenRepository();
+ TestUtils.deleteDir(localMavenRepo);
+ final Path installedJar = localMavenRepo.resolve(
"org/jboss/fuse/mvnd/test/single-module/single-module/0.0.1-SNAPSHOT/single-module-0.0.1-SNAPSHOT.jar");
Assertions.assertThat(installedJar).doesNotExist();
diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java
index eb9d96af..a776754e 100644
--- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java
+++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/MvndTestExtension.java
@@ -21,7 +21,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Comparator;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Stream;
@@ -38,6 +37,8 @@ import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExtensionContext.Store;
+import static org.jboss.fuse.mvnd.junit.TestUtils.deleteDir;
+
public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback {
/** A placeholder to replace with a temporary directory outside of the current source tree */
@@ -204,29 +205,12 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
return new MvndResource(layout, registry, isNative, timeoutMs);
}
- static Path deleteDir(Path dir) {
- if (Files.exists(dir)) {
- try (Stream files = Files.walk(dir)) {
- files.sorted(Comparator.reverseOrder())
- .forEach(f -> {
- try {
- Files.delete(f);
- } catch (IOException e) {
- throw new RuntimeException("Could not delete " + f);
- }
- });
- } catch (IOException e1) {
- throw new RuntimeException("Could not walk " + dir);
- }
- }
- return dir;
- }
-
static Path createSettings(Path settingsPath) {
final Path settingsTemplatePath = Paths.get("src/test/resources/settings-template.xml");
try {
- final String template = new String(Files.readAllBytes(settingsTemplatePath), StandardCharsets.UTF_8);
- final String content = template;
+ final String template = Files.readString(settingsTemplatePath);
+ final String content = template.replaceAll("@mrm.repository.url@",
+ Objects.requireNonNull(System.getProperty("mrm.repository.url")));
try {
Files.write(settingsPath, content.getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
diff --git a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/TestUtils.java b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/TestUtils.java
index 3dd40f49..531b3f16 100644
--- a/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/TestUtils.java
+++ b/integration-tests/src/test/java/org/jboss/fuse/mvnd/junit/TestUtils.java
@@ -19,12 +19,14 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.Comparator;
+import java.util.stream.Stream;
public class TestUtils {
public static void replace(Path path, String find, String replacement) {
try {
- final String originalSrc = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
+ final String originalSrc = Files.readString(path);
final String newSrc = originalSrc.replace(find, replacement);
if (originalSrc.equals(newSrc)) {
throw new IllegalStateException("[" + find + "] not found in " + path);
@@ -34,4 +36,24 @@ public class TestUtils {
throw new RuntimeException("Could not read or write " + path, e);
}
}
+
+ public static Path deleteDir(Path dir) {
+ if (Files.exists(dir)) {
+ try (Stream files = Files.walk(dir)) {
+ files.sorted(Comparator.reverseOrder()).forEach(TestUtils::deleteFile);
+ } catch (Exception e) {
+ throw new RuntimeException("Could not walk " + dir, e);
+ }
+ }
+ return dir;
+ }
+
+ private static void deleteFile(Path f) {
+ try {
+ Files.delete(f);
+ } catch (Exception e) {
+ throw new RuntimeException("Could not delete " + f, e);
+ }
+ }
+
}
diff --git a/integration-tests/src/test/resources/settings-template.xml b/integration-tests/src/test/resources/settings-template.xml
index a2bf5590..aae8ac89 100644
--- a/integration-tests/src/test/resources/settings-template.xml
+++ b/integration-tests/src/test/resources/settings-template.xml
@@ -17,5 +17,52 @@
-->
-
+
+
+ mrm-maven-plugin
+ Mock Repository Manager
+ @mrm.repository.url@
+ *
+
+
+
+
+ it-repo
+
+
+ snapshots
+ @mrm.repository.url@
+
+ true
+ ignore
+ never
+
+
+ true
+ ignore
+ always
+
+
+
+
+
+ snapshots
+ @mrm.repository.url@
+
+ true
+ ignore
+ never
+
+
+ true
+ ignore
+ always
+
+
+
+
+
+
+ it-repo
+