Commit Graph

675 Commits

Author SHA1 Message Date
Sam Brannen
de78f05707 Polishing 2016-06-07 16:24:50 +02:00
Sam Brannen
eaa9511921 Avoid ClassCastException in HandlerResultMatchers.methodCall() 2016-06-07 16:13:42 +02:00
Sam Brannen
5a0100111e Polish HandlerAssertionTests 2016-06-07 16:13:42 +02:00
Juergen Hoeller
8c4bc3656b Polishing 2016-06-07 15:42:16 +02:00
Sam Brannen
c19740a020 Clean up warnings in spring-test 2016-06-06 18:54:16 +02:00
Rossen Stoyanchev
998b83ce8c Fix hardcoded value MockRestServiceServerBuilder 2016-06-06 08:46:50 -04:00
Rossen Stoyanchev
d10134b5a5 Polish 2016-05-31 12:56:17 -04:00
Rob Winch
54f84cbd97 MockMvcWebConnection stores cookies from response
Previously MockMvcWebConnection did not update the cookie manager with the
cookies from MockHttpServletResponse. This meant that newly added cookies
are not saved to the cookie manager and thus are not presented in the next
request.

This commit ensures that MockMvcWebConnection stores the response cookies
in the cookie manager.

Issue: SPR-14265
2016-05-31 12:43:58 -04:00
Juergen Hoeller
822e40e24f AssertionErrors.assertEquals exposes readable array representation
Issue: SPR-14281
2016-05-30 17:16:03 +02:00
Juergen Hoeller
a1e9459a43 @SafeVarargs for header(String, Matcher...) method
Issue: SPR-14278
2016-05-30 15:06:55 +02:00
Sam Brannen
31a93792b2 Delete unused imports 2016-05-27 16:33:43 +02:00
Rossen Stoyanchev
4e8754ea87 Add reset() to MockRestServiceServer
Issue: SPR-14306
2016-05-26 11:44:40 -04:00
Rossen Stoyanchev
f4ab6d8d52 MockRestServiceServerBuilder can be re-used
Issue: SPR-14306
2016-05-26 09:48:16 -04:00
Sam Brannen
a1a87679da Support test annotations on interfaces
Prior to Java 8 it never really made much sense to author integration
tests using interfaces. Consequently, the Spring TestContext Framework
has never supported finding test-related annotations on interfaces in
its search algorithms.

However, Java 8's support for interface default methods introduces new
testing use cases for which it makes sense to declare test
configuration (e.g., @ContextConfiguration, etc.) on an interface
containing default methods instead of on an abstract base class.

This commit ensures that all non-repeatable, class-level test
annotations in the Spring TestContext Framework can now be declared on
test interfaces. The only test annotations that cannot be declared on
interfaces are therefore @Sql and @SqlGroup.

Issue: SPR-14184
2016-05-05 19:54:44 +02:00
Sam Brannen
f09c7868d8 Polishing 2016-05-04 16:04:37 +02:00
Sam Brannen
e26478e3de Polish Javadoc regarding @Commit support 2016-05-03 20:26:11 +02:00
Sam Brannen
0f6711fe3b Support @[Before|After]Transaction on default methods
Prior to this commit, @BeforeTransaction and @AfterTransaction could
only be declared on methods within test classes. However, JUnit 5 as
well as some existing third-party Runner implementations for JUnit 4
already support Java 8 based interface default methods in various
scenarios -- for example, @Test, @BeforeEach, etc.

This commit brings the Spring TestContext Framework up to date by
supporting the declaration of @BeforeTransaction and @AfterTransaction
on interface default methods.

Issue: SPR-14183
2016-05-03 18:57:31 +02:00
Sam Brannen
3433fe35df Fix assertion failure messages in TransactionalTestExecutionListenerTests 2016-05-03 18:57:31 +02:00
Juergen Hoeller
8ddb432694 Polishing 2016-04-27 21:35:26 +02:00
Rob Winch
9ec0873604 MockWebResponseBuilder defaults cookie domain
Previously MockWebResponseBuilder would use the cookie domain of the cookie
received from MockMvc response. This caused problems because the cookie
domain can be null, but HtmlUnit forbids a null domain.

This commit defaults the domain of the cookie to the domain of the
WebRequest.

Issues SPR-14169
2016-04-25 16:35:56 -05:00
Sam Brannen
c84c1cfd1b Update Javadoc for TestContextBootstrapper
@WebAppConfiguration is no longer meta-annotated with @BootstrapWith.
2016-04-25 15:44:15 +02:00
Sam Brannen
67a9f40c95 Polish Javadoc for TestContextManager 2016-04-23 18:23:25 +02:00
Johnny Lim
44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Sam Brannen
ff38224da6 Introduce tests for @[Before|After]Transaction on default methods
This commit introduces @Ignore'd tests for future support for declaring
@BeforeTransaction and @AfterTransaction on interface default methods.

