|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.assertThat; |
19 | 19 |
|
| 20 | +import io.awspring.cloud.autoconfigure.ConfiguredAwsClient; |
20 | 21 | import io.awspring.cloud.autoconfigure.core.AwsAutoConfiguration; |
21 | 22 | import io.awspring.cloud.autoconfigure.core.CredentialsProviderAutoConfiguration; |
22 | 23 | import io.awspring.cloud.autoconfigure.core.RegionProviderAutoConfiguration; |
|
29 | 30 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
30 | 31 | import org.springframework.context.annotation.Bean; |
31 | 32 | import org.springframework.context.annotation.Configuration; |
32 | | -import org.springframework.test.util.ReflectionTestUtils; |
33 | 33 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
34 | 34 | import software.amazon.awssdk.arns.Arn; |
35 | | -import software.amazon.awssdk.core.client.config.SdkClientConfiguration; |
36 | | -import software.amazon.awssdk.core.client.config.SdkClientOption; |
37 | 35 | import software.amazon.awssdk.services.sns.SnsClient; |
38 | | -import software.amazon.awssdk.utils.AttributeMap; |
39 | 36 |
|
40 | 37 | /** |
41 | 38 | * Tests for class {@link io.awspring.cloud.autoconfigure.sns.SnsAutoConfiguration}. |
@@ -63,28 +60,21 @@ void snsAutoConfigurationIsEnabled() { |
63 | 60 | assertThat(context).hasSingleBean(SnsTemplate.class); |
64 | 61 | assertThat(context).hasBean("snsWebMvcConfigurer"); |
65 | 62 |
|
66 | | - SnsClient client = context.getBean(SnsClient.class); |
67 | | - SdkClientConfiguration clientConfiguration = (SdkClientConfiguration) ReflectionTestUtils.getField(client, |
68 | | - "clientConfiguration"); |
69 | | - AttributeMap attributes = (AttributeMap) ReflectionTestUtils.getField(clientConfiguration, "attributes"); |
70 | | - assertThat(attributes.get(SdkClientOption.ENDPOINT)) |
71 | | - .isEqualTo(URI.create("https://sns.eu-west-1.amazonaws.com")); |
| 63 | + ConfiguredAwsClient client = new ConfiguredAwsClient(context.getBean(SnsClient.class)); |
| 64 | + assertThat(client.getEndpoint()).isEqualTo(URI.create("https://sns.eu-west-1.amazonaws.com")); |
72 | 65 |
|
73 | 66 | }); |
74 | 67 | } |
75 | 68 |
|
76 | 69 | @Test |
77 | 70 | void withCustomEndpoint() { |
78 | 71 | this.contextRunner.withPropertyValues("spring.cloud.aws.sns.endpoint:http://localhost:8090").run(context -> { |
79 | | - SnsClient client = context.getBean(SnsClient.class); |
80 | 72 | assertThat(context).hasSingleBean(SnsTemplate.class); |
81 | 73 | assertThat(context).hasBean("snsWebMvcConfigurer"); |
82 | 74 |
|
83 | | - SdkClientConfiguration clientConfiguration = (SdkClientConfiguration) ReflectionTestUtils.getField(client, |
84 | | - "clientConfiguration"); |
85 | | - AttributeMap attributes = (AttributeMap) ReflectionTestUtils.getField(clientConfiguration, "attributes"); |
86 | | - assertThat(attributes.get(SdkClientOption.ENDPOINT)).isEqualTo(URI.create("http://localhost:8090")); |
87 | | - assertThat(attributes.get(SdkClientOption.ENDPOINT_OVERRIDDEN)).isTrue(); |
| 75 | + ConfiguredAwsClient client = new ConfiguredAwsClient(context.getBean(SnsClient.class)); |
| 76 | + assertThat(client.getEndpoint()).isEqualTo(URI.create("http://localhost:8090")); |
| 77 | + assertThat(client.isEndpointOverridden()).isTrue(); |
88 | 78 | }); |
89 | 79 | } |
90 | 80 |
|
|
0 commit comments