From b03d43de748a3671d02dd12f82142ccb76c51a80 Mon Sep 17 00:00:00 2001 From: Sina Madani Date: Thu, 9 Jan 2025 16:24:56 +0000 Subject: [PATCH] test: Fix class initialisation bug --- .../java/com/vonage/client/AbstractMethodTest.java | 13 +++++-------- .../java/com/vonage/client/DynamicEndpointTest.java | 6 +++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/vonage/client/AbstractMethodTest.java b/src/test/java/com/vonage/client/AbstractMethodTest.java index 144d78773..1d5031cae 100644 --- a/src/test/java/com/vonage/client/AbstractMethodTest.java +++ b/src/test/java/com/vonage/client/AbstractMethodTest.java @@ -32,8 +32,6 @@ import org.apache.http.message.BasicStatusLine; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.*; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; import org.mockito.ArgumentCaptor; import static org.mockito.Mockito.*; import java.io.*; @@ -54,6 +52,11 @@ public ConcreteMethod(HttpWrapper httpWrapper) { super(httpWrapper); } + static { + LogManager.getLogManager().getLogger(AbstractMethod.class.getName()) + .setLevel(java.util.logging.Level.FINE); + } + RequestBuilder makeRequest() throws UnsupportedEncodingException { return makeRequest("http://example.org/resource") .addParameter("foo", "bar") @@ -110,12 +113,6 @@ public void close() { private AuthMethod mockAuthMethod; private final CloseableHttpResponse basicResponse = new CloseableBasicHttpResponse(); - @BeforeAll - public static void setUpBeforeClass() { - LogManager.getLogManager().getLogger(AbstractMethod.class.getName()) - .setLevel(java.util.logging.Level.FINE); - } - @BeforeEach public void setUp() throws Exception { mockWrapper = mock(HttpWrapper.class); diff --git a/src/test/java/com/vonage/client/DynamicEndpointTest.java b/src/test/java/com/vonage/client/DynamicEndpointTest.java index 6cf59f7d4..02fb92811 100644 --- a/src/test/java/com/vonage/client/DynamicEndpointTest.java +++ b/src/test/java/com/vonage/client/DynamicEndpointTest.java @@ -22,16 +22,20 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.net.URI; +import java.util.logging.Level; +import java.util.logging.Logger; public class DynamicEndpointTest { private static final HttpWrapper WRAPPER = new HttpWrapper(new NoAuthMethod()); @SuppressWarnings("unchecked") static DynamicEndpoint newEndpoint(R... responseType) { - return DynamicEndpoint. builder(responseType) + var endpoint = DynamicEndpoint. builder(responseType) .wrapper(WRAPPER).authMethod(NoAuthMethod.class) .pathGetter((de, req) -> TEST_BASE_URI) .requestMethod(HttpMethod.GET).acceptHeader("text").build(); + Logger.getLogger(endpoint.getClass().getName()).setLevel(Level.FINE); + return endpoint; } @Test