From 6b4f1b778b41d4c4f817656c15ece2d03572e099 Mon Sep 17 00:00:00 2001 From: ramanathan Date: Fri, 20 Mar 2026 17:25:51 +0530 Subject: [PATCH 1/3] [logging-log4j-samples]Add integration test and logging setup to Maven configuration --- log4j-samples-jlink/pom.xml | 73 ++++++++++++++++++- .../log4j/samples/jlink/StandardIT.java | 47 ++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java diff --git a/log4j-samples-jlink/pom.xml b/log4j-samples-jlink/pom.xml index 7019762d..c03268ab 100644 --- a/log4j-samples-jlink/pom.xml +++ b/log4j-samples-jlink/pom.xml @@ -43,7 +43,6 @@ org.apache.logging.log4j log4j-core - runtime @@ -52,9 +51,81 @@ runtime + + + + org.assertj + assertj-core + test + + + + org.junit.jupiter + junit-jupiter-api + test + + + + org.apache.maven.plugins + maven-antrun-plugin + + + prepare-integration-test-logs + + run + + pre-integration-test + + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + run-custom-jlink-launcher + + exec + + integration-test + + ${project.build.directory}/maven-jlink/default/bin/${project.artifactId} + ${project.build.directory}/logs/out.log + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + integration-test + + integration-test + verify + + + + **/StandardIT.class + + + + + + org.apache.maven.plugins maven-jlink-plugin diff --git a/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java b/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java new file mode 100644 index 00000000..9dba8627 --- /dev/null +++ b/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java @@ -0,0 +1,47 @@ +/* + * 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.logging.log4j.samples.jlink; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import org.junit.jupiter.api.Test; + +class StandardIT { + + @Test + void verifyStdOut() throws IOException { + final Path basePath = Paths.get(System.getProperty("basedir"), "target", "logs"); + final Path logFile = basePath.resolve("out.log"); + + assertThat(logFile).exists().isNotEmptyFile(); + + final List lines = Files.readAllLines(logFile, StandardCharsets.UTF_8); + + assertThat(lines).hasSize(2); + assertThat(lines.get(0)) + .matches("XML: .* INFO\\s+\\[main] o\\.a\\.l\\.l\\.s\\.j\\.Main Starting Log4j JLink Sample\\.\\.\\."); + assertThat(lines.get(1)) + .matches( + "XML: .* WARN\\s+\\[main] o\\.a\\.l\\.l\\.s\\.j\\.Main Please add your name as command line parameter\\."); + } +} From 4166506c277269578b1b5fdd0d191844cc36f747 Mon Sep 17 00:00:00 2001 From: ramanathan Date: Fri, 20 Mar 2026 17:42:41 +0530 Subject: [PATCH 2/3] [logging-log4j-samples] Refactor tests to use JUnit assertions and update dependencies in pom.xml --- log4j-samples-jlink/pom.xml | 11 ++------ .../log4j/samples/jlink/StandardIT.java | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/log4j-samples-jlink/pom.xml b/log4j-samples-jlink/pom.xml index c03268ab..d81c0f34 100644 --- a/log4j-samples-jlink/pom.xml +++ b/log4j-samples-jlink/pom.xml @@ -52,16 +52,9 @@ - - - org.assertj - assertj-core - test - - - org.junit.jupiter - junit-jupiter-api + junit + junit test diff --git a/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java b/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java index 9dba8627..c23d0ac0 100644 --- a/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java +++ b/log4j-samples-jlink/src/test/java/org/apache/logging/log4j/samples/jlink/StandardIT.java @@ -16,32 +16,33 @@ */ package org.apache.logging.log4j.samples.jlink; -import static org.assertj.core.api.Assertions.assertThat; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Test; -class StandardIT { +public class StandardIT { @Test - void verifyStdOut() throws IOException { + public void verifyStdOut() throws IOException { final Path basePath = Paths.get(System.getProperty("basedir"), "target", "logs"); final Path logFile = basePath.resolve("out.log"); - assertThat(logFile).exists().isNotEmptyFile(); + Assert.assertTrue("Log file does not exist", Files.exists(logFile)); + Assert.assertTrue("Log file is empty", Files.size(logFile) > 0); final List lines = Files.readAllLines(logFile, StandardCharsets.UTF_8); - assertThat(lines).hasSize(2); - assertThat(lines.get(0)) - .matches("XML: .* INFO\\s+\\[main] o\\.a\\.l\\.l\\.s\\.j\\.Main Starting Log4j JLink Sample\\.\\.\\."); - assertThat(lines.get(1)) - .matches( - "XML: .* WARN\\s+\\[main] o\\.a\\.l\\.l\\.s\\.j\\.Main Please add your name as command line parameter\\."); + Assert.assertEquals(2, lines.size()); + Assert.assertTrue(lines.get(0) + .matches("XML: .* INFO\\s+\\[main] o\\.a\\.l\\.l\\.s\\.j\\.Main Starting Log4j JLink Sample\\.\\.\\.")); + Assert.assertTrue( + lines.get(1) + .matches( + "XML: .* WARN\\s+\\[main] o\\.a\\.l\\.l\\.s\\.j\\.Main Please add your name as command line parameter\\.")); } } From 9c8ad5b1a13a7a70f29f8c7029b335b5f830b1b6 Mon Sep 17 00:00:00 2001 From: ramanathan Date: Thu, 2 Apr 2026 16:17:19 +0530 Subject: [PATCH 3/3] [logging-log4j-samples issues-231] Enhance pom.xml with OS-specific launcher configuration and readability improvements --- log4j-samples-jlink/pom.xml | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/log4j-samples-jlink/pom.xml b/log4j-samples-jlink/pom.xml index d81c0f34..d2d27df1 100644 --- a/log4j-samples-jlink/pom.xml +++ b/log4j-samples-jlink/pom.xml @@ -15,8 +15,10 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + + 4.0.0 + org.apache.logging.log4j.samples log4j-samples @@ -30,6 +32,12 @@ 3.2.0 + + + + + + ${project.build.directory}/maven-jlink/default/bin/${project.artifactId}${launcher.suffix} @@ -39,7 +47,6 @@ log4j-api - org.apache.logging.log4j log4j-core @@ -51,7 +58,7 @@ runtime - + junit junit @@ -59,8 +66,10 @@ + + org.apache.maven.plugins maven-antrun-plugin @@ -81,6 +90,7 @@ + org.codehaus.mojo exec-maven-plugin @@ -93,7 +103,7 @@ integration-test - ${project.build.directory}/maven-jlink/default/bin/${project.artifactId} + ${jlink.launcher.path} ${project.build.directory}/logs/out.log @@ -128,6 +138,23 @@ log4j-samples-jlink=org.apache.logging.log4j.samples.jlink/org.apache.logging.log4j.samples.jlink.Main + + + + + + windows + + + Windows + + + + .exe + + + +