|
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; |
| 68 | +import org.springframework.amqp.support.converter.SimpleMessageConverter; |
63 | 69 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
64 | 70 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
65 | 71 | import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
|
|
107 | 113 | * @author Andy Wilkinson
|
108 | 114 | * @author Phillip Webb
|
109 | 115 | * @author Scott Frederick
|
| 116 | + * @author Yanming Zhou |
110 | 117 | */
|
111 | 118 | @ExtendWith(OutputCaptureExtension.class)
|
112 | 119 | class RabbitAutoConfigurationTests {
|
@@ -796,6 +803,24 @@ void customizeRequestedChannelMax() {
|
796 | 803 | });
|
797 | 804 | }
|
798 | 805 |
|
| 806 | + @SuppressWarnings("unchecked") |
| 807 | + @ParameterizedTest |
| 808 | + @ValueSource(classes = { TestConfiguration.class, TestConfiguration6.class }) |
| 809 | + void customizeAllowedListPatterns(Class<?> configuration) { |
| 810 | + this.contextRunner.withUserConfiguration(configuration) |
| 811 | + .withPropertyValues("spring.rabbitmq.template.allowed-list-patterns:*") |
| 812 | + .run((context) -> { |
| 813 | + MessageConverter messageConverter = context.getBean(RabbitTemplate.class).getMessageConverter(); |
| 814 | + assertThat(messageConverter).isInstanceOfSatisfying(AllowedListDeserializingMessageConverter.class, |
| 815 | + (mc) -> { |
| 816 | + assertThat(mc).extracting("allowedListPatterns") |
| 817 | + .isInstanceOfSatisfying(Collection.class, (set) -> { |
| 818 | + assertThat(set).contains("*"); |
| 819 | + }); |
| 820 | + }); |
| 821 | + }); |
| 822 | + } |
| 823 | + |
799 | 824 | @Test
|
800 | 825 | void noSslByDefault() {
|
801 | 826 | this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
|
@@ -1113,6 +1138,16 @@ RabbitListenerContainerFactory<?> rabbitListenerContainerFactory() {
|
1113 | 1138 |
|
1114 | 1139 | }
|
1115 | 1140 |
|
| 1141 | + @Configuration(proxyBeanMethods = false) |
| 1142 | + static class TestConfiguration6 { |
| 1143 | + |
| 1144 | + @Bean |
| 1145 | + MessageConverter messageConverter() { |
| 1146 | + return new SerializerMessageConverter(); |
| 1147 | + } |
| 1148 | + |
| 1149 | + } |
| 1150 | + |
1116 | 1151 | @Configuration(proxyBeanMethods = false)
|
1117 | 1152 | static class MessageConvertersConfiguration {
|
1118 | 1153 |
|
|
0 commit comments