|
|
|
@ -24,7 +24,6 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import net.minidev.json.JSONArray; |
|
|
|
import net.minidev.json.JSONArray; |
|
|
|
import org.hamcrest.collection.IsIterableContainingInAnyOrder; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.AfterEach; |
|
|
|
import org.junit.jupiter.api.AfterEach; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.mockito.Mockito; |
|
|
|
import org.mockito.Mockito; |
|
|
|
@ -39,9 +38,11 @@ import org.springframework.boot.logging.LoggingSystem; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
import org.springframework.core.ParameterizedTypeReference; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.test.web.reactive.server.WebTestClient; |
|
|
|
import org.springframework.test.web.reactive.server.WebTestClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.mockito.BDDMockito.given; |
|
|
|
import static org.mockito.BDDMockito.given; |
|
|
|
import static org.mockito.BDDMockito.then; |
|
|
|
import static org.mockito.BDDMockito.then; |
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
@ -64,6 +65,9 @@ class LoggersEndpointWebIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
private static final String V3_JSON = ApiVersion.V3.getProducedMimeType().toString(); |
|
|
|
private static final String V3_JSON = ApiVersion.V3.getProducedMimeType().toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final ParameterizedTypeReference<List<String>> STRING_LIST = new ParameterizedTypeReference<>() { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private WebTestClient client; |
|
|
|
private WebTestClient client; |
|
|
|
|
|
|
|
|
|
|
|
private LoggingSystem loggingSystem; |
|
|
|
private LoggingSystem loggingSystem; |
|
|
|
@ -134,6 +138,7 @@ class LoggersEndpointWebIntegrationTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@WebEndpointTest |
|
|
|
@WebEndpointTest |
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
void getLoggerGroupShouldReturnConfiguredLogLevelAndMembers() { |
|
|
|
void getLoggerGroupShouldReturnConfiguredLogLevelAndMembers() { |
|
|
|
setLogLevelToDebug("test"); |
|
|
|
setLogLevelToDebug("test"); |
|
|
|
this.client.get() |
|
|
|
this.client.get() |
|
|
|
@ -145,7 +150,8 @@ class LoggersEndpointWebIntegrationTests { |
|
|
|
.jsonPath("$.length()") |
|
|
|
.jsonPath("$.length()") |
|
|
|
.isEqualTo(2) |
|
|
|
.isEqualTo(2) |
|
|
|
.jsonPath("members") |
|
|
|
.jsonPath("members") |
|
|
|
.value(IsIterableContainingInAnyOrder.containsInAnyOrder("test.member1", "test.member2")) |
|
|
|
.value(STRING_LIST, |
|
|
|
|
|
|
|
(members) -> assertThat(members).containsExactlyInAnyOrder("test.member1", "test.member2")) |
|
|
|
.jsonPath("configuredLevel") |
|
|
|
.jsonPath("configuredLevel") |
|
|
|
.isEqualTo("DEBUG"); |
|
|
|
.isEqualTo("DEBUG"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -293,6 +299,7 @@ class LoggersEndpointWebIntegrationTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@WebEndpointTest |
|
|
|
@WebEndpointTest |
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
void logLevelForLoggerGroupWithNameThatCouldBeMistakenForAPathExtension() { |
|
|
|
void logLevelForLoggerGroupWithNameThatCouldBeMistakenForAPathExtension() { |
|
|
|
setLogLevelToDebug("group.png"); |
|
|
|
setLogLevelToDebug("group.png"); |
|
|
|
this.client.get() |
|
|
|
this.client.get() |
|
|
|
@ -306,7 +313,8 @@ class LoggersEndpointWebIntegrationTests { |
|
|
|
.jsonPath("configuredLevel") |
|
|
|
.jsonPath("configuredLevel") |
|
|
|
.isEqualTo("DEBUG") |
|
|
|
.isEqualTo("DEBUG") |
|
|
|
.jsonPath("members") |
|
|
|
.jsonPath("members") |
|
|
|
.value(IsIterableContainingInAnyOrder.containsInAnyOrder("png.member1", "png.member2")); |
|
|
|
.value(STRING_LIST, |
|
|
|
|
|
|
|
(members) -> assertThat(members).containsExactlyInAnyOrder("png.member1", "png.member2")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setLogLevelToDebug(String name) { |
|
|
|
private void setLogLevelToDebug(String name) { |
|
|
|
|