From 3c8e7eb634053b7031d277ab7789b7ccbfd2b75a Mon Sep 17 00:00:00 2001 From: parthiv39731 <70740707+parthiv39731@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:48:55 +0530 Subject: [PATCH] BAEL-7135 migrated to junit 5 --- persistence-modules/spring-jdbc-2/pom.xml | 1 + .../jdbcclient/JdbcClientUnitTest.java | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/persistence-modules/spring-jdbc-2/pom.xml b/persistence-modules/spring-jdbc-2/pom.xml index 24744b28dc..ce79c1c615 100644 --- a/persistence-modules/spring-jdbc-2/pom.xml +++ b/persistence-modules/spring-jdbc-2/pom.xml @@ -86,6 +86,7 @@ 3.2.0-SNAPSHOT + 5.10.0 UTF-8 diff --git a/persistence-modules/spring-jdbc-2/src/test/java/com/baeldung/jdbcclient/JdbcClientUnitTest.java b/persistence-modules/spring-jdbc-2/src/test/java/com/baeldung/jdbcclient/JdbcClientUnitTest.java index 42ac1eb4d0..be30efcb9c 100644 --- a/persistence-modules/spring-jdbc-2/src/test/java/com/baeldung/jdbcclient/JdbcClientUnitTest.java +++ b/persistence-modules/spring-jdbc-2/src/test/java/com/baeldung/jdbcclient/JdbcClientUnitTest.java @@ -2,15 +2,13 @@ package com.baeldung.jdbcclient; import com.baeldung.jdbcclient.dao.StudentDao; import com.baeldung.jdbcclient.model.Student; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import java.util.Map; @@ -19,11 +17,11 @@ import java.util.Optional; import static org.junit.jupiter.api.Assertions.*; -@RunWith(SpringRunner.class) @Sql(value = "/jdbcclient/student.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) @Sql(value = "/jdbcclient/drop_student.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) @SpringBootTest(classes = JdbcClientDemoApplication.class) @TestPropertySource(locations = {"classpath:jdbcclient/application.properties"}) + public class JdbcClientUnitTest { private static final Logger logger = LoggerFactory.getLogger(JdbcClientUnitTest.class); @@ -31,14 +29,14 @@ public class JdbcClientUnitTest { private StudentDao studentDao; @Test - public void givenJdbcClient_whenInsertWithNamedParamAndSqlType_thenSuccess() { + void givenJdbcClient_whenInsertWithNamedParamAndSqlType_thenSuccess() { logger.info("testing invoked successfully"); Student student = getSampleStudent("Johny Dep", 8, 4, "Male", "New York"); assertEquals(1, studentDao.insertWithSetParamWithNamedParamAndSqlType(student)); } @Test - public void givenJdbcClient_whenQueryWithPositionalParams_thenSuccess() { + void givenJdbcClient_whenQueryWithPositionalParams_thenSuccess() { logger.info("testing invoked successfully"); List students = studentDao.getStudentsOfGradeStateAndGenderWithPositionalParams( 1, "New York", "Male"); @@ -47,7 +45,7 @@ public class JdbcClientUnitTest { } @Test - public void givenJdbcClient_whenQueryWithParamsInVarargs_thenSuccess() { + void givenJdbcClient_whenQueryWithParamsInVarargs_thenSuccess() { logger.info("testing invoked successfully"); Student student = studentDao.getStudentsOfGradeStateAndGenderWithParamsInVarargs( 1, "New York", "Male"); @@ -55,7 +53,7 @@ public class JdbcClientUnitTest { } @Test - public void givenJdbcClient_whenQueryWithParamsInList_thenSuccess() { + void givenJdbcClient_whenQueryWithParamsInList_thenSuccess() { logger.info("testing invoked successfully"); List params = List.of(1, "New York", "Male"); Optional optional = studentDao.getStudentsOfGradeStateAndGenderWithParamsInList(params); @@ -67,14 +65,14 @@ public class JdbcClientUnitTest { } @Test - public void givenJdbcClient_whenQueryWithParamsIndex_thenSuccess() { + void givenJdbcClient_whenQueryWithParamsIndex_thenSuccess() { logger.info("testing invoked successfully"); List students = studentDao.getStudentsOfGradeStateAndGenderWithParamIndex( 1, "New York", "Male"); assertEquals(6, students.size()); } @Test - public void givenJdbcClient_whenQueryWithNamedParam_thenSuccess() { + void givenJdbcClient_whenQueryWithNamedParam_thenSuccess() { logger.info("testing invoked successfully"); Integer count = studentDao.getCountOfStudentsOfGradeStateAndGenderWithNamedParam( 1, "New York", "Male"); @@ -82,7 +80,7 @@ public class JdbcClientUnitTest { assertEquals(6, count); } @Test - public void givenJdbcClient_whenQueryWithParamMap_thenSuccess() { + void givenJdbcClient_whenQueryWithParamMap_thenSuccess() { logger.info("testing invoked successfully"); Map paramMap = Map.of( "grade", 1,