1
1
/**
2
- * Copyright 2010-2017 the original author or authors.
2
+ * Copyright 2010-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
38
38
import static org .junit .jupiter .api .Assertions .fail ;
39
39
import static org .junit .jupiter .api .Assertions .assertThrows ;
40
40
41
- public final class MyBatisSpringTest extends AbstractMyBatisSpringTest {
41
+ class MyBatisSpringTest extends AbstractMyBatisSpringTest {
42
42
43
43
private SqlSession session ;
44
44
45
45
@ AfterEach
46
- public void validateSessionClose () {
46
+ void validateSessionClose () {
47
47
// assume if the Executor is closed, the Session is too
48
48
if ((session != null ) && !executorInterceptor .isExecutorClosed ()) {
49
49
session = null ;
@@ -55,7 +55,7 @@ public void validateSessionClose() {
55
55
56
56
// ensure MyBatis API still works with SpringManagedTransaction
57
57
@ Test
58
- public void testMyBatisAPI () {
58
+ void testMyBatisAPI () {
59
59
session = sqlSessionFactory .openSession ();
60
60
session .getMapper (TestMapper .class ).findTest ();
61
61
session .close ();
@@ -66,7 +66,7 @@ public void testMyBatisAPI() {
66
66
}
67
67
68
68
@ Test
69
- public void testMyBatisAPIWithCommit () {
69
+ void testMyBatisAPIWithCommit () {
70
70
session = sqlSessionFactory .openSession ();
71
71
session .getMapper (TestMapper .class ).findTest ();
72
72
session .commit (true );
@@ -78,7 +78,7 @@ public void testMyBatisAPIWithCommit() {
78
78
}
79
79
80
80
@ Test
81
- public void testMyBatisAPIWithRollback () {
81
+ void testMyBatisAPIWithRollback () {
82
82
session = sqlSessionFactory .openSession ();
83
83
session .getMapper (TestMapper .class ).findTest ();
84
84
session .rollback (true );
@@ -91,7 +91,7 @@ public void testMyBatisAPIWithRollback() {
91
91
92
92
// basic tests using SqlSessionUtils instead of using the MyBatis API directly
93
93
@ Test
94
- public void testSpringAPI () {
94
+ void testSpringAPI () {
95
95
session = SqlSessionUtils .getSqlSession (sqlSessionFactory );
96
96
session .getMapper (TestMapper .class ).findTest ();
97
97
SqlSessionUtils .closeSqlSession (session , sqlSessionFactory );
@@ -102,7 +102,7 @@ public void testSpringAPI() {
102
102
}
103
103
104
104
@ Test
105
- public void testSpringAPIWithCommit () {
105
+ void testSpringAPIWithCommit () {
106
106
session = SqlSessionUtils .getSqlSession (sqlSessionFactory );
107
107
session .getMapper (TestMapper .class ).findTest ();
108
108
session .commit (true );
@@ -113,7 +113,7 @@ public void testSpringAPIWithCommit() {
113
113
}
114
114
115
115
@ Test
116
- public void testSpringAPIWithRollback () {
116
+ void testSpringAPIWithRollback () {
117
117
session = SqlSessionUtils .getSqlSession (sqlSessionFactory );
118
118
session .getMapper (TestMapper .class ).findTest ();
119
119
session .rollback (true );
@@ -124,7 +124,7 @@ public void testSpringAPIWithRollback() {
124
124
}
125
125
126
126
@ Test
127
- public void testSpringAPIWithMyBatisClose () {
127
+ void testSpringAPIWithMyBatisClose () {
128
128
// This is a programming error and could lead to connection leak if there is a transaction
129
129
// in progress. But, the API allows it, so make sure it at least works without a tx.
130
130
session = SqlSessionUtils .getSqlSession (sqlSessionFactory );
@@ -137,7 +137,7 @@ public void testSpringAPIWithMyBatisClose() {
137
137
138
138
// Spring API should work with a MyBatis TransactionFactories
139
139
@ Test
140
- public void testWithNonSpringTransactionFactory () {
140
+ void testWithNonSpringTransactionFactory () {
141
141
Environment original = sqlSessionFactory .getConfiguration ().getEnvironment ();
142
142
Environment nonSpring = new Environment ("non-spring" , new JdbcTransactionFactory (), dataSource );
143
143
sqlSessionFactory .getConfiguration ().setEnvironment (nonSpring );
@@ -159,7 +159,7 @@ public void testWithNonSpringTransactionFactory() {
159
159
// Spring TX, non-Spring TransactionFactory, Spring managed DataSource
160
160
// this should not work since the DS will be out of sync with MyBatis
161
161
@ Test
162
- public void testNonSpringTxFactoryWithTx () throws Exception {
162
+ void testNonSpringTxFactoryWithTx () throws Exception {
163
163
Environment original = sqlSessionFactory .getConfiguration ().getEnvironment ();
164
164
Environment nonSpring = new Environment ("non-spring" , new JdbcTransactionFactory (), dataSource );
165
165
sqlSessionFactory .getConfiguration ().setEnvironment (nonSpring );
@@ -184,7 +184,7 @@ public void testNonSpringTxFactoryWithTx() throws Exception {
184
184
// Spring TX, non-Spring TransactionFactory, MyBatis managed DataSource
185
185
// this should work since the DS is managed MyBatis
186
186
@ Test
187
- public void testNonSpringTxFactoryNonSpringDSWithTx () throws java .sql .SQLException {
187
+ void testNonSpringTxFactoryNonSpringDSWithTx () throws java .sql .SQLException {
188
188
Environment original = sqlSessionFactory .getConfiguration ().getEnvironment ();
189
189
190
190
MockDataSource mockDataSource = new MockDataSource ();
@@ -222,7 +222,7 @@ public void testNonSpringTxFactoryNonSpringDSWithTx() throws java.sql.SQLExcepti
222
222
}
223
223
224
224
@ Test
225
- public void testChangeExecutorTypeInTx () throws Exception {
225
+ void testChangeExecutorTypeInTx () throws Exception {
226
226
TransactionStatus status = null ;
227
227
228
228
try {
@@ -244,7 +244,7 @@ public void testChangeExecutorTypeInTx() throws Exception {
244
244
}
245
245
246
246
@ Test
247
- public void testChangeExecutorTypeInTxRequiresNew () throws Exception {
247
+ void testChangeExecutorTypeInTxRequiresNew () throws Exception {
248
248
249
249
try {
250
250
txManager .setDataSource (dataSource );
@@ -276,7 +276,7 @@ public void testChangeExecutorTypeInTxRequiresNew() throws Exception {
276
276
}
277
277
278
278
@ Test
279
- public void testWithJtaTxManager () {
279
+ void testWithJtaTxManager () {
280
280
JtaTransactionManager jtaManager = new JtaTransactionManager (new MockUserTransaction ());
281
281
282
282
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
@@ -297,7 +297,7 @@ public void testWithJtaTxManager() {
297
297
}
298
298
299
299
@ Test
300
- public void testWithJtaTxManagerAndNonSpringTxManager () throws java .sql .SQLException {
300
+ void testWithJtaTxManagerAndNonSpringTxManager () throws java .sql .SQLException {
301
301
Environment original = sqlSessionFactory .getConfiguration ().getEnvironment ();
302
302
303
303
MockDataSource mockDataSource = new MockDataSource ();
@@ -344,7 +344,7 @@ public void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLExcep
344
344
}
345
345
346
346
@ Test
347
- public void testWithTxSupports () {
347
+ void testWithTxSupports () {
348
348
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
349
349
txDef .setPropagationBehaviorName ("PROPAGATION_SUPPORTS" );
350
350
@@ -363,7 +363,7 @@ public void testWithTxSupports() {
363
363
364
364
365
365
@ Test
366
- public void testRollbackWithTxSupports () {
366
+ void testRollbackWithTxSupports () {
367
367
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
368
368
txDef .setPropagationBehaviorName ("PROPAGATION_SUPPORTS" );
369
369
@@ -381,7 +381,7 @@ public void testRollbackWithTxSupports() {
381
381
}
382
382
383
383
@ Test
384
- public void testWithTxRequired () {
384
+ void testWithTxRequired () {
385
385
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
386
386
txDef .setPropagationBehaviorName ("PROPAGATION_REQUIRED" );
387
387
@@ -399,7 +399,7 @@ public void testWithTxRequired() {
399
399
}
400
400
401
401
@ Test
402
- public void testSqlSessionCommitWithTx () {
402
+ void testSqlSessionCommitWithTx () {
403
403
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
404
404
txDef .setPropagationBehaviorName ("PROPAGATION_REQUIRED" );
405
405
@@ -424,7 +424,7 @@ public void testSqlSessionCommitWithTx() {
424
424
}
425
425
426
426
@ Test
427
- public void testWithInterleavedTx () throws Exception {
427
+ void testWithInterleavedTx () {
428
428
// this session will use one Connection
429
429
session = SqlSessionUtils .getSqlSession (sqlSessionFactory );
430
430
session .getMapper (TestMapper .class ).findTest ();
@@ -460,7 +460,7 @@ public void testWithInterleavedTx() throws Exception {
460
460
}
461
461
462
462
@ Test
463
- public void testSuspendAndResume () throws Exception {
463
+ void testSuspendAndResume () {
464
464
465
465
try {
466
466
txManager .setDataSource (dataSource );
@@ -512,7 +512,7 @@ public void testSuspendAndResume() throws Exception {
512
512
}
513
513
514
514
@ Test
515
- public void testBatch () {
515
+ void testBatch () {
516
516
setupBatchStatements ();
517
517
518
518
session = SqlSessionUtils .getSqlSession (sqlSessionFactory , ExecutorType .BATCH , exceptionTranslator );
@@ -533,7 +533,7 @@ public void testBatch() {
533
533
}
534
534
535
535
@ Test
536
- public void testBatchInTx () {
536
+ void testBatchInTx () {
537
537
setupBatchStatements ();
538
538
539
539
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
@@ -557,7 +557,7 @@ public void testBatchInTx() {
557
557
}
558
558
559
559
@ Test
560
- public void testBatchWithError () {
560
+ void testBatchWithError () {
561
561
try {
562
562
setupBatchStatements ();
563
563
@@ -577,7 +577,7 @@ public void testBatchWithError() {
577
577
}
578
578
579
579
@ Test
580
- public void testBatchInTxWithError () {
580
+ void testBatchInTxWithError () {
581
581
setupBatchStatements ();
582
582
583
583
DefaultTransactionDefinition txDef = new DefaultTransactionDefinition ();
0 commit comments