提交 966d9513 编写于 作者: S Sam Brannen

Remove deprecated @TransactionConfiguration & TxCfgAttributes

Issue: SPR-14430
上级 57c43f42
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.context.transaction;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* {@code TransactionConfiguration} defines class-level metadata for configuring
* transactional tests.
*
* <p>As of Spring Framework 4.0, this annotation may be used as a
* <em>meta-annotation</em> to create custom <em>composed annotations</em>.
*
* @author Sam Brannen
* @since 2.5
* @see TransactionalTestExecutionListener
* @see org.springframework.transaction.annotation.Transactional
* @see org.springframework.test.annotation.Commit
* @see org.springframework.test.annotation.Rollback
* @see org.springframework.test.context.jdbc.Sql
* @see org.springframework.test.context.jdbc.SqlConfig
* @see org.springframework.test.context.jdbc.SqlConfig#transactionManager
* @see org.springframework.test.context.ContextConfiguration
* @deprecated As of Spring Framework 4.2, use {@code @Rollback} or
* {@code @Commit} at the class level and the {@code transactionManager}
* qualifier in {@code @Transactional}.
*/
@Deprecated
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface TransactionConfiguration {
/**
* The bean name of the {@link org.springframework.transaction.PlatformTransactionManager
* PlatformTransactionManager} that should be used to drive <em>test-managed transactions</em>.
*
* <p>The name is only used if there is more than one bean of type
* {@code PlatformTransactionManager} in the test's {@code ApplicationContext}.
* If there is only one such bean, it is not necessary to specify a bean name.
*
* <p>Defaults to an empty string, requiring that one of the following is
* true:
* <ol>
* <li>There is only one bean of type {@code PlatformTransactionManager} in
* the test's {@code ApplicationContext}.</li>
* <li>{@link org.springframework.transaction.annotation.TransactionManagementConfigurer
* TransactionManagementConfigurer} has been implemented to specify which
* {@code PlatformTransactionManager} bean should be used for annotation-driven
* transaction management.</li>
* <li>The {@code PlatformTransactionManager} to use is named
* {@code "transactionManager"}.</li>
* </ol>
*
* <p><b>NOTE:</b> The XML {@code <tx:annotation-driven>} element also refers
* to a bean named {@code "transactionManager"} by default. If you are using both
* features in combination, make sure to point to the same transaction manager
* bean &mdash; here in {@code @TransactionConfiguration} and also in
* {@code <tx:annotation-driven transaction-manager="...">}.
*/
String transactionManager() default "";
/**
* Whether <em>test-managed transactions</em> should be rolled back by default.
*/
boolean defaultRollback() default true;
}
/*
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.context.transaction;
import org.springframework.core.style.ToStringCreator;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
/**
* Configuration attributes for configuring transactional tests.
*
* @author Sam Brannen
* @author Juergen Hoeller
* @since 2.5
* @see TransactionConfiguration
* @deprecated As of Spring Framework 4.2, this class is officially deprecated
* and will be removed when {@code @TransactionConfiguration} is removed.
*/
@Deprecated
public class TransactionConfigurationAttributes {
private final String transactionManagerName;
private final boolean defaultRollback;
/**
* Construct a new {@code TransactionConfigurationAttributes} instance
* using an empty string for the bean name of the
* {@link PlatformTransactionManager} and {@code true} for the default
* rollback flag.
* @see #TransactionConfigurationAttributes(String, boolean)
*/
public TransactionConfigurationAttributes() {
this("", true);
}
/**
* Construct a new {@code TransactionConfigurationAttributes} instance
* from the supplied arguments.
* @param transactionManagerName the bean name of the
* {@link PlatformTransactionManager} that is to be used to drive
* <em>test-managed transactions</em>
* @param defaultRollback whether or not <em>test-managed transactions</em>
* should be rolled back by default
*/
public TransactionConfigurationAttributes(String transactionManagerName, boolean defaultRollback) {
Assert.notNull(transactionManagerName, "transactionManagerName must not be null");
this.transactionManagerName = transactionManagerName;
this.defaultRollback = defaultRollback;
}
/**
* Get the bean name of the {@link PlatformTransactionManager} that is to
* be used to drive <em>test-managed transactions</em>.
*/
public final String getTransactionManagerName() {
return this.transactionManagerName;
}
/**
* Whether <em>test-managed transactions</em> should be rolled back by default.
* @return the <em>default rollback</em> flag
*/
public final boolean isDefaultRollback() {
return this.defaultRollback;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("transactionManagerName", this.transactionManagerName)
.append("defaultRollback", this.defaultRollback)
.toString();
}
}
......@@ -132,16 +132,9 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
private static final Log logger = LogFactory.getLog(TransactionalTestExecutionListener.class);
@SuppressWarnings("deprecation")
private static final TransactionConfigurationAttributes defaultTxConfigAttributes = new TransactionConfigurationAttributes();
// Do not require @Transactional test methods to be public.
protected final TransactionAttributeSource attributeSource = new AnnotationTransactionAttributeSource(false);
@SuppressWarnings("deprecation")
private TransactionConfigurationAttributes configurationAttributes;
/**
* Returns {@code 4000}.
*/
......@@ -356,33 +349,23 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
* @see #getTransactionManager(TestContext, String)
*/
protected PlatformTransactionManager getTransactionManager(TestContext testContext) {
@SuppressWarnings("deprecation")
String tmName = retrieveConfigurationAttributes(testContext).getTransactionManagerName();
return TestContextTransactionUtils.retrieveTransactionManager(testContext, tmName);
return TestContextTransactionUtils.retrieveTransactionManager(testContext, null);
}
/**
* Determine whether or not to rollback transactions by default for the
* supplied {@linkplain TestContext test context}.
* <p>Supports {@link Rollback @Rollback}, {@link Commit @Commit}, or
* {@link TransactionConfiguration @TransactionConfiguration} at the
* <p>Supports {@link Rollback @Rollback} or {@link Commit @Commit} at the
* class-level.
* @param testContext the test context for which the default rollback flag
* should be retrieved
* @return the <em>default rollback</em> flag for the supplied test context
* @throws Exception if an error occurs while determining the default rollback flag
*/
@SuppressWarnings("deprecation")
protected final boolean isDefaultRollback(TestContext testContext) throws Exception {
Class<?> testClass = testContext.getTestClass();
Rollback rollback = AnnotatedElementUtils.findMergedAnnotation(testClass, Rollback.class);
boolean rollbackPresent = (rollback != null);
TransactionConfigurationAttributes txConfigAttributes = retrieveConfigurationAttributes(testContext);
if (rollbackPresent && txConfigAttributes != defaultTxConfigAttributes) {
throw new IllegalStateException(String.format("Test class [%s] is annotated with both @Rollback "
+ "and @TransactionConfiguration, but only one is permitted.", testClass.getName()));
}
if (rollbackPresent) {
boolean defaultRollback = rollback.value();
......@@ -394,7 +377,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
}
// else
return txConfigAttributes.isDefaultRollback();
return true;
}
/**
......@@ -447,41 +430,4 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
.collect(Collectors.toList());
}
/**
* Retrieve the {@link TransactionConfigurationAttributes} for the
* supplied {@link TestContext} whose {@linkplain Class test class}
* may optionally declare or inherit
* {@link TransactionConfiguration @TransactionConfiguration}.
* <p>If {@code @TransactionConfiguration} is not present for the
* supplied {@code TestContext}, a default instance of
* {@code TransactionConfigurationAttributes} will be used instead.
* @param testContext the test context for which the configuration
* attributes should be retrieved
* @return the TransactionConfigurationAttributes instance for this listener,
* potentially cached
* @see TransactionConfigurationAttributes#TransactionConfigurationAttributes()
*/
@SuppressWarnings("deprecation")
TransactionConfigurationAttributes retrieveConfigurationAttributes(TestContext testContext) {
if (this.configurationAttributes == null) {
Class<?> clazz = testContext.getTestClass();
TransactionConfiguration txConfig =
AnnotatedElementUtils.findMergedAnnotation(clazz, TransactionConfiguration.class);
if (logger.isDebugEnabled()) {
logger.debug(String.format("Retrieved @TransactionConfiguration [%s] for test class [%s].",
txConfig, clazz.getName()));
}
TransactionConfigurationAttributes configAttributes = (txConfig == null ? defaultTxConfigAttributes :
new TransactionConfigurationAttributes(txConfig.transactionManager(), txConfig.defaultRollback()));
if (logger.isDebugEnabled()) {
logger.debug(String.format("Using TransactionConfigurationAttributes %s for test class [%s].",
configAttributes, clazz.getName()));
}
this.configurationAttributes = configAttributes;
}
return this.configurationAttributes;
}
}
/*
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.context.junit4;
import javax.sql.DataSource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.Assert.*;
import static org.springframework.test.transaction.TransactionTestUtils.*;
/**
* JUnit 4 based integration test which verifies proper transactional behavior when the
* {@link TransactionConfiguration#defaultRollback() defaultRollback} attribute
* of the {@link TransactionConfiguration} annotation is set to <strong>{@code false}</strong>.
*
* <p>Also tests configuration of the
* {@link TransactionConfiguration#transactionManager() transaction manager name}.
*
* @author Sam Brannen
* @since 2.5
* @see TransactionConfiguration
* @see DefaultRollbackFalseRollbackAnnotationTransactionalTests
*/
@TransactionConfiguration(transactionManager = "transactionManager2", defaultRollback = false)
@Transactional
@SuppressWarnings("deprecation")
public class DefaultRollbackFalseTransactionalTests extends AbstractTransactionalSpringRunnerTests {
private static JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("dataSource2")
public void setDataSource(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Before
public void verifyInitialTestData() {
clearPersonTable(jdbcTemplate);
assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB));
assertEquals("Verifying the initial number of rows in the person table.", 1,
countRowsInPersonTable(jdbcTemplate));
}
@Test
public void modifyTestDataWithinTransaction() {
assertInTransaction(true);
assertEquals("Deleting bob", 1, deletePerson(jdbcTemplate, BOB));
assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE));
assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE));
assertEquals("Verifying the number of rows in the person table within a transaction.", 2,
countRowsInPersonTable(jdbcTemplate));
}
@AfterClass
public static void verifyFinalTestData() {
assertEquals("Verifying the final number of rows in the person table after all tests.", 2,
countRowsInPersonTable(jdbcTemplate));
}
}
/*
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.context.junit4;
import javax.sql.DataSource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.Assert.*;
import static org.springframework.test.transaction.TransactionTestUtils.*;
/**
* JUnit 4 based integration test which verifies proper transactional behavior when the
* {@link TransactionConfiguration#defaultRollback() defaultRollback} attribute
* of the {@link TransactionConfiguration} annotation is set to <strong>{@code true}</strong>.
*
* @author Sam Brannen
* @since 2.5
* @see TransactionConfiguration
*/
@Transactional
@TransactionConfiguration(defaultRollback = true)
@SuppressWarnings("deprecation")
public class DefaultRollbackTrueTransactionalTests extends AbstractTransactionalSpringRunnerTests {
private static int originalNumRows;
private static JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Before
public void verifyInitialTestData() {
originalNumRows = clearPersonTable(jdbcTemplate);
assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB));
assertEquals("Verifying the initial number of rows in the person table.", 1,
countRowsInPersonTable(jdbcTemplate));
}
@Test(timeout = 1000)
public void modifyTestDataWithinTransaction() {
assertInTransaction(true);
assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE));
assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE));
assertEquals("Verifying the number of rows in the person table within a transaction.", 3,
countRowsInPersonTable(jdbcTemplate));
}
@AfterClass
public static void verifyFinalTestData() {
assertEquals("Verifying the final number of rows in the person table after all tests.", originalNumRows,
countRowsInPersonTable(jdbcTemplate));
}
}
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -23,7 +23,6 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.annotation.Rollback;
......@@ -31,15 +30,16 @@ import static org.junit.Assert.*;
import static org.springframework.test.transaction.TransactionTestUtils.*;
/**
* Extension of {@link DefaultRollbackFalseTransactionalTests} which
* tests method-level <em>rollback override</em> behavior via the
* Extension of {@link DefaultRollbackFalseRollbackAnnotationTransactionalTests}
* which tests method-level <em>rollback override</em> behavior via the
* {@link Rollback @Rollback} annotation.
*
* @author Sam Brannen
* @since 2.5
* @see Rollback
*/
public class RollbackOverrideDefaultRollbackFalseTransactionalTests extends DefaultRollbackFalseTransactionalTests {
public class RollbackOverrideDefaultRollbackFalseTransactionalTests
extends DefaultRollbackFalseRollbackAnnotationTransactionalTests {
private static int originalNumRows;
......@@ -47,7 +47,6 @@ public class RollbackOverrideDefaultRollbackFalseTransactionalTests extends Defa
@Autowired
@Qualifier("dataSource2")
@Override
public void setDataSource(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
......
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -30,15 +30,16 @@ import static org.junit.Assert.*;
import static org.springframework.test.transaction.TransactionTestUtils.*;
/**
* Extension of {@link DefaultRollbackTrueTransactionalTests} which
* tests method-level <em>rollback override</em> behavior via the
* Extension of {@link DefaultRollbackTrueRollbackAnnotationTransactionalTests}
* which tests method-level <em>rollback override</em> behavior via the
* {@link Rollback @Rollback} annotation.
*
* @author Sam Brannen
* @since 2.5
* @see Rollback
*/
public class RollbackOverrideDefaultRollbackTrueTransactionalTests extends DefaultRollbackTrueTransactionalTests {
public class RollbackOverrideDefaultRollbackTrueTransactionalTests
extends DefaultRollbackTrueRollbackAnnotationTransactionalTests {
private static JdbcTemplate jdbcTemplate;
......
......@@ -104,8 +104,8 @@ StandardJUnit4FeaturesTests.class,//
ConcreteTransactionalJUnit4SpringContextTests.class,//
ClassLevelTransactionalSpringRunnerTests.class,//
MethodLevelTransactionalSpringRunnerTests.class,//
DefaultRollbackTrueTransactionalTests.class,//
DefaultRollbackFalseTransactionalTests.class,//
DefaultRollbackTrueRollbackAnnotationTransactionalTests.class,//
DefaultRollbackFalseRollbackAnnotationTransactionalTests.class,//
RollbackOverrideDefaultRollbackTrueTransactionalTests.class,//
RollbackOverrideDefaultRollbackFalseTransactionalTests.class,//
BeforeAndAfterTransactionAnnotationTests.class,//
......
......@@ -36,7 +36,6 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.SimpleTransactionStatus;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
import static org.springframework.transaction.annotation.Propagation.*;
......@@ -47,7 +46,6 @@ import static org.springframework.transaction.annotation.Propagation.*;
* @author Sam Brannen
* @since 4.0
*/
@SuppressWarnings("deprecation")
public class TransactionalTestExecutionListenerTests {
private final PlatformTransactionManager tm = mock(PlatformTransactionManager.class);
......@@ -135,16 +133,6 @@ public class TransactionalTestExecutionListenerTests {
assertFalse("callback should not have been invoked", instance.invoked());
}
private void assertTransactionConfigurationAttributes(Class<?> clazz, String transactionManagerName,
boolean defaultRollback) {
BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
TransactionConfigurationAttributes attributes = listener.retrieveConfigurationAttributes(testContext);
assertNotNull(attributes);
assertEquals(transactionManagerName, attributes.getTransactionManagerName());
assertEquals(defaultRollback, attributes.isDefaultRollback());
}
private void assertIsRollback(Class<?> clazz, boolean rollback) throws NoSuchMethodException, Exception {
BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("test"));
......@@ -255,70 +243,6 @@ public class TransactionalTestExecutionListenerTests {
assertAfterTestMethod(AfterTransactionDeclaredAsInterfaceDefaultMethodTestCase.class);
}
@Test
public void retrieveConfigurationAttributesWithMissingTransactionConfiguration() throws Exception {
assertTransactionConfigurationAttributes(MissingTransactionConfigurationTestCase.class, "", true);
}
@Test
public void retrieveConfigurationAttributesWithEmptyTransactionConfiguration() throws Exception {
assertTransactionConfigurationAttributes(EmptyTransactionConfigurationTestCase.class, "", true);
}
@Test
public void retrieveConfigurationAttributesWithExplicitValues() throws Exception {
assertTransactionConfigurationAttributes(TransactionConfigurationWithExplicitValuesTestCase.class, "tm", false);
}
@Test
public void retrieveConfigurationAttributesViaMetaAnnotation() throws Exception {
assertTransactionConfigurationAttributes(TransactionConfigurationViaMetaAnnotationTestCase.class, "metaTxMgr",
true);
}
@Test
public void retrieveConfigurationAttributesViaMetaAnnotationWithOverride() throws Exception {
assertTransactionConfigurationAttributes(TransactionConfigurationViaMetaAnnotationWithOverrideTestCase.class,
"overriddenTxMgr", true);
}
@Test
public void retrieveConfigurationAttributesWithEmptyTransactionalAnnotation() throws Exception {
assertTransactionConfigurationAttributes(EmptyTransactionalTestCase.class, "", true);
}
@Test
public void retrieveConfigurationAttributesFromTransactionalAnnotationWithExplicitQualifier() throws Exception {
// The test class configures "tm" as the qualifier via @Transactional;
// however, retrieveConfigurationAttributes() only supports
// @TransactionConfiguration. So we actually expect "" as the qualifier here,
// relying on beforeTestMethod() to properly obtain the actual qualifier via the
// TransactionAttribute.
assertTransactionConfigurationAttributes(TransactionalWithExplicitQualifierTestCase.class, "", true);
}
@Test
public void retrieveConfigurationAttributesFromTransactionalAnnotationViaMetaAnnotation() throws Exception {
// The test class configures "metaTxMgr" as the qualifier via @Transactional;
// however, retrieveConfigurationAttributes() only supports
// @TransactionConfiguration. So we actually expect "" as the qualifier here,
// relying on beforeTestMethod() to properly obtain the actual qualifier via the
// TransactionAttribute.
assertTransactionConfigurationAttributes(TransactionalViaMetaAnnotationTestCase.class, "", true);
}
@Test
public void retrieveConfigurationAttributesFromTransactionalAnnotationViaMetaAnnotationWithExplicitQualifier()
throws Exception {
// The test class configures "overriddenTxMgr" as the qualifier via
// @Transactional; however, retrieveConfigurationAttributes() only supports
// @TransactionConfiguration. So we actually expect "" as the qualifier here,
// relying on beforeTestMethod() to properly obtain the actual qualifier via the
// TransactionAttribute.
assertTransactionConfigurationAttributes(TransactionalViaMetaAnnotationWithExplicitQualifierTestCase.class, "",
true);
}
@Test
public void isRollbackWithMissingRollback() throws Exception {
assertIsRollback(MissingRollbackTestCase.class, true);
......@@ -364,16 +288,6 @@ public class TransactionalTestExecutionListenerTests {
assertIsRollback(ClassLevelRollbackViaMetaAnnotationOnTestInterfaceTestCase.class, false);
}
@Test
public void isRollbackWithRollbackAndTransactionConfigurationDeclaredAtClassLevel() throws Exception {
Class<?> clazz = ClassLevelRollbackAndTransactionConfigurationTestCase.class;
BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
exception.expect(IllegalStateException.class);
exception.expectMessage(containsString("annotated with both @Rollback and @TransactionConfiguration, but only one is permitted"));
listener.isRollback(testContext);
}
// -------------------------------------------------------------------------
......@@ -402,13 +316,6 @@ public class TransactionalTestExecutionListenerTests {
private static @interface MetaAfterTransaction {
}
@TransactionConfiguration
@Retention(RetentionPolicy.RUNTIME)
private static @interface MetaTxConfig {
String transactionManager() default "metaTxMgr";
}
private interface Invocable {
void invoked(boolean invoked);
......@@ -632,41 +539,6 @@ public class TransactionalTestExecutionListenerTests {
}
}
static class MissingTransactionConfigurationTestCase {
}
@TransactionConfiguration
static class EmptyTransactionConfigurationTestCase {
}
@TransactionConfiguration(transactionManager = "tm", defaultRollback = false)
static class TransactionConfigurationWithExplicitValuesTestCase {
}
@MetaTxConfig
static class TransactionConfigurationViaMetaAnnotationTestCase {
}
@MetaTxConfig(transactionManager = "overriddenTxMgr")
static class TransactionConfigurationViaMetaAnnotationWithOverrideTestCase {
}
@Transactional
static class EmptyTransactionalTestCase {
}
@Transactional(transactionManager = "tm")
static class TransactionalWithExplicitQualifierTestCase {
}
@MetaTransactional
static class TransactionalViaMetaAnnotationTestCase {
}
@MetaTxWithOverride(transactionManager = "tm")
static class TransactionalViaMetaAnnotationWithExplicitQualifierTestCase {
}
static class MissingRollbackTestCase {
public void test() {
......@@ -694,14 +566,6 @@ public class TransactionalTestExecutionListenerTests {
}
}
@Rollback
@TransactionConfiguration
static class ClassLevelRollbackAndTransactionConfigurationTestCase {
public void test() {
}
}
@Rollback
static class EmptyClassLevelRollbackTestCase {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册