parent
3b68e97710
commit
92b8e99cbc
|
|
@ -114,7 +114,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
|
||||||
* The default implementation returns the configured
|
* The default implementation returns the configured
|
||||||
* {@link #setResponse(ClientHttpResponse) response}.
|
* {@link #setResponse(ClientHttpResponse) response}.
|
||||||
* <p>Override this method to execute the request and provide a response,
|
* <p>Override this method to execute the request and provide a response,
|
||||||
* potentially different than the configured response.
|
* potentially different from the configured response.
|
||||||
*/
|
*/
|
||||||
protected ClientHttpResponse executeInternal() throws IOException {
|
protected ClientHttpResponse executeInternal() throws IOException {
|
||||||
Assert.state(this.clientHttpResponse != null, "No ClientHttpResponse");
|
Assert.state(this.clientHttpResponse != null, "No ClientHttpResponse");
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a builder with a raw HTTP method value value that is outside the
|
* Create a builder with a raw HTTP method value that is outside the
|
||||||
* range of {@link HttpMethod} enum values.
|
* range of {@link HttpMethod} enum values.
|
||||||
* @param httpMethod the HTTP methodValue value
|
* @param httpMethod the HTTP methodValue value
|
||||||
* @param uri the URI template for target the URL
|
* @param uri the URI template for target the URL
|
||||||
|
|
@ -254,7 +254,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request builder exposing properties not related to the body.
|
* Request builder exposing properties not related to the body.
|
||||||
* @param <B> the builder sub-class
|
* @param <B> the builder subclass
|
||||||
*/
|
*/
|
||||||
public interface BaseBuilder<B extends BaseBuilder<B>> {
|
public interface BaseBuilder<B extends BaseBuilder<B>> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public @interface ActiveProfiles {
|
||||||
Class<? extends ActiveProfilesResolver> resolver() default ActiveProfilesResolver.class;
|
Class<? extends ActiveProfilesResolver> resolver() default ActiveProfilesResolver.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not bean definition profiles from superclasses and enclosing
|
* Whether bean definition profiles from superclasses and enclosing
|
||||||
* classes should be <em>inherited</em>.
|
* classes should be <em>inherited</em>.
|
||||||
* <p>The default value is {@code true}, which means that a test class will
|
* <p>The default value is {@code true}, which means that a test class will
|
||||||
* <em>inherit</em> bean definition profiles defined by a test superclass or
|
* <em>inherit</em> bean definition profiles defined by a test superclass or
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ import java.lang.annotation.Target;
|
||||||
* {@code SoapWebServiceTests} and {@code RestWebServiceTests} both extend
|
* {@code SoapWebServiceTests} and {@code RestWebServiceTests} both extend
|
||||||
* {@code AbstractWebTests} and define a context hierarchy via {@code @ContextHierarchy}.
|
* {@code AbstractWebTests} and define a context hierarchy via {@code @ContextHierarchy}.
|
||||||
* The result is that three application contexts will be loaded (one for each
|
* The result is that three application contexts will be loaded (one for each
|
||||||
* declaration of {@code @ContextConfiguration}, and the application context
|
* declaration of {@code @ContextConfiguration}), and the application context
|
||||||
* loaded based on the configuration in {@code AbstractWebTests} will be set as
|
* loaded based on the configuration in {@code AbstractWebTests} will be set as
|
||||||
* the parent context for each of the contexts loaded for the concrete subclasses.
|
* the parent context for each of the contexts loaded for the concrete subclasses.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.springframework.lang.Nullable;
|
||||||
* enclosing class hierarchies (i.e., for <em>inner</em> test classes).
|
* enclosing class hierarchies (i.e., for <em>inner</em> test classes).
|
||||||
*
|
*
|
||||||
* <p>If {@code @NestedTestConfiguration} is not <em>present</em> or
|
* <p>If {@code @NestedTestConfiguration} is not <em>present</em> or
|
||||||
* <em>meta-present</em> on a test class, in its super type hierarchy, or in its
|
* <em>meta-present</em> on a test class, in its supertype hierarchy, or in its
|
||||||
* enclosing class hierarchy, the default <em>enclosing configuration inheritance
|
* enclosing class hierarchy, the default <em>enclosing configuration inheritance
|
||||||
* mode</em> will be used. A {@code @NestedTestConfiguration} declaration on an
|
* mode</em> will be used. A {@code @NestedTestConfiguration} declaration on an
|
||||||
* enclosing class for a nested interface will be ignored when searching for the
|
* enclosing class for a nested interface will be ignored when searching for the
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public @interface TestExecutionListeners {
|
||||||
Class<? extends TestExecutionListener>[] listeners() default {};
|
Class<? extends TestExecutionListener>[] listeners() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not {@link #listeners TestExecutionListeners} from superclasses
|
* Whether {@link #listeners TestExecutionListeners} from superclasses
|
||||||
* and enclosing classes should be <em>inherited</em>.
|
* and enclosing classes should be <em>inherited</em>.
|
||||||
* <p>The default value is {@code true}, which means that an annotated class
|
* <p>The default value is {@code true}, which means that an annotated class
|
||||||
* will <em>inherit</em> the listeners defined by an annotated superclass or
|
* will <em>inherit</em> the listeners defined by an annotated superclass or
|
||||||
|
|
@ -130,7 +130,7 @@ public @interface TestExecutionListeners {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumeration of <em>modes</em> that dictate whether or not explicitly
|
* Enumeration of <em>modes</em> that dictate whether explicitly
|
||||||
* declared listeners are merged with the default listeners when
|
* declared listeners are merged with the default listeners when
|
||||||
* {@code @TestExecutionListeners} is declared on a class that does
|
* {@code @TestExecutionListeners} is declared on a class that does
|
||||||
* <strong>not</strong> inherit listeners from a superclass or enclosing
|
* <strong>not</strong> inherit listeners from a superclass or enclosing
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ public @interface TestPropertySource {
|
||||||
String[] locations() default {};
|
String[] locations() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not test property source {@link #locations} from superclasses
|
* Whether test property source {@link #locations} from superclasses
|
||||||
* and enclosing classes should be <em>inherited</em>.
|
* and enclosing classes should be <em>inherited</em>.
|
||||||
* <p>The default value is {@code true}, which means that a test class will
|
* <p>The default value is {@code true}, which means that a test class will
|
||||||
* <em>inherit</em> property source locations defined by a superclass or
|
* <em>inherit</em> property source locations defined by a superclass or
|
||||||
|
|
@ -230,7 +230,7 @@ public @interface TestPropertySource {
|
||||||
String[] properties() default {};
|
String[] properties() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not inlined test {@link #properties} from superclasses and
|
* Whether inlined test {@link #properties} from superclasses and
|
||||||
* enclosing classes should be <em>inherited</em>.
|
* enclosing classes should be <em>inherited</em>.
|
||||||
* <p>The default value is {@code true}, which means that a test class will
|
* <p>The default value is {@code true}, which means that a test class will
|
||||||
* <em>inherit</em> inlined properties defined by a superclass or enclosing
|
* <em>inherit</em> inlined properties defined by a superclass or enclosing
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import org.springframework.test.context.MergedContextConfiguration;
|
||||||
* initialization is complex. Although the initialization of a Spring context
|
* initialization is complex. Although the initialization of a Spring context
|
||||||
* itself is typically very quick, some beans in a context — for example,
|
* itself is typically very quick, some beans in a context — for example,
|
||||||
* an embedded database or a {@code LocalContainerEntityManagerFactoryBean} for
|
* an embedded database or a {@code LocalContainerEntityManagerFactoryBean} for
|
||||||
* working with JPA — may take several seconds to initialize. Hence it
|
* working with JPA — may take several seconds to initialize. Hence, it
|
||||||
* often makes sense to perform that initialization only once per test suite or
|
* often makes sense to perform that initialization only once per test suite or
|
||||||
* JVM process.
|
* JVM process.
|
||||||
*
|
*
|
||||||
|
|
@ -155,7 +155,7 @@ public interface ContextCache {
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear hit and miss count statistics for the cache (i.e., reset counters to zero).
|
* Clear hit-and-miss count statistics for the cache (i.e., reset counters to zero).
|
||||||
*/
|
*/
|
||||||
void clearStatistics();
|
void clearStatistics();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ public abstract class AbstractTransactionalJUnit4SpringContextTests extends Abst
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for dropping all of the specified tables.
|
* Convenience method for dropping all the specified tables.
|
||||||
* <p>Use with caution outside of a transaction!
|
* <p>Use with caution outside of a transaction!
|
||||||
* @param names the names of the tables to drop
|
* @param names the names of the tables to drop
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
|
|
@ -209,7 +209,7 @@ public abstract class AbstractTransactionalJUnit4SpringContextTests extends Abst
|
||||||
* <p>The script will normally be loaded by classpath.
|
* <p>The script will normally be loaded by classpath.
|
||||||
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
||||||
* @param sqlResourcePath the Spring resource path for the SQL script
|
* @param sqlResourcePath the Spring resource path for the SQL script
|
||||||
* @param continueOnError whether or not to continue without throwing an
|
* @param continueOnError whether to continue without throwing an
|
||||||
* exception in the event of an error
|
* exception in the event of an error
|
||||||
* @throws DataAccessException if there is an error executing a statement
|
* @throws DataAccessException if there is an error executing a statement
|
||||||
* @see ResourceDatabasePopulator
|
* @see ResourceDatabasePopulator
|
||||||
|
|
|
||||||
|
|
@ -284,13 +284,13 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether or not <em>default</em> resource locations should be
|
* Determine whether <em>default</em> resource locations should be
|
||||||
* generated if the {@code locations} provided to
|
* generated if the {@code locations} provided to
|
||||||
* {@link #processLocations(Class, String...)} are {@code null} or empty.
|
* {@link #processLocations(Class, String...)} are {@code null} or empty.
|
||||||
* <p>As of Spring 3.1, the semantics of this method have been overloaded
|
* <p>As of Spring 3.1, the semantics of this method have been overloaded
|
||||||
* to include detection of either default resource locations or default
|
* to include detection of either default resource locations or default
|
||||||
* configuration classes. Consequently, this method can also be used to
|
* configuration classes. Consequently, this method can also be used to
|
||||||
* determine whether or not <em>default</em> configuration classes should be
|
* determine whether <em>default</em> configuration classes should be
|
||||||
* detected if the {@code classes} present in the
|
* detected if the {@code classes} present in the
|
||||||
* {@link ContextConfigurationAttributes configuration attributes} supplied
|
* {@link ContextConfigurationAttributes configuration attributes} supplied
|
||||||
* to {@link #processContextConfiguration(ContextConfigurationAttributes)}
|
* to {@link #processContextConfiguration(ContextConfigurationAttributes)}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute name for a {@link TestContext} attribute which indicates
|
* Attribute name for a {@link TestContext} attribute which indicates
|
||||||
* whether or not the dependencies of a test instance should be
|
* whether the dependencies of a test instance should be
|
||||||
* <em>reinjected</em> in
|
* <em>reinjected</em> in
|
||||||
* {@link #beforeTestMethod(TestContext) beforeTestMethod()}. Note that
|
* {@link #beforeTestMethod(TestContext) beforeTestMethod()}. Note that
|
||||||
* dependencies will be injected in
|
* dependencies will be injected in
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,9 @@ class TestPropertySourceAttributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all of the supplied elements to the provided list, honoring the
|
* Add all the supplied elements to the provided list, honoring the
|
||||||
* {@code prepend} flag.
|
* {@code prepend} flag.
|
||||||
* <p>If the {@code prepend} flag is {@code false}, the elements will appended
|
* <p>If the {@code prepend} flag is {@code false}, the elements will be appended
|
||||||
* to the list.
|
* to the list.
|
||||||
* @param prepend whether the elements should be prepended to the list
|
* @param prepend whether the elements should be prepended to the list
|
||||||
* @param list the list to which to add the elements
|
* @param list the list to which to add the elements
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public abstract class TestPropertySourceUtils {
|
||||||
for (List<MergedAnnotation<TestPropertySource>> aggregatedAnnotations :
|
for (List<MergedAnnotation<TestPropertySource>> aggregatedAnnotations :
|
||||||
findRepeatableAnnotations(testClass, TestPropertySource.class)) {
|
findRepeatableAnnotations(testClass, TestPropertySource.class)) {
|
||||||
|
|
||||||
// Convert all of the merged annotations for the current aggregate
|
// Convert all the merged annotations for the current aggregate
|
||||||
// level to a list of TestPropertySourceAttributes.
|
// level to a list of TestPropertySourceAttributes.
|
||||||
List<TestPropertySourceAttributes> aggregatedAttributesList =
|
List<TestPropertySourceAttributes> aggregatedAttributesList =
|
||||||
aggregatedAnnotations.stream().map(TestPropertySourceAttributes::new).collect(Collectors.toList());
|
aggregatedAnnotations.stream().map(TestPropertySourceAttributes::new).collect(Collectors.toList());
|
||||||
|
|
@ -200,7 +200,7 @@ public abstract class TestPropertySourceUtils {
|
||||||
* against the {@code Environment}.
|
* against the {@code Environment}.
|
||||||
* <p>Each properties file will be converted to a {@link ResourcePropertySource}
|
* <p>Each properties file will be converted to a {@link ResourcePropertySource}
|
||||||
* that will be added to the {@link PropertySources} of the environment with
|
* that will be added to the {@link PropertySources} of the environment with
|
||||||
* highest precedence.
|
* the highest precedence.
|
||||||
* @param environment the environment to update; never {@code null}
|
* @param environment the environment to update; never {@code null}
|
||||||
* @param resourceLoader the {@code ResourceLoader} to use to load each resource;
|
* @param resourceLoader the {@code ResourceLoader} to use to load each resource;
|
||||||
* never {@code null}
|
* never {@code null}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ public abstract class AbstractTransactionalTestNGSpringContextTests extends Abst
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for dropping all of the specified tables.
|
* Convenience method for dropping all the specified tables.
|
||||||
* <p>Use with caution outside of a transaction!
|
* <p>Use with caution outside of a transaction!
|
||||||
* @param names the names of the tables to drop
|
* @param names the names of the tables to drop
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
|
|
@ -193,7 +193,7 @@ public abstract class AbstractTransactionalTestNGSpringContextTests extends Abst
|
||||||
* <p>The script will normally be loaded by classpath.
|
* <p>The script will normally be loaded by classpath.
|
||||||
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
||||||
* @param sqlResourcePath the Spring resource path for the SQL script
|
* @param sqlResourcePath the Spring resource path for the SQL script
|
||||||
* @param continueOnError whether or not to continue without throwing an
|
* @param continueOnError whether to continue without throwing an
|
||||||
* exception in the event of an error
|
* exception in the event of an error
|
||||||
* @throws DataAccessException if there is an error executing a statement
|
* @throws DataAccessException if there is an error executing a statement
|
||||||
* @see ResourceDatabasePopulator
|
* @see ResourceDatabasePopulator
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public final class TestTransaction {
|
||||||
/**
|
/**
|
||||||
* Flag the current test-managed transaction for <em>rollback</em>.
|
* Flag the current test-managed transaction for <em>rollback</em>.
|
||||||
* <p>Invoking this method will <em>not</em> end the current transaction.
|
* <p>Invoking this method will <em>not</em> end the current transaction.
|
||||||
* Rather, the value of this flag will be used to determine whether or not
|
* Rather, the value of this flag will be used to determine whether
|
||||||
* the current test-managed transaction should be rolled back or committed
|
* the current test-managed transaction should be rolled back or committed
|
||||||
* once it is {@linkplain #end ended}.
|
* once it is {@linkplain #end ended}.
|
||||||
* @throws IllegalStateException if no transaction is active for the current test
|
* @throws IllegalStateException if no transaction is active for the current test
|
||||||
|
|
@ -96,7 +96,7 @@ public final class TestTransaction {
|
||||||
/**
|
/**
|
||||||
* Flag the current test-managed transaction for <em>commit</em>.
|
* Flag the current test-managed transaction for <em>commit</em>.
|
||||||
* <p>Invoking this method will <em>not</em> end the current transaction.
|
* <p>Invoking this method will <em>not</em> end the current transaction.
|
||||||
* Rather, the value of this flag will be used to determine whether or not
|
* Rather, the value of this flag will be used to determine whether
|
||||||
* the current test-managed transaction should be rolled back or committed
|
* the current test-managed transaction should be rolled back or committed
|
||||||
* once it is {@linkplain #end ended}.
|
* once it is {@linkplain #end ended}.
|
||||||
* @throws IllegalStateException if no transaction is active for the current test
|
* @throws IllegalStateException if no transaction is active for the current test
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ import org.springframework.util.StringUtils;
|
||||||
*
|
*
|
||||||
* <h3>Executing Code outside of a Transaction</h3>
|
* <h3>Executing Code outside of a Transaction</h3>
|
||||||
* <p>When executing transactional tests, it is sometimes useful to be able to
|
* <p>When executing transactional tests, it is sometimes useful to be able to
|
||||||
* execute certain <em>set up</em> or <em>tear down</em> code outside of a
|
* execute certain <em>set up</em> or <em>tear down</em> code outside a
|
||||||
* transaction. {@code TransactionalTestExecutionListener} provides such
|
* transaction. {@code TransactionalTestExecutionListener} provides such
|
||||||
* support for methods annotated with {@link BeforeTransaction @BeforeTransaction}
|
* support for methods annotated with {@link BeforeTransaction @BeforeTransaction}
|
||||||
* or {@link AfterTransaction @AfterTransaction}. As of Spring Framework 4.3,
|
* or {@link AfterTransaction @AfterTransaction}. As of Spring Framework 4.3,
|
||||||
|
|
@ -390,7 +390,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether or not to rollback transactions by default for the
|
* Determine whether to rollback transactions by default for the
|
||||||
* supplied {@linkplain TestContext test context}.
|
* supplied {@linkplain TestContext test context}.
|
||||||
* <p>Supports {@link Rollback @Rollback} or {@link Commit @Commit} at the
|
* <p>Supports {@link Rollback @Rollback} or {@link Commit @Commit} at the
|
||||||
* class-level.
|
* class-level.
|
||||||
|
|
@ -418,7 +418,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether or not to rollback transactions for the supplied
|
* Determine whether to rollback transactions for the supplied
|
||||||
* {@linkplain TestContext test context} by taking into consideration the
|
* {@linkplain TestContext test context} by taking into consideration the
|
||||||
* {@linkplain #isDefaultRollback(TestContext) default rollback} flag and a
|
* {@linkplain #isDefaultRollback(TestContext) default rollback} flag and a
|
||||||
* possible method-level override via the {@link Rollback @Rollback}
|
* possible method-level override via the {@link Rollback @Rollback}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute name for a {@link TestContext} attribute which indicates
|
* Attribute name for a {@link TestContext} attribute which indicates
|
||||||
* whether or not the {@code ServletTestExecutionListener} should {@linkplain
|
* whether the {@code ServletTestExecutionListener} should {@linkplain
|
||||||
* RequestContextHolder#resetRequestAttributes() reset} Spring Web's
|
* RequestContextHolder#resetRequestAttributes() reset} Spring Web's
|
||||||
* {@code RequestContextHolder} in {@link #afterTestMethod(TestContext)}.
|
* {@code RequestContextHolder} in {@link #afterTestMethod(TestContext)}.
|
||||||
* <p>Permissible values include {@link Boolean#TRUE} and {@link Boolean#FALSE}.
|
* <p>Permissible values include {@link Boolean#TRUE} and {@link Boolean#FALSE}.
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public abstract class ModelAndViewAssert {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the model value under the given {@code modelName}
|
* Checks whether the model value under the given {@code modelName}
|
||||||
* exists and checks it type, based on the {@code expectedType}. If the
|
* exists and checks its type, based on the {@code expectedType}. If the
|
||||||
* model entry exists and the type matches, the model value is returned.
|
* model entry exists and the type matches, the model value is returned.
|
||||||
* @param mav the ModelAndView to test against (never {@code null})
|
* @param mav the ModelAndView to test against (never {@code null})
|
||||||
* @param modelName name of the object to add to the model (never {@code null})
|
* @param modelName name of the object to add to the model (never {@code null})
|
||||||
|
|
@ -81,7 +81,7 @@ public abstract class ModelAndViewAssert {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert whether or not a model attribute is available.
|
* Assert whether a model attribute is available.
|
||||||
* @param mav the ModelAndView to test against (never {@code null})
|
* @param mav the ModelAndView to test against (never {@code null})
|
||||||
* @param modelName name of the object to add to the model (never {@code null})
|
* @param modelName name of the object to add to the model (never {@code null})
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import org.springframework.util.Assert;
|
||||||
* expectations at the end.
|
* expectations at the end.
|
||||||
*
|
*
|
||||||
* <p>Subclasses are responsible for validating each request by matching it to
|
* <p>Subclasses are responsible for validating each request by matching it to
|
||||||
* to expectations following the order of declaration or not.
|
* expectations following the order of declaration or not.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|
@ -203,7 +203,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an {@code AssertionError} that a sub-class can raise for an
|
* Return an {@code AssertionError} that a subclass can raise for an
|
||||||
* unexpected request.
|
* unexpected request.
|
||||||
*/
|
*/
|
||||||
protected AssertionError createUnexpectedRequestError(ClientHttpRequest request) {
|
protected AssertionError createUnexpectedRequestError(ClientHttpRequest request) {
|
||||||
|
|
@ -247,7 +247,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
|
||||||
return expectation;
|
return expectation;
|
||||||
}
|
}
|
||||||
catch (AssertionError error) {
|
catch (AssertionError error) {
|
||||||
// We're looking to find a match or return null..
|
// We're looking to find a match or return null.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public final class MockRestServiceServer {
|
||||||
* Variant of {@link #verify()} that waits for up to the specified time for
|
* Variant of {@link #verify()} that waits for up to the specified time for
|
||||||
* all expectations to be fulfilled. This can be useful for tests that
|
* all expectations to be fulfilled. This can be useful for tests that
|
||||||
* involve asynchronous requests.
|
* involve asynchronous requests.
|
||||||
* @param timeout how long to wait for all expecations to be met
|
* @param timeout how long to wait for all expectations to be met
|
||||||
* @throws AssertionError if not all expectations are met by the specified
|
* @throws AssertionError if not all expectations are met by the specified
|
||||||
* timeout, or if any expectation fails at any time before that.
|
* timeout, or if any expectation fails at any time before that.
|
||||||
* @since 5.3.4
|
* @since 5.3.4
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public interface RequestExpectationManager {
|
||||||
* Variant of {@link #verify()} that waits for up to the specified time for
|
* Variant of {@link #verify()} that waits for up to the specified time for
|
||||||
* all expectations to be fulfilled. This can be useful for tests that
|
* all expectations to be fulfilled. This can be useful for tests that
|
||||||
* involve asynchronous requests.
|
* involve asynchronous requests.
|
||||||
* @param timeout how long to wait for all expecations to be met
|
* @param timeout how long to wait for all expectations to be met
|
||||||
* @throws AssertionError if not all expectations are met by the specified
|
* @throws AssertionError if not all expectations are met by the specified
|
||||||
* timeout, or if any expectation fails at any time before that.
|
* timeout, or if any expectation fails at any time before that.
|
||||||
* @since 5.3.4
|
* @since 5.3.4
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ abstract class AbstractMockServerSpec<B extends WebTestClient.MockServerSpec<B>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub-classes must create an {@code WebHttpHandlerBuilder} that will then
|
* Subclasses must create an {@code WebHttpHandlerBuilder} that will then
|
||||||
* be used to create the HttpHandler for the mock server.
|
* be used to create the HttpHandler for the mock server.
|
||||||
*/
|
*/
|
||||||
protected abstract WebHttpHandlerBuilder initHttpHandlerBuilder();
|
protected abstract WebHttpHandlerBuilder initHttpHandlerBuilder();
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
* {@link WebTestClient}.
|
* {@link WebTestClient}.
|
||||||
*
|
*
|
||||||
* <p>Note that a decoded response body is not exposed at this level since the
|
* <p>Note that a decoded response body is not exposed at this level since the
|
||||||
* body may not have been decoded and consumed yet. Sub-types
|
* body may not have been decoded and consumed yet. Subtypes
|
||||||
* {@link EntityExchangeResult} and {@link FluxExchangeResult} provide access
|
* {@link EntityExchangeResult} and {@link FluxExchangeResult} provide access
|
||||||
* to a decoded response entity and a decoded (but not consumed) response body
|
* to a decoded response entity and a decoded (but not consumed) response body
|
||||||
* respectively.
|
* respectively.
|
||||||
|
|
@ -161,7 +161,7 @@ public class ExchangeResult {
|
||||||
* Return the raw request body content written through the request.
|
* Return the raw request body content written through the request.
|
||||||
* <p><strong>Note:</strong> If the request content has not been consumed
|
* <p><strong>Note:</strong> If the request content has not been consumed
|
||||||
* for any reason yet, use of this method will trigger consumption.
|
* for any reason yet, use of this method will trigger consumption.
|
||||||
* @throws IllegalStateException if the request body is not been fully written.
|
* @throws IllegalStateException if the request body has not been fully written.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public byte[] getRequestBodyContent() {
|
public byte[] getRequestBodyContent() {
|
||||||
|
|
@ -203,7 +203,7 @@ public class ExchangeResult {
|
||||||
* Return the raw request body content written to the response.
|
* Return the raw request body content written to the response.
|
||||||
* <p><strong>Note:</strong> If the response content has not been consumed
|
* <p><strong>Note:</strong> If the response content has not been consumed
|
||||||
* yet, use of this method will trigger consumption.
|
* yet, use of this method will trigger consumption.
|
||||||
* @throws IllegalStateException if the response is not been fully read.
|
* @throws IllegalStateException if the response has not been fully read.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public byte[] getResponseBodyContent() {
|
public byte[] getResponseBodyContent() {
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ public interface WebTestClient {
|
||||||
* There are builder methods to customize the Java config. The resulting
|
* There are builder methods to customize the Java config. The resulting
|
||||||
* WebFlux application will be tested without an HTTP server using a mock
|
* WebFlux application will be tested without an HTTP server using a mock
|
||||||
* request and response.
|
* request and response.
|
||||||
* @param controllers one or more controller instances to tests
|
* @param controllers one or more controller instances to test
|
||||||
* (specified {@code Class} will be turned into instance)
|
* (specified {@code Class} will be turned into instance)
|
||||||
* @return chained API to customize server and client config; use
|
* @return chained API to customize server and client config; use
|
||||||
* {@link MockServerSpec#configureClient()} to transition to client config
|
* {@link MockServerSpec#configureClient()} to transition to client config
|
||||||
|
|
@ -203,7 +203,7 @@ public interface WebTestClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this option to setup a server from the Spring configuration of your
|
* Use this option to set up a server from the Spring configuration of your
|
||||||
* application, or some subset of it. Internally the provided configuration
|
* application, or some subset of it. Internally the provided configuration
|
||||||
* is passed to {@code WebHttpHandlerBuilder} to set up the request
|
* is passed to {@code WebHttpHandlerBuilder} to set up the request
|
||||||
* processing chain. The resulting WebFlux application will be tested
|
* processing chain. The resulting WebFlux application will be tested
|
||||||
|
|
@ -796,7 +796,7 @@ public interface WebTestClient {
|
||||||
* <p>If a single {@link Error} or {@link RuntimeException} is thrown,
|
* <p>If a single {@link Error} or {@link RuntimeException} is thrown,
|
||||||
* it will be rethrown.
|
* it will be rethrown.
|
||||||
* <p>If multiple exceptions are thrown, this method will throw an
|
* <p>If multiple exceptions are thrown, this method will throw an
|
||||||
* {@link AssertionError} whose error message is a summary of all of the
|
* {@link AssertionError} whose error message is a summary of all the
|
||||||
* exceptions. In addition, each exception will be added as a
|
* exceptions. In addition, each exception will be added as a
|
||||||
* {@linkplain Throwable#addSuppressed(Throwable) suppressed exception} to
|
* {@linkplain Throwable#addSuppressed(Throwable) suppressed exception} to
|
||||||
* the {@code AssertionError}.
|
* the {@code AssertionError}.
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public interface ResultActions {
|
||||||
* <p>If a single {@link Error} or {@link Exception} is thrown, it will
|
* <p>If a single {@link Error} or {@link Exception} is thrown, it will
|
||||||
* be rethrown.
|
* be rethrown.
|
||||||
* <p>If multiple exceptions are thrown, this method will throw an
|
* <p>If multiple exceptions are thrown, this method will throw an
|
||||||
* {@link AssertionError} whose error message is a summary of all of the
|
* {@link AssertionError} whose error message is a summary of all the
|
||||||
* exceptions. In addition, each exception will be added as a
|
* exceptions. In addition, each exception will be added as a
|
||||||
* {@linkplain Throwable#addSuppressed(Throwable) suppressed exception} to
|
* {@linkplain Throwable#addSuppressed(Throwable) suppressed exception} to
|
||||||
* the {@code AssertionError}.
|
* the {@code AssertionError}.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
public interface SmartRequestBuilder extends RequestBuilder {
|
public interface SmartRequestBuilder extends RequestBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply request post processing. Typically that means invoking one or more
|
* Apply request post-processing. Typically, that means invoking one or more
|
||||||
* {@link org.springframework.test.web.servlet.request.RequestPostProcessor org.springframework.test.web.servlet.request.RequestPostProcessors}.
|
* {@link org.springframework.test.web.servlet.request.RequestPostProcessor org.springframework.test.web.servlet.request.RequestPostProcessors}.
|
||||||
* @param request the request to initialize
|
* @param request the request to initialize
|
||||||
* @return the request to use, either the one passed in or a wrapped one
|
* @return the request to use, either the one passed in or a wrapped one
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.util.WebUtils;
|
import org.springframework.web.util.WebUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sub-class of {@code DispatcherServlet} that saves the result in an
|
* A subclass of {@code DispatcherServlet} that saves the result in an
|
||||||
* {@link MvcResult}. The {@code MvcResult} instance is expected to be available
|
* {@link MvcResult}. The {@code MvcResult} instance is expected to be available
|
||||||
* as the request attribute {@link MockMvc#MVC_RESULT_ATTRIBUTE}.
|
* as the request attribute {@link MockMvc#MVC_RESULT_ATTRIBUTE}.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ import org.springframework.test.web.servlet.setup.MockMvcConfigurer;
|
||||||
/**
|
/**
|
||||||
* Base class for implementations of {@link MockMvcWebTestClient.MockMvcServerSpec}
|
* Base class for implementations of {@link MockMvcWebTestClient.MockMvcServerSpec}
|
||||||
* that simply delegates to a {@link ConfigurableMockMvcBuilder} supplied by
|
* that simply delegates to a {@link ConfigurableMockMvcBuilder} supplied by
|
||||||
* the concrete sub-classes.
|
* the concrete subclasses.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
* @param <B> the type of the concrete sub-class spec
|
* @param <B> the type of the concrete subclass spec
|
||||||
*/
|
*/
|
||||||
abstract class AbstractMockMvcServerSpec<B extends MockMvcWebTestClient.MockMvcServerSpec<B>>
|
abstract class AbstractMockMvcServerSpec<B extends MockMvcWebTestClient.MockMvcServerSpec<B>>
|
||||||
implements MockMvcWebTestClient.MockMvcServerSpec<B> {
|
implements MockMvcWebTestClient.MockMvcServerSpec<B> {
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ public class MockHttpServletRequestBuilder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the 'Content-Type' header of the request as a raw String value,
|
* Set the 'Content-Type' header of the request as a raw String value,
|
||||||
* possibly not even well formed (for testing purposes).
|
* possibly not even well-formed (for testing purposes).
|
||||||
* @param contentType the content type
|
* @param contentType the content type
|
||||||
* @since 4.1.2
|
* @since 4.1.2
|
||||||
*/
|
*/
|
||||||
|
|
@ -327,8 +327,8 @@ public class MockHttpServletRequestBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the 'Accept' header using raw String values, possibly not even well
|
* Set the {@code Accept} header using raw String values, possibly not even
|
||||||
* formed (for testing purposes).
|
* well-formed (for testing purposes).
|
||||||
* @param mediaTypes one or more media types; internally joined as
|
* @param mediaTypes one or more media types; internally joined as
|
||||||
* comma-separated String
|
* comma-separated String
|
||||||
*/
|
*/
|
||||||
|
|
@ -408,7 +408,7 @@ public class MockHttpServletRequestBuilder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append to the query string and also add to the
|
* Append to the query string and also add to the
|
||||||
* {@link #params(MultiValueMap)} request parameters} map. The parameter
|
* {@link #params(MultiValueMap) request parameters} map. The parameter
|
||||||
* name and value are encoded when they are added to the query string.
|
* name and value are encoded when they are added to the query string.
|
||||||
* @param params the parameters to add
|
* @param params the parameters to add
|
||||||
* @since 5.2.2
|
* @since 5.2.2
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ public class ContentResultMatchers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert the ServletResponse content type. The given content type must
|
* Assert the ServletResponse content type. The given content type must
|
||||||
* fully match including type, sub-type, and parameters. For checking
|
* fully match including type, subtype, and parameters. For checking
|
||||||
* only the type and sub-type see {@link #contentTypeCompatibleWith(String)}.
|
* only the type and subtype see {@link #contentTypeCompatibleWith(String)}.
|
||||||
*/
|
*/
|
||||||
public ResultMatcher contentType(String contentType) {
|
public ResultMatcher contentType(String contentType) {
|
||||||
return contentType(MediaType.parseMediaType(contentType));
|
return contentType(MediaType.parseMediaType(contentType));
|
||||||
|
|
@ -75,8 +75,8 @@ public class ContentResultMatchers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert the ServletResponse content type after parsing it as a MediaType.
|
* Assert the ServletResponse content type after parsing it as a MediaType.
|
||||||
* The given content type must fully match including type, sub-type, and
|
* The given content type must fully match including type, subtype, and
|
||||||
* parameters. For checking only the type and sub-type see
|
* parameters. For checking only the type and subtype see
|
||||||
* {@link #contentTypeCompatibleWith(MediaType)}.
|
* {@link #contentTypeCompatibleWith(MediaType)}.
|
||||||
*/
|
*/
|
||||||
public ResultMatcher contentType(MediaType contentType) {
|
public ResultMatcher contentType(MediaType contentType) {
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method could be used from a sub-class to register additional Spring
|
* This method could be used from a subclass to register additional Spring
|
||||||
* MVC infrastructure such as additional {@code HandlerMapping},
|
* MVC infrastructure such as additional {@code HandlerMapping},
|
||||||
* {@code HandlerAdapter}, and others.
|
* {@code HandlerAdapter}, and others.
|
||||||
* @param servletContext the ServletContext
|
* @param servletContext the ServletContext
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import java.lang.annotation.Target;
|
||||||
/**
|
/**
|
||||||
* Demo <em>composed annotation</em> for {@link DisabledIf @DisabledIf} that
|
* Demo <em>composed annotation</em> for {@link DisabledIf @DisabledIf} that
|
||||||
* disables a test class or test method if the current operating system is
|
* disables a test class or test method if the current operating system is
|
||||||
* Mac OS.
|
* macOS.
|
||||||
*
|
*
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import java.lang.annotation.Target;
|
||||||
/**
|
/**
|
||||||
* Demo <em>composed annotation</em> for {@link EnabledIf @EnabledIf} that
|
* Demo <em>composed annotation</em> for {@link EnabledIf @EnabledIf} that
|
||||||
* enables a test class or test method if the current operating system is
|
* enables a test class or test method if the current operating system is
|
||||||
* Mac OS.
|
* macOS.
|
||||||
*
|
*
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public interface PublishedEvents {
|
||||||
/**
|
/**
|
||||||
* Further constrain the event type for downstream assertions.
|
* Further constrain the event type for downstream assertions.
|
||||||
*
|
*
|
||||||
* @param subType the sub type
|
* @param subType the subtype
|
||||||
* @return will never be {@literal null}
|
* @return will never be {@literal null}
|
||||||
*/
|
*/
|
||||||
<S extends T> TypedPublishedEvents<S> ofSubType(Class<S> subType);
|
<S extends T> TypedPublishedEvents<S> ofSubType(Class<S> subType);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared configuration for tests that need an embedded database pre-loaded
|
* Shared configuration for tests that need an embedded database preloaded
|
||||||
* with the schema for the 'person' table.
|
* with the schema for the 'person' table.
|
||||||
*
|
*
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigurationUt
|
||||||
MergedContextConfiguration parent = mergedConfig.getParent();
|
MergedContextConfiguration parent = mergedConfig.getParent();
|
||||||
assertThat(parent).as("parent config").isNotNull();
|
assertThat(parent).as("parent config").isNotNull();
|
||||||
// The following does not work -- at least not in Eclipse.
|
// The following does not work -- at least not in Eclipse.
|
||||||
// asssertThat(parent.getClasses())...
|
// assertThat(parent.getClasses())...
|
||||||
// So we use AssertionsForClassTypes directly.
|
// So we use AssertionsForClassTypes directly.
|
||||||
AssertionsForClassTypes.assertThat(parent.getClasses()).containsExactly(FooConfig.class);
|
AssertionsForClassTypes.assertThat(parent.getClasses()).containsExactly(FooConfig.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ public class MockServerTests {
|
||||||
.expectStatus().isOk()
|
.expectStatus().isOk()
|
||||||
.returnResult(String.class);
|
.returnResult(String.class);
|
||||||
|
|
||||||
// Get the raw content without consuming the response body flux..
|
// Get the raw content without consuming the response body flux.
|
||||||
byte[] bytes = result.getResponseBodyContent();
|
byte[] bytes = result.getResponseBodyContent();
|
||||||
|
|
||||||
assertThat(bytes).isNotNull();
|
assertThat(bytes).isNotNull();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue