Commit Graph

1943 Commits

Author SHA1 Message Date
Sam Brannen
933474000b Polishing 2022-12-08 18:45:02 -05:00
Sam Brannen
41a6b7ec20 Update copyright headers for source code changed since August 2022
The changes in this commit were performed using the newly introduced
update_copyright_headers.sh script.
2022-12-03 17:23:21 -05:00
Sam Brannen
8e64701cb7 Fix Javadoc formatting issue in TestSocketUtils 2022-11-15 14:47:00 +01:00
Sam Brannen
698f8995f7 Revise TestSocketUtils and tests
Closes gh-29132
2022-11-14 20:26:58 +01:00
Chris Bono
ee51dab1f3 Introduce TestSocketUtils as a replacement for SocketUtils
SocketUtils was officially deprecated in 5.3.16 (gh-28052) and removed
in 6.0 M3 (gh-28054); however, there is still need for a subset of this
functionality in integration tests for testing scenarios in which it is
not possible for the system under test to select its own random port
(or rely on the operating system to provide an ephemeral port).

This commit therefore introduces a scaled down version in the
spring-test module called TestSocketUtils which supports retrieval of a
single TCP port.

See gh-29132
2022-11-14 20:26:58 +01:00
Juergen Hoeller
d7d44c6c51 Polishing 2022-11-10 18:26:49 +01:00
Sam Brannen
5f02323b9c Avoid String allocations with Assert.isTrue() 2022-11-05 14:40:45 +01:00
Sam Brannen
a281d8c3fd Polishing 2022-11-04 16:24:59 +01:00
Sam Brannen
b71d95df71 Document how to switch to the default set of TestExecutionListeners
Closes gh-29281
2022-10-08 16:20:55 +02:00
Sam Brannen
b20de758b2 Support custom status code in ExchangeResult for WebTestClient
Prior to this commit, ExchangeResult.assertWithDiagnostics() threw an
IllegalArgumentException for a custom HTTP status code since toString()
invoked getStatus() without a try-catch block.

This commit addresses this issue by introducing a formatStatus() method
that defensively formats the response status, initially trying to
format the HttpStatus and falling back to formatting the raw integer
status code.

Closes gh-29283
2022-10-08 15:45:24 +02:00
Johnny Lim
1c1a0afbed Use AssertJ static imports consistently in 5.3.x
Closes gh-29282
2022-10-08 13:57:21 +02:00
Sam Brannen
a599601dd9 Document how to switch to the default set of TestExecutionListeners
Closes gh-29281
2022-10-07 17:58:22 +02:00
Sam Brannen
5eee4673c1 Document limitation of AopTestUtils.getUltimateTargetObject() regarding non-static TargetSource
Closes gh-29276
2022-10-07 16:09:39 +02:00
Marc Wrobel
ce49068ff9 Fix links in Javadoc and reference docs
- Fix broken links (by using a new URL, an alternative URL, or a
  Wayback Machine link)

- Use HTTPS where possible

- Remove https://issuetracker.springsource.com/browse/EBR-349: this
  link is dead and is also mentioned in
  https://jira.spring.io/browse/SPR-8093

- Clean up nohttp allowlist.lines

Closes gh-28876
2022-09-14 17:00:11 +02:00
Johnny Lim
5f5d383eeb Fix Javadoc since tag for AbstractGenericWebContextLoader.createContext()
See gh-28983
Closes gh-29154
2022-09-14 15:53:18 +02:00
Sam Brannen
2c75eb8745 Support @Nested tests in MockServerContainerContextCustomizerFactory
Prior to this commit, MockServerContainerContextCustomizerFactory did
not find @WebAppConfiguration on an enclosing class and therefore
failed to create a MockServerContainerContextCustomizer for a @Nested
test class.

This commit addresses this by using TestContextAnnotationUtils to
determine if the test class is "annotated" with @WebAppConfiguration.

Closes gh-29037
2022-08-28 18:41:27 +02:00
Sam Brannen
711820ec70 Introduce createContext() factory method in AbstractWebGenericContextLoader
Prior to this commit it was possible to configure the
DefaultListableBeanFactory used by the GenericWebApplicationContext
created by AbstractWebGenericContextLoader, but it was not possible to
completely replace the bean factory.

This commit introduces a new createContext() factory method in
AbstractWebGenericContextLoader which indirectly allows subclasses to
supply a custom DefaultListableBeanFactory implementation to the
GenericWebApplicationContext.

See gh-25600
Closes gh-28983
2022-08-21 15:05:23 +02:00
Sam Brannen
69d87f16ee Reorganize internals of DefaultCacheAwareContextLoaderDelegate 2022-08-21 15:02:28 +02:00
Sam Brannen
38f94799f4 Use andExpectAll() in example in MockMvc Javadoc 2022-08-19 16:05:31 +02:00
Sam Brannen
4264d0becd Fix example in MockMvc Javadoc 2022-08-19 16:02:10 +02:00
Marc Wrobel
bd3499671c Fix typos in test code
This commit fixes typos in test class names, test method names, and
test variable names.

Closes gh-28807
2022-07-13 16:24:11 +02:00
Sam Brannen
31a9694fc8 Improve Javadoc for ContextCache#clearStatistics()
See gh-28795
2022-07-12 13:04:34 +02:00
Marc Wrobel
92b8e99cbc Fix and improve Javadoc in spring-test
Closes gh-28795
2022-07-12 12:55:59 +02:00
Sam Brannen
d274e893a6 Remove superfluous static declaration for enum, annotation, & interface 2022-07-09 16:16:13 +02:00
Sam Brannen
9ea45697ac Support cookie comments in MockHttpServletResponse and MockCookie
Prior to this commit, if a cookie was added to MockHttpServletResponse,
the comment attribute was not included in the generated Set-Cookie
header. In addition, MockCookie.parse(String) did not support the
Comment attribute.

