Skip to content

Commit bbe6f13

Browse files
committed
[tests] Upgrade to junit 5.3.1
1 parent 12b186d commit bbe6f13

File tree

5 files changed

+47
-45
lines changed

5 files changed

+47
-45
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@
9292

9393
<!-- TEST -->
9494
<dependency>
95-
<groupId>org.junit.vintage</groupId>
96-
<artifactId>junit-vintage-engine</artifactId>
97-
<version>4.12.2</version>
95+
<groupId>org.junit.jupiter</groupId>
96+
<artifactId>junit-jupiter-engine</artifactId>
97+
<version>5.3.1</version>
9898
<scope>test</scope>
9999
</dependency>
100100
<dependency>

src/test/java/org/mybatis/scripting/freemarker/CustomizedDataContextTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2017 the original author or authors.
2+
* Copyright 2015-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,9 +28,9 @@
2828
import org.apache.ibatis.transaction.TransactionFactory;
2929
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
3030
import org.hsqldb.jdbc.JDBCDataSource;
31-
import org.junit.Assert;
32-
import org.junit.BeforeClass;
33-
import org.junit.Test;
31+
import org.junit.jupiter.api.Assertions;
32+
import org.junit.jupiter.api.BeforeAll;
33+
import org.junit.jupiter.api.Test;
3434

3535
import java.io.Reader;
3636
import java.sql.Connection;
@@ -43,7 +43,7 @@
4343
public class CustomizedDataContextTest {
4444
protected static SqlSessionFactory sqlSessionFactory;
4545

46-
@BeforeClass
46+
@BeforeAll
4747
public static void setUp() throws Exception {
4848
Class.forName("org.hsqldb.jdbcDriver");
4949

@@ -102,7 +102,7 @@ public void test() {
102102
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
103103
CustomizedDataContextMapper mapper = sqlSession.getMapper(CustomizedDataContextMapper.class);
104104
List<Name> names = mapper.find();
105-
Assert.assertTrue(names.size() == 1);
105+
Assertions.assertTrue(names.size() == 1);
106106
}
107107
}
108108
}

src/test/java/org/mybatis/scripting/freemarker/FreeMarkerInAnnotationsTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2017 the original author or authors.
2+
* Copyright 2015-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,9 +25,9 @@
2525
import org.apache.ibatis.transaction.TransactionFactory;
2626
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
2727
import org.hsqldb.jdbc.JDBCDataSource;
28-
import org.junit.Assert;
29-
import org.junit.BeforeClass;
30-
import org.junit.Test;
28+
import org.junit.jupiter.api.Assertions;
29+
import org.junit.jupiter.api.BeforeAll;
30+
import org.junit.jupiter.api.Test;
3131

3232
import java.io.Reader;
3333
import java.sql.Connection;
@@ -42,7 +42,7 @@
4242
public class FreeMarkerInAnnotationsTest {
4343
protected static SqlSessionFactory sqlSessionFactory;
4444

45-
@BeforeClass
45+
@BeforeAll
4646
public static void setUp() throws Exception {
4747
Class.forName("org.hsqldb.jdbcDriver");
4848

@@ -77,7 +77,7 @@ public void testNoParamsCall() {
7777
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
7878
NameMapper mapper = sqlSession.getMapper(NameMapper.class);
7979
List<Name> allNames = mapper.getAllNames();
80-
Assert.assertTrue(allNames.size() == 5);
80+
Assertions.assertTrue(allNames.size() == 5);
8181
}
8282
}
8383

@@ -86,7 +86,7 @@ public void testMyBatisParamCall() {
8686
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
8787
NameMapper mapper = sqlSession.getMapper(NameMapper.class);
8888
Name pebble = mapper.findName("Pebbles");
89-
Assert.assertTrue(pebble != null && pebble.getFirstName().equals("Pebbles"));
89+
Assertions.assertTrue(pebble != null && pebble.getFirstName().equals("Pebbles"));
9090
}
9191
}
9292

