Skip to content

Commit 28a3817

Browse files
committed
minor change
1 parent 9aa1c49 commit 28a3817

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderBuilderTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
2020
import static org.junit.jupiter.api.Assertions.assertNotNull;
2121
import static org.junit.jupiter.api.Assertions.assertThrows;
22-
import static org.mockito.Mockito.mock;
2322

2423
import java.net.MalformedURLException;
2524
import java.net.URL;
@@ -44,14 +43,12 @@ private HttpAppender.Builder<?> getBuilder() {
4443
@Test
4544
@UsingStatusListener
4645
void testBuilderWithoutUrl(final ListStatusListener listener) throws Exception {
47-
// Build the HttpAppender without URL
4846
HttpAppender appender = HttpAppender.newBuilder()
4947
.setConfiguration(new DefaultConfiguration())
5048
.setName("TestAppender")
5149
.setLayout(JsonLayout.createDefaultLayout()) // Providing a layout here
5250
.build();
5351

54-
// Verify that the error message for missing URL is captured
5552
assertThat(listener.findStatusData(Level.ERROR))
5653
.anyMatch(statusData ->
5754
statusData.getMessage().getFormattedMessage().contains("HttpAppender requires URL to be set."));
@@ -60,14 +57,12 @@ void testBuilderWithoutUrl(final ListStatusListener listener) throws Exception {
6057
@Test
6158
@UsingStatusListener
6259
void testBuilderWithUrlAndWithoutLayout(final ListStatusListener listener) throws Exception {
63-
// Build the HttpAppender with URL but without Layout
6460
HttpAppender appender = HttpAppender.newBuilder()
6561
.setConfiguration(new DefaultConfiguration())
6662
.setName("TestAppender")
67-
.setUrl(new URL("http://localhost:8080/logs")) // Providing the URL
63+
.setUrl(new URL("http://localhost:8080/logs"))
6864
.build();
6965

70-
// Verify that the error message for missing layout is captured
7166
assertThat(listener.findStatusData(Level.ERROR)).anyMatch(statusData -> statusData
7267
.getMessage()
7368
.getFormattedMessage()
@@ -77,7 +72,7 @@ void testBuilderWithUrlAndWithoutLayout(final ListStatusListener listener) throw
7772
@Test
7873
void testBuilderWithValidConfiguration() throws Exception {
7974
URL url = new URL("http://example.com");
80-
Layout<?> layout = JsonLayout.createDefaultLayout(); // Valid layout
75+
Layout<?> layout = JsonLayout.createDefaultLayout();
8176

8277
HttpAppender.Builder<?> builder = getBuilder().setUrl(url).setLayout(layout);
8378

@@ -117,7 +112,9 @@ void testBuilderWithHeaders() throws Exception {
117112
void testBuilderWithSslConfiguration() throws Exception {
118113
URL url = new URL("https://example.com");
119114
Layout<?> layout = JsonLayout.createDefaultLayout();
120-
SslConfiguration sslConfig = mock(SslConfiguration.class);
115+
116+
// ✅ FIXED: Use real SslConfiguration instead of Mockito mock
117+
SslConfiguration sslConfig = SslConfiguration.createSSLConfiguration(null, null, null, false);
121118

122119
HttpAppender.Builder<?> builder =
123120
getBuilder().setUrl(url).setLayout(layout).setSslConfiguration(sslConfig);

0 commit comments

Comments
 (0)