This commit addresses both of these issues.

Closes gh-28730
2022-06-30 16:51:43 +02:00
Sam Brannen
d6768ccc18 Ensure meta-annotations are not unnecessarily synthesized
Prior to this commit, meta-annotations were unnecessarily synthesized
when attempting to synthesize a MergedAnnotation retrieved via the
MergedAnnotations.from(AnnotatedElement, ...).get(<annotationType>) API.

This is a regression in our merged annotation support that was
introduced when the MergedAnnotations API replaced our previous support.

This commit fixes this by revising the logic in TypeMappedAnnotation's
createSynthesizedAnnotation() method so that a meta-annotation is
returned unmodified if it is not synthesizable.

This commit also updates BootstrapUtilsTests, since @BootstrapWith
should never have been synthesized, and Class#getCanonicalName() is
only used in the toString() implementation of an annotation synthesized
by Spring or normal annotations on Java 19+ (see
https://bugs.openjdk.org/browse/JDK-8281462).

Closes gh-28704
2022-06-25 20:02:04 +02:00
Sam Brannen
661996471e Polishing 2022-06-25 19:24:51 +02:00
Sam Brannen
fb1fa073a6 Polishing 2022-06-15 15:07:58 +02:00
Sam Brannen
e9806a96dc Polish contribution and introduce test
See gh-28631
2022-06-15 15:07:58 +02:00
Johnny Lim
9b93508374 Add MockMvcRequestBuilders.multipart(HttpMethod, String, Object...)
See gh-28545
Closes gh-28631
2022-06-15 14:09:59 +02:00
rstoyanchev
7c47b470ff MockMvc allows HttpMethod input for multipart request
Closes gh-28545
2022-06-08 10:07:52 +01:00
Sam Brannen
479ef3f3fd Update documentation regarding nested test class support
Closes gh-28579
2022-06-08 09:52:42 +02:00
Sam Brannen
1beb7068f6 Use new AssertJ exception assertions 2022-05-31 14:08:28 +02:00
Sam Brannen
afa799b4f0 Suppress warning in test 2022-05-03 11:46:47 +02:00
rstoyanchev
f0d149b330 Polishing contribution
Closes gh-27830
2022-04-28 11:26:50 +01:00
binchoo
caaf83b8e6 Add tests for binding to a Part field
See gh-27830
2022-04-28 10:45:09 +01:00
Sam Brannen
1d302bf384 Introduce tests for gh-28228 2022-03-27 16:29:45 +02:00
Sam Brannen
c462fe30ed Use Named arguments in parameterized tests 2022-03-16 14:45:47 +01:00
rstoyanchev
ee7f60000e Polishing contribution
Closes gh-28105
2022-03-16 05:56:47 +00:00
azzureman
f1fdc11fab Support custom HTTP status in MockClientHttpResponse
See gh-28105
2022-03-16 05:56:23 +00:00
Sam Brannen
d9c22e657f Document the effect of @DirtiesContext on test execution events
See gh-27757
2022-03-12 16:05:14 +01:00
Sam Brannen
af977c0891 Improve documentation for @EnabledIf and @DisabledIf test support
Closes gh-28157
2022-03-10 19:27:41 +01:00
Sam Brannen
a2f02dbfc0 Improve documentation for TestContext events
This commit improves the documentation for test execution events,
especially with regard to the fact that, by default, a
BeforeTestClassEvent is not published for the first test class using a
particular ApplicationContext.

This commit also introduces tests that verify the default behavior and
the ability to change the default behavior with a custom
TestExecutionListener that eagerly loads the context.

Closes gh-27757
2022-03-06 17:51:49 +01:00
Sam Brannen
3ac60147f3 Improve documentation for uri(URI) method in WebTestClient
Prior to this commit, it was not clear that a configured base URI would
not be applied when invoking uri(URI).

This commit adds a note to the Javadoc to clarify that behavior.

Closes gh-28058
2022-02-16 12:11:33 +01:00
Sam Brannen
ce87285be5 Use canonical names for types in synthesized annotation toString
My proposal for the same change in the JDK is currently targeted for
JDK 19.

- https://bugs.openjdk.java.net/browse/JDK-8281462
- https://bugs.openjdk.java.net/browse/JDK-8281568
- https://github.com/openjdk/jdk/pull/7418

See gh-28015
2022-02-10 16:59:00 +01:00
Sam Brannen
038b88e2a1 Polishing 2022-02-05 20:23:45 +01:00
Sam Brannen
eb84c84373 Polish contribution
See gh-27993
2022-02-05 20:15:30 +01:00
Gleidson Leopoldo
920be8e1b2 Add support for strict JSON comparison in WebTestClient
Prior to this commit, WebTestClient only supported "lenient" comparison
of the expected JSON body.

This commit introduces an overloaded variant of `json()` in the
BodyContentSpec that accepts an additional boolean flag to specify
whether a "strict" comparison should be performed.

This new feature is analogous to the existing support in MockMvc.

Closes gh-27993
2022-02-05 20:15:30 +01:00
Sam Brannen
a13ad3e969 Polishing 2022-02-05 20:15:30 +01:00
Stephane Nicoll
cfefcee788 Polishing
See gh-27926
2022-01-13 08:28:54 +01:00