@@ -102,7 +102,7 @@ public void testInQuery() {
102102
add(4);
103103
}
104104
});
105-
Assert.assertTrue(namesByIds.size() == 3);
105+
Assertions.assertTrue(namesByIds.size() == 3);
106106
}
107107
}
108108

@@ -111,7 +111,7 @@ public void testParamObject() {
111111
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
112112
NameMapper mapper = sqlSession.getMapper(NameMapper.class);
113113
Name name = mapper.find(new NameParam(4));
114-
Assert.assertTrue(name != null && name.getId() == 4);
114+
Assertions.assertTrue(name != null && name.getId() == 4);
115115
}
116116
}
117117

@@ -121,10 +121,10 @@ public void testStringParam() {
121121
NameMapper mapper = sqlSession.getMapper(NameMapper.class);
122122
List<Name> stdLangResult = mapper.getNamesOddBehaviourStdLang("Pebbles");
123123
List<Name> freeMarkerLangResult = mapper.getNamesOddBehaviourFreeMarkerLang("Pebbles");
124-
Assert.assertTrue(stdLangResult.size() == 1);
125-
Assert.assertTrue(stdLangResult.get(0).getFirstName().equals("Pebbles"));
126-
Assert.assertTrue(freeMarkerLangResult.size() == 1);
127-
Assert.assertTrue(freeMarkerLangResult.get(0).getFirstName().equals("Pebbles"));
124+
Assertions.assertTrue(stdLangResult.size() == 1);
125+
Assertions.assertTrue(stdLangResult.get(0).getFirstName().equals("Pebbles"));
126+
Assertions.assertTrue(freeMarkerLangResult.size() == 1);
127+
Assertions.assertTrue(freeMarkerLangResult.get(0).getFirstName().equals("Pebbles"));
128128
}
129129
}
130130
}

src/test/java/org/mybatis/scripting/freemarker/FreeMarkerInXmlTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2017 the original author or authors.
2+
* Copyright 2015-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.apache.ibatis.session.SqlSession;
2121
import org.apache.ibatis.session.SqlSessionFactory;
2222
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
23-
import org.junit.Assert;
24-
import org.junit.BeforeClass;
25-
import org.junit.Test;
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.BeforeAll;
25+
import org.junit.jupiter.api.Test;
2626

2727
import java.io.Reader;
2828
import java.sql.Connection;
@@ -39,7 +39,7 @@
3939
public class FreeMarkerInXmlTest {
4040
protected static SqlSessionFactory sqlSessionFactory;
4141

42-
@BeforeClass
42+
@BeforeAll
4343
public static void setUp() throws Exception {
4444
Connection conn = null;
4545

@@ -70,7 +70,7 @@ public static void setUp() throws Exception {
7070
public void testNoParamsCall() {
7171
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
7272
List<Name> allNames = sqlSession.selectList("getAllNames");
73-
Assert.assertTrue(allNames.size() == 5);
73+
Assertions.assertTrue(allNames.size() == 5);
7474
}
7575
}
7676

@@ -80,7 +80,7 @@ public void testMyBatisParamCall() {
8080
HashMap<String, Object> paramsMap = new HashMap<>();
8181
paramsMap.put("name", "Pebbles");
8282
Name pebble = sqlSession.selectOne("findName", paramsMap);
83-
Assert.assertTrue(pebble != null && pebble.getFirstName().equals("Pebbles"));
83+
Assertions.assertTrue(pebble != null && pebble.getFirstName().equals("Pebbles"));
8484
}
8585
}
8686

@@ -97,15 +97,15 @@ public void testInQuery() {
9797
}
9898
});
9999
List<Name> namesByIds = sqlSession.selectList("findNamesByIds", paramsMap);
100-
Assert.assertTrue(namesByIds.size() == 3);
100+
Assertions.assertTrue(namesByIds.size() == 3);
101101
}
102102
}
103103

