BAEL-7135

migrated to junit 5
This commit is contained in:
parthiv39731 2023-10-25 15:48:55 +05:30
parent 78f5072f7c
commit 3c8e7eb634
2 changed files with 10 additions and 11 deletions

View File

@ -86,6 +86,7 @@
<properties>
<spring-boot.version>3.2.0-SNAPSHOT</spring-boot.version>
<junit-jupiter.version>5.10.0</junit-jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@ -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<Student> 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<Student> 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<Student> 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<String, ?> paramMap = Map.of(
"grade", 1,