From 7b4b0f7de35a2e6697b35b1e3106d408824f8801 Mon Sep 17 00:00:00 2001 From: Conor H Date: Tue, 23 Jul 2024 17:11:14 +0100 Subject: [PATCH 1/2] Update pom.xml tidy up spring boot dependencies --- pom.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 91249a7..2dd3a98 100644 --- a/pom.xml +++ b/pom.xml @@ -30,23 +30,24 @@ UTF-8 UTF-8 21 + 3.3.2 org.springframework.boot spring-boot - 3.3.1 + ${spring.version} org.springframework.boot spring-boot-starter-web - 3.3.1 + ${spring.version} org.springframework.boot spring-boot-starter-tomcat - 3.3.1 + ${spring.version} provided @@ -83,7 +84,7 @@ org.springframework.boot spring-boot-starter-test test - 3.0.1 + ${spring.version} junit From 5eb778414dd9c6a32b29eacde418974376a7522a Mon Sep 17 00:00:00 2001 From: Conor H Date: Tue, 23 Jul 2024 17:27:52 +0100 Subject: [PATCH 2/2] Resolve spring test conflict Bug fix - tests were not running as part of build after upgrading spring dependencies --- src/test/java/com/ironoc/portfolio/AppTest.java | 5 +---- .../com/ironoc/portfolio/config/IronocMvcConfigTest.java | 8 ++++---- .../portfolio/controller/CustomErrorControllerTest.java | 8 ++++---- .../ironoc/portfolio/controller/HomeControllerTest.java | 8 ++++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/ironoc/portfolio/AppTest.java b/src/test/java/com/ironoc/portfolio/AppTest.java index 50d7232..3e4fcf0 100644 --- a/src/test/java/com/ironoc/portfolio/AppTest.java +++ b/src/test/java/com/ironoc/portfolio/AppTest.java @@ -1,15 +1,12 @@ package com.ironoc.portfolio; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; -import org.mockito.junit.MockitoJUnitRunner; import org.springframework.boot.SpringApplication; import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.times; -@RunWith(MockitoJUnitRunner.class) public class AppTest { // mocks diff --git a/src/test/java/com/ironoc/portfolio/config/IronocMvcConfigTest.java b/src/test/java/com/ironoc/portfolio/config/IronocMvcConfigTest.java index 0d5d2c7..c749158 100644 --- a/src/test/java/com/ironoc/portfolio/config/IronocMvcConfigTest.java +++ b/src/test/java/com/ironoc/portfolio/config/IronocMvcConfigTest.java @@ -1,12 +1,12 @@ package com.ironoc.portfolio.config; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.web.servlet.ViewResolver; @@ -22,7 +22,7 @@ import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.*; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class IronocMvcConfigTest { @InjectMocks diff --git a/src/test/java/com/ironoc/portfolio/controller/CustomErrorControllerTest.java b/src/test/java/com/ironoc/portfolio/controller/CustomErrorControllerTest.java index f908a61..721a497 100644 --- a/src/test/java/com/ironoc/portfolio/controller/CustomErrorControllerTest.java +++ b/src/test/java/com/ironoc/portfolio/controller/CustomErrorControllerTest.java @@ -2,18 +2,18 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.web.servlet.view.RedirectView; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.mockito.Mockito.verify; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CustomErrorControllerTest { @InjectMocks diff --git a/src/test/java/com/ironoc/portfolio/controller/HomeControllerTest.java b/src/test/java/com/ironoc/portfolio/controller/HomeControllerTest.java index 8f99039..6ef625e 100644 --- a/src/test/java/com/ironoc/portfolio/controller/HomeControllerTest.java +++ b/src/test/java/com/ironoc/portfolio/controller/HomeControllerTest.java @@ -1,18 +1,18 @@ package com.ironoc.portfolio.controller; import jakarta.servlet.http.HttpServletRequest; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.*; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class HomeControllerTest { @InjectMocks