Skip to content

Commit

Permalink
feat : upgrade localstack to 4.0.3 & polish TC (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored Dec 27, 2024
1 parent 22559c8 commit a78f768
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion aws-cloudwatch-project/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "5432:5432"

localstack:
image: localstack/localstack:3.8.1
image: localstack/localstack:4.0.3
ports:
- "4566:4566"
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

@SpringBootApplication
@EnableConfigurationProperties({ApplicationProperties.class})
public class Application {
public class CloudWatchApplication {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
SpringApplication.run(CloudWatchApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

Expand All @@ -11,7 +12,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
private final ApplicationProperties properties;

@Override
public void addCorsMappings(CorsRegistry registry) {
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping(properties.getCors().getPathPattern())
.allowedMethods(properties.getCors().getAllowedMethods())
.allowedHeaders(properties.getCors().getAllowedHeaders())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.awsspring;

import com.example.awsspring.common.ContainerConfig;
import org.springframework.boot.SpringApplication;

public class TestCloudWatchApplication {

public static void main(String[] args) {
SpringApplication.from(CloudWatchApplication::main).with(ContainerConfig.class).run(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static com.example.awsspring.utils.AppConstants.PROFILE_TEST;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import com.example.awsspring.TestApplication;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
Expand All @@ -21,7 +20,7 @@
"management.metrics.enable.all=false",
"management.metrics.enable.http=true"
},
classes = TestApplication.class)
classes = ContainerConfig.class)
@AutoConfigureObservability
@AutoConfigureMockMvc
public abstract class AbstractIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.awsspring;
package com.example.awsspring.common;

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;
Expand All @@ -9,22 +8,18 @@
import org.testcontainers.utility.DockerImageName;

@TestConfiguration(proxyBeanMethods = false)
public class TestApplication {
public class ContainerConfig {

@Bean
@ServiceConnection
LocalStackContainer localstackContainer() {
return new LocalStackContainer(
DockerImageName.parse("localstack/localstack").withTag("3.7.2"));
DockerImageName.parse("localstack/localstack").withTag("4.0.3"));
}

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgreSQLContainer() {
return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.0-alpine"));
}

public static void main(String[] args) {
SpringApplication.from(Application::main).with(TestApplication.class).run(args);
return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.2-alpine"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

@WebMvcTest(controllers = CustomerController.class)
Expand All @@ -35,7 +35,7 @@ class CustomerControllerTest {

@Autowired private MockMvc mockMvc;

@MockBean private CustomerService customerService;
@MockitoBean private CustomerService customerService;

@Autowired private ObjectMapper objectMapper;

Expand Down

0 comments on commit a78f768

Please sign in to comment.