Skip to content

Commit 9d3de4f

Browse files
hgh1472rstoyanchev
authored andcommitted
Remove duplicated setup
See gh-34807 Signed-off-by: hgh1472 <[email protected]>
1 parent 8f3ca49 commit 9d3de4f

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ void verifyTransactionSynchronizationManagerState() {
8181

8282
@Test
8383
void testTransactionCommit() {
84-
given(manager.getTransaction()).willReturn(tx);
85-
8684
final List<String> l = new ArrayList<>();
8785
l.add("test");
8886

@@ -106,7 +104,6 @@ void testTransactionCommit() {
106104

107105
@Test
108106
void testTransactionCommitWithRollbackException() {
109-
given(manager.getTransaction()).willReturn(tx);
110107
given(tx.getRollbackOnly()).willReturn(true);
111108
willThrow(new RollbackException()).given(tx).commit();
112109

@@ -138,7 +135,6 @@ void testTransactionCommitWithRollbackException() {
138135

139136
@Test
140137
void testTransactionRollback() {
141-
given(manager.getTransaction()).willReturn(tx);
142138
given(tx.isActive()).willReturn(true);
143139

144140
final List<String> l = new ArrayList<>();
@@ -163,8 +159,6 @@ void testTransactionRollback() {
163159

164160
@Test
165161
void testTransactionRollbackWithAlreadyRolledBack() {
166-
given(manager.getTransaction()).willReturn(tx);
167-
168162
final List<String> l = new ArrayList<>();
169163
l.add("test");
170164

@@ -186,7 +180,6 @@ void testTransactionRollbackWithAlreadyRolledBack() {
186180

187181
@Test
188182
void testTransactionRollbackOnly() {
189-
given(manager.getTransaction()).willReturn(tx);
190183
given(tx.isActive()).willReturn(true);
191184

192185
final List<String> l = new ArrayList<>();
@@ -214,8 +207,6 @@ void testTransactionRollbackOnly() {
214207

215208
@Test
216209
void testParticipatingTransactionWithCommit() {
217-
given(manager.getTransaction()).willReturn(tx);
218-
219210
final List<String> l = new ArrayList<>();
220211
l.add("test");
221212

@@ -241,7 +232,6 @@ void testParticipatingTransactionWithCommit() {
241232

242233
@Test
243234
void testParticipatingTransactionWithRollback() {
244-
given(manager.getTransaction()).willReturn(tx);
245235
given(tx.isActive()).willReturn(true);
246236

247237
final List<String> l = new ArrayList<>();
@@ -269,7 +259,6 @@ void testParticipatingTransactionWithRollback() {
269259

270260
@Test
271261
void testParticipatingTransactionWithRollbackOnly() {
272-
given(manager.getTransaction()).willReturn(tx);
273262
given(tx.isActive()).willReturn(true);
274263
given(tx.getRollbackOnly()).willReturn(true);
275264
willThrow(new RollbackException()).given(tx).commit();
@@ -304,10 +293,6 @@ void testParticipatingTransactionWithRollbackOnly() {
304293
void testParticipatingTransactionWithRequiresNew() {
305294
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
306295

307-
given(factory.createEntityManager()).willReturn(manager);
308-
given(manager.getTransaction()).willReturn(tx);
309-
given(manager.isOpen()).willReturn(true);
310-
311296
final List<String> l = new ArrayList<>();
312297
l.add("test");
313298

@@ -335,7 +320,6 @@ void testParticipatingTransactionWithRequiresNew() {
335320
void testParticipatingTransactionWithRequiresNewAndPrebound() {
336321
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
337322

338-
given(manager.getTransaction()).willReturn(tx);
339323

340324
final List<String> l = new ArrayList<>();
341325
l.add("test");
@@ -374,8 +358,6 @@ void testParticipatingTransactionWithRequiresNewAndPrebound() {
374358
void testPropagationSupportsAndRequiresNew() {
375359
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
376360

377-
given(manager.getTransaction()).willReturn(tx);
378-
379361
final List<String> l = new ArrayList<>();
380362
l.add("test");
381363

@@ -405,10 +387,6 @@ void testPropagationSupportsAndRequiresNew() {
405387
void testPropagationSupportsAndRequiresNewAndEarlyAccess() {
406388
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
407389

408-
given(factory.createEntityManager()).willReturn(manager);
409-
given(manager.getTransaction()).willReturn(tx);
410-
given(manager.isOpen()).willReturn(true);
411-
412390
final List<String> l = new ArrayList<>();
413391
l.add("test");
414392

@@ -443,7 +421,6 @@ void testTransactionWithRequiresNewInAfterCompletion() {
443421
EntityManager manager2 = mock();
444422
EntityTransaction tx2 = mock();
445423

446-
given(manager.getTransaction()).willReturn(tx);
447424
given(factory.createEntityManager()).willReturn(manager, manager2);
448425
given(manager2.getTransaction()).willReturn(tx2);
449426
given(manager2.isOpen()).willReturn(true);
@@ -479,8 +456,6 @@ public void afterCompletion(int status) {
479456

480457
@Test
481458
void testTransactionCommitWithPropagationSupports() {
482-
given(manager.isOpen()).willReturn(true);
483-
484459
final List<String> l = new ArrayList<>();
485460
l.add("test");
486461

@@ -507,8 +482,6 @@ void testTransactionCommitWithPropagationSupports() {
507482

508483
@Test
509484
void testTransactionRollbackWithPropagationSupports() {
510-
given(manager.isOpen()).willReturn(true);
511-
512485
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
513486

514487
assertThat(TransactionSynchronizationManager.hasResource(factory)).isFalse();
@@ -532,8 +505,6 @@ void testTransactionRollbackWithPropagationSupports() {
532505

533506
@Test
534507
void testTransactionCommitWithPrebound() {
535-
given(manager.getTransaction()).willReturn(tx);
536-
537508
final List<String> l = new ArrayList<>();
538509
l.add("test");
539510

@@ -563,7 +534,6 @@ void testTransactionCommitWithPrebound() {
563534

564535
@Test
565536
void testTransactionRollbackWithPrebound() {
566-
given(manager.getTransaction()).willReturn(tx);
567537
given(tx.isActive()).willReturn(true);
568538

569539
assertThat(TransactionSynchronizationManager.hasResource(factory)).isFalse();
@@ -655,8 +625,6 @@ void testTransactionRollbackWithPreboundAndPropagationSupports() {
655625
void testInvalidIsolation() {
656626
tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
657627

658-
given(manager.isOpen()).willReturn(true);
659-
660628
assertThatExceptionOfType(InvalidIsolationLevelException.class).isThrownBy(() ->
661629
tt.execute(new TransactionCallbackWithoutResult() {
662630
@Override
@@ -669,8 +637,6 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
669637

670638
@Test
671639
void testTransactionFlush() {
672-
given(manager.getTransaction()).willReturn(tx);
673-
674640
assertThat(TransactionSynchronizationManager.hasResource(factory)).isFalse();
675641
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
676642

0 commit comments

Comments
 (0)