Merge pull request #29157 from izeye

* pr/29157:
  Polish

Closes gh-29157
pull/30003/head
Stephane Nicoll 3 years ago
commit 576eb50ed8

@ -56,7 +56,7 @@ class StackdriverPropertiesConfigAdapterTests {
} }
@Test @Test
void whenPropertiesUseSemanticMetricTypesIsSetAdapterResourceTypeReturnsIt() { void whenPropertiesUseSemanticMetricTypesIsSetAdapterUseSemanticMetricTypesReturnsIt() {
StackdriverProperties properties = new StackdriverProperties(); StackdriverProperties properties = new StackdriverProperties();
properties.setUseSemanticMetricTypes(true); properties.setUseSemanticMetricTypes(true);
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue(); assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();

@ -234,32 +234,32 @@ class CachingOperationInvokerTests {
given(target.invoke(contextV2)).willReturn(expectedV2); given(target.invoke(contextV2)).willReturn(expectedV2);
given(target.invoke(contextV3)).willReturn(expectedV3); given(target.invoke(contextV3)).willReturn(expectedV3);
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL); CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
Object response = invoker.invoke(contextV2); Object responseV2 = invoker.invoke(contextV2);
assertThat(response).isSameAs(expectedV2); assertThat(responseV2).isSameAs(expectedV2);
verify(target, times(1)).invoke(contextV2); verify(target, times(1)).invoke(contextV2);
Object cachedResponse = invoker.invoke(contextV3); Object responseV3 = invoker.invoke(contextV3);
assertThat(cachedResponse).isNotSameAs(response); assertThat(responseV3).isNotSameAs(responseV2);
verify(target, times(1)).invoke(contextV3); verify(target, times(1)).invoke(contextV3);
} }
@Test @Test
void targetInvokedWithDifferentWebServerNamespace() { void targetInvokedWithDifferentWebServerNamespace() {
OperationInvoker target = mock(OperationInvoker.class); OperationInvoker target = mock(OperationInvoker.class);
Object expectedV2 = new Object(); Object expectedServer = new Object();
Object expectedV3 = new Object(); Object expectedManagement = new Object();
InvocationContext contextV2 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(), InvocationContext contextServer = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
new WebServerNamespaceArgumentResolver(WebServerNamespace.SERVER)); 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)); new WebServerNamespaceArgumentResolver(WebServerNamespace.MANAGEMENT));
given(target.invoke(contextV2)).willReturn(expectedV2); given(target.invoke(contextServer)).willReturn(expectedServer);
given(target.invoke(contextV3)).willReturn(expectedV3); given(target.invoke(contextManagement)).willReturn(expectedManagement);
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL); CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
Object response = invoker.invoke(contextV2); Object responseServer = invoker.invoke(contextServer);
assertThat(response).isSameAs(expectedV2); assertThat(responseServer).isSameAs(expectedServer);
verify(target, times(1)).invoke(contextV2); verify(target, times(1)).invoke(contextServer);
Object cachedResponse = invoker.invoke(contextV3); Object responseManagement = invoker.invoke(contextManagement);
assertThat(cachedResponse).isNotSameAs(response); assertThat(responseManagement).isNotSameAs(responseServer);
verify(target, times(1)).invoke(contextV3); verify(target, times(1)).invoke(contextManagement);
} }
private static class MonoOperationInvoker implements OperationInvoker { private static class MonoOperationInvoker implements OperationInvoker {

@ -45,7 +45,7 @@ class AbstractHealthIndicatorTests {
} }
@Test @Test
void healthCheckWhenDownWithExceptionThrownDoesNotLogHealthCheckFailedMessage(CapturedOutput output) { void healthCheckWhenDownWithExceptionThrownLogsHealthCheckFailedMessage(CapturedOutput output) {
TestHealthIndicator indicator = new TestHealthIndicator("Test message", (builder) -> { TestHealthIndicator indicator = new TestHealthIndicator("Test message", (builder) -> {
throw new IllegalStateException("Test exception"); throw new IllegalStateException("Test exception");
}); });
@ -55,7 +55,7 @@ class AbstractHealthIndicatorTests {
} }
@Test @Test
void healthCheckWhenDownWithExceptionConfiguredDoesNotLogHealthCheckFailedMessage(CapturedOutput output) { void healthCheckWhenDownWithExceptionConfiguredLogsHealthCheckFailedMessage(CapturedOutput output) {
Health heath = new TestHealthIndicator("Test message", Health heath = new TestHealthIndicator("Test message",
(builder) -> builder.down().withException(new IllegalStateException("Test exception"))).health(); (builder) -> builder.down().withException(new IllegalStateException("Test exception"))).health();
assertThat(heath.getStatus()).isEqualTo(Status.DOWN); assertThat(heath.getStatus()).isEqualTo(Status.DOWN);

@ -182,7 +182,7 @@ class WebMvcMetricsFilterTests {
@Test @Test
void unhandledError() { 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); .hasRootCauseInstanceOf(RuntimeException.class);
assertThat(this.registry.get("http.server.requests").tags("exception", "RuntimeException").timer().count()) assertThat(this.registry.get("http.server.requests").tags("exception", "RuntimeException").timer().count())
.isEqualTo(1L); .isEqualTo(1L);
@ -191,8 +191,8 @@ class WebMvcMetricsFilterTests {
@Test @Test
void unhandledServletException() { void unhandledServletException() {
assertThatCode(() -> this.mvc assertThatCode(() -> this.mvc
.perform(get("/api/filterError").header(CustomBehaviorFilter.TEST_SERVLET_EXCEPTION_HEADER, "throw")) .perform(get("/api/filterError").header(CustomBehaviorFilter.TEST_SERVLET_EXCEPTION_HEADER, "throw")))
.andExpect(status().isOk())).isInstanceOf(ServletException.class); .isInstanceOf(ServletException.class);
Id meterId = this.registry.get("http.server.requests").tags("exception", "ServletException").timer().getId(); Id meterId = this.registry.get("http.server.requests").tags("exception", "ServletException").timer().getId();
assertThat(meterId.getTag("status")).isEqualTo("500"); assertThat(meterId.getTag("status")).isEqualTo("500");
} }
@ -372,7 +372,7 @@ class WebMvcMetricsFilterTests {
} }
@Bean @Bean
CustomBehaviorFilter redirectAndNotFoundFilter() { CustomBehaviorFilter customBehaviorFilter() {
return new CustomBehaviorFilter(); return new CustomBehaviorFilter();
} }

@ -85,7 +85,7 @@ class RabbitStreamConfigurationTests {
} }
@Test @Test
void whenCustomMessageListenerContainerIsDefinedThenAutoConfiguredContainerBacksOff() { void whenCustomMessageListenerContainerFactoryIsDefinedThenAutoConfiguredContainerFactoryBacksOff() {
this.contextRunner.withUserConfiguration(CustomMessageListenerContainerFactoryConfiguration.class) this.contextRunner.withUserConfiguration(CustomMessageListenerContainerFactoryConfiguration.class)
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(RabbitListenerContainerFactory.class); assertThat(context).hasSingleBean(RabbitListenerContainerFactory.class);

@ -27,6 +27,7 @@ import io.rsocket.transport.ClientTransport;
import io.rsocket.transport.netty.client.TcpClientTransport; import io.rsocket.transport.netty.client.TcpClientTransport;
import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -58,8 +59,10 @@ import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.config.IntegrationManagementConfigurer;
import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.endpoint.MessageProcessorMessageSource; import org.springframework.integration.endpoint.MessageProcessorMessageSource;
import org.springframework.integration.gateway.RequestReplyExchanger; import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.integration.rsocket.ClientRSocketConnector; import org.springframework.integration.rsocket.ClientRSocketConnector;
import org.springframework.integration.rsocket.IntegrationRSocketEndpoint; import org.springframework.integration.rsocket.IntegrationRSocketEndpoint;
import org.springframework.integration.rsocket.ServerRSocketConnector; import org.springframework.integration.rsocket.ServerRSocketConnector;
@ -526,9 +529,8 @@ class IntegrationAutoConfigurationTests {
static class MessageSourceConfiguration { static class MessageSourceConfiguration {
@Bean @Bean
org.springframework.integration.core.MessageSource<?> myMessageSource() { MessageSource<?> myMessageSource() {
return new MessageProcessorMessageSource( return new MessageProcessorMessageSource(mock(MessageProcessor.class));
mock(org.springframework.integration.handler.MessageProcessor.class));
} }
} }
@ -541,7 +543,7 @@ class IntegrationAutoConfigurationTests {
return new IntegrationRSocketEndpoint() { return new IntegrationRSocketEndpoint() {
@Override @Override
public reactor.core.publisher.Mono<Void> handleMessage(Message<?> message) { public Mono<Void> handleMessage(Message<?> message) {
return null; return null;
} }

@ -11,6 +11,6 @@ For instance, the following service triggers the validation of the first argumen
include::{docs-java}/io/validation/MyBean.java[] include::{docs-java}/io/validation/MyBean.java[]
---- ----
The application's `MessageSource` is used when resolving +`{parameters}`+ in constraint messages. The application's `MessageSource` is used when resolving `+{parameters}+` in constraint messages.
This allows you to use <<features.adoc#features.internationalization,your application's `messages.properties` files>> for Bean Validation messages. This allows you to use <<features.adoc#features.internationalization,your application's `messages.properties` files>> for Bean Validation messages.
Once the parameters have been resolved, message interpolation is completed using Bean Validation's default interpolator. Once the parameters have been resolved, message interpolation is completed using Bean Validation's default interpolator.

@ -234,7 +234,7 @@ public class TestEntityManager {
*/ */
public final EntityManager getEntityManager() { public final EntityManager getEntityManager() {
EntityManager manager = EntityManagerFactoryUtils.getTransactionalEntityManager(this.entityManagerFactory); EntityManager manager = EntityManagerFactoryUtils.getTransactionalEntityManager(this.entityManagerFactory);
Assert.state(manager != null, "No transactional EntityManager found, is your test running in a transactional?"); Assert.state(manager != null, "No transactional EntityManager found, is your test running in a transaction?");
return manager; return manager;
} }

@ -223,7 +223,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
filters.add(new JavaLangAnnotationFilter()); filters.add(new JavaLangAnnotationFilter());
filters.add(new KotlinAnnotationFilter()); filters.add(new KotlinAnnotationFilter());
filters.add(new SpockAnnotationFilter()); filters.add(new SpockAnnotationFilter());
filters.add(new JunitAnnotationFilter()); filters.add(new JUnitAnnotationFilter());
ANNOTATION_FILTERS = Collections.unmodifiableSet(filters); ANNOTATION_FILTERS = Collections.unmodifiableSet(filters);
} }
@ -389,7 +389,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
/** /**
* {@link AnnotationFilter} for JUnit annotations. * {@link AnnotationFilter} for JUnit annotations.
*/ */
private static final class JunitAnnotationFilter implements AnnotationFilter { private static final class JUnitAnnotationFilter implements AnnotationFilter {
@Override @Override
public boolean isIgnored(Annotation annotation) { public boolean isIgnored(Annotation annotation) {

@ -75,9 +75,9 @@ class ImportsContextCustomizerTests {
} }
@Test @Test
void customizersForTestClassesWithDifferentJunitAnnotationsAreEqual() { void customizersForTestClassesWithDifferentJUnitAnnotationsAreEqual() {
assertThat(new ImportsContextCustomizer(FirstJunitAnnotatedTestClass.class)) assertThat(new ImportsContextCustomizer(FirstJUnitAnnotatedTestClass.class))
.isEqualTo(new ImportsContextCustomizer(SecondJunitAnnotatedTestClass.class)); .isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
} }
@Import(TestImportSelector.class) @Import(TestImportSelector.class)
@ -142,13 +142,13 @@ class ImportsContextCustomizerTests {
@Nested @Nested
@Import(TestImportSelector.class) @Import(TestImportSelector.class)
static class FirstJunitAnnotatedTestClass { static class FirstJUnitAnnotatedTestClass {
} }
@Tag("test") @Tag("test")
@Import(TestImportSelector.class) @Import(TestImportSelector.class)
static class SecondJunitAnnotatedTestClass { static class SecondJUnitAnnotatedTestClass {
} }

Loading…
Cancel
Save