[SPR-6043] @NotTransactional is now deprecated
This commit is contained in:
parent
eb5d47c64e
commit
a07da0d950
|
|
@ -3,15 +3,16 @@ SPRING FRAMEWORK CHANGELOG
|
||||||
http://www.springsource.org
|
http://www.springsource.org
|
||||||
|
|
||||||
|
|
||||||
Changes in version 3.0.0.RC1 (2009 Q3)
|
Changes in version 3.0.0.RC1 (2009-09-XX)
|
||||||
--------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
* upgraded to JUnit 4.7 and TestNG 5.10
|
* upgraded to JUnit 4.7 and TestNG 5.10
|
||||||
* SpringJUnit4ClassRunner is now compatible with JUnit 4.5 - 4.7
|
* SpringJUnit4ClassRunner is now compatible with JUnit 4.5, 4.6, and 4.7
|
||||||
|
* @NotTransactional is now deprecated
|
||||||
|
|
||||||
|
|
||||||
Changes in version 3.0.0.M4 (2009-08-10)
|
Changes in version 3.0.0.M4 (2009-08-10)
|
||||||
-----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
* upgraded to JUnit 4.6, TestNG 5.9, and EasyMock 2.5.1
|
* upgraded to JUnit 4.6, TestNG 5.9, and EasyMock 2.5.1
|
||||||
* updated all Spring Framework OSGI manifests to list unversioned imports explicitly
|
* updated all Spring Framework OSGI manifests to list unversioned imports explicitly
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2007 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,14 +23,21 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test annotation to indicate that a method is not transactional.
|
* Test annotation to indicate that a method is <i>not transactional</i>.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
|
* @deprecated as of Spring 3.0, in favor of moving the non-transactional test
|
||||||
|
* method to a separate (non-transactional) test class or to a
|
||||||
|
* {@link org.springframework.test.context.transaction.BeforeTransaction
|
||||||
|
* @BeforeTransaction} or
|
||||||
|
* {@link org.springframework.test.context.transaction.AfterTransaction
|
||||||
|
* @AfterTransaction} method.
|
||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
|
@Deprecated
|
||||||
public @interface NotTransactional {
|
public @interface NotTransactional {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@
|
||||||
use, thus allowing instrumentation of tests in various environments
|
use, thus allowing instrumentation of tests in various environments
|
||||||
including JUnit, TestNG, etc.</para>
|
including JUnit, TestNG, etc.</para>
|
||||||
|
|
||||||
<note>
|
<warning>
|
||||||
<title>Legacy JUnit 3.8 class hierarchy is deprecated</title>
|
<title>Legacy JUnit 3.8 class hierarchy is deprecated</title>
|
||||||
|
|
||||||
<para>As of Spring 3.0, the legacy JUnit 3.8 base class hierarchy
|
<para>As of Spring 3.0, the legacy JUnit 3.8 base class hierarchy
|
||||||
|
|
@ -192,7 +192,7 @@
|
||||||
Thus any code which depends on the legacy JUnit 3.8 support should be
|
Thus any code which depends on the legacy JUnit 3.8 support should be
|
||||||
migrated to the <link linkend="testcontext-framework">Spring
|
migrated to the <link linkend="testcontext-framework">Spring
|
||||||
TestContext Framework</link>.</para>
|
TestContext Framework</link>.</para>
|
||||||
</note>
|
</warning>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="integration-testing-goals">
|
<section id="integration-testing-goals">
|
||||||
|
|
@ -613,6 +613,23 @@ public void afterTransaction() {
|
||||||
public void testProcessWithoutTransaction() {
|
public void testProcessWithoutTransaction() {
|
||||||
<lineannotation>// ...</lineannotation>
|
<lineannotation>// ...</lineannotation>
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
|
|
||||||
|
<warning>
|
||||||
|
<title>@NotTransactional is deprecated</title>
|
||||||
|
<para>As of Spring 3.0, <interfacename>@NotTransactional</interfacename>
|
||||||
|
is deprecated in favor of moving the
|
||||||
|
<emphasis>non-transactional</emphasis> test
|
||||||
|
method to a separate (non-transactional) test class or to a
|
||||||
|
<interfacename>@BeforeTransaction</interfacename> or
|
||||||
|
<interfacename>@AfterTransaction</interfacename> method.
|
||||||
|
As an alternative to annotating an entire class with
|
||||||
|
<interfacename>@Transactional</interfacename> consider
|
||||||
|
annotating individual methods with
|
||||||
|
<interfacename>@Transactional</interfacename>;
|
||||||
|
doing so allows a mix of transactional and non-transactional
|
||||||
|
methods in the same test class without the need for
|
||||||
|
using <interfacename>@NotTransactional</interfacename>.</para>
|
||||||
|
</warning>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
|
|
@ -1318,14 +1335,9 @@ public final class HibernateTitleDaoTests {
|
||||||
in the <link linkend="integration-testing-annotations">annotation
|
in the <link linkend="integration-testing-annotations">annotation
|
||||||
support</link> section.</para>
|
support</link> section.</para>
|
||||||
|
|
||||||
<para>There are several options for configuring transactions for
|
<para>If transactions are not enabled for the
|
||||||
individual test methods. If transactions are not enabled for the
|
|
||||||
entire test class, methods may be explicitly annotated with
|
entire test class, methods may be explicitly annotated with
|
||||||
<interfacename>@Transactional</interfacename>. Similarly, if
|
<interfacename>@Transactional</interfacename>. To control whether
|
||||||
transactions <emphasis>are</emphasis> enabled for the entire test
|
|
||||||
class, methods may be explicitly flagged not to run within a
|
|
||||||
transaction by annotating them with
|
|
||||||
<interfacename>@NotTransactional</interfacename>. To control whether
|
|
||||||
or not a transaction should commit for a particular test method, you
|
or not a transaction should commit for a particular test method, you
|
||||||
may use the <interfacename>@Rollback</interfacename> annotation to
|
may use the <interfacename>@Rollback</interfacename> annotation to
|
||||||
override the class-level default rollback setting.</para>
|
override the class-level default rollback setting.</para>
|
||||||
|
|
@ -1364,7 +1376,9 @@ public final class HibernateTitleDaoTests {
|
||||||
<interfacename>@BeforeTransaction</interfacename> or
|
<interfacename>@BeforeTransaction</interfacename> or
|
||||||
<interfacename>@AfterTransaction</interfacename> will naturally not
|
<interfacename>@AfterTransaction</interfacename> will naturally not
|
||||||
be executed for tests annotated with
|
be executed for tests annotated with
|
||||||
<interfacename>@NotTransactional</interfacename>.</para>
|
<interfacename>@NotTransactional</interfacename>. Note, however,
|
||||||
|
that <interfacename>@NotTransactional</interfacename> is
|
||||||
|
deprecated as of Spring 3.0.</para>
|
||||||
</tip>
|
</tip>
|
||||||
|
|
||||||
<para>The following JUnit 4 based example displays a fictitious
|
<para>The following JUnit 4 based example displays a fictitious
|
||||||
|
|
@ -1407,11 +1421,6 @@ public class FictitiousTransactionalTest {
|
||||||
<lineannotation>// logic to verify the final state after transaction has rolled back</lineannotation>
|
<lineannotation>// logic to verify the final state after transaction has rolled back</lineannotation>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
<emphasis role="bold">@NotTransactional</emphasis>
|
|
||||||
public void performNonDatabaseRelatedAction() {
|
|
||||||
<lineannotation>// logic which does not modify database state</lineannotation>
|
|
||||||
}
|
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue