Skip to content

Commit

Permalink
Upgrade to spring boot 3.4.0 and polish
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Dec 12, 2024
1 parent 96d6c3d commit 0f55f7a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions boot-togglz-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.6</version>
<version>3.4.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.featuretoggle</groupId>
Expand All @@ -19,7 +19,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>21</java.version>
<springdoc-openapi.version>2.6.0</springdoc-openapi.version>
<springdoc-openapi.version>2.7.0</springdoc-openapi.version>
<togglz.version>4.4.0</togglz.version>

<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
Expand Down Expand Up @@ -234,7 +234,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.22.0</version>
<version>1.25.0</version>
<style>AOSP</style>
</googleJavaFormat>
</java>
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 TogglzApplication {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
SpringApplication.run(TogglzApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ApplicationIntegrationTest extends AbstractIntegrationTest {

@Test
void shouldFindCustomerByIdWithEmptyData() throws Exception {
Customer customer = new Customer(101L, "New Customer", "name 1", 1);
Customer customer = new Customer(null, "New Customer", "name 1", 1);
this.mockMvc
.perform(
post("/api/customers")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.featuretoggle;

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

public class TestTogglzApplication {

public static void main(String[] args) {
SpringApplication.from(TogglzApplication::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.featuretoggle.utils.AppConstants.PROFILE_TEST;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import com.example.featuretoggle.TestApplication;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
Expand All @@ -12,7 +11,7 @@
import org.springframework.test.web.servlet.MockMvc;

@ActiveProfiles({PROFILE_TEST})
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = TestApplication.class)
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = ContainerConfig.class)
@AutoConfigureMockMvc
public abstract class AbstractIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.featuretoggle;
package com.example.featuretoggle.common;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.devtools.restart.RestartScope;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
Expand All @@ -9,16 +8,12 @@
import org.testcontainers.utility.DockerImageName;

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

@Bean
@ServiceConnection
@RestartScope
MySQLContainer<?> sqlContainer() {
return new MySQLContainer<>(DockerImageName.parse("mysql:9.0"));
}

public static void main(String[] args) {
SpringApplication.from(Application::main).with(TestApplication.class).run(args);
return new MySQLContainer<>(DockerImageName.parse("mysql:9.1"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,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 @@ -36,7 +36,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 0f55f7a

Please sign in to comment.