Commit Graph

655 Commits

Author SHA1 Message Date
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
Sam Brannen 43661ededb Verify inlined props override files in @TestPropertySource
This commit introduces a test to demonstrate that inlined properties
override properties loaded from Properties files in
@TestPropertySource.

Issue: SPR-14068
2016-03-18 15:04:14 +01:00
Sam Brannen 7a3bc2e473 Polishing 2016-03-17 14:08:13 +01:00
Rossen Stoyanchev f5a5a81e95 Support response cookies in HtmlUnit integration
Issue: SPR-14051
2016-03-16 15:26:06 -04:00
Sam Brannen d9025ddaa7 Fully test proxy support in ReflectionTestUtils
This commit adds a test for JDK dynamic proxies and fleshes out the
test for CGLIB proxies.

Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 7beff7b40a Polishing 2016-03-16 18:34:07 +01:00
Sam Brannen b1ca18e0dc Document proxy support in ReflectionTestUtils
Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 2d565c7944 Fix bugs in ReflectionTestUtils related to proxies
Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 7c7e7865bf Polishing 2016-03-16 18:34:07 +01:00
Marten Deinum 8d3ec50e87 Support proxied objects in ReflectionTestUtils
This commit adds support for unwrapping proxies in the setField() and
getField() methods in ReflectionTestUtils.

Instead of always accessing fields directly on the supplied
targetObject (which may be a proxy), AopTestUtils is now used to obtain
the potential ultimateTargetObject which is then used for accessing
fields.

Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen c41c5dd5c9 Polishing 2016-03-12 14:58:06 +01:00
Sam Brannen cbd1342fbb Polish ContextCustomizer support in the TCF
Issue: SPR-13998
2016-03-11 21:22:08 +01:00
Phillip Webb 87a3a5cb3b Introduce ContextCustomizer API in the TestContext Framework
Allow third-parties to contribute ContextCustomizers that can customize
ApplicationContexts created by the Spring TestContext Framework (TCF)
before they are refreshed.

A customizer may be provided via a ContextCustomizerFactory which is
registered with `spring.factories`. Each factory is consulted whenever
a new ApplicationContext needs to be created by the TCF. Factories may
inspect various details about the test and either return a new
ContextCustomizer or null.

ContextCustomizers are similar to ApplicationContextInitializers and
may perform any number of tasks, including bean registration, setting
of active profiles, etc.

Issue: SPR-13998
2016-03-11 20:53:06 +01:00
Juergen Hoeller d124a13eb4 Consistent use of empty enumerations 2016-03-11 15:07:59 +01:00
Sam Brannen 51eccf552f Polish ServletTestExecutionListener[Tests] 2016-03-10 17:20:02 +01:00
Phillip Webb bb590db396 Support servlet listener activate attribute
Add a ServletTestExecutionListener.ACTIVATE_LISTENER attribute which
can be set on the TestContext to trigger activation of the listener
even if a `@WebAppConfiguration` is not present.

Issue: SPR-14035
2016-03-10 16:54:14 +01:00
Phillip Webb 2244461778 Allow @ContextConfiguration to be omitted
Prior to this commit, the @ContextConfiguration annotation was required
to be present even if default XML files, Groovy scripts, or
@Configuration classes were detected; however, in such cases the
@ContextConfiguration was typically declared empty and therefore
seemingly unnecessary boilerplate.

This commit permits @ContextConfiguration to be omitted whenever it can
be reasonably deduced. Consequently, integration tests such as the
following are now supported.

    @RunWith(SpringRunner.class)
    public class MyTest {

        @Autowired String myBean;

        @Test public void example() { /* ... */ }

        @Configuration
        static class Config {

            @Bean String myBean() {
                return "Hello";
            }
        }
    }

Issue: SPR-13955
2016-03-08 19:36:49 +01:00
Sam Brannen 89cf4772d5 Fix malformed HTML in Javadoc 2016-03-08 15:27:35 +01:00
Sam Brannen 93fb7be783 Polishing 2016-03-08 15:18:21 +01:00
Phillip Webb 504779e210 Remove @BootstrapWith from @WebAppConfiguration
Update @WebAppConfiguration so that it no longer directly specifies
a TestContextBootstrapper. This allows third parties to use the
annotation in combination with their own bootstrapper.

BootstrapUtils now provides the detection logic for when
WebTestContextBootstrapper should be used.

Issue: SPR-13991
2016-03-08 14:31:06 +01:00
Sam Brannen 067994712d Make TestContextManager.getTestContext() public
This commit changes the visibility of the getTestContext() method in
TestContextManager from 'protected' to 'public' in order to support
test method injection in JUnit 5 and similar use cases.

Issue: SPR-14011
2016-03-02 20:19:25 +01:00