Merge branch '3.4.x'

Closes gh-45332
This commit is contained in:
Andy Wilkinson
2025-04-29 12:56:36 +01:00

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,6 @@ import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.messaging.converter.CompositeMessageConverter;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.converter.SimpleMessageConverter;
@@ -65,7 +64,6 @@ import org.springframework.messaging.simp.stomp.StompHeaders;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.messaging.simp.stomp.StompSessionHandler;
import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter;
import org.springframework.security.util.FieldUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.client.RestTemplate;
@@ -144,27 +142,25 @@ class WebSocketMessagingAutoConfigurationTests {
}
@Test
void predefinedThreadExecutorIsSelectedForInboundChannel() throws Throwable {
void predefinedThreadExecutorIsSelectedForInboundChannel() {
AsyncTaskExecutor expectedExecutor = new SimpleAsyncTaskExecutor();
ChannelRegistration registration = new ChannelRegistration();
WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration configuration = new WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration(
new ObjectMapper(),
Map.of(TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME, expectedExecutor));
configuration.configureClientInboundChannel(registration);
TaskExecutor executor = (TaskExecutor) FieldUtils.getFieldValue(registration, "executor");
assertThat(executor).isEqualTo(expectedExecutor);
assertThat(registration).extracting("executor").isEqualTo(expectedExecutor);
}
@Test
void predefinedThreadExecutorIsSelectedForOutboundChannel() throws Throwable {
void predefinedThreadExecutorIsSelectedForOutboundChannel() {
AsyncTaskExecutor expectedExecutor = new SimpleAsyncTaskExecutor();
ChannelRegistration registration = new ChannelRegistration();
WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration configuration = new WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration(
new ObjectMapper(),
Map.of(TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME, expectedExecutor));
configuration.configureClientOutboundChannel(registration);
TaskExecutor executor = (TaskExecutor) FieldUtils.getFieldValue(registration, "executor");
assertThat(executor).isEqualTo(expectedExecutor);
assertThat(registration).extracting("executor").isEqualTo(expectedExecutor);
}
@Test