You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2024/09/27 14:42:43 UTC
(logging-log4j2) 02/02: Increase diagnostics in `SocketAppenderReconnectTest` (#3004)
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit d51050144c03326c82b3e4a6d3655962c660a871
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Fri Sep 27 16:41:58 2024 +0200
Increase diagnostics in `SocketAppenderReconnectTest` (#3004)
---
.../log4j/core/appender/SocketAppenderReconnectTest.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
index 8bc9b417f2..36e33fe5e9 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
@@ -46,6 +46,7 @@ import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.apache.logging.log4j.core.net.TcpSocketManager;
import org.apache.logging.log4j.core.net.TcpSocketManager.HostResolver;
import org.apache.logging.log4j.core.net.ssl.SslKeyStoreConstants;
+import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.test.junit.UsingStatusListener;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.CleanupMode;
@@ -56,6 +57,8 @@ import org.junit.jupiter.api.io.TempDir;
*/
public class SocketAppenderReconnectTest {
+ private static final String CLASS_NAME = SocketAppenderReconnectTest.class.getSimpleName();
+
private static final int EPHEMERAL_PORT = 0;
private static final String APPENDER_NAME = "TestSocket";
@@ -340,6 +343,9 @@ public class SocketAppenderReconnectTest {
final BufferingErrorHandler errorHandler)
throws Exception {
+ // Report status
+ StatusLogger.getLogger().trace("[{}] verifying logging success", CLASS_NAME);
+
// Create messages to log
final int messageCount = 2;
assertThat(messageCount)
@@ -380,11 +386,18 @@ public class SocketAppenderReconnectTest {
private static void verifyLoggingFailure(
final LoggerContext loggerContext, final BufferingErrorHandler errorHandler) {
+
+ // Report status
+ StatusLogger.getLogger().trace("[{}] verifying logging failure", CLASS_NAME);
+
+ // Verify the configuration
final Logger logger = loggerContext.getRootLogger();
final int retryCount = 3;
assertThat(retryCount)
.as("expecting `retryCount > 1` due to LOG4J2-2829")
.isGreaterThan(1);
+
+ // Verify the failure
for (int i = 0; i < retryCount; i++) {
try {
logger.info("should fail #" + i);