diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/NewManagedModuleNativeIT.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/NewManagedModuleNativeIT.java new file mode 100644 index 000000000..1734d885c --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/NewManagedModuleNativeIT.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mvndaemon.mvnd.it; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.inject.Inject; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mvndaemon.mvnd.assertj.TestClientOutput; +import org.mvndaemon.mvnd.client.Client; +import org.mvndaemon.mvnd.common.DaemonInfo; +import org.mvndaemon.mvnd.junit.ClientFactory; +import org.mvndaemon.mvnd.junit.MvndNativeTest; +import org.mvndaemon.mvnd.junit.TestParameters; +import org.mvndaemon.mvnd.junit.TestRegistry; + +@MvndNativeTest(projectDir = "src/test/projects/new-managed-module") +public class NewManagedModuleNativeIT { + + @Inject + TestParameters parameters; + + @Inject + TestRegistry registry; + + @Inject + ClientFactory clientFactory; + + @Test + void upgrade() throws IOException, InterruptedException { + Assertions.assertThat(registry.getAll().size()).isEqualTo(0); + + /* Build the initial state of the test project */ + final Path parentDir = parameters.getTestDir().resolve("project/parent"); + final Client cl = clientFactory.newClient(parameters.cd(parentDir)); + { + final TestClientOutput output = new TestClientOutput(); + cl.execute(output, "clean", "install", "-e").assertSuccess(); + } + Assertions.assertThat(registry.getAll().size()).isEqualTo(1); + + final DaemonInfo d = registry.getAll().get(0); + /* Wait, till the instance becomes idle */ + registry.awaitIdle(d.getUid()); + + /* Do the changes */ + final Path srcDir = parentDir.resolve("../changes").normalize(); + try (Stream files = Files.walk(srcDir)) { + files.forEach(source -> { + final Path relPath = srcDir.relativize(source); + final Path dest = parentDir.resolve(relPath); + try { + if (Files.isDirectory(source)) { + Files.createDirectories(dest); + } else { + Files.createDirectories(dest.getParent()); + Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } + + /* Build again */ + { + final TestClientOutput output = new TestClientOutput(); + cl.execute(output, "clean", "install", "-e", "-B").assertSuccess(); + + final List messagesToString = output.messagesToString(); + Assertions.assertThat(messagesToString.stream().noneMatch(m -> m.contains("[ERROR]"))) + .withFailMessage("Should contain no errors:\n %s", + messagesToString.stream().collect(Collectors.joining("\n "))) + .isTrue(); + } + Assertions.assertThat(registry.getAll().size()).isEqualTo(1); + + } +} diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/NewManagedModuleTest.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/NewManagedModuleTest.java new file mode 100644 index 000000000..4848589f5 --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/NewManagedModuleTest.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mvndaemon.mvnd.it; + +import org.mvndaemon.mvnd.junit.MvndTest; + +@MvndTest(projectDir = "src/test/projects/new-managed-module") +public class NewManagedModuleTest extends NewManagedModuleNativeIT { + +} diff --git a/integration-tests/src/test/projects/new-managed-module/changes/bom/pom.xml b/integration-tests/src/test/projects/new-managed-module/changes/bom/pom.xml new file mode 100644 index 000000000..8fd7a6db5 --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/changes/bom/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + new-managed-module-bom + pom + + + 0.0.1-SNAPSHOT + + + + + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-module + ${new-managed-module.version} + + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-new-module + ${new-managed-module.version} + + + + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/new-managed-module/changes/module/pom.xml b/integration-tests/src/test/projects/new-managed-module/changes/module/pom.xml new file mode 100644 index 000000000..70b785b36 --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/changes/module/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + new-managed-module-module + + + + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-bom + 0.0.1-SNAPSHOT + pom + import + + + + + + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-new-module + + + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/new-managed-module/changes/module/src/main/java/org/mvndaemon/mvnd/test/upgrades/bom/module/UseHello.java b/integration-tests/src/test/projects/new-managed-module/changes/module/src/main/java/org/mvndaemon/mvnd/test/upgrades/bom/module/UseHello.java new file mode 100644 index 000000000..4cf284e1b --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/changes/module/src/main/java/org/mvndaemon/mvnd/test/upgrades/bom/module/UseHello.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mvndaemon.mvnd.test.upgrades.bom.module; + +import org.mvndaemon.mvnd.test.upgrades.nw.module.Hello; + +public class UseHello { + + public void use() { + System.out.println(new Hello().hi()); + } + +} diff --git a/integration-tests/src/test/projects/new-managed-module/changes/new-module/pom.xml b/integration-tests/src/test/projects/new-managed-module/changes/new-module/pom.xml new file mode 100644 index 000000000..01289229d --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/changes/new-module/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + new-managed-module-new-module + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/new-managed-module/changes/new-module/src/main/java/org/mvndaemon/mvnd/test/upgrades/nw/module/Hello.java b/integration-tests/src/test/projects/new-managed-module/changes/new-module/src/main/java/org/mvndaemon/mvnd/test/upgrades/nw/module/Hello.java new file mode 100644 index 000000000..6258e1a51 --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/changes/new-module/src/main/java/org/mvndaemon/mvnd/test/upgrades/nw/module/Hello.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mvndaemon.mvnd.test.upgrades.nw.module; + +public class Hello { + + public String hi() { + return "Hi"; + } + +} diff --git a/integration-tests/src/test/projects/new-managed-module/changes/pom.xml b/integration-tests/src/test/projects/new-managed-module/changes/pom.xml new file mode 100644 index 000000000..50440e9ae --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/changes/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + pom + + + UTF-8 + 1.8 + 1.8 + + 2.5 + 3.8.0 + 2.4 + 2.6 + 2.22.2 + + + + bom + module + new-module + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/new-managed-module/parent/.mvn/.gitkeep b/integration-tests/src/test/projects/new-managed-module/parent/.mvn/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/src/test/projects/new-managed-module/parent/bom/pom.xml b/integration-tests/src/test/projects/new-managed-module/parent/bom/pom.xml new file mode 100644 index 000000000..39a19b5ac --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/parent/bom/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + new-managed-module-bom + pom + + + + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-module + ${project.version} + + + + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/new-managed-module/parent/module/pom.xml b/integration-tests/src/test/projects/new-managed-module/parent/module/pom.xml new file mode 100644 index 000000000..04a4cfeec --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/parent/module/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + new-managed-module-module + + + + + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-bom + 0.0.1-SNAPSHOT + pom + import + + + + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/new-managed-module/parent/module/src/main/java/org/mvndaemon/mvnd/test/upgrades/bom/module/UseHello.java b/integration-tests/src/test/projects/new-managed-module/parent/module/src/main/java/org/mvndaemon/mvnd/test/upgrades/bom/module/UseHello.java new file mode 100644 index 000000000..6e8f54ff2 --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/parent/module/src/main/java/org/mvndaemon/mvnd/test/upgrades/bom/module/UseHello.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mvndaemon.mvnd.test.upgrades.bom.module; + +public class UseHello { + + public void use() { + System.out.println("Hello"); + } + +} diff --git a/integration-tests/src/test/projects/new-managed-module/parent/pom.xml b/integration-tests/src/test/projects/new-managed-module/parent/pom.xml new file mode 100644 index 000000000..1a25cce5b --- /dev/null +++ b/integration-tests/src/test/projects/new-managed-module/parent/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + org.mvndaemon.mvnd.test.new-managed-module + new-managed-module-parent + 0.0.1-SNAPSHOT + pom + + + UTF-8 + 1.8 + 1.8 + + 2.5 + 3.8.0 + 2.4 + 2.6 + 2.22.2 + + + + bom + module + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + \ No newline at end of file