This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new a8da31741db CAMEL-20367: Adds Jolokia and Hawtio tests (#16048)
a8da31741db is described below
commit a8da31741db8ddb14d5ef6f9082a8d8aa14c7e09
Author: Jakub Vrubel <[email protected]>
AuthorDate: Tue Oct 22 14:20:03 2024 +0200
CAMEL-20367: Adds Jolokia and Hawtio tests (#16048)
Co-authored-by: Jakub Vrubel <[email protected]>
---
.../apache/camel/dsl/jbang/it/JolokiaITCase.java | 62 ++++++++++++++++++++++
.../dsl/jbang/it/support/JBangTestSupport.java | 4 ++
2 files changed, 66 insertions(+)
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/JolokiaITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/JolokiaITCase.java
new file mode 100644
index 00000000000..31f43ad678d
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/JolokiaITCase.java
@@ -0,0 +1,62 @@
+/*
+ * 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.dsl.jbang.it;
+
+import java.io.IOException;
+import java.time.Duration;
+
+import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
+import org.assertj.core.api.Assertions;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+
+public class JolokiaITCase extends JBangTestSupport {
+
+ @Test
+ public void testAttachJolokia() throws IOException {
+ copyResourceInDataFolder(TestResources.DIR_ROUTE);
+ String processID = executeBackground(String.format("run
%s/FromDirectoryRoute.java", mountPoint()));
+ checkLogContains("(FromDirectoryRoute) started");
+ execute("jolokia FromDirectoryRoute");
+ Assertions.assertThat(execInContainer("curl
http://127.0.0.1:8778/jolokia/"))
+ .as("Jolokia should be reachable")
+ .contains("\"agentContext\":\"/jolokia\"");
+ Assertions.assertThat(execute("jolokia FromDirectoryRoute --stop"))
+ .as("Jolokia should stop")
+ .contains("Stopped Jolokia for PID " + processID);
+
+ }
+
+ @Test
+ public void testRunHawtio() throws IOException, InterruptedException {
+ copyResourceInDataFolder(TestResources.DIR_ROUTE);
+ executeBackground(String.format("run %s/FromDirectoryRoute.java",
mountPoint()));
+ checkLogContains("(FromDirectoryRoute) started");
+ execInContainer("nohup camel hawtio FromDirectoryRoute &");
+ Awaitility.await()
+ .atMost(Duration.ofSeconds(30))
+ .pollInterval(Duration.ofSeconds(1))
+ .untilAsserted(() -> Assertions
+ .assertThat(
+ execInContainer("curl
http://localhost:8888/hawtio/"))
+ .as("Hawtio should be reachable")
+ .contains("content=\"Hawtio Management Console\""));
+ Assertions.assertThat(execInContainer("curl
http://127.0.0.1:8778/jolokia/"))
+ .as("Jolokia agent should be attached")
+ .contains("\"agentContext\":\"/jolokia\"");
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
index b6d96afe9af..5f6ae8f624d 100644
---
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
@@ -119,6 +119,10 @@ public abstract class JBangTestSupport {
}
}
+ protected String execInContainer(final String command) {
+ return containerService.executeGenericCommand(command);
+ }
+
protected String execute(final String command) {
return containerService.execute(command);
}