You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/08/03 11:14:37 UTC

[camel] branch main updated: (chores) camel-xmpp: fix most of the test log output to stdout (#10975)

This is an automated email from the ASF dual-hosted git repository.

orpiske 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 b680698fcee (chores) camel-xmpp: fix most of the test log output to stdout (#10975)
b680698fcee is described below

commit b680698fceee14586bb89acd5a733281579d8bc9
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Aug 3 13:14:31 2023 +0200

    (chores) camel-xmpp: fix most of the test log output to stdout (#10975)
---
 components/camel-xmpp/pom.xml                      | 33 +++++-----------------
 .../component/xmpp/XmppBaseContainerTest.java      | 18 ++++++++++++
 .../component/xmpp/integration/XmppBaseIT.java     | 18 ++++++++++++
 .../src/test/resources/logging.properties          | 18 ++++++++++++
 4 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/components/camel-xmpp/pom.xml b/components/camel-xmpp/pom.xml
index d39f3209526..e1f4b96830e 100644
--- a/components/camel-xmpp/pom.xml
+++ b/components/camel-xmpp/pom.xml
@@ -82,6 +82,13 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jul-to-slf4j</artifactId>
+            <version>${slf4j-version}</version>
+            <scope>test</scope>
+        </dependency>
+
         <!-- test infra -->
         <dependency>
             <groupId>org.apache.camel</groupId>
@@ -91,30 +98,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-
-    <profiles>
-        <profile>
-            <id>full</id>
-            <activation>
-                <property>
-                    <name>!quickly</name>
-                </property>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-surefire-plugin</artifactId>
-                        <configuration>
-                            <!-- Something on the tests generate a lot of bogus output-->
-                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
-                            <systemPropertyVariables>
-                                <visibleassertions.silence>true</visibleassertions.silence>
-                            </systemPropertyVariables>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
 </project>
diff --git a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java
index 339c192f565..42adbeec05f 100644
--- a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java
+++ b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppBaseContainerTest.java
@@ -17,14 +17,32 @@
 
 package org.apache.camel.component.xmpp;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.LogManager;
+
 import org.apache.camel.spi.Registry;
 import org.apache.camel.support.SimpleRegistry;
 import org.apache.camel.test.infra.xmpp.services.XmppServerContainer;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class XmppBaseContainerTest extends CamelTestSupport {
     protected XmppServerContainer xmppServer = new XmppServerContainer();
 
+    static {
+        try (InputStream is = XmppBaseContainerTest.class.getClassLoader().getResourceAsStream("logging.properties")) {
+            LogManager.getLogManager().readConfiguration(is);
+        } catch (IOException e) {
+            Logger logger = LoggerFactory.getLogger(XmppBaseContainerTest.class);
+
+            logger.warn(
+                    "Unable to setup JUL-to-slf4j logging bridge. The test execution should result in a log of bogus output. Error: {}",
+                    e.getMessage(), e);
+        }
+    }
+
     @Override
     protected Registry createCamelRegistry() throws Exception {
         Registry registry = new SimpleRegistry();
diff --git a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java
index 9cd81e4d352..ae59a76001e 100644
--- a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java
+++ b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/integration/XmppBaseIT.java
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.component.xmpp.integration;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.LogManager;
+
 import org.apache.camel.component.xmpp.XmppTestUtil;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.support.SimpleRegistry;
@@ -25,6 +29,8 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
 import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 // This was originally disabled on the pom file with the reason given below.
 @DisabledOnOs(value = OS.AIX, disabledReason = "has problem with all the new reconnection stuff and whatnot")
@@ -32,6 +38,18 @@ public class XmppBaseIT extends CamelTestSupport {
     @RegisterExtension
     static XmppService service = XmppServiceFactory.createService();
 
+    static {
+        try (InputStream is = XmppBaseIT.class.getClassLoader().getResourceAsStream("logging.properties")) {
+            LogManager.getLogManager().readConfiguration(is);
+        } catch (IOException e) {
+            Logger logger = LoggerFactory.getLogger(XmppBaseIT.class);
+
+            logger.warn(
+                    "Unable to setup JUL-to-slf4j logging bridge. The test execution should result in a log of bogus output. Error: {}",
+                    e.getMessage(), e);
+        }
+    }
+
     @Override
     protected Registry createCamelRegistry() throws Exception {
         Registry registry = new SimpleRegistry();
diff --git a/components/camel-xmpp/src/test/resources/logging.properties b/components/camel-xmpp/src/test/resources/logging.properties
new file mode 100644
index 00000000000..24628f3ff2f
--- /dev/null
+++ b/components/camel-xmpp/src/test/resources/logging.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.
+## ---------------------------------------------------------------------------
+handlers = org.slf4j.bridge.SLF4JBridgeHandler
+.level = FINEST