Delete deprecated code in the TestContext framework
This commit deletes the deprecated @ExpectedException and @NotTransactional annotations, supporting code, and related Javadoc and reference documentation. Issue: SPR-10499
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -18,21 +18,18 @@ package org.springframework.test.context.junit4;
|
||||
|
||||
import org.springframework.jdbc.BadSqlGrammarException;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.test.annotation.NotTransactional;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Abstract base class for verifying support of Spring's {@link Transactional
|
||||
* @Transactional} and {@link NotTransactional @NotTransactional}
|
||||
* annotations.
|
||||
* @Transactional} annotation.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see ClassLevelTransactionalSpringRunnerTests
|
||||
* @see MethodLevelTransactionalSpringRunnerTests
|
||||
* @see Transactional
|
||||
* @see NotTransactional
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@ContextConfiguration("transactionalTests-context.xml")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -27,20 +27,19 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.test.annotation.NotTransactional;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListener;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
|
||||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* JUnit 4 based integration test which verifies support of Spring's
|
||||
* {@link Transactional @Transactional}, {@link NotTransactional
|
||||
* @NotTransactional}, {@link TestExecutionListeners
|
||||
* {@link Transactional @Transactional}, {@link TestExecutionListeners
|
||||
* @TestExecutionListeners}, and {@link ContextConfiguration
|
||||
* @ContextConfiguration} annotations in conjunction with the
|
||||
* {@link SpringJUnit4ClassRunner} and the following
|
||||
@@ -94,7 +93,7 @@ public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactio
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void modifyTestDataWithoutTransaction() {
|
||||
assertInTransaction(false);
|
||||
assertEquals("Adding luke", 1, addPerson(simpleJdbcTemplate, LUKE));
|
||||
|
||||
@@ -36,11 +36,12 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.BadSqlGrammarException;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.test.annotation.NotTransactional;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Combined integration test for {@link AbstractJUnit4SpringContextTests} and
|
||||
@@ -131,7 +132,7 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyApplicationContext() {
|
||||
assertInTransaction(false);
|
||||
assertNotNull("The application context should have been set due to ApplicationContextAware semantics.",
|
||||
@@ -139,7 +140,7 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyBeanInitialized() {
|
||||
assertInTransaction(false);
|
||||
assertTrue("This test bean should have been initialized due to InitializingBean semantics.",
|
||||
@@ -147,7 +148,7 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyBeanNameSet() {
|
||||
assertInTransaction(false);
|
||||
assertEquals("The bean name of this test instance should have been set to the fully qualified class name "
|
||||
@@ -155,7 +156,7 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyAnnotationAutowiredFields() {
|
||||
assertInTransaction(false);
|
||||
assertNull("The nonrequiredLong property should NOT have been autowired.", this.nonrequiredLong);
|
||||
@@ -164,7 +165,7 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyAnnotationAutowiredMethods() {
|
||||
assertInTransaction(false);
|
||||
assertNotNull("The employee setter method should have been autowired.", this.employee);
|
||||
@@ -172,14 +173,14 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyResourceAnnotationWiredFields() {
|
||||
assertInTransaction(false);
|
||||
assertEquals("The foo field should have been wired via @Resource.", "Foo", this.foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public final void verifyResourceAnnotationWiredMethods() {
|
||||
assertInTransaction(false);
|
||||
assertEquals("The bar method should have been wired via @Resource.", "Bar", this.bar);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -25,7 +25,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runner.notification.RunNotifier;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.springframework.test.annotation.ExpectedException;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
/**
|
||||
@@ -33,7 +32,6 @@ import org.springframework.test.context.TestExecutionListeners;
|
||||
* {@link SpringJUnit4ClassRunner}:
|
||||
* <ul>
|
||||
* <li>JUnit's {@link Test#expected() @Test(expected=...)}</li>
|
||||
* <li>Spring's {@link ExpectedException @ExpectedException}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Sam Brannen
|
||||
@@ -51,11 +49,11 @@ public class ExpectedExceptionSpringRunnerTests {
|
||||
notifier.addListener(listener);
|
||||
|
||||
new SpringJUnit4ClassRunner(testClass).run(notifier);
|
||||
assertEquals("Verifying number of failures for test class [" + testClass + "].", 1,
|
||||
assertEquals("Verifying number of failures for test class [" + testClass + "].", 0,
|
||||
listener.getTestFailureCount());
|
||||
assertEquals("Verifying number of tests started for test class [" + testClass + "].", 3,
|
||||
assertEquals("Verifying number of tests started for test class [" + testClass + "].", 1,
|
||||
listener.getTestStartedCount());
|
||||
assertEquals("Verifying number of tests finished for test class [" + testClass + "].", 3,
|
||||
assertEquals("Verifying number of tests finished for test class [" + testClass + "].", 1,
|
||||
listener.getTestFinishedCount());
|
||||
}
|
||||
|
||||
@@ -71,20 +69,6 @@ public class ExpectedExceptionSpringRunnerTests {
|
||||
new ArrayList<Object>().get(1);
|
||||
}
|
||||
|
||||
// Should Pass.
|
||||
@Test
|
||||
@ExpectedException(IndexOutOfBoundsException.class)
|
||||
public void verifySpringExpectedException() {
|
||||
new ArrayList<Object>().get(1);
|
||||
}
|
||||
|
||||
// Should Fail due to duplicate configuration.
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@ExpectedException(IllegalStateException.class)
|
||||
public void verifyJUnitAndSpringExpectedException() {
|
||||
new ArrayList<Object>().get(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -20,17 +20,17 @@ import static org.springframework.test.transaction.TransactionTestUtils.assertIn
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.annotation.NotTransactional;
|
||||
import org.springframework.test.annotation.Repeat;
|
||||
import org.springframework.test.annotation.Timed;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* JUnit 4 based integration test which verifies support of Spring's
|
||||
* {@link Transactional @Transactional} and {@link NotTransactional
|
||||
* @NotTransactional} annotations in conjunction with {@link Timed
|
||||
* @Timed} and JUnit 4's {@link Test#timeout() timeout} attribute.
|
||||
* {@link Transactional @Transactional} annotation in conjunction
|
||||
* with {@link Timed @Timed} and JUnit 4's {@link Test#timeout()
|
||||
* timeout} attribute.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
@@ -55,7 +55,7 @@ public class TimedTransactionalSpringRunnerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
@Timed(millis = 10000)
|
||||
@Repeat(5)
|
||||
public void notTransactionalWithSpringTimeout() {
|
||||
@@ -63,7 +63,7 @@ public class TimedTransactionalSpringRunnerTests {
|
||||
}
|
||||
|
||||
@Test(timeout = 10000)
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
@Repeat(5)
|
||||
public void notTransactionalWithJUnitTimeout() {
|
||||
assertInTransaction(false);
|
||||
|
||||
@@ -30,11 +30,12 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.test.annotation.NotTransactional;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@@ -111,7 +112,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void autowiringFromConfigClass() {
|
||||
assertNotNull(employee, "The employee should have been autowired.");
|
||||
assertEquals(employee.getName(), "John Smith");
|
||||
|
||||
@@ -30,10 +30,11 @@ import org.springframework.tests.sample.beans.Pet;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.NotTransactional;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@@ -136,7 +137,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyApplicationContextSet() {
|
||||
assertInTransaction(false);
|
||||
assertNotNull(super.applicationContext,
|
||||
@@ -146,7 +147,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyBeanInitialized() {
|
||||
assertInTransaction(false);
|
||||
assertTrue(beanInitialized,
|
||||
@@ -154,7 +155,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyBeanNameSet() {
|
||||
assertInTransaction(false);
|
||||
assertEquals(beanName, getClass().getName(),
|
||||
@@ -162,7 +163,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyAnnotationAutowiredFields() {
|
||||
assertInTransaction(false);
|
||||
assertNull(nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
|
||||
@@ -171,7 +172,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyAnnotationAutowiredMethods() {
|
||||
assertInTransaction(false);
|
||||
assertNotNull(employee, "The setEmployee() method should have been autowired.");
|
||||
@@ -179,14 +180,14 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyResourceAnnotationInjectedFields() {
|
||||
assertInTransaction(false);
|
||||
assertEquals(foo, "Foo", "The foo field should have been injected via @Resource.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotTransactional
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void verifyResourceAnnotationInjectedMethods() {
|
||||
assertInTransaction(false);
|
||||
assertEquals(bar, "Bar", "The setBar() method should have been injected via @Resource.");
|
||||
|
||||
Reference in New Issue
Block a user