[SPR-4702] Reference manual updates

This commit is contained in:
Sam Brannen 2009-07-06 18:04:37 +00:00
parent 1f087b412d
commit e77e070e7a
1 changed files with 30 additions and 9 deletions

View File

@ -409,7 +409,7 @@
<emphasis>Spring-specific</emphasis> annotations that you can use in <emphasis>Spring-specific</emphasis> annotations that you can use in
your unit and integration tests in conjunction with the TestContext your unit and integration tests in conjunction with the TestContext
framework. Refer to the respective JavaDoc for further information, framework. Refer to the respective JavaDoc for further information,
including default attribute values, etc.</para> including default attribute values, attribute aliases, etc.</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
@ -419,10 +419,10 @@
<para>Defines class-level metadata which is used to determine how to <para>Defines class-level metadata which is used to determine how to
load and configure an load and configure an
<interfacename>ApplicationContext</interfacename>. Specifically, <interfacename>ApplicationContext</interfacename>. Specifically,
@ContextConfiguration defines the application context resource <interfacename>@ContextConfiguration</interfacename> defines the
<literal>locations</literal> to load as well as the application context resource <literal>locations</literal> to
<interfacename>ContextLoader</interfacename> strategy to use for load as well as the <interfacename>ContextLoader</interfacename>
loading the context.</para> strategy to use for loading the context.</para>
<programlisting language="java">@ContextConfiguration(locations={"example/test-context.xml"}, loader=CustomContextLoader.class) <programlisting language="java">@ContextConfiguration(locations={"example/test-context.xml"}, loader=CustomContextLoader.class)
public class CustomConfiguredApplicationContextTests { public class CustomConfiguredApplicationContextTests {
@ -442,16 +442,37 @@ public class CustomConfiguredApplicationContextTests {
role="bold"><interfacename>@DirtiesContext</interfacename></emphasis></para> role="bold"><interfacename>@DirtiesContext</interfacename></emphasis></para>
<para>The presence of this annotation on a test method indicates <para>The presence of this annotation on a test method indicates
that the underlying Spring container is 'dirtied' during the that the underlying Spring container has been <emphasis>dirtied</emphasis>
execution of the test method, and thus must be rebuilt after the during the execution of the test method and thus must be closed after the
test method finishes execution (regardless of whether the test test method finishes execution (regardless of whether the annotated test
passed or not).</para> passed or not). Similarly, if a test class is annotated with
<interfacename>@DirtiesContext</interfacename>, the underlying
Spring container will be marked as dirty after all tests in the
class have completed execution.</para>
<programlisting language="java">@DirtiesContext
public class ContextDirtyingTests {
<lineannotation>// some tests that result in the Spring container being dirtied</lineannotation>
}</programlisting>
<programlisting language="java">@DirtiesContext <programlisting language="java">@DirtiesContext
@Test @Test
public void testProcessWhichDirtiesAppCtx() { public void testProcessWhichDirtiesAppCtx() {
<lineannotation>// some logic that results in the Spring container being dirtied</lineannotation> <lineannotation>// some logic that results in the Spring container being dirtied</lineannotation>
}</programlisting> }</programlisting>
<para>Whenever an application context is marked as
<emphasis>dirty</emphasis>, it will be removed from the testing
framework's cache and closed; thus the underlying Spring container will be
rebuilt for any subsequent test which requires a context with the
same set of resource locations.</para>
<note>
<title>Limitations of <interfacename>@DirtiesContext</interfacename> with JUnit 3.8</title>
<para>In a JUnit 3.8 environment <interfacename>@DirtiesContext</interfacename>
is only supported on methods and thus not at the class level.</para>
</note>
</listitem> </listitem>
<listitem> <listitem>