File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed
src/test/java/com/github/abel533/test/mysql Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change 5
5
import com .github .abel533 .model .Country ;
6
6
import org .apache .ibatis .session .SqlSession ;
7
7
import org .junit .Assert ;
8
- import org .junit .Test ;
9
8
10
9
import java .util .ArrayList ;
11
10
import java .util .List ;
15
14
*
16
15
* @author liuzh
17
16
*/
18
- public class TestInsertList {
17
+ public class TestMysql {
19
18
20
19
/**
21
20
* 插入完整数据
22
21
*/
23
22
//该方法测试需要mysql或者h2数据库,所以这里注释掉
24
- @ Test
25
- public void testInsert () {
23
+ // @Test
24
+ public void testInsertList () {
26
25
SqlSession sqlSession = MybatisHelper .getSqlSession ();
27
26
try {
28
27
CountryMapper mapper = sqlSession .getMapper (CountryMapper .class );
@@ -43,4 +42,25 @@ public void testInsert() {
43
42
sqlSession .close ();
44
43
}
45
44
}
45
+
46
+ /**
47
+ * 插入完整数据
48
+ */
49
+ //该方法测试需要mysql或者h2数据库,所以这里注释掉
50
+ //@Test
51
+ public void testInsert () {
52
+ SqlSession sqlSession = MybatisHelper .getSqlSession ();
53
+ try {
54
+ CountryMapper mapper = sqlSession .getMapper (CountryMapper .class );
55
+ Country country = new Country ();
56
+ country .setCountrycode ("CN" );
57
+ country .setCountryname ("天朝" );
58
+ int count = mapper .InsertUseGeneratedKeysMapper (country );
59
+ Assert .assertEquals (1 , count );
60
+ Assert .assertNotNull (country .getId ());
61
+ } finally {
62
+ sqlSession .rollback ();
63
+ sqlSession .close ();
64
+ }
65
+ }
46
66
}
You can’t perform that action at this time.
0 commit comments