Skip to content

Commit c4bbc9d

Browse files
committed
Migrate @TxConfig usage to @Rollback & @transactional qualifiers
Issue: SPR-13276, SPR-13277
1 parent 3f8b512 commit c4bbc9d

11 files changed

+70
-40
lines changed

spring-test/src/test/java/org/springframework/test/context/junit4/spr9645/LookUpTxMgrByTypeAndNameTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 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,7 +25,6 @@
2525
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2626
import org.springframework.test.context.transaction.AfterTransaction;
2727
import org.springframework.test.context.transaction.BeforeTransaction;
28-
import org.springframework.test.context.transaction.TransactionConfiguration;
2928
import org.springframework.tests.transaction.CallCountingTransactionManager;
3029
import org.springframework.transaction.PlatformTransactionManager;
3130
import org.springframework.transaction.annotation.Transactional;
@@ -41,8 +40,7 @@
4140
*/
4241
@RunWith(SpringJUnit4ClassRunner.class)
4342
@ContextConfiguration
44-
@Transactional
45-
@TransactionConfiguration(transactionManager = "txManager1")
43+
@Transactional("txManager1")
4644
public class LookUpTxMgrByTypeAndNameTests {
4745

4846
private static final CallCountingTransactionManager txManager1 = new CallCountingTransactionManager();

spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiredEjbTxDaoTestNGTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -16,13 +16,13 @@
1616

1717
package org.springframework.test.context.testng.transaction.ejb;
1818

19-
import org.testng.annotations.Test;
20-
2119
import org.springframework.test.context.ContextConfiguration;
22-
import org.springframework.test.context.transaction.TransactionConfiguration;
20+
import org.springframework.test.context.transaction.Commit;
2321
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2422
import org.springframework.test.context.transaction.ejb.dao.RequiredEjbTxTestEntityDao;
2523

24+
import org.testng.annotations.Test;
25+
2626
/**
2727
* Concrete subclass of {@link AbstractEjbTxDaoTestNGTests} which uses the
2828
* {@link RequiredEjbTxTestEntityDao} and sets the default rollback semantics
@@ -34,7 +34,7 @@
3434
*/
3535
@Test(suiteName = "Commit for REQUIRED")
3636
@ContextConfiguration("/org/springframework/test/context/transaction/ejb/required-tx-config.xml")
37-
@TransactionConfiguration(defaultRollback = false)
37+
@Commit
3838
public class CommitForRequiredEjbTxDaoTestNGTests extends AbstractEjbTxDaoTestNGTests {
3939

4040
/* test methods in superclass */

spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiresNewEjbTxDaoTestNGTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -16,13 +16,13 @@
1616

1717
package org.springframework.test.context.testng.transaction.ejb;
1818

19-
import org.testng.annotations.Test;
20-
2119
import org.springframework.test.context.ContextConfiguration;
22-
import org.springframework.test.context.transaction.TransactionConfiguration;
20+
import org.springframework.test.context.transaction.Commit;
2321
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2422
import org.springframework.test.context.transaction.ejb.dao.RequiresNewEjbTxTestEntityDao;
2523

24+
import org.testng.annotations.Test;
25+
2626
/**
2727
* Concrete subclass of {@link AbstractEjbTxDaoTestNGTests} which uses the
2828
* {@link RequiresNewEjbTxTestEntityDao} and sets the default rollback semantics
@@ -34,7 +34,7 @@
3434
*/
3535
@Test(suiteName = "Commit for REQUIRES_NEW")
3636
@ContextConfiguration("/org/springframework/test/context/transaction/ejb/requires-new-tx-config.xml")
37-
@TransactionConfiguration(defaultRollback = false)
37+
@Commit
3838
public class CommitForRequiresNewEjbTxDaoTestNGTests extends AbstractEjbTxDaoTestNGTests {
3939

4040
/* test methods in superclass */

spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiredEjbTxDaoTestNGTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -16,11 +16,11 @@
1616

1717
package org.springframework.test.context.testng.transaction.ejb;
1818

19-
import org.testng.annotations.Test;
20-
21-
import org.springframework.test.context.transaction.TransactionConfiguration;
19+
import org.springframework.test.annotation.Rollback;
2220
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2321

22+
import org.testng.annotations.Test;
23+
2424
import static org.testng.AssertJUnit.*;
2525

2626
/**
@@ -35,7 +35,7 @@
3535
* @since 4.0.1
3636
*/
3737
@Test(suiteName = "Rollback for REQUIRED")
38-
@TransactionConfiguration(defaultRollback = true)
38+
@Rollback
3939
public class RollbackForRequiredEjbTxDaoTestNGTests extends CommitForRequiredEjbTxDaoTestNGTests {
4040

4141
/**

spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiresNewEjbTxDaoTestNGTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -16,11 +16,11 @@
1616

1717
package org.springframework.test.context.testng.transaction.ejb;
1818

19-
import org.testng.annotations.Test;
20-
21-
import org.springframework.test.context.transaction.TransactionConfiguration;
19+
import org.springframework.test.annotation.Rollback;
2220
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2321

22+
import org.testng.annotations.Test;
23+
2424
/**
2525
* Extension of {@link CommitForRequiresNewEjbTxDaoTestNGTests} which sets the default
2626
* rollback semantics for the {@link TransactionalTestExecutionListener} to
@@ -37,7 +37,7 @@
3737
* @since 4.0.1
3838
*/
3939
@Test(suiteName = "Rollback for REQUIRES_NEW")
40-
@TransactionConfiguration(defaultRollback = true)
40+
@Rollback
4141
public class RollbackForRequiresNewEjbTxDaoTestNGTests extends CommitForRequiresNewEjbTxDaoTestNGTests {
4242

4343
/* test methods in superclass */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2002-2015 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.test.context.transaction;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.Target;
22+
23+
import org.springframework.test.annotation.Rollback;
24+
25+
import static java.lang.annotation.ElementType.*;
26+
import static java.lang.annotation.RetentionPolicy.*;
27+
28+
/**
29+
* @author Sam Brannen
30+
* @since 4.2
31+
*/
32+
@Documented
33+
@Retention(RUNTIME)
34+
@Target({ TYPE, METHOD, ANNOTATION_TYPE })
35+
@Rollback(false)
36+
public @interface Commit {
37+
}

spring-test/src/test/java/org/springframework/test/context/transaction/TransactionalTestExecutionListenerTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,6 @@ public void isRollbackWithRollbackAndTransactionConfigurationDeclaredAtClassLeve
355355
String transactionManager() default "metaTxMgr";
356356
}
357357

358-
@Rollback(false)
359-
@Retention(RetentionPolicy.RUNTIME)
360-
private static @interface Commit {
361-
}
362-
363358
private static abstract class Invocable {
364359

365360
boolean invoked = false;

spring-test/src/test/java/org/springframework/test/context/transaction/ejb/CommitForRequiredEjbTxDaoTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.test.context.transaction.ejb;
1818

1919
import org.springframework.test.context.ContextConfiguration;
20-
import org.springframework.test.context.transaction.TransactionConfiguration;
20+
import org.springframework.test.context.transaction.Commit;
2121
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2222
import org.springframework.test.context.transaction.ejb.dao.RequiredEjbTxTestEntityDao;
2323

@@ -31,7 +31,7 @@
3131
* @since 4.0.1
3232
*/
3333
@ContextConfiguration("required-tx-config.xml")
34-
@TransactionConfiguration(defaultRollback = false)
34+
@Commit
3535
public class CommitForRequiredEjbTxDaoTests extends AbstractEjbTxDaoTests {
3636

3737
/* test methods in superclass */

spring-test/src/test/java/org/springframework/test/context/transaction/ejb/CommitForRequiresNewEjbTxDaoTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -17,7 +17,7 @@
1717
package org.springframework.test.context.transaction.ejb;
1818

1919
import org.springframework.test.context.ContextConfiguration;
20-
import org.springframework.test.context.transaction.TransactionConfiguration;
20+
import org.springframework.test.context.transaction.Commit;
2121
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2222
import org.springframework.test.context.transaction.ejb.dao.RequiresNewEjbTxTestEntityDao;
2323

@@ -31,7 +31,7 @@
3131
* @since 4.0.1
3232
*/
3333
@ContextConfiguration("requires-new-tx-config.xml")
34-
@TransactionConfiguration(defaultRollback = false)
34+
@Commit
3535
public class CommitForRequiresNewEjbTxDaoTests extends AbstractEjbTxDaoTests {
3636

3737
/* test methods in superclass */

spring-test/src/test/java/org/springframework/test/context/transaction/ejb/RollbackForRequiredEjbTxDaoTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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,7 +20,7 @@
2020
import org.junit.Test;
2121
import org.junit.runners.MethodSorters;
2222

23-
import org.springframework.test.context.transaction.TransactionConfiguration;
23+
import org.springframework.test.annotation.Rollback;
2424
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
2525

2626
import static org.junit.Assert.*;
@@ -37,7 +37,7 @@
3737
* @since 4.0.1
3838
*/
3939
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
40-
@TransactionConfiguration(defaultRollback = true)
40+
@Rollback
4141
public class RollbackForRequiredEjbTxDaoTests extends CommitForRequiredEjbTxDaoTests {
4242

4343
/**

0 commit comments

Comments
 (0)