Issue: SPR-14183
2016-04-17 16:01:07 +02:00
Johnny Lim
c402932ba1 Use the defined constant in MergedContextConfiguration
Closes gh-1037
2016-04-16 10:32:41 +02:00
Rob Winch
87ed8e939c HtmlUnitRequestBuilder decodes parameter names
Previously HtmlUnitRequestBuilder did not decode parameter names. This
means if a parameter like row[0] was submittted it would be encoded as
row%5B0%5D When the HttpServletRequest was created the parameter name would
not be decoded so the parameter name row[0] would not be found.

This commit ensures that HTTP parameter names are decoded.

Issue SPR-14177
2016-04-15 10:23:00 -05:00
Juergen Hoeller
f1cb793ccb Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
2016-04-14 16:38:59 +02:00
Juergen Hoeller
b6f1afd471 Polishing 2016-04-11 21:20:31 +02:00
Juergen Hoeller
537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Sam Brannen
463c8f149d Add properties files directly to environment in TestPropertySourceUtils
This commit introduces a new method in TestPropertySourceUtils that
allows properties files to be added directly to the environment without
the need for a ConfigurableApplicationContext upfront; however, a
ResourceLoader is still necessary.

Issue: SPR-14131
2016-04-07 17:02:37 +02:00
Juergen Hoeller
6573e9142c Polishing 2016-04-05 12:17:21 +02:00
Juergen Hoeller
d2d528dc05 Polishing 2016-04-05 09:42:41 +02:00
Sam Brannen
6c0cae87b4 Clean up warnings in spring-test 2016-04-04 21:30:01 +02:00
Sam Brannen
e18d5b591a Limit size of context cache in the TestContext framework
Prior to this commit, the size of the ApplicationContext cache in the
Spring TestContext Framework could grow without bound, leading to
issues with memory and performance in large test suites.

This commit addresses this issue by introducing support for setting the
maximum cache size via a JVM system property or Spring property called
"spring.test.context.cache.maxSize". If no such property is set, a
default value of 32 will be used.

Furthermore, the DefaultContextCache has been refactored to use a
synchronized LRU cache internally instead of a ConcurrentHashMap. The
LRU cache is a simple bounded cache with a "least recently used" (LRU)
eviction policy.

Issue: SPR-8055
2016-04-04 20:56:04 +02:00
Sam Brannen
2ed3382a60 Document composed support for @Scheduled, @JmsListener, & @Sql
Issue: SPR-13973
2016-03-29 19:53:58 +02:00
Sam Brannen
26bbb6e767 Polishing 2016-03-28 16:17:47 +02:00
Juergen Hoeller
94cb7786c8 Polishing 2016-03-25 23:28:45 +01:00
Sam Brannen
b0c6357540 Test @Sql as a merged composed annotation
Issue: SPR-13973
2016-03-25 20:47:16 +01:00
Phillip Webb
fc839331a7 Refine TestPropertySourceUtils for direct use
Update methods in TestPropertySourceUtils to accept var-args and allow
addInlinedProperties to be called more than once.

Issue: SPR-14088
2016-03-25 11:12:27 -07:00
Sam Brannen
c6f6e192c0 Support @Sql as a merged composed annotation
Issue: SPR-13973
2016-03-25 00:51:42 +01:00
Juergen Hoeller
517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller
9af12d290e Polishing 2016-03-23 18:39:29 +01:00
Juergen Hoeller
5025c615b1 Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
2016-03-23 18:39:20 +01:00
Sam Brannen
532ed0a4cf Clean up warnings in the spring-test module 2016-03-20 19:37:54 +01:00
Sam Brannen
c5200978b0 Polishing 2016-03-18 19:44:20 +01:00
Rob Winch
411ff8450f Refine tests for SPR-14066
Explicitly define the response type as text/plain to avoid content type
confusion.

Issue SPR-14066
2016-03-18 13:24:10 -05:00
Sam Brannen
455bf45fa4 Fix test that failed due to upgrade to HtmlUnit 2.20 2016-03-18 18:43:46 +01:00
Brian Clozel
7ae44c2565 Allow skipping JSON prefix in MockMvc result matchers
JSON payloads are sometimes prepended with a static string prefix
to prevent Cross Site Scripting Inclusion attacks (XSSI).
Prior to this commit, doing so would fail the MockMvc
`JsonPathResultMatchers` since they're considering the whole response as
the JSON payload.

This commit adds a new `JsonPathResultMatchers.prefix` method that
configures the matchers to check for the presence of that string (i.e.
fail if it's not there) and only consider the rest of the response body
as the JSON payload for other assertions.

Issue: SPR-13577
2016-03-18 18:13:42 +01:00
Rossen Stoyanchev
d3822c8d19 Polish 2016-03-18 12:01:09 -04:00
Rob Winch
7d96ad1f6e MockMvc HtmlUnit support shares CookieManager
Previously MockMvc builders failed to share the WebConnection used for
managing cookies in the MockMvcWebConnection. This meant that the various
CookieManagers would have different states.

This commit ensures that the WebConnection is set on the
MockMvcWebConnection.

Fixes SPR-14066
2016-03-18 12:01:09 -04:00