-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : upgrade to spring cloud 2024.0.0.0 and localstack to 4.0.3
- Loading branch information
1 parent
df73958
commit fa39570
Showing
5 changed files
with
56 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 2 additions & 41 deletions
43
...roject/producer/src/test/java/com/learning/aws/spring/TestKinesisProducerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,13 @@ | ||
package com.learning.aws.spring; | ||
|
||
import static org.testcontainers.containers.localstack.LocalStackContainer.Service.KINESIS; | ||
|
||
import com.learning.aws.spring.common.ContainerConfig; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.testcontainers.containers.localstack.LocalStackContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class TestKinesisProducerApplication { | ||
|
||
@Bean | ||
LocalStackContainer localStackContainer(DynamicPropertyRegistry dynamicPropertyRegistry) { | ||
LocalStackContainer localStackContainer = | ||
new LocalStackContainer( | ||
DockerImageName.parse("localstack/localstack").withTag("3.7.2")); | ||
dynamicPropertyRegistry.add("spring.cloud.aws.endpoint", localStackContainer::getEndpoint); | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.region.static", localStackContainer::getRegion); | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.access-key", localStackContainer::getAccessKey); | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.secret-key", localStackContainer::getSecretKey); | ||
return localStackContainer; | ||
} | ||
|
||
@Bean | ||
KinesisAsyncClient amazonKinesis(LocalStackContainer localStackContainer) { | ||
return KinesisAsyncClient.builder() | ||
.endpointOverride(localStackContainer.getEndpointOverride(KINESIS)) | ||
.region(Region.of(localStackContainer.getRegion())) | ||
.credentialsProvider( | ||
StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create( | ||
localStackContainer.getAccessKey(), | ||
localStackContainer.getSecretKey()))) | ||
.build(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(KinesisProducerApplication::main) | ||
.with(TestKinesisProducerApplication.class) | ||
.with(ContainerConfig.class) | ||
.run(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...inesis-project/producer/src/test/java/com/learning/aws/spring/common/ContainerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.learning.aws.spring.common; | ||
|
||
import static org.testcontainers.containers.localstack.LocalStackContainer.Service.KINESIS; | ||
|
||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.test.context.DynamicPropertyRegistrar; | ||
import org.testcontainers.containers.localstack.LocalStackContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class ContainerConfig { | ||
|
||
@Bean | ||
LocalStackContainer localStackContainer() { | ||
return new LocalStackContainer( | ||
DockerImageName.parse("localstack/localstack").withTag("4.0.3")); | ||
} | ||
|
||
@Bean | ||
DynamicPropertyRegistrar dynamicPropertyRegistrar(LocalStackContainer localStackContainer) { | ||
return dynamicPropertyRegistry -> { | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.endpoint", localStackContainer::getEndpoint); | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.region.static", localStackContainer::getRegion); | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.access-key", localStackContainer::getAccessKey); | ||
dynamicPropertyRegistry.add( | ||
"spring.cloud.aws.secret-key", localStackContainer::getSecretKey); | ||
}; | ||
} | ||
|
||
@Bean | ||
KinesisAsyncClient amazonKinesis(LocalStackContainer localStackContainer) { | ||
return KinesisAsyncClient.builder() | ||
.endpointOverride(localStackContainer.getEndpointOverride(KINESIS)) | ||
.region(Region.of(localStackContainer.getRegion())) | ||
.credentialsProvider( | ||
StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create( | ||
localStackContainer.getAccessKey(), | ||
localStackContainer.getSecretKey()))) | ||
.build(); | ||
} | ||
} |