Merge branch '2.6.x' into 2.7.x
Closes gh-29176
This commit is contained in:
@@ -234,32 +234,32 @@ class CachingOperationInvokerTests {
|
||||
given(target.invoke(contextV2)).willReturn(expectedV2);
|
||||
given(target.invoke(contextV3)).willReturn(expectedV3);
|
||||
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
||||
Object response = invoker.invoke(contextV2);
|
||||
assertThat(response).isSameAs(expectedV2);
|
||||
Object responseV2 = invoker.invoke(contextV2);
|
||||
assertThat(responseV2).isSameAs(expectedV2);
|
||||
verify(target, times(1)).invoke(contextV2);
|
||||
Object cachedResponse = invoker.invoke(contextV3);
|
||||
assertThat(cachedResponse).isNotSameAs(response);
|
||||
Object responseV3 = invoker.invoke(contextV3);
|
||||
assertThat(responseV3).isNotSameAs(responseV2);
|
||||
verify(target, times(1)).invoke(contextV3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void targetInvokedWithDifferentWebServerNamespace() {
|
||||
OperationInvoker target = mock(OperationInvoker.class);
|
||||
Object expectedV2 = new Object();
|
||||
Object expectedV3 = new Object();
|
||||
InvocationContext contextV2 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
||||
Object expectedServer = new Object();
|
||||
Object expectedManagement = new Object();
|
||||
InvocationContext contextServer = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
||||
new WebServerNamespaceArgumentResolver(WebServerNamespace.SERVER));
|
||||
InvocationContext contextV3 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
||||
InvocationContext contextManagement = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
||||
new WebServerNamespaceArgumentResolver(WebServerNamespace.MANAGEMENT));
|
||||
given(target.invoke(contextV2)).willReturn(expectedV2);
|
||||
given(target.invoke(contextV3)).willReturn(expectedV3);
|
||||
given(target.invoke(contextServer)).willReturn(expectedServer);
|
||||
given(target.invoke(contextManagement)).willReturn(expectedManagement);
|
||||
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
||||
Object response = invoker.invoke(contextV2);
|
||||
assertThat(response).isSameAs(expectedV2);
|
||||
verify(target, times(1)).invoke(contextV2);
|
||||
Object cachedResponse = invoker.invoke(contextV3);
|
||||
assertThat(cachedResponse).isNotSameAs(response);
|
||||
verify(target, times(1)).invoke(contextV3);
|
||||
Object responseServer = invoker.invoke(contextServer);
|
||||
assertThat(responseServer).isSameAs(expectedServer);
|
||||
verify(target, times(1)).invoke(contextServer);
|
||||
Object responseManagement = invoker.invoke(contextManagement);
|
||||
assertThat(responseManagement).isNotSameAs(responseServer);
|
||||
verify(target, times(1)).invoke(contextManagement);
|
||||
}
|
||||
|
||||
private static class MonoOperationInvoker implements OperationInvoker {
|
||||
|
||||
@@ -45,7 +45,7 @@ class AbstractHealthIndicatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthCheckWhenDownWithExceptionThrownDoesNotLogHealthCheckFailedMessage(CapturedOutput output) {
|
||||
void healthCheckWhenDownWithExceptionThrownLogsHealthCheckFailedMessage(CapturedOutput output) {
|
||||
TestHealthIndicator indicator = new TestHealthIndicator("Test message", (builder) -> {
|
||||
throw new IllegalStateException("Test exception");
|
||||
});
|
||||
@@ -55,7 +55,7 @@ class AbstractHealthIndicatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthCheckWhenDownWithExceptionConfiguredDoesNotLogHealthCheckFailedMessage(CapturedOutput output) {
|
||||
void healthCheckWhenDownWithExceptionConfiguredLogsHealthCheckFailedMessage(CapturedOutput output) {
|
||||
Health heath = new TestHealthIndicator("Test message",
|
||||
(builder) -> builder.down().withException(new IllegalStateException("Test exception"))).health();
|
||||
assertThat(heath.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
||||
@@ -182,7 +182,7 @@ class WebMvcMetricsFilterTests {
|
||||
|
||||
@Test
|
||||
void unhandledError() {
|
||||
assertThatCode(() -> this.mvc.perform(get("/api/c1/unhandledError/10")).andExpect(status().isOk()))
|
||||
assertThatCode(() -> this.mvc.perform(get("/api/c1/unhandledError/10")))
|
||||
.hasRootCauseInstanceOf(RuntimeException.class);
|
||||
assertThat(this.registry.get("http.server.requests").tags("exception", "RuntimeException").timer().count())
|
||||
.isEqualTo(1L);
|
||||
@@ -191,8 +191,8 @@ class WebMvcMetricsFilterTests {
|
||||
@Test
|
||||
void unhandledServletException() {
|
||||
assertThatCode(() -> this.mvc
|
||||
.perform(get("/api/filterError").header(CustomBehaviorFilter.TEST_SERVLET_EXCEPTION_HEADER, "throw"))
|
||||
.andExpect(status().isOk())).isInstanceOf(ServletException.class);
|
||||
.perform(get("/api/filterError").header(CustomBehaviorFilter.TEST_SERVLET_EXCEPTION_HEADER, "throw")))
|
||||
.isInstanceOf(ServletException.class);
|
||||
Id meterId = this.registry.get("http.server.requests").tags("exception", "ServletException").timer().getId();
|
||||
assertThat(meterId.getTag("status")).isEqualTo("500");
|
||||
}
|
||||
@@ -372,7 +372,7 @@ class WebMvcMetricsFilterTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
CustomBehaviorFilter redirectAndNotFoundFilter() {
|
||||
CustomBehaviorFilter customBehaviorFilter() {
|
||||
return new CustomBehaviorFilter();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user