Fix and improve Javadoc in spring-test

Closes gh-28795
This commit is contained in:
Marc Wrobel 2022-07-12 12:20:39 +02:00 committed by Sam Brannen
parent 3b68e97710
commit 92b8e99cbc
37 changed files with 63 additions and 63 deletions

View File

@ -114,7 +114,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
* The default implementation returns the configured
* {@link #setResponse(ClientHttpResponse) 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 {
Assert.state(this.clientHttpResponse != null, "No ClientHttpResponse");

View File

@ -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.
* @param httpMethod the HTTP methodValue value
* @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.
* @param <B> the builder sub-class
* @param <B> the builder subclass
*/
public interface BaseBuilder<B extends BaseBuilder<B>> {

View File

@ -78,7 +78,7 @@ public @interface ActiveProfiles {
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>.
* <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

View File

@ -66,7 +66,7 @@ import java.lang.annotation.Target;
* {@code SoapWebServiceTests} and {@code RestWebServiceTests} both extend
* {@code AbstractWebTests} and define a context hierarchy via {@code @ContextHierarchy}.
* 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
* the parent context for each of the contexts loaded for the concrete subclasses.
*

View File

@ -34,7 +34,7 @@ import org.springframework.lang.Nullable;
* enclosing class hierarchies (i.e., for <em>inner</em> test classes).
*
* <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
* mode</em> will be used. A {@code @NestedTestConfiguration} declaration on an
* enclosing class for a nested interface will be ignored when searching for the

View File

@ -78,7 +78,7 @@ public @interface TestExecutionListeners {
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>.
* <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
@ -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
* {@code @TestExecutionListeners} is declared on a class that does
* <strong>not</strong> inherit listeners from a superclass or enclosing

View File

@ -150,7 +150,7 @@ public @interface TestPropertySource {
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>.
* <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
@ -230,7 +230,7 @@ public @interface TestPropertySource {
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>.
* <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

View File

@ -36,7 +36,7 @@ import org.springframework.test.context.MergedContextConfiguration;
* initialization is complex. Although the initialization of a Spring context
* itself is typically very quick, some beans in a context &mdash; for example,
* an embedded database or a {@code LocalContainerEntityManagerFactoryBean} for
* working with JPA &mdash; may take several seconds to initialize. Hence it
* working with JPA &mdash; may take several seconds to initialize. Hence, it
* often makes sense to perform that initialization only once per test suite or
* JVM process.
*
@ -155,7 +155,7 @@ public interface ContextCache {
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();

View File

@ -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!
* @param names the names of the tables to drop
* @since 3.2
@ -209,7 +209,7 @@ public abstract class AbstractTransactionalJUnit4SpringContextTests extends Abst
* <p>The script will normally be loaded by classpath.
* <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 continueOnError whether or not to continue without throwing an
* @param continueOnError whether to continue without throwing an
* exception in the event of an error
* @throws DataAccessException if there is an error executing a statement
* @see ResourceDatabasePopulator

View File

@ -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
* {@link #processLocations(Class, String...)} are {@code null} or empty.
* <p>As of Spring 3.1, the semantics of this method have been overloaded
* to include detection of either default resource locations or default
* 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
* {@link ContextConfigurationAttributes configuration attributes} supplied
* to {@link #processContextConfiguration(ContextConfigurationAttributes)}

View File

@ -35,7 +35,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
/**
* 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
* {@link #beforeTestMethod(TestContext) beforeTestMethod()}. Note that
* dependencies will be injected in

View File

@ -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.
* <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.
* @param prepend whether the elements should be prepended to the list
* @param list the list to which to add the elements

View File

@ -85,7 +85,7 @@ public abstract class TestPropertySourceUtils {
for (List<MergedAnnotation<TestPropertySource>> aggregatedAnnotations :
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.
List<TestPropertySourceAttributes> aggregatedAttributesList =
aggregatedAnnotations.stream().map(TestPropertySourceAttributes::new).collect(Collectors.toList());
@ -200,7 +200,7 @@ public abstract class TestPropertySourceUtils {
* against the {@code Environment}.
* <p>Each properties file will be converted to a {@link ResourcePropertySource}
* 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 resourceLoader the {@code ResourceLoader} to use to load each resource;
* never {@code null}

View File

@ -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!
* @param names the names of the tables to drop
* @since 3.2
@ -193,7 +193,7 @@ public abstract class AbstractTransactionalTestNGSpringContextTests extends Abst
* <p>The script will normally be loaded by classpath.
* <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 continueOnError whether or not to continue without throwing an
* @param continueOnError whether to continue without throwing an
* exception in the event of an error
* @throws DataAccessException if there is an error executing a statement
* @see ResourceDatabasePopulator

View File

@ -80,7 +80,7 @@ public final class TestTransaction {
/**
* Flag the current test-managed transaction for <em>rollback</em>.
* <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
* once it is {@linkplain #end ended}.
* @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>.
* <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
* once it is {@linkplain #end ended}.
* @throws IllegalStateException if no transaction is active for the current test

View File

@ -97,7 +97,7 @@ import org.springframework.util.StringUtils;
*
* <h3>Executing Code outside of a Transaction</h3>
* <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
* support for methods annotated with {@link BeforeTransaction @BeforeTransaction}
* 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}.
* <p>Supports {@link Rollback @Rollback} or {@link Commit @Commit} at the
* 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 #isDefaultRollback(TestContext) default rollback} flag and a
* possible method-level override via the {@link Rollback @Rollback}

View File

@ -68,7 +68,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener
/**
* 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
* {@code RequestContextHolder} in {@link #afterTestMethod(TestContext)}.
* <p>Permissible values include {@link Boolean#TRUE} and {@link Boolean#FALSE}.

View File

@ -46,7 +46,7 @@ public abstract class ModelAndViewAssert {
/**
* 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.
* @param mav the ModelAndView to test against (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 modelName name of the object to add to the model (never {@code null})
*/

View File

@ -42,7 +42,7 @@ import org.springframework.util.Assert;
* expectations at the end.
*
* <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 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.
*/
protected AssertionError createUnexpectedRequestError(ClientHttpRequest request) {
@ -247,7 +247,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
return expectation;
}
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;

View File

@ -121,7 +121,7 @@ public final class MockRestServiceServer {
* 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
* 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
* timeout, or if any expectation fails at any time before that.
* @since 5.3.4

View File

@ -61,7 +61,7 @@ public interface RequestExpectationManager {
* 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
* 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
* timeout, or if any expectation fails at any time before that.
* @since 5.3.4

View File

@ -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.
*/
protected abstract WebHttpHandlerBuilder initHttpHandlerBuilder();

View File

@ -44,7 +44,7 @@ import org.springframework.util.MultiValueMap;
* {@link WebTestClient}.
*
* <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
* to a decoded response entity and a decoded (but not consumed) response body
* respectively.
@ -161,7 +161,7 @@ public class ExchangeResult {
* Return the raw request body content written through the request.
* <p><strong>Note:</strong> If the request content has not been consumed
* 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
public byte[] getRequestBodyContent() {
@ -203,7 +203,7 @@ public class ExchangeResult {
* Return the raw request body content written to the response.
* <p><strong>Note:</strong> If the response content has not been consumed
* 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
public byte[] getResponseBodyContent() {

View File

@ -180,7 +180,7 @@ public interface WebTestClient {
* There are builder methods to customize the Java config. The resulting
* WebFlux application will be tested without an HTTP server using a mock
* 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)
* @return chained API to customize server and client config; use
* {@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
* is passed to {@code WebHttpHandlerBuilder} to set up the request
* 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,
* it will be rethrown.
* <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
* {@linkplain Throwable#addSuppressed(Throwable) suppressed exception} to
* the {@code AssertionError}.

View File

@ -57,7 +57,7 @@ public interface ResultActions {
* <p>If a single {@link Error} or {@link Exception} is thrown, it will
* be rethrown.
* <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
* {@linkplain Throwable#addSuppressed(Throwable) suppressed exception} to
* the {@code AssertionError}.

View File

@ -29,7 +29,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
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}.
* @param request the request to initialize
* @return the request to use, either the one passed in or a wrapped one

View File

@ -41,7 +41,7 @@ import org.springframework.web.servlet.ModelAndView;
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
* as the request attribute {@link MockMvc#MVC_RESULT_ATTRIBUTE}.
*

View File

@ -30,11 +30,11 @@ import org.springframework.test.web.servlet.setup.MockMvcConfigurer;
/**
* Base class for implementations of {@link MockMvcWebTestClient.MockMvcServerSpec}
* that simply delegates to a {@link ConfigurableMockMvcBuilder} supplied by
* the concrete sub-classes.
* the concrete subclasses.
*
* @author Rossen Stoyanchev
* @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>>
implements MockMvcWebTestClient.MockMvcServerSpec<B> {

View File

@ -306,7 +306,7 @@ public class MockHttpServletRequestBuilder
/**
* 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
* @since 4.1.2
*/
@ -327,8 +327,8 @@ public class MockHttpServletRequestBuilder
}
/**
* Set the 'Accept' header using raw String values, possibly not even well
* formed (for testing purposes).
* Set the {@code Accept} header using raw String values, possibly not even
* well-formed (for testing purposes).
* @param mediaTypes one or more media types; internally joined as
* comma-separated String
*/
@ -408,7 +408,7 @@ public class MockHttpServletRequestBuilder
/**
* 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.
* @param params the parameters to add
* @since 5.2.2

View File

@ -66,8 +66,8 @@ public class ContentResultMatchers {
/**
* Assert the ServletResponse content type. The given content type must
* fully match including type, sub-type, and parameters. For checking
* only the type and sub-type see {@link #contentTypeCompatibleWith(String)}.
* fully match including type, subtype, and parameters. For checking
* only the type and subtype see {@link #contentTypeCompatibleWith(String)}.
*/
public ResultMatcher contentType(String contentType) {
return contentType(MediaType.parseMediaType(contentType));
@ -75,8 +75,8 @@ public class ContentResultMatchers {
/**
* Assert the ServletResponse content type after parsing it as a MediaType.
* The given content type must fully match including type, sub-type, and
* parameters. For checking only the type and sub-type see
* The given content type must fully match including type, subtype, and
* parameters. For checking only the type and subtype see
* {@link #contentTypeCompatibleWith(MediaType)}.
*/
public ResultMatcher contentType(MediaType contentType) {

View File

@ -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},
* {@code HandlerAdapter}, and others.
* @param servletContext the ServletContext

View File

@ -25,7 +25,7 @@ import java.lang.annotation.Target;
/**
* Demo <em>composed annotation</em> for {@link DisabledIf @DisabledIf} that
* disables a test class or test method if the current operating system is
* Mac OS.
* macOS.
*
* @author Sam Brannen
* @since 5.0

View File

@ -25,7 +25,7 @@ import java.lang.annotation.Target;
/**
* Demo <em>composed annotation</em> for {@link EnabledIf @EnabledIf} that
* enables a test class or test method if the current operating system is
* Mac OS.
* macOS.
*
* @author Sam Brannen
* @since 5.0

View File

@ -58,7 +58,7 @@ public interface PublishedEvents {
/**
* Further constrain the event type for downstream assertions.
*
* @param subType the sub type
* @param subType the subtype
* @return will never be {@literal null}
*/
<S extends T> TypedPublishedEvents<S> ofSubType(Class<S> subType);

View File

@ -25,7 +25,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
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.
*
* @author Sam Brannen

View File

@ -290,7 +290,7 @@ class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigurationUt
MergedContextConfiguration parent = mergedConfig.getParent();
assertThat(parent).as("parent config").isNotNull();
// The following does not work -- at least not in Eclipse.
// asssertThat(parent.getClasses())...
// assertThat(parent.getClasses())...
// So we use AssertionsForClassTypes directly.
AssertionsForClassTypes.assertThat(parent.getClasses()).containsExactly(FooConfig.class);

View File

@ -152,7 +152,7 @@ public class MockServerTests {
.expectStatus().isOk()
.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();
assertThat(bytes).isNotNull();