|
17 | 17 | package org.springframework.boot.autoconfigure.amqp;
|
18 | 18 |
|
19 | 19 | import java.security.NoSuchAlgorithmException;
|
| 20 | +import java.util.Collection; |
20 | 21 | import java.util.List;
|
21 | 22 | import java.util.concurrent.ThreadFactory;
|
22 | 23 | import java.util.concurrent.atomic.AtomicInteger;
|
|
35 | 36 | import org.junit.jupiter.api.condition.EnabledForJreRange;
|
36 | 37 | import org.junit.jupiter.api.condition.JRE;
|
37 | 38 | import org.junit.jupiter.api.extension.ExtendWith;
|
| 39 | +import org.junit.jupiter.params.ParameterizedTest; |
| 40 | +import org.junit.jupiter.params.provider.ValueSource; |
38 | 41 | import org.mockito.InOrder;
|
39 | 42 |
|
40 | 43 | import org.springframework.amqp.core.AcknowledgeMode;
|
|
59 | 62 | import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
|
60 | 63 | import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
61 | 64 | import org.springframework.amqp.rabbit.retry.MessageRecoverer;
|
| 65 | +import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter; |
62 | 66 | import org.springframework.amqp.support.converter.MessageConverter;
|
| 67 | +import org.springframework.amqp.support.converter.SerializerMessageConverter; |
63 | 68 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
64 | 69 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
65 | 70 | import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
|
|
107 | 112 | * @author Andy Wilkinson
|
108 | 113 | * @author Phillip Webb
|
109 | 114 | * @author Scott Frederick
|
| 115 | + * @author Yanming Zhou |
110 | 116 | */
|
111 | 117 | @ExtendWith(OutputCaptureExtension.class)
|
112 | 118 | class RabbitAutoConfigurationTests {
|
@@ -796,6 +802,20 @@ void customizeRequestedChannelMax() {
|
796 | 802 | });
|
797 | 803 | }
|
798 | 804 |
|
| 805 | + @SuppressWarnings("unchecked") |
| 806 | + @ParameterizedTest |
| 807 | + @ValueSource(classes = { TestConfiguration.class, TestConfiguration6.class }) |
| 808 | + void customizeAllowedListPatterns(Class<?> configuration) { |
| 809 | + this.contextRunner.withUserConfiguration(configuration) |
| 810 | + .withPropertyValues("spring.rabbitmq.template.allowed-list-patterns:*") |
| 811 | + .run((context) -> { |
| 812 | + MessageConverter messageConverter = context.getBean(RabbitTemplate.class).getMessageConverter(); |
| 813 | + assertThat(messageConverter).isInstanceOfSatisfying(AllowedListDeserializingMessageConverter.class, |
| 814 | + (mc) -> assertThat(mc).extracting("allowedListPatterns") |
| 815 | + .isInstanceOfSatisfying(Collection.class, (set) -> assertThat(set).contains("*"))); |
| 816 | + }); |
| 817 | + } |
| 818 | + |
799 | 819 | @Test
|
800 | 820 | void noSslByDefault() {
|
801 | 821 | this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
@@ -1113,6 +1133,16 @@ RabbitListenerContainerFactory<?> rabbitListenerContainerFactory() {
|
1113 | 1133 |
|
1114 | 1134 | }
|
1115 | 1135 |
|
| 1136 | + @Configuration(proxyBeanMethods = false) |
| 1137 | + static class TestConfiguration6 { |
| 1138 | + |
| 1139 | + @Bean |
| 1140 | + MessageConverter messageConverter() { |
| 1141 | + return new SerializerMessageConverter(); |
| 1142 | + } |
| 1143 | + |
| 1144 | + } |
| 1145 | + |
1116 | 1146 | @Configuration(proxyBeanMethods = false)
|
1117 | 1147 | static class MessageConvertersConfiguration {
|
1118 | 1148 |
|
|
0 commit comments