You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/07/14 20:47:58 UTC
[camel-quarkus] 01/04: Fix #1448 Add an integration test for the
command mode
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 50efe791c97f3a6cbbe9f901cda6f694f9d44313
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue Jul 14 15:24:18 2020 +0200
Fix #1448 Add an integration test for the command mode
---
extensions-core/main/runtime/pom.xml | 2 +-
integration-tests/main-command-mode/pom.xml | 147 +++++++++++++++++++++
.../apache/camel/quarkus/main/cmd/CamelRoute.java | 36 +++++
.../src/main/resources/application.properties | 18 +++
.../camel/quarkus/main/cmd/it/CommandModeIT.java | 32 +++++
.../camel/quarkus/main/cmd/it/CommandModeTest.java | 52 ++++++++
integration-tests/pom.xml | 1 +
pom.xml | 1 +
poms/bom-test/pom.xml | 5 +
tooling/scripts/test-categories.yaml | 1 +
10 files changed, 294 insertions(+), 1 deletion(-)
diff --git a/extensions-core/main/runtime/pom.xml b/extensions-core/main/runtime/pom.xml
index 8c5a9c1..140accf 100644
--- a/extensions-core/main/runtime/pom.xml
+++ b/extensions-core/main/runtime/pom.xml
@@ -75,7 +75,7 @@
<execution>
<id>update-extension-doc-page</id>
<goals><goal>update-extension-doc-page</goal></goals>
- <phase>process-resources</phase>
+ <phase>process-classes</phase>
</execution>
</executions>
</plugin>
diff --git a/integration-tests/main-command-mode/pom.xml b/integration-tests/main-command-mode/pom.xml
new file mode 100644
index 0000000..be9dc9a
--- /dev/null
+++ b/integration-tests/main-command-mode/pom.xml
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-quarkus-integration-test-main-command-mode</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Main Command Mode</name>
+
+ <properties>
+ <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd -->
+ <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
+ <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
+ <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
+ <!-- Please update rule whenever you change the dependencies of this module by running -->
+ <!-- mvn process-resources -Pformat from the root directory -->
+ <mvnd.builder.rule>camel-quarkus-log-deployment,camel-quarkus-main-deployment,camel-quarkus-support-policy-deployment,camel-quarkus-timer-deployment</mvnd.builder.rule>
+
+ <quarkus.runner.jar>${basedir}/target/${project.artifactId}-${project.version}-runner.jar</quarkus.runner.jar>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-main</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.zeroturnaround</groupId>
+ <artifactId>zt-exec</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- Move surefire:test to integration-test phase to be able to run
+ java -jar target/*runner.jar from a test -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <phase>integration-test</phase>
+ <configuration>
+ <systemProperties>
+ <quarkus.runner.jar>${quarkus.runner.jar}</quarkus.runner.jar>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ <quarkus.runner.jar>${basedir}/target/${project.artifactId}-${project.version}-native-image-source-jar/${project.artifactId}-${project.version}-runner.jar</quarkus.runner.jar>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <quarkus.runner>${basedir}/target/${project.artifactId}-${project.version}-runner</quarkus.runner>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/main-command-mode/src/main/java/org/apache/camel/quarkus/main/cmd/CamelRoute.java b/integration-tests/main-command-mode/src/main/java/org/apache/camel/quarkus/main/cmd/CamelRoute.java
new file mode 100644
index 0000000..b0d6df4
--- /dev/null
+++ b/integration-tests/main-command-mode/src/main/java/org/apache/camel/quarkus/main/cmd/CamelRoute.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.quarkus.main.cmd;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@ApplicationScoped
+public class CamelRoute extends RouteBuilder {
+
+ @ConfigProperty(name = "greeted.subject", defaultValue = "World")
+ String greetedSubject;
+
+ @Override
+ public void configure() {
+ from("timer:hello")
+ .setBody().constant("Hello " + greetedSubject + "!")
+ .to("log:hello");
+ }
+}
diff --git a/integration-tests/main-command-mode/src/main/resources/application.properties b/integration-tests/main-command-mode/src/main/resources/application.properties
new file mode 100644
index 0000000..ade6fba
--- /dev/null
+++ b/integration-tests/main-command-mode/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You 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.
+## ---------------------------------------------------------------------------
+
+camel.main.duration-max-messages = 1
diff --git a/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeIT.java b/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeIT.java
new file mode 100644
index 0000000..16cec19
--- /dev/null
+++ b/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeIT.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.quarkus.main.cmd.it;
+
+import java.nio.file.Paths;
+
+import org.assertj.core.api.Assertions;
+
+public class CommandModeIT extends CommandModeTest {
+
+ protected String[] command(String greetingSubject) {
+ final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
+ final String runner = System.getProperty("quarkus.runner") + (isWindows ? ".exe" : "");
+ Assertions.assertThat(Paths.get(runner)).exists();
+ return new String[] { runner, "-Dgreeted.subject=" + greetingSubject };
+ }
+
+}
diff --git a/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java b/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java
new file mode 100644
index 0000000..2de094b
--- /dev/null
+++ b/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.quarkus.main.cmd.it;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.concurrent.TimeoutException;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.zeroturnaround.exec.InvalidExitValueException;
+import org.zeroturnaround.exec.ProcessExecutor;
+import org.zeroturnaround.exec.ProcessResult;
+
+public class CommandModeTest {
+
+ @Test
+ void hello() throws InvalidExitValueException, IOException, InterruptedException, TimeoutException {
+
+ final ProcessResult result = new ProcessExecutor()
+ .command(command("Joe"))
+ .readOutput(true)
+ .execute();
+
+ Assertions.assertThat(result.getExitValue()).isEqualTo(0);
+ Assertions.assertThat(result.outputUTF8()).contains("Hello Joe!");
+
+ }
+
+ protected String[] command(String greetingSubject) {
+ final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
+ final String javaExecutable = System.getProperty("java.home") + (isWindows ? "/bin/java.exe" : "/bin/java");
+ final String runnerJar = System.getProperty("quarkus.runner.jar");
+ Assertions.assertThat(Paths.get(runnerJar)).exists();
+ return new String[] { javaExecutable, "-Dgreeted.subject=" + greetingSubject, "-jar", runnerJar };
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 95519d2..b9a3835 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -61,6 +61,7 @@
<module>main-xml-io</module>
<module>main-collector</module>
<module>main-caffeine-lrucache</module>
+ <module>main-command-mode</module>
<!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat -->
<module>activemq</module>
diff --git a/pom.xml b/pom.xml
index 1156791..5069db3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,7 @@
<sshd.version>2.3.0</sshd.version>
<stax2.version>4.2</stax2.version>
<testcontainers.version>1.14.3</testcontainers.version>
+ <zt-exec.version>1.11</zt-exec.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<maven.compiler.target>1.8</maven.compiler.target>
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index 58a15df..672b042 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -130,6 +130,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.zeroturnaround</groupId>
+ <artifactId>zt-exec</artifactId>
+ <version>${zt-exec.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 3dc42a0..375ea1f 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -29,6 +29,7 @@ main:
- main-caffeine-lrucache
- main-collector
- main-devmode
+ - main-command-mode
- main-xml-io
- main-xml-jaxb
database: