-
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.
- Loading branch information
1 parent
6dc56a3
commit 04d7150
Showing
4 changed files
with
42 additions
and
37 deletions.
There are no files selected for viewing
18 changes: 2 additions & 16 deletions
18
...roject/consumer/src/test/java/com/learning/aws/spring/TestKinesisConsumerApplication.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,27 +1,13 @@ | ||
package com.learning.aws.spring; | ||
|
||
import com.learning.aws.spring.common.LocalStackConfig; | ||
import com.learning.aws.spring.common.ContainersConfig; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Import; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
@Import(LocalStackConfig.class) | ||
public class TestKinesisConsumerApplication { | ||
|
||
@Bean | ||
@ServiceConnection | ||
PostgreSQLContainer<?> postgreSQLContainer() { | ||
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:17.2-alpine")); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(KinesisConsumerApplication::main) | ||
.with(TestKinesisConsumerApplication.class) | ||
.with(ContainersConfig.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
37 changes: 37 additions & 0 deletions
37
...nesis-project/consumer/src/test/java/com/learning/aws/spring/common/ContainersConfig.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,37 @@ | ||
package com.learning.aws.spring.common; | ||
|
||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.test.context.DynamicPropertyRegistrar; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.containers.localstack.LocalStackContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class ContainersConfig { | ||
|
||
@Bean | ||
LocalStackContainer localStackContainer() { | ||
return new LocalStackContainer( | ||
DockerImageName.parse("localstack/localstack").withTag("4.0.3")); | ||
} | ||
|
||
@Bean | ||
@ServiceConnection | ||
PostgreSQLContainer<?> postgreSQLContainer() { | ||
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:17.2-alpine")); | ||
} | ||
|
||
@Bean | ||
DynamicPropertyRegistrar dynamicPropertyRegistrar(LocalStackContainer localStackContainer) { | ||
return registry -> { | ||
registry.add("spring.cloud.aws.endpoint", localStackContainer::getEndpoint); | ||
registry.add("spring.cloud.aws.region.static", localStackContainer::getRegion); | ||
registry.add( | ||
"spring.cloud.aws.credentials.access-key", localStackContainer::getAccessKey); | ||
registry.add( | ||
"spring.cloud.aws.credentials.secret-key", localStackContainer::getSecretKey); | ||
}; | ||
} | ||
} |
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