File tree Expand file tree Collapse file tree
main/java/com/learning/aws/spring/consumer
test/java/com/learning/aws/spring
producer/src/test/java/com/learning/aws/spring/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313@ Configuration (proxyBeanMethods = false )
1414@ ConditionalOnProperty (
1515 value = "spring.cloud.stream.kinesis.binder.kpl-kcl-enabled" ,
16- havingValue = "true" ,
17- matchIfMissing = false )
16+ havingValue = "true" )
1817public class IpConsumerKCLEnabled {
1918
2019 private static final Logger log = LoggerFactory .getLogger (IpConsumerKCLEnabled .class );
Original file line number Diff line number Diff line change 1414@ Configuration (proxyBeanMethods = false )
1515@ ConditionalOnProperty (
1616 value = "spring.cloud.stream.kinesis.binder.kpl-kcl-enabled" ,
17- havingValue = "false" ,
18- matchIfMissing = false )
17+ havingValue = "false" )
1918public class IpConsumerWithOutKCL {
2019
2120 private static final Logger log = LoggerFactory .getLogger (IpConsumerWithOutKCL .class );
Original file line number Diff line number Diff line change 55
66import com .learning .aws .spring .common .AbstractIntegrationTest ;
77import java .time .Duration ;
8- import java .util .concurrent .TimeUnit ;
98import org .junit .jupiter .api .Test ;
109
1110class ApplicationIntegrationTest extends AbstractIntegrationTest {
1211
1312 @ Test
14- void contextLoads () throws InterruptedException {
15- // awaiting consumer to start processing
16- TimeUnit .SECONDS .sleep (3 );
13+ void contextLoads () {
1714 Long initialCount = ipAddressEventRepository .count ().block ();
1815 await ().atMost (Duration .ofSeconds (30 ))
19- .pollDelay (Duration .ofSeconds (1 ))
16+ .pollInterval (Duration .ofMillis (200 ))
17+ .pollDelay (Duration .ofSeconds (3 ))
2018 .untilAsserted (
2119 () ->
2220 assertThat (ipAddressEventRepository .count ().block () + initialCount )
Original file line number Diff line number Diff line change 33import org .springframework .boot .test .context .TestConfiguration ;
44import org .springframework .boot .testcontainers .service .connection .ServiceConnection ;
55import org .springframework .context .annotation .Bean ;
6+ import org .springframework .test .context .DynamicPropertyRegistrar ;
67import org .testcontainers .localstack .LocalStackContainer ;
78import org .testcontainers .postgresql .PostgreSQLContainer ;
89import org .testcontainers .utility .DockerImageName ;
@@ -22,4 +23,16 @@ LocalStackContainer localStackContainer() {
2223 PostgreSQLContainer postgreSQLContainer () {
2324 return new PostgreSQLContainer (DockerImageName .parse ("postgres:18.1-alpine" ));
2425 }
26+
27+ @ Bean
28+ DynamicPropertyRegistrar dynamicPropertyRegistrar (LocalStackContainer localStackContainer ) {
29+ return registry -> {
30+ registry .add ("spring.cloud.aws.endpoint" , localStackContainer ::getEndpoint );
31+ registry .add ("spring.cloud.aws.region.static" , localStackContainer ::getRegion );
32+ registry .add (
33+ "spring.cloud.aws.credentials.access-key" , localStackContainer ::getAccessKey );
34+ registry .add (
35+ "spring.cloud.aws.credentials.secret-key" , localStackContainer ::getSecretKey );
36+ };
37+ }
2538}
Original file line number Diff line number Diff line change 44import org .springframework .boot .test .context .TestConfiguration ;
55import org .springframework .boot .testcontainers .service .connection .ServiceConnection ;
66import org .springframework .context .annotation .Bean ;
7+ import org .springframework .test .context .DynamicPropertyRegistrar ;
78import org .testcontainers .localstack .LocalStackContainer ;
89import org .testcontainers .utility .DockerImageName ;
910import software .amazon .awssdk .auth .credentials .AwsBasicCredentials ;
@@ -44,4 +45,16 @@ KinesisAsyncClient amazonKinesis(LocalStackContainer localStackContainer) {
4445 .build ())
4546 .build ();
4647 }
48+
49+ @ Bean
50+ DynamicPropertyRegistrar dynamicPropertyRegistrar (LocalStackContainer localStackContainer ) {
51+ return registry -> {
52+ registry .add ("spring.cloud.aws.endpoint" , localStackContainer ::getEndpoint );
53+ registry .add ("spring.cloud.aws.region.static" , localStackContainer ::getRegion );
54+ registry .add (
55+ "spring.cloud.aws.credentials.access-key" , localStackContainer ::getAccessKey );
56+ registry .add (
57+ "spring.cloud.aws.credentials.secret-key" , localStackContainer ::getSecretKey );
58+ };
59+ }
4760}
You can’t perform that action at this time.
0 commit comments