104104
@Test
105105
public void testParamObject() {
106106
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
107107
Name name = sqlSession.selectOne("find", new NameParam(4));
108-
Assert.assertTrue(name != null && name.getId() == 4);
108+
Assertions.assertTrue(name != null && name.getId() == 4);
109109
}
110110
}
111111

@@ -114,10 +114,10 @@ public void testStringParam() {
114114
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
115115
List<Name> stdLangResult = sqlSession.selectList("getNamesOddBehaviourStdLang", "Pebbles");
116116
List<Name> freeMarkerLangResult = sqlSession.selectList("getNamesOddBehaviourFreeMarkerLang", "Pebbles");
117-
Assert.assertTrue(stdLangResult.size() == 1);
118-
Assert.assertTrue(stdLangResult.get(0).getFirstName().equals("Pebbles"));
119-
Assert.assertTrue(freeMarkerLangResult.size() == 1);
120-
Assert.assertTrue(freeMarkerLangResult.get(0).getFirstName().equals("Pebbles"));
117+
Assertions.assertTrue(stdLangResult.size() == 1);
118+
Assertions.assertTrue(stdLangResult.get(0).getFirstName().equals("Pebbles"));
119+
Assertions.assertTrue(freeMarkerLangResult.size() == 1);
120+
Assertions.assertTrue(freeMarkerLangResult.get(0).getFirstName().equals("Pebbles"));
121121
}
122122
}
123123
}

src/test/java/org/mybatis/scripting/freemarker/PreparedParamsTest.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2017 the original author or authors.
2+
* Copyright 2015-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,9 +26,9 @@
2626
import org.apache.ibatis.transaction.TransactionFactory;
2727
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
2828
import org.hsqldb.jdbc.JDBCDataSource;
29-
import org.junit.Assert;
30-
import org.junit.BeforeClass;
31-
import org.junit.Test;
29+
import org.junit.jupiter.api.Assertions;
30+
import org.junit.jupiter.api.BeforeAll;
31+
import org.junit.jupiter.api.Test;
3232

3333
import java.io.Reader;
3434
import java.sql.Connection;
@@ -43,7 +43,7 @@
4343
public class PreparedParamsTest {
4444
protected static SqlSessionFactory sqlSessionFactory;
4545

46-
@BeforeClass
46+
@BeforeAll
4747
public static void setUp() throws Exception {
4848
Class.forName("org.hsqldb.jdbcDriver");
4949

@@ -85,18 +85,20 @@ public void testInCall() {
8585
add("Betty");
8686
}
8787
});
88-
Assert.assertTrue(names.size() == 3);
88+
Assertions.assertTrue(names.size() == 3);
8989
}
9090
}
9191

9292
/**
9393
* PersistenceException will be thrown with cause of UnsupportedOperationException
9494
*/
95-
@Test(expected = PersistenceException.class)
95+
@Test
9696
public void testParamsObjectCall() {
9797
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
98-
PreparedParamsMapper mapper = sqlSession.getMapper(PreparedParamsMapper.class);
99-
mapper.findUsingParamsObject(new PreparedParam());
98+
final PreparedParamsMapper mapper = sqlSession.getMapper(PreparedParamsMapper.class);
99+
Assertions.assertThrows(PersistenceException.class, () -> {
100+
mapper.findUsingParamsObject(new PreparedParam());
101+
});
100102
}
101103
}
102104

@@ -105,7 +107,7 @@ public void testNoParamsCall() {
105107
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
106108
PreparedParamsMapper mapper = sqlSession.getMapper(PreparedParamsMapper.class);
107109
Name name = mapper.findUsingParams(new PreparedParam.InnerClass());
108-
Assert.assertTrue(name != null && name.getFirstName().equals("Wilma"));
110+
Assertions.assertTrue(name != null && name.getFirstName().equals("Wilma"));
109111
}
110112
}
111113
}

0 commit comments

Comments
 (0)