Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
xargs perl -p -i -e "s/[ \t]*$//g" {} \;
Issue: SPR-10127
This commit is contained in:
committed by
Chris Beams
parent
44a474a014
commit
1762157ad1
@@ -23,7 +23,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
* Simple {@link ConfigurableEnvironment} implementation exposing
|
||||
* {@link #setProperty(String, String)} and {@link #withProperty(String, String)}
|
||||
* methods for testing purposes.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* {@link org.springframework.core.env.Environment Environment} and
|
||||
* {@link org.springframework.core.env.PropertySource PropertySource}
|
||||
* abstractions introduced in Spring 3.1.
|
||||
*
|
||||
*
|
||||
* <p>These <em>mocks</em> are useful for developing <em>out-of-container</em>
|
||||
* unit tests for code that depends on environment-specific properties.
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.springframework.util.ClassUtils;
|
||||
* DataSource ds = new DriverManagerDataSource(...);
|
||||
* builder.bind("java:comp/env/jdbc/myds", ds);
|
||||
* builder.activate();</pre>
|
||||
*
|
||||
*
|
||||
* Note that it's impossible to activate multiple builders within the same JVM,
|
||||
* due to JNDI restrictions. Thus to configure a fresh builder repeatedly, use
|
||||
* the following code to get a reference to either an already activated builder
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
*
|
||||
* The simplest implementation of the JNDI SPI that could possibly work.
|
||||
*
|
||||
*
|
||||
* <p>Useful for setting up a simple JNDI environment for test suites
|
||||
* or stand-alone applications. If, for example, JDBC DataSources get bound to the
|
||||
* same JNDI names as within a Java EE container, both application code and
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
|
||||
* <p>
|
||||
* Note that the Jakarta JSTL implementation (jstl.jar, standard.jar) has to be
|
||||
* available on the class path to use this expression evaluator.
|
||||
*
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.1.5
|
||||
* @see org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager
|
||||
@@ -49,7 +49,7 @@ public class MockExpressionEvaluator extends ExpressionEvaluator {
|
||||
|
||||
/**
|
||||
* Create a new MockExpressionEvaluator for the given PageContext.
|
||||
*
|
||||
*
|
||||
* @param pageContext the JSP PageContext to run in
|
||||
*/
|
||||
public MockExpressionEvaluator(PageContext pageContext) {
|
||||
|
||||
@@ -747,7 +747,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
private static final String CHARSET_PREFIX = "charset=";
|
||||
|
||||
private static final String CONTENT_TYPE_HEADER = "Content-Type";
|
||||
|
||||
|
||||
private static final String CONTENT_LENGTH_HEADER = "Content-Length";
|
||||
|
||||
private static final String LOCATION_HEADER = "Location";
|
||||
@@ -65,7 +65,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
private boolean writerAccessAllowed = true;
|
||||
|
||||
private String characterEncoding = WebUtils.DEFAULT_CHARACTER_ENCODING;
|
||||
|
||||
|
||||
private boolean charset = false;
|
||||
|
||||
private final ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||
@@ -141,7 +141,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.charset = true;
|
||||
updateContentTypeHeader();
|
||||
}
|
||||
|
||||
|
||||
private void updateContentTypeHeader() {
|
||||
if (this.contentType != null) {
|
||||
StringBuilder sb = new StringBuilder(this.contentType);
|
||||
@@ -151,7 +151,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
doAddHeaderValue(CONTENT_TYPE_HEADER, sb.toString(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
doAddHeaderValue(name, value, false);
|
||||
}
|
||||
|
||||
|
||||
private boolean setSpecialHeader(String name, Object value) {
|
||||
if (CONTENT_TYPE_HEADER.equalsIgnoreCase(name)) {
|
||||
setContentType((String) value);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession with a default {@link MockServletContext}.
|
||||
*
|
||||
*
|
||||
* @see MockServletContext
|
||||
*/
|
||||
public MockHttpSession() {
|
||||
@@ -80,7 +80,7 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
*/
|
||||
public MockHttpSession(ServletContext servletContext) {
|
||||
@@ -89,7 +89,7 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
* @param id a unique identifier for this session
|
||||
*/
|
||||
@@ -222,7 +222,7 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Serialize the attributes of this session into an object that can be
|
||||
* turned into a byte array with standard Java serialization.
|
||||
*
|
||||
*
|
||||
* @return a representation of this session's serialized state
|
||||
*/
|
||||
public Serializable serializeState() {
|
||||
@@ -249,7 +249,7 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Deserialize the attributes of this session from a state object created by
|
||||
* {@link #serializeState()}.
|
||||
*
|
||||
*
|
||||
* @param state a representation of this session's serialized state
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* A comprehensive set of Servlet API 2.5 mock objects,
|
||||
* targeted at usage with Spring's web MVC framework.
|
||||
* Useful for testing web contexts and controllers.
|
||||
*
|
||||
*
|
||||
* <p>More convenient to use than dynamic mock objects
|
||||
* (<a href="http://www.easymock.org">EasyMock</a>) or
|
||||
* existing Servlet API mock objects
|
||||
|
||||
@@ -95,15 +95,15 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.portletName = portletName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getPortletName() {
|
||||
return this.portletName;
|
||||
}
|
||||
|
||||
|
||||
public PortletContext getPortletContext() {
|
||||
return this.portletContext;
|
||||
}
|
||||
|
||||
|
||||
public void setResourceBundle(Locale locale, ResourceBundle resourceBundle) {
|
||||
Assert.notNull(locale, "Locale must not be null");
|
||||
this.resourceBundles.put(locale, resourceBundle);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MockPortletContext implements PortletContext {
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private final String resourceBasePath;
|
||||
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
private final Map<String, Object> attributes = new LinkedHashMap<String, Object>();
|
||||
@@ -70,7 +70,7 @@ public class MockPortletContext implements PortletContext {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MockPortletContext with no base path and a
|
||||
* Create a new MockPortletContext with no base path and a
|
||||
* DefaultResourceLoader (i.e. the classpath root as WAR root).
|
||||
* @see org.springframework.core.io.DefaultResourceLoader
|
||||
*/
|
||||
@@ -125,7 +125,7 @@ public class MockPortletContext implements PortletContext {
|
||||
return this.resourceBasePath + path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getServerInfo() {
|
||||
return "MockPortal/1.0";
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class MockPortletContext implements PortletContext {
|
||||
public int getMinorVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public String getMimeType(String filePath) {
|
||||
return MimeTypeResolver.getMimeType(filePath);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.portlet.PortletRequest} interface.
|
||||
*
|
||||
*
|
||||
* @author John A. Lewis
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
@@ -103,7 +103,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
/**
|
||||
* Create a new MockPortletRequest with a default {@link MockPortalContext}
|
||||
* and a default {@link MockPortletContext}.
|
||||
*
|
||||
*
|
||||
* @see MockPortalContext
|
||||
* @see MockPortletContext
|
||||
*/
|
||||
@@ -113,7 +113,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
|
||||
/**
|
||||
* Create a new MockPortletRequest with a default {@link MockPortalContext}.
|
||||
*
|
||||
*
|
||||
* @param portletContext the PortletContext that the request runs in
|
||||
* @see MockPortalContext
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
|
||||
/**
|
||||
* Create a new MockPortletRequest.
|
||||
*
|
||||
*
|
||||
* @param portalContext the PortalContext that the request runs in
|
||||
* @param portletContext the PortletContext that the request runs in
|
||||
*/
|
||||
|
||||
@@ -76,7 +76,7 @@ public class MockPortletSession implements PortletSession {
|
||||
this.portletContext = (portletContext != null ? portletContext : new MockPortletContext());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Object getAttribute(String name) {
|
||||
return this.portletAttributes.get(name);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* A comprehensive set of Portlet API 2.0 mock objects,
|
||||
* targeted at usage with Spring's web MVC framework.
|
||||
* Useful for testing web contexts and controllers.
|
||||
*
|
||||
*
|
||||
* <p>More convenient to use than dynamic mock objects
|
||||
* (<a href="http://www.easymock.org">EasyMock</a>) or
|
||||
* existing Portlet API mock objects.
|
||||
|
||||
@@ -166,7 +166,7 @@ public abstract class AssertThrows {
|
||||
* {@link #test() test logic} and the
|
||||
* {@link #checkExceptionExpectations(Exception) checking} of the
|
||||
* resulting (expected) {@link java.lang.Exception}.
|
||||
* @see #test()
|
||||
* @see #test()
|
||||
* @see #doFail()
|
||||
* @see #checkExceptionExpectations(Exception)
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.lang.annotation.Target;
|
||||
* AFTER_EACH_TEST_METHOD}, the context will be marked dirty after each test
|
||||
* method in the class.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Rod Johnson
|
||||
* @since 2.0
|
||||
|
||||
@@ -25,12 +25,12 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* Test annotation to indicate that a test method is required to throw the
|
||||
* specified exception.
|
||||
*
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
* @deprecated as of Spring 3.1 in favor of using built-in support for declaring
|
||||
* expected exceptions in the underlying testing framework (e.g., JUnit, TestNG, etc.)
|
||||
* expected exceptions in the underlying testing framework (e.g., JUnit, TestNG, etc.)
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.lang.annotation.Target;
|
||||
* {@link ProfileValueSource} implementation, you can configure a test method to
|
||||
* run only on Java VMs from Sun Microsystems as follows:
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <pre class="code">
|
||||
* @IfProfileValue(name = "java.vendor", value = "Sun Microsystems Inc.")
|
||||
* public void testSomething() {
|
||||
@@ -54,14 +54,14 @@ import java.lang.annotation.Target;
|
||||
* (assuming a {@link ProfileValueSource} has been appropriately configured for
|
||||
* the "test-groups" name):
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <pre class="code">
|
||||
* @IfProfileValue(name = "test-groups", values = { "unit-tests", "integration-tests" })
|
||||
* public void testWhichRunsForUnitOrIntegrationTestGroups() {
|
||||
* // ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Test annotation to indicate that a method is <i>not transactional</i>.
|
||||
*
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
|
||||
* <em>profile values</em> configured via the {@link IfProfileValue
|
||||
* @IfProfileValue} annotation.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see ProfileValueSource
|
||||
@@ -48,7 +48,7 @@ public @interface ProfileValueSourceConfiguration {
|
||||
* The type of {@link ProfileValueSource} to use when retrieving
|
||||
* <em>profile values</em>.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @see SystemProfileValueSource
|
||||
*/
|
||||
Class<? extends ProfileValueSource> value() default SystemProfileValueSource.class;
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* General utility methods for working with <em>profile values</em>.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
@@ -51,7 +51,7 @@ public abstract class ProfileValueUtils {
|
||||
* @ProfileValueSourceConfiguration} is not present on the specified
|
||||
* class or if a custom {@link ProfileValueSource} is not declared, the
|
||||
* default {@link SystemProfileValueSource} will be returned instead.
|
||||
*
|
||||
*
|
||||
* @param testClass The test class for which the ProfileValueSource should
|
||||
* be retrieved
|
||||
* @return the configured (or default) ProfileValueSource for the specified
|
||||
@@ -108,7 +108,7 @@ public abstract class ProfileValueUtils {
|
||||
* <p>
|
||||
* Defaults to <code>true</code> if no {@link IfProfileValue
|
||||
* @IfProfileValue} annotation is declared.
|
||||
*
|
||||
*
|
||||
* @param testClass the test class
|
||||
* @return <code>true</code> if the test is <em>enabled</em> in the current
|
||||
* environment
|
||||
@@ -127,7 +127,7 @@ public abstract class ProfileValueUtils {
|
||||
* <p>
|
||||
* Defaults to <code>true</code> if no {@link IfProfileValue
|
||||
* @IfProfileValue} annotation is declared.
|
||||
*
|
||||
*
|
||||
* @param testMethod the test method
|
||||
* @param testClass the test class
|
||||
* @return <code>true</code> if the test is <em>enabled</em> in the current
|
||||
@@ -146,7 +146,7 @@ public abstract class ProfileValueUtils {
|
||||
* <p>
|
||||
* Defaults to <code>true</code> if no {@link IfProfileValue
|
||||
* @IfProfileValue} annotation is declared.
|
||||
*
|
||||
*
|
||||
* @param profileValueSource the ProfileValueSource to use to determine if
|
||||
* the test is enabled
|
||||
* @param testMethod the test method
|
||||
@@ -172,7 +172,7 @@ public abstract class ProfileValueUtils {
|
||||
* Determine if the <code>value</code> (or one of the <code>values</code>)
|
||||
* in the supplied {@link IfProfileValue @IfProfileValue} annotation is
|
||||
* <em>enabled</em> in the current environment.
|
||||
*
|
||||
*
|
||||
* @param profileValueSource the ProfileValueSource to use to determine if
|
||||
* the test is enabled
|
||||
* @param ifProfileValue the annotation to introspect; may be
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
|
||||
* Note that the scope of execution to be repeated includes execution of the
|
||||
* test method itself as well as any <em>set up</em> or <em>tear down</em> of
|
||||
* the test fixture.
|
||||
*
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
|
||||
* test method should be <em>rolled back</em> after the test method has
|
||||
* completed. If <code>true</code>, the transaction will be rolled back;
|
||||
* otherwise, the transaction will be committed.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.lang.annotation.Target;
|
||||
* {@link Repeat repetitions} of the test, and any <em>set up</em> or
|
||||
* <em>tear down</em> of the test fixture.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
|
||||
@@ -45,7 +45,7 @@ public @interface ActiveProfiles {
|
||||
|
||||
/**
|
||||
* Alias for {@link #profiles}.
|
||||
*
|
||||
*
|
||||
* <p>This attribute may <strong>not</strong> be used in conjunction
|
||||
* with {@link #profiles}, but it may be used <em>instead</em> of
|
||||
* {@link #profiles}.
|
||||
@@ -54,7 +54,7 @@ public @interface ActiveProfiles {
|
||||
|
||||
/**
|
||||
* The bean definition profiles to activate.
|
||||
*
|
||||
*
|
||||
* <p>This attribute may <strong>not</strong> be used in conjunction
|
||||
* with {@link #value}, but it may be used <em>instead</em> of
|
||||
* {@link #value}.
|
||||
@@ -88,7 +88,7 @@ public @interface ActiveProfiles {
|
||||
* public class BaseTest {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @ActiveProfiles("extended")
|
||||
* @ContextConfiguration
|
||||
* public class ExtendedTest extends BaseTest {
|
||||
@@ -96,7 +96,7 @@ public @interface ActiveProfiles {
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>Note: {@code @ActiveProfiles} can be used when loading an
|
||||
* <p>Note: {@code @ActiveProfiles} can be used when loading an
|
||||
* {@code ApplicationContext} from path-based resource locations or
|
||||
* annotated classes.
|
||||
*
|
||||
|
||||
@@ -81,7 +81,7 @@ public @interface ContextConfiguration {
|
||||
|
||||
/**
|
||||
* Alias for {@link #locations}.
|
||||
*
|
||||
*
|
||||
* <p>This attribute may <strong>not</strong> be used in conjunction
|
||||
* with {@link #locations} or {@link #classes}, but it may be used
|
||||
* instead of {@link #locations}.
|
||||
@@ -93,7 +93,7 @@ public @interface ContextConfiguration {
|
||||
/**
|
||||
* The resource locations to use for loading an
|
||||
* {@link org.springframework.context.ApplicationContext ApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>Check out the Javadoc for
|
||||
* {@link org.springframework.test.context.support.AbstractContextLoader#modifyLocations
|
||||
* AbstractContextLoader.modifyLocations()} for details on how a location
|
||||
@@ -102,7 +102,7 @@ public @interface ContextConfiguration {
|
||||
* {@link org.springframework.test.context.support.AbstractContextLoader#generateDefaultLocations
|
||||
* AbstractContextLoader.generateDefaultLocations()} for details on the default
|
||||
* locations that are going to be used if none are specified.
|
||||
*
|
||||
*
|
||||
* <p>Note that the above-mentioned default rules only apply for a standard
|
||||
* {@link org.springframework.test.context.support.AbstractContextLoader
|
||||
* AbstractContextLoader} subclass such as
|
||||
@@ -111,7 +111,7 @@ public @interface ContextConfiguration {
|
||||
* used at runtime if <code>locations</code> are configured. See the
|
||||
* documentation for {@link #loader} for further details regarding default
|
||||
* loaders.
|
||||
*
|
||||
*
|
||||
* <p>This attribute may <strong>not</strong> be used in conjunction with
|
||||
* {@link #value} or {@link #classes}, but it may be used instead of
|
||||
* {@link #value}.
|
||||
@@ -123,14 +123,14 @@ public @interface ContextConfiguration {
|
||||
/**
|
||||
* The <em>annotated classes</em> to use for loading an
|
||||
* {@link org.springframework.context.ApplicationContext ApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>Check out the Javadoc for
|
||||
* {@link org.springframework.test.context.support.AnnotationConfigContextLoader#detectDefaultConfigurationClasses
|
||||
* AnnotationConfigContextLoader.detectDefaultConfigurationClasses()} for details
|
||||
* on how default configuration classes will be detected if no
|
||||
* <em>annotated classes</em> are specified. See the documentation for
|
||||
* {@link #loader} for further details regarding default loaders.
|
||||
*
|
||||
*
|
||||
* <p>This attribute may <strong>not</strong> be used in conjunction with
|
||||
* {@link #locations} or {@link #value}.
|
||||
*
|
||||
@@ -144,7 +144,7 @@ public @interface ContextConfiguration {
|
||||
/**
|
||||
* The application context <em>initializer classes</em> to use for initializing
|
||||
* a {@link ConfigurableApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>The concrete {@code ConfigurableApplicationContext} type supported by each
|
||||
* declared initializer must be compatible with the type of {@code ApplicationContext}
|
||||
* created by the {@link SmartContextLoader} in use.
|
||||
@@ -173,12 +173,12 @@ public @interface ContextConfiguration {
|
||||
* resource locations or annotated classes defined by test superclasses.
|
||||
* Thus, subclasses have the option of <em>extending</em> the list of resource
|
||||
* locations or annotated classes.
|
||||
*
|
||||
*
|
||||
* <p>If <code>inheritLocations</code> is set to <code>false</code>, the
|
||||
* resource locations or annotated classes for the annotated class
|
||||
* will <em>shadow</em> and effectively replace any resource locations
|
||||
* will <em>shadow</em> and effectively replace any resource locations
|
||||
* or annotated classes defined by superclasses.
|
||||
*
|
||||
*
|
||||
* <p>In the following example that uses path-based resource locations, the
|
||||
* {@link org.springframework.context.ApplicationContext ApplicationContext}
|
||||
* for {@code ExtendedTest} will be loaded from
|
||||
@@ -191,18 +191,18 @@ public @interface ContextConfiguration {
|
||||
* public class BaseTest {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @ContextConfiguration("extended-context.xml")
|
||||
* public class ExtendedTest extends BaseTest {
|
||||
* // ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>Similarly, in the following example that uses annotated
|
||||
* classes, the
|
||||
* {@link org.springframework.context.ApplicationContext ApplicationContext}
|
||||
* for {@code ExtendedTest} will be loaded from the
|
||||
* {@code BaseConfig} <strong>and</strong> {@code ExtendedConfig}
|
||||
* {@code BaseConfig} <strong>and</strong> {@code ExtendedConfig}
|
||||
* configuration classes, in that order. Beans defined in
|
||||
* {@code ExtendedConfig} may therefore override those defined in
|
||||
* {@code BaseConfig}.
|
||||
@@ -211,7 +211,7 @@ public @interface ContextConfiguration {
|
||||
* public class BaseTest {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @ContextConfiguration(classes=ExtendedConfig.class)
|
||||
* public class ExtendedTest extends BaseTest {
|
||||
* // ...
|
||||
@@ -249,7 +249,7 @@ public @interface ContextConfiguration {
|
||||
* public class BaseTest {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @ContextConfiguration(initializers = ExtendedInitializer.class)
|
||||
* public class ExtendedTest extends BaseTest {
|
||||
* // ...
|
||||
@@ -263,12 +263,12 @@ public @interface ContextConfiguration {
|
||||
* The type of {@link SmartContextLoader} (or {@link ContextLoader}) to use
|
||||
* for loading an {@link org.springframework.context.ApplicationContext
|
||||
* ApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>If not specified, the loader will be inherited from the first superclass
|
||||
* that is annotated with {@code @ContextConfiguration} and specifies an
|
||||
* explicit loader. If no class in the hierarchy specifies an explicit
|
||||
* loader, a default loader will be used instead.
|
||||
*
|
||||
*
|
||||
* <p>The default concrete implementation chosen at runtime will be
|
||||
* {@link org.springframework.test.context.support.DelegatingSmartContextLoader
|
||||
* DelegatingSmartContextLoader}. For further details on the default behavior
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.context.ApplicationContext;
|
||||
/**
|
||||
* Strategy interface for loading an {@link ApplicationContext application context}
|
||||
* for an integration test managed by the Spring TestContext Framework.
|
||||
*
|
||||
*
|
||||
* <p><b>Note</b>: as of Spring 3.1, implement {@link SmartContextLoader} instead
|
||||
* of this interface in order to provide support for annotated classes, active
|
||||
* bean definition profiles, and application context initializers.
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.StringUtils;
|
||||
* Utility methods for working with {@link ContextLoader ContextLoaders} and
|
||||
* {@link SmartContextLoader SmartContextLoaders} and resolving resource locations,
|
||||
* annotated classes, and active bean definition profiles.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
* @see ContextLoader
|
||||
@@ -112,15 +112,15 @@ abstract class ContextLoaderUtils {
|
||||
/**
|
||||
* Resolve the {@link ContextLoader} {@linkplain Class class} to use for the
|
||||
* supplied list of {@link ContextConfigurationAttributes}.
|
||||
*
|
||||
*
|
||||
* <p>Beginning with the first level in the context configuration attributes
|
||||
* hierarchy:
|
||||
* hierarchy:
|
||||
*
|
||||
* <ol>
|
||||
* <li>If the {@link ContextConfigurationAttributes#getContextLoaderClass()
|
||||
* contextLoaderClass} property of {@link ContextConfigurationAttributes} is
|
||||
* configured with an explicit class, that class will be returned.</li>
|
||||
* <li>If an explicit {@code ContextLoader} class is not specified at the
|
||||
* <li>If an explicit {@code ContextLoader} class is not specified at the
|
||||
* current level in the hierarchy, traverse to the next level in the hierarchy
|
||||
* and return to step #1.</li>
|
||||
* <li>If no explicit {@code ContextLoader} class is found after traversing
|
||||
@@ -137,9 +137,9 @@ abstract class ContextLoaderUtils {
|
||||
* {@code ContextLoader} class to use; must not be {@code null} or empty
|
||||
* @return the {@code ContextLoader} class to use for the supplied test class
|
||||
* @throws IllegalArgumentException if {@code @ContextConfiguration} is not
|
||||
* <em>present</em> on the supplied test class
|
||||
* <em>present</em> on the supplied test class
|
||||
* @throws IllegalStateException if the default {@code ContextLoader} class
|
||||
* could not be loaded
|
||||
* could not be loaded
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static Class<? extends ContextLoader> resolveContextLoaderClass(Class<?> testClass,
|
||||
@@ -407,7 +407,7 @@ abstract class ContextLoaderUtils {
|
||||
/**
|
||||
* Load the {@link org.springframework.test.context.web.WebAppConfiguration @WebAppConfiguration}
|
||||
* class, using reflection in order to avoid package cycles.
|
||||
*
|
||||
*
|
||||
* @return the {@code @WebAppConfiguration} class or <code>null</code> if it
|
||||
* cannot be loaded
|
||||
* @since 3.2
|
||||
|
||||
@@ -41,15 +41,15 @@ import org.springframework.util.StringUtils;
|
||||
* {@link ContextConfiguration#inheritLocations inheritLocations} and
|
||||
* {@link ActiveProfiles#inheritProfiles inheritProfiles} flags in
|
||||
* {@code @ContextConfiguration} and {@code @ActiveProfiles}, respectively.
|
||||
*
|
||||
*
|
||||
* <p>A {@link SmartContextLoader} uses {@code MergedContextConfiguration}
|
||||
* to load an {@link org.springframework.context.ApplicationContext ApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>{@code MergedContextConfiguration} is also used by the {@link TestContext}
|
||||
* as the context cache key for caching an
|
||||
* {@link org.springframework.context.ApplicationContext ApplicationContext}
|
||||
* that was loaded using properties of this {@code MergedContextConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
* @see ContextConfiguration
|
||||
@@ -118,7 +118,7 @@ public class MergedContextConfiguration implements Serializable {
|
||||
* <code>classes</code>, or <code>activeProfiles</code> an empty array will
|
||||
* be stored instead. Furthermore, active profiles will be sorted, and duplicate
|
||||
* profiles will be removed.
|
||||
*
|
||||
*
|
||||
* @param testClass the test class for which the configuration was merged
|
||||
* @param locations the merged resource locations
|
||||
* @param classes the merged annotated classes
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.context.ApplicationContext;
|
||||
* <p>See the Javadoc for
|
||||
* {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration}
|
||||
* for a definition of <em>annotated class</em>.
|
||||
*
|
||||
*
|
||||
* <p>Clients of a {@code SmartContextLoader} should call
|
||||
* {@link #processContextConfiguration(ContextConfigurationAttributes)
|
||||
* processContextConfiguration()} prior to calling
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* <code>TestContext</code> encapsulates the context in which a test is executed,
|
||||
* agnostic of the actual testing framework in use.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
|
||||
@@ -64,7 +64,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* <em>after class methods</em> of a particular testing framework (e.g., JUnit
|
||||
* 4's {@link org.junit.AfterClass @AfterClass})</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
|
||||
@@ -41,7 +41,7 @@ package org.springframework.test.context;
|
||||
* {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
* TransactionalTestExecutionListener}</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
@@ -58,7 +58,7 @@ public interface TestExecutionListener {
|
||||
* If a given testing framework (e.g., JUnit 3.8) does not support
|
||||
* <em>before class</em> lifecycle callbacks, this method will not be called
|
||||
* for that framework.
|
||||
*
|
||||
*
|
||||
* @param testContext the test context for the test; never <code>null</code>
|
||||
* @throws Exception allows any exception to propagate
|
||||
*/
|
||||
@@ -70,7 +70,7 @@ public interface TestExecutionListener {
|
||||
* <p>
|
||||
* This method should be called immediately after instantiation of the test
|
||||
* instance but prior to any framework-specific lifecycle callbacks.
|
||||
*
|
||||
*
|
||||
* @param testContext the test context for the test; never <code>null</code>
|
||||
* @throws Exception allows any exception to propagate
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ public interface TestExecutionListener {
|
||||
* <p>
|
||||
* This method should be called immediately prior to framework-specific
|
||||
* <em>before</em> lifecycle callbacks.
|
||||
*
|
||||
*
|
||||
* @param testContext the test context in which the test method will be
|
||||
* executed; never <code>null</code>
|
||||
* @throws Exception allows any exception to propagate
|
||||
@@ -99,7 +99,7 @@ public interface TestExecutionListener {
|
||||
* <p>
|
||||
* This method should be called immediately after framework-specific
|
||||
* <em>after</em> lifecycle callbacks.
|
||||
*
|
||||
*
|
||||
* @param testContext the test context in which the test method was
|
||||
* executed; never <code>null</code>
|
||||
* @throws Exception allows any exception to propagate
|
||||
@@ -116,7 +116,7 @@ public interface TestExecutionListener {
|
||||
* If a given testing framework (e.g., JUnit 3.8) does not support
|
||||
* <em>after class</em> lifecycle callbacks, this method will not be called
|
||||
* for that framework.
|
||||
*
|
||||
*
|
||||
* @param testContext the test context for the test; never <code>null</code>
|
||||
* @throws Exception allows any exception to propagate
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.lang.annotation.Target;
|
||||
* be registered with a {@link TestContextManager}. Typically,
|
||||
* <code>@TestExecutionListeners</code> will be used in conjunction with
|
||||
* {@link ContextConfiguration @ContextConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see TestExecutionListener
|
||||
@@ -47,7 +47,7 @@ public @interface TestExecutionListeners {
|
||||
* The {@link TestExecutionListener TestExecutionListeners} to register with
|
||||
* a {@link TestContextManager}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @see org.springframework.test.context.support.DependencyInjectionTestExecutionListener
|
||||
* @see org.springframework.test.context.support.DirtiesContextTestExecutionListener
|
||||
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
|
||||
@@ -78,14 +78,14 @@ public @interface TestExecutionListeners {
|
||||
* <code>DirtiesContextTestExecutionListener</code>, <strong>and</strong>
|
||||
* <code>TransactionalTestExecutionListener</code>, in that order.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <pre class="code">
|
||||
* @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
|
||||
* DirtiesContextTestExecutionListener.class })
|
||||
* public abstract class AbstractBaseTest {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @TestExecutionListeners(TransactionalTestExecutionListener.class)
|
||||
* public class TransactionalTest extends AbstractBaseTest {
|
||||
* // ...
|
||||
|
||||
@@ -99,7 +99,7 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
|
||||
* {@link org.springframework.test.context.TestExecutionListener#afterTestClass(org.springframework.test.context.TestContext)
|
||||
* afterTestClass()}</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
@@ -164,7 +164,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
* supplied <code>name</code>; initializes the internal
|
||||
* {@link TestContextManager} for the current test; and retrieves the
|
||||
* configured (or default) {@link ProfileValueSource}.
|
||||
*
|
||||
*
|
||||
* @param name the name of the current test to execute
|
||||
*/
|
||||
public AbstractJUnit38SpringContextTests(String name) {
|
||||
@@ -200,7 +200,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
* <li>Provides support for {@link ExpectedException
|
||||
* @ExpectedException}.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @see ProfileValueUtils#isTestEnabledInThisEnvironment
|
||||
*/
|
||||
@Override
|
||||
@@ -242,7 +242,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
/**
|
||||
* Runs a <em>timed</em> test via the supplied {@link TestExecutionCallback}
|
||||
* , providing support for the {@link Timed @Timed} annotation.
|
||||
*
|
||||
*
|
||||
* @param tec the test execution callback to run
|
||||
* @param testMethod the actual test method: used to retrieve the
|
||||
* <code>timeout</code>
|
||||
@@ -273,7 +273,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
* Runs a test via the supplied {@link TestExecutionCallback}, providing
|
||||
* support for the {@link ExpectedException @ExpectedException} and
|
||||
* {@link Repeat @Repeat} annotations.
|
||||
*
|
||||
*
|
||||
* @param tec the test execution callback to run
|
||||
* @param testMethod the actual test method: used to retrieve the
|
||||
* {@link ExpectedException @ExpectedException} and {@link Repeat
|
||||
@@ -320,7 +320,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
* Calls {@link TestContextManager#beforeTestMethod(Object,Method)} and
|
||||
* {@link TestContextManager#afterTestMethod(Object,Method,Throwable)} at
|
||||
* the appropriate test execution points.
|
||||
*
|
||||
*
|
||||
* @param testMethod the test method to run
|
||||
* @throws Throwable if any exception is thrown
|
||||
* @see #runBare()
|
||||
@@ -374,7 +374,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
* Records the supplied test method as <em>disabled</em> in the current
|
||||
* environment by incrementing the total number of disabled tests and
|
||||
* logging a debug message.
|
||||
*
|
||||
*
|
||||
* @param testMethod the test method that is disabled.
|
||||
* @see #getDisabledTestCount()
|
||||
*/
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
|
||||
* {@link SpringJUnit4ClassRunner}, {@link ContextConfiguration
|
||||
* @ContextConfiguration}, {@link TestExecutionListeners
|
||||
* @TestExecutionListeners}, etc.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see ContextConfiguration
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @ContextConfiguration}, {@link TestExecutionListeners
|
||||
* @TestExecutionListeners}, {@link Transactional @Transactional},
|
||||
* etc.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
|
||||
@@ -79,7 +79,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* <b>NOTE:</b> As of Spring 3.0, <code>SpringJUnit4ClassRunner</code> requires
|
||||
* JUnit 4.5+.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.test.context.TestContextManager;
|
||||
* be plugged into the JUnit execution chain by calling
|
||||
* {@link TestContextManager#afterTestClass() afterTestClass()} on the supplied
|
||||
* {@link TestContextManager}.
|
||||
*
|
||||
*
|
||||
* @see #evaluate()
|
||||
* @see RunBeforeTestMethodCallbacks
|
||||
* @author Sam Brannen
|
||||
@@ -45,7 +45,7 @@ public class RunAfterTestClassCallbacks extends Statement {
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RunAfterTestClassCallbacks</code> statement.
|
||||
*
|
||||
*
|
||||
* @param next the next <code>Statement</code> in the execution chain
|
||||
* @param testContextManager the TestContextManager upon which to call
|
||||
* <code>afterTestClass()</code>
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.test.context.TestContextManager;
|
||||
* be plugged into the JUnit execution chain by calling
|
||||
* {@link TestContextManager#beforeTestClass() beforeTestClass()} on the
|
||||
* supplied {@link TestContextManager}.
|
||||
*
|
||||
*
|
||||
* @see #evaluate()
|
||||
* @see RunAfterTestMethodCallbacks
|
||||
* @author Sam Brannen
|
||||
@@ -40,7 +40,7 @@ public class RunBeforeTestClassCallbacks extends Statement {
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RunBeforeTestClassCallbacks</code> statement.
|
||||
*
|
||||
*
|
||||
* @param next the next <code>Statement</code> in the execution chain
|
||||
* @param testContextManager the TestContextManager upon which to call
|
||||
* <code>beforeTestClass()</code>
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.test.context.TestContextManager;
|
||||
* be plugged into the JUnit execution chain by calling
|
||||
* {@link TestContextManager#beforeTestMethod(Object, Method)
|
||||
* beforeTestMethod()} on the supplied {@link TestContextManager}.
|
||||
*
|
||||
*
|
||||
* @see #evaluate()
|
||||
* @see RunAfterTestMethodCallbacks
|
||||
* @author Sam Brannen
|
||||
@@ -46,7 +46,7 @@ public class RunBeforeTestMethodCallbacks extends Statement {
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RunBeforeTestMethodCallbacks</code> statement.
|
||||
*
|
||||
*
|
||||
* @param next the next <code>Statement</code> in the execution chain
|
||||
* @param testInstance the current test instance (never <code>null</code>)
|
||||
* @param testMethod the test method which is about to be executed on the
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.test.annotation.Timed;
|
||||
* which adds support for Spring's {@link Timed @Timed} annotation by throwing
|
||||
* an exception if the next statement in the execution chain takes more than the
|
||||
* specified number of milliseconds.
|
||||
*
|
||||
*
|
||||
* @see #evaluate()
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
@@ -40,7 +40,7 @@ public class SpringFailOnTimeout extends Statement {
|
||||
|
||||
/**
|
||||
* Constructs a new <code>SpringFailOnTimeout</code> statement.
|
||||
*
|
||||
*
|
||||
* @param next the next <code>Statement</code> in the execution chain
|
||||
* @param timeout the configured <code>timeout</code> for the current test
|
||||
* @see Timed#millis()
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.util.ClassUtils;
|
||||
* <code>SpringRepeat</code> is a custom JUnit 4.5+ {@link Statement} which adds
|
||||
* support for Spring's {@link Repeat @Repeat} annotation by repeating the
|
||||
* test for the specified number of times.
|
||||
*
|
||||
*
|
||||
* @see #evaluate()
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
@@ -46,7 +46,7 @@ public class SpringRepeat extends Statement {
|
||||
|
||||
/**
|
||||
* Constructs a new <code>SpringRepeat</code> statement.
|
||||
*
|
||||
*
|
||||
* @param next the next <code>Statement</code> in the execution chain
|
||||
* @param testMethod the current test method
|
||||
* @param repeat the configured repeat count for the current test method
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* agnostic of the actual testing framework in use. The same techniques and
|
||||
* annotation-based configuration used in, for example, a JUnit 4.5+ environment
|
||||
* can also be applied to tests written with TestNG, etc.
|
||||
*
|
||||
*
|
||||
* <p>In addition to providing generic and extensible testing infrastructure,
|
||||
* the Spring TestContext Framework provides out-of-the-box support for
|
||||
* Spring-specific integration testing functionality such as context management
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the {@link ConfigurableApplicationContext} created by this
|
||||
* Prepare the {@link ConfigurableApplicationContext} created by this
|
||||
* {@code SmartContextLoader} <i>before</i> bean definitions are read.
|
||||
*
|
||||
* <p>The default implementation:
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* that is annotated with {@link ContextConfiguration @ContextConfiguration}, and
|
||||
* the candidate that supports the merged, processed configuration will be used to
|
||||
* actually {@link #loadContext load} the context.
|
||||
*
|
||||
*
|
||||
* <p>Placing an empty {@code @ContextConfiguration} annotation on a test class signals
|
||||
* that default resource locations (i.e., XML configuration files) or default
|
||||
* {@link org.springframework.context.annotation.Configuration configuration classes}
|
||||
@@ -52,13 +52,13 @@ import org.springframework.util.ObjectUtils;
|
||||
* {@code AbstractDelegatingSmartContextLoader} will be used as the default loader,
|
||||
* thus providing automatic support for either XML configuration files or annotated
|
||||
* classes, but not both simultaneously.
|
||||
*
|
||||
*
|
||||
* <p>As of Spring 3.2, a test class may optionally declare neither XML configuration
|
||||
* files nor annotated classes and instead declare only {@linkplain
|
||||
* ContextConfiguration#initializers application context initializers}. In such
|
||||
* cases, an attempt will still be made to detect defaults, but their absence will
|
||||
* not result an an exception.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
* @see SmartContextLoader
|
||||
@@ -111,15 +111,15 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
/**
|
||||
* Delegates to candidate {@code SmartContextLoaders} to process the supplied
|
||||
* {@link ContextConfigurationAttributes}.
|
||||
*
|
||||
*
|
||||
* <p>Delegation is based on explicit knowledge of the implementations of the
|
||||
* default loaders for {@link #getXmlLoader() XML configuration files} and
|
||||
* {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the
|
||||
* delegation algorithm is as follows:
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>If the resource locations or annotated classes in the supplied
|
||||
* {@code ContextConfigurationAttributes} are not empty, the appropriate
|
||||
* {@code ContextConfigurationAttributes} are not empty, the appropriate
|
||||
* candidate loader will be allowed to process the configuration <em>as is</em>,
|
||||
* without any checks for detection of defaults.</li>
|
||||
* <li>Otherwise, the XML-based loader will be allowed to process
|
||||
@@ -131,7 +131,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* If the annotation-based loader detects default configuration
|
||||
* classes, an {@code info} message will be logged.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @param configAttributes the context configuration attributes to process
|
||||
* @throws IllegalArgumentException if the supplied configuration attributes are
|
||||
* <code>null</code>, or if the supplied configuration attributes include both
|
||||
@@ -216,12 +216,12 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
/**
|
||||
* Delegates to an appropriate candidate {@code SmartContextLoader} to load
|
||||
* an {@link ApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>Delegation is based on explicit knowledge of the implementations of the
|
||||
* default loaders for {@link #getXmlLoader() XML configuration files} and
|
||||
* {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the
|
||||
* delegation algorithm is as follows:
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>If the resource locations in the supplied {@code MergedContextConfiguration}
|
||||
* are not empty and the annotated classes are empty,
|
||||
@@ -230,7 +230,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* are not empty and the resource locations are empty,
|
||||
* the annotation-based loader will load the {@code ApplicationContext}.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @param mergedConfig the merged context configuration to use to load the application context
|
||||
* @throws IllegalArgumentException if the supplied merged configuration is <code>null</code>
|
||||
* @throws IllegalStateException if neither candidate loader is capable of loading an
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.test.context.TestExecutionListener;
|
||||
* Abstract implementation of the {@link TestExecutionListener} interface which
|
||||
* provides empty method stubs. Subclasses can extend this class and override
|
||||
* only those methods suitable for the task at hand.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.springframework.util.ObjectUtils;
|
||||
/**
|
||||
* Concrete implementation of {@link AbstractGenericContextLoader} that loads
|
||||
* bean definitions from annotated classes.
|
||||
*
|
||||
*
|
||||
* <p>See the Javadoc for
|
||||
* {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration}
|
||||
* for a definition of <em>annotated class</em>.
|
||||
*
|
||||
*
|
||||
* <p>Note: <code>AnnotationConfigContextLoader</code> supports <em>annotated classes</em>
|
||||
* rather than the String-based resource locations defined by the legacy
|
||||
* {@link org.springframework.test.context.ContextLoader ContextLoader} API. Thus,
|
||||
@@ -68,7 +68,7 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
|
||||
* {@link ContextConfigurationAttributes#setClasses(Class[]) set} in the
|
||||
* supplied configuration attributes. Otherwise, properties in the supplied
|
||||
* configuration attributes will not be modified.
|
||||
*
|
||||
*
|
||||
* @param configAttributes the context configuration attributes to process
|
||||
* @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes)
|
||||
* @see #isGenerateDefaultLocations()
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.test.context.SmartContextLoader;
|
||||
* {@code DelegatingSmartContextLoader} is a concrete implementation of
|
||||
* {@link AbstractDelegatingSmartContextLoader} that delegates to a
|
||||
* {@link GenericXmlContextLoader} and an {@link AnnotationConfigContextLoader}.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
* @see SmartContextLoader
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
|
||||
* <code>ApplicationContext</code> associated with a test as <em>dirty</em> for
|
||||
* both test classes and test methods configured with the {@link DirtiesContext
|
||||
* @DirtiesContext} annotation.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.testng.annotations.BeforeMethod;
|
||||
* <li>Must have constructors which either implicitly or explicitly delegate to
|
||||
* {@code super();}.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
@@ -96,7 +96,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
/**
|
||||
* Set the {@link ApplicationContext} to be used by this test instance,
|
||||
* provided via {@link ApplicationContextAware} semantics.
|
||||
*
|
||||
*
|
||||
* @param applicationContext the applicationContext to set
|
||||
*/
|
||||
public final void setApplicationContext(ApplicationContext applicationContext) {
|
||||
@@ -107,7 +107,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
* Delegates to the configured {@link TestContextManager} to call
|
||||
* {@link TestContextManager#beforeTestClass() 'before test class'}
|
||||
* callbacks.
|
||||
*
|
||||
*
|
||||
* @throws Exception if a registered TestExecutionListener throws an
|
||||
* exception
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
* {@link TestContextManager#prepareTestInstance(Object) prepare} this test
|
||||
* instance prior to execution of any individual tests, for example for
|
||||
* injecting dependencies, etc.
|
||||
*
|
||||
*
|
||||
* @throws Exception if a registered TestExecutionListener throws an
|
||||
* exception
|
||||
*/
|
||||
@@ -134,7 +134,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
* Delegates to the configured {@link TestContextManager} to
|
||||
* {@link TestContextManager#beforeTestMethod(Object,Method) pre-process}
|
||||
* the test method before the actual test is executed.
|
||||
*
|
||||
*
|
||||
* @param testMethod the test method which is about to be executed.
|
||||
* @throws Exception allows all exceptions to propagate.
|
||||
*/
|
||||
@@ -147,7 +147,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
* Delegates to the {@link IHookCallBack#runTestMethod(ITestResult) test
|
||||
* method} in the supplied <code>callback</code> to execute the actual test
|
||||
* and then tracks the exception thrown during test execution, if any.
|
||||
*
|
||||
*
|
||||
* @see org.testng.IHookable#run(org.testng.IHookCallBack,
|
||||
* org.testng.ITestResult)
|
||||
*/
|
||||
@@ -165,7 +165,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
* Delegates to the configured {@link TestContextManager} to
|
||||
* {@link TestContextManager#afterTestMethod(Object, Method, Throwable)
|
||||
* post-process} the test method after the actual test has executed.
|
||||
*
|
||||
*
|
||||
* @param testMethod the test method which has just been executed on the
|
||||
* test instance
|
||||
* @throws Exception allows all exceptions to propagate
|
||||
@@ -183,7 +183,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
/**
|
||||
* Delegates to the configured {@link TestContextManager} to call
|
||||
* {@link TestContextManager#afterTestClass() 'after test class'} callbacks.
|
||||
*
|
||||
*
|
||||
* @throws Exception if a registered TestExecutionListener throws an
|
||||
* exception
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
|
||||
* The <code>@AfterTransaction</code> methods of superclasses will be
|
||||
* executed after those of the current class.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
|
||||
* The <code>@BeforeTransaction</code> methods of superclasses will be
|
||||
* executed before those of the current class.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
||||
* the {@code MockServletContext} under the
|
||||
* {@link WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE} key.</li>
|
||||
* <li>Finally, the {@code MockServletContext} is set in the
|
||||
* {@code WebApplicationContext}.</li>
|
||||
* {@code WebApplicationContext}.</li>
|
||||
*
|
||||
* @param context the web application context for which to configure the web
|
||||
* resources
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
/**
|
||||
* Concrete implementation of {@link AbstractGenericWebContextLoader} that loads
|
||||
* bean definitions from annotated classes.
|
||||
*
|
||||
*
|
||||
* <p>See the Javadoc for
|
||||
* {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration}
|
||||
* for a definition of <em>annotated class</em>.
|
||||
*
|
||||
*
|
||||
* <p>Note: <code>AnnotationConfigWebContextLoader</code> supports <em>annotated classes</em>
|
||||
* rather than the String-based resource locations defined by the legacy
|
||||
* {@link org.springframework.test.context.ContextLoader ContextLoader} API. Thus,
|
||||
@@ -69,7 +69,7 @@ public class AnnotationConfigWebContextLoader extends AbstractGenericWebContextL
|
||||
* {@linkplain ContextConfigurationAttributes#setClasses(Class[]) set} in the
|
||||
* supplied configuration attributes. Otherwise, properties in the supplied
|
||||
* configuration attributes will not be modified.
|
||||
*
|
||||
*
|
||||
* @param configAttributes the context configuration attributes to process
|
||||
* @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes)
|
||||
* @see #isGenerateDefaultLocations()
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
* {@code TestExecutionListener} which provides mock Servlet API support to
|
||||
* {@link WebApplicationContext WebApplicationContexts} loaded by the <em>Spring
|
||||
* TestContext Framework</em>.
|
||||
*
|
||||
*
|
||||
* <p>Specifically, {@code ServletTestExecutionListener} sets up thread-local
|
||||
* state via Spring Web's {@link RequestContextHolder} during {@linkplain
|
||||
* #prepareTestInstance(TestContext) test instance preparation} and {@linkplain
|
||||
@@ -61,7 +61,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ServletTestExecutionListener.class);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets up thread-local state during the <em>test instance preparation</em>
|
||||
* callback phase via Spring Web's {@link RequestContextHolder}.
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* {@code @WebAppConfiguration} is a class-level annotation that is used to
|
||||
* {@code @WebAppConfiguration} is a class-level annotation that is used to
|
||||
* declare that the {@code ApplicationContext} loaded for an integration test
|
||||
* should be a {@link org.springframework.web.context.WebApplicationContext
|
||||
* WebApplicationContext}.
|
||||
*
|
||||
*
|
||||
* <p>The mere presence of {@code @WebAppConfiguration} on a test class ensures
|
||||
* that a {@code WebApplicationContext} will be loaded for the test using a default
|
||||
* for the path to the root of the web application. To override the default,
|
||||
@@ -36,7 +36,7 @@ import java.lang.annotation.Target;
|
||||
*
|
||||
* <p>Note that {@code @WebAppConfiguration} must be used in conjunction with
|
||||
* {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration},
|
||||
* either within a single test class or within a test class hierarchy.
|
||||
* either within a single test class or within a test class hierarchy.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.test.context.support.AbstractDelegatingSmartContextLo
|
||||
* {@code WebDelegatingSmartContextLoader} is a concrete implementation of
|
||||
* {@link AbstractDelegatingSmartContextLoader} that delegates to a
|
||||
* {@link GenericXmlWebContextLoader} and an {@link AnnotationConfigWebContextLoader}.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
* @see SmartContextLoader
|
||||
|
||||
@@ -117,7 +117,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
|
||||
* instance by comparing both object's {@linkplain #getLocations() locations},
|
||||
* {@linkplain #getClasses() annotated classes},
|
||||
* {@linkplain #getContextInitializerClasses() context initializer classes},
|
||||
* {@linkplain #getActiveProfiles() active profiles},
|
||||
* {@linkplain #getActiveProfiles() active profiles},
|
||||
* {@linkplain #getResourceBasePath() resource base path}, and the fully
|
||||
* qualified names of their {@link #getContextLoader() ContextLoaders}.
|
||||
*/
|
||||
|
||||
@@ -233,7 +233,7 @@ public class JdbcTestUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a script from the provided {@code LineNumberReader}, using
|
||||
* Read a script from the provided {@code LineNumberReader}, using
|
||||
* "{@code --}" as the comment prefix, and build a {@code String} containing
|
||||
* the lines.
|
||||
* @param lineNumberReader the {@code LineNumberReader} containing the script
|
||||
|
||||
@@ -59,8 +59,8 @@ import org.springframework.util.StringUtils;
|
||||
* JpaTransactionManager through the superclass.
|
||||
*
|
||||
* <p>When using Xerces, make sure a post 2.0.2 version is available on the classpath
|
||||
* to avoid a critical
|
||||
* <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16014"/>bug</a>
|
||||
* to avoid a critical
|
||||
* <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16014"/>bug</a>
|
||||
* that leads to StackOverflow. Maven users are likely to encounter this problem since
|
||||
* 2.0.2 is used by default.
|
||||
*
|
||||
@@ -84,7 +84,7 @@ import org.springframework.util.StringUtils;
|
||||
public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactionalTests {
|
||||
|
||||
private static final String DEFAULT_ORM_XML_LOCATION = "META-INF/orm.xml";
|
||||
|
||||
|
||||
/**
|
||||
* Map from String defining unique combination of config locations, to ApplicationContext.
|
||||
* Values are intentionally not strongly typed, to avoid potential class cast exceptions
|
||||
@@ -140,15 +140,15 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
|
||||
@Override
|
||||
public void setDirty() {
|
||||
super.setDirty();
|
||||
super.setDirty();
|
||||
contextCache.remove(cacheKeys());
|
||||
classLoaderCache.remove(cacheKeys());
|
||||
|
||||
|
||||
// If we are a shadow loader, we need to invoke
|
||||
// the shadow parent to set it dirty, as
|
||||
// the shadow parent to set it dirty, as
|
||||
// it is the shadow parent that maintains the cache state,
|
||||
// not the child
|
||||
if (this.shadowParent != null) {
|
||||
if (this.shadowParent != null) {
|
||||
try {
|
||||
Method m = shadowParent.getClass().getMethod("setDirty", (Class[]) null);
|
||||
m.invoke(shadowParent, (Object[]) null);
|
||||
@@ -159,11 +159,11 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void runBare() throws Throwable {
|
||||
|
||||
|
||||
// getName will return the name of the method being run.
|
||||
if (isDisabledInThisEnvironment(getName())) {
|
||||
// Let superclass log that we didn't run the test.
|
||||
@@ -185,7 +185,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
return;
|
||||
}
|
||||
|
||||
String combinationOfContextLocationsForThisTestClass = cacheKeys();
|
||||
String combinationOfContextLocationsForThisTestClass = cacheKeys();
|
||||
ClassLoader classLoaderForThisTestClass = getClass().getClassLoader();
|
||||
// save the TCCL
|
||||
ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
@@ -255,7 +255,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
}
|
||||
// create the shadowed test
|
||||
Class shadowedTestClass = shadowingClassLoader.loadClass(getClass().getName());
|
||||
|
||||
|
||||
// So long as JUnit is excluded from shadowing we
|
||||
// can minimize reflective invocation here
|
||||
TestCase shadowedTestCase = (TestCase) BeanUtils.instantiateClass(shadowedTestClass);
|
||||
@@ -295,12 +295,12 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
* class to be loaded eagerly when this test case loads, creating verify errors at runtime.
|
||||
*/
|
||||
protected ClassLoader createShadowingClassLoader(ClassLoader classLoader) {
|
||||
OrmXmlOverridingShadowingClassLoader orxl = new OrmXmlOverridingShadowingClassLoader(classLoader,
|
||||
getActualOrmXmlLocation());
|
||||
OrmXmlOverridingShadowingClassLoader orxl = new OrmXmlOverridingShadowingClassLoader(classLoader,
|
||||
getActualOrmXmlLocation());
|
||||
customizeResourceOverridingShadowingClassLoader(orxl);
|
||||
return orxl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Customize the shadowing class loader.
|
||||
* @param shadowingClassLoader this parameter is actually of type
|
||||
@@ -311,7 +311,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
protected void customizeResourceOverridingShadowingClassLoader(ClassLoader shadowingClassLoader) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subclasses can override this to return the real location path for
|
||||
* orm.xml or null if they do not wish to find any orm.xml
|
||||
@@ -367,7 +367,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
public ClassLoader getInstrumentableClassLoader() {
|
||||
return this.shadowingClassLoader;
|
||||
}
|
||||
|
||||
|
||||
public ClassLoader getThrowawayClassLoader() {
|
||||
// Be sure to copy the same resource overrides and same class file transformers:
|
||||
// We want the throwaway class loader to behave like the instrumentable class loader.
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.instrument.classloading.ResourceOverridingShadowingCl
|
||||
* @since 2.0
|
||||
*/
|
||||
class OrmXmlOverridingShadowingClassLoader extends ResourceOverridingShadowingClassLoader {
|
||||
|
||||
|
||||
/**
|
||||
* Default location of the <code>orm.xml</code> file in the class path:
|
||||
* "META-INF/orm.xml"
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* {@code ReflectionTestUtils} is a collection of reflection-based utility
|
||||
* methods for use in unit and integration testing scenarios.
|
||||
*
|
||||
*
|
||||
* <p>There are often times when it would be beneficial to be able to set a
|
||||
* non-{@code public} field, invoke a non-{@code public} setter method, or
|
||||
* invoke a non-{@code public} <em>configuration</em> or <em>lifecycle</em>
|
||||
* callback method when testing code involving, for example:
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>ORM frameworks such as JPA and Hibernate which condone the usage of
|
||||
* {@code private} or {@code protected} field access as opposed to
|
||||
@@ -49,7 +49,7 @@ import org.springframework.util.StringUtils;
|
||||
* and {@link javax.annotation.PreDestroy @PreDestroy} for lifecycle callback
|
||||
* methods.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
@@ -67,12 +67,12 @@ public class ReflectionTestUtils {
|
||||
/**
|
||||
* Set the {@link Field field} with the given {@code name} on the provided
|
||||
* {@link Object target object} to the supplied {@code value}.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired field.
|
||||
* In addition, an attempt will be made to make non-{@code public} fields
|
||||
* <em>accessible</em>, thus allowing one to set {@code protected},
|
||||
* {@code private}, and <em>package-private</em> fields.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to set the field
|
||||
* @param name the name of the field to set
|
||||
* @param value the value to set
|
||||
@@ -87,12 +87,12 @@ public class ReflectionTestUtils {
|
||||
/**
|
||||
* Set the {@link Field field} with the given {@code name} on the provided
|
||||
* {@link Object target object} to the supplied {@code value}.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired
|
||||
* field. In addition, an attempt will be made to make non-{@code public}
|
||||
* fields <em>accessible</em>, thus allowing one to set {@code protected},
|
||||
* {@code private}, and <em>package-private</em> fields.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to set the field
|
||||
* @param name the name of the field to set
|
||||
* @param value the value to set
|
||||
@@ -123,12 +123,12 @@ public class ReflectionTestUtils {
|
||||
|
||||
/**
|
||||
* Get the field with the given {@code name} from the provided target object.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired
|
||||
* field. In addition, an attempt will be made to make non-{@code public}
|
||||
* fields <em>accessible</em>, thus allowing one to get {@code protected},
|
||||
* {@code private}, and <em>package-private</em> fields.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to set the field
|
||||
* @param name the name of the field to get
|
||||
* @return the field's current value
|
||||
@@ -151,17 +151,17 @@ public class ReflectionTestUtils {
|
||||
/**
|
||||
* Invoke the setter method with the given {@code name} on the supplied
|
||||
* target object with the supplied {@code value}.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired
|
||||
* method. In addition, an attempt will be made to make non-{@code public}
|
||||
* methods <em>accessible</em>, thus allowing one to invoke {@code protected},
|
||||
* {@code private}, and <em>package-private</em> setter methods.
|
||||
*
|
||||
*
|
||||
* <p>In addition, this method supports JavaBean-style <em>property</em>
|
||||
* names. For example, if you wish to set the {@code name} property on the
|
||||
* target object, you may pass either "name" or
|
||||
* "setName" as the method name.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to invoke the specified setter
|
||||
* method
|
||||
* @param name the name of the setter method to invoke or the corresponding
|
||||
@@ -178,17 +178,17 @@ public class ReflectionTestUtils {
|
||||
/**
|
||||
* Invoke the setter method with the given {@code name} on the supplied
|
||||
* target object with the supplied {@code value}.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired
|
||||
* method. In addition, an attempt will be made to make non-{@code public}
|
||||
* methods <em>accessible</em>, thus allowing one to invoke {@code protected},
|
||||
* {@code private}, and <em>package-private</em> setter methods.
|
||||
*
|
||||
*
|
||||
* <p>In addition, this method supports JavaBean-style <em>property</em>
|
||||
* names. For example, if you wish to set the {@code name} property on the
|
||||
* target object, you may pass either "name" or
|
||||
* "setName" as the method name.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to invoke the specified setter
|
||||
* method
|
||||
* @param name the name of the setter method to invoke or the corresponding
|
||||
@@ -226,17 +226,17 @@ public class ReflectionTestUtils {
|
||||
/**
|
||||
* Invoke the getter method with the given {@code name} on the supplied
|
||||
* target object with the supplied {@code value}.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired
|
||||
* method. In addition, an attempt will be made to make non-{@code public}
|
||||
* methods <em>accessible</em>, thus allowing one to invoke {@code protected},
|
||||
* {@code private}, and <em>package-private</em> getter methods.
|
||||
*
|
||||
*
|
||||
* <p>In addition, this method supports JavaBean-style <em>property</em>
|
||||
* names. For example, if you wish to get the {@code name} property on the
|
||||
* target object, you may pass either "name" or
|
||||
* "getName" as the method name.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to invoke the specified getter
|
||||
* method
|
||||
* @param name the name of the getter method to invoke or the corresponding
|
||||
@@ -271,12 +271,12 @@ public class ReflectionTestUtils {
|
||||
/**
|
||||
* Invoke the method with the given {@code name} on the supplied target
|
||||
* object with the supplied arguments.
|
||||
*
|
||||
*
|
||||
* <p>This method traverses the class hierarchy in search of the desired
|
||||
* method. In addition, an attempt will be made to make non-{@code public}
|
||||
* methods <em>accessible</em>, thus allowing one to invoke {@code protected},
|
||||
* {@code private}, and <em>package-private</em> methods.
|
||||
*
|
||||
*
|
||||
* @param target the target object on which to invoke the specified method
|
||||
* @param name the name of the method to invoke
|
||||
* @param args the arguments to provide to the method
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
/**
|
||||
* Convenient JUnit 3.8 base class for tests dealing with Spring Web MVC
|
||||
* {@link org.springframework.web.servlet.ModelAndView ModelAndView} objects.
|
||||
*
|
||||
*
|
||||
* <p>All <code>assert*()</code> methods throw {@link AssertionFailedError}s.
|
||||
*
|
||||
*
|
||||
* <p>Consider the use of {@link ModelAndViewAssert} with JUnit 4 and TestNG.
|
||||
*
|
||||
*
|
||||
* @author Alef Arendsen
|
||||
* @author Bram Smeets
|
||||
* @author Sam Brannen
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* <p>
|
||||
* Intended for use with JUnit 4 and TestNG. All <code>assert*()</code> methods
|
||||
* throw {@link AssertionError}s.
|
||||
*
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Alef Arendsen
|
||||
* @author Bram Smeets
|
||||
@@ -48,7 +48,7 @@ public abstract class ModelAndViewAssert {
|
||||
* Checks whether the model value under the given <code>modelName</code>
|
||||
* exists and checks it type, based on the <code>expectedType</code>. If the
|
||||
* model entry exists and the type matches, the model value is returned.
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param modelName name of the object to add to the model (never
|
||||
* <code>null</code>)
|
||||
@@ -68,7 +68,7 @@ public abstract class ModelAndViewAssert {
|
||||
|
||||
/**
|
||||
* Compare each individual entry in a list, without first sorting the lists.
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param modelName name of the object to add to the model (never
|
||||
* <code>null</code>)
|
||||
@@ -87,7 +87,7 @@ public abstract class ModelAndViewAssert {
|
||||
|
||||
/**
|
||||
* Assert whether or not a model attribute is available.
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param modelName name of the object to add to the model (never
|
||||
* <code>null</code>)
|
||||
@@ -102,7 +102,7 @@ public abstract class ModelAndViewAssert {
|
||||
/**
|
||||
* Compare a given <code>expectedValue</code> to the value from the model
|
||||
* bound under the given <code>modelName</code>.
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param modelName name of the object to add to the model (never
|
||||
* <code>null</code>)
|
||||
@@ -118,7 +118,7 @@ public abstract class ModelAndViewAssert {
|
||||
/**
|
||||
* Inspect the <code>expectedModel</code> to see if all elements in the
|
||||
* model appear and are equal.
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param expectedModel the expected model
|
||||
*/
|
||||
@@ -151,7 +151,7 @@ public abstract class ModelAndViewAssert {
|
||||
/**
|
||||
* Compare each individual entry in a list after having sorted both lists
|
||||
* (optionally using a comparator).
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param modelName name of the object to add to the model (never
|
||||
* <code>null</code>)
|
||||
@@ -187,7 +187,7 @@ public abstract class ModelAndViewAssert {
|
||||
/**
|
||||
* Check to see if the view name in the ModelAndView matches the given
|
||||
* <code>expectedName</code>.
|
||||
*
|
||||
*
|
||||
* @param mav ModelAndView to test against (never <code>null</code>)
|
||||
* @param expectedName the name of the model value
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user