Commit Graph

198 Commits

Author SHA1 Message Date
Andy Wilkinson
abf39915e8 Polish 2017-08-04 11:12:33 +01:00
Phillip Webb
9127c48fb5 Fixup warnings 2017-07-27 16:39:49 -07:00
Phillip Webb
a869d25dbb Polish 2017-07-27 16:16:35 -07:00
Stephane Nicoll
579c6feb93 Polish 2017-07-27 11:10:12 +02:00
Stephane Nicoll
eacb6b13f3 Fix compatibility with JUnit's ExpectedException
This commit ensures that an exception that is thrown as part of the
`ContextConsumer` callback is thrown as is.

Closes gh-9878
2017-07-27 11:08:01 +02:00
Phillip Webb
ad9f28110c Make TestPropertyValues immutable
Update `TestPropertyValues` so that it is totally immutable. Methods
now return a new instance rather than changing existing state.

See gh-9875
2017-07-26 17:49:31 -07:00
Phillip Webb
07556cda51 Restructure boot.test.context package
Split up `org.springframework.boot.test.context` into distinct packages
for `runner` and `assertj`.

See gh-9875
2017-07-26 17:47:59 -07:00
Phillip Webb
497457c397 Rename ApplicationContextTester -> Runner
Rename `ApplicationContextTester` and related classes to
`ApplicationContextRunner` and refactor existing tests to use correctly
named variables.

See gh-9875
2017-07-26 17:46:06 -07:00
Emanuel Campolo
2626a3a795 Use lambdas when possible
Replace anonymous inner classes with lambda declarations (when possible
using method references).

See gh-9781
2017-07-25 00:53:38 -07:00
Phillip Webb
3a01f4a6da Polish lambda formatting 2017-07-24 13:18:33 -07:00
Johnny Lim
bd27d147d7 Polish
Closes gh-9827
2017-07-21 15:38:00 +01:00
Andy Wilkinson
ee3525aa47 Merge branch '1.5.x' 2017-07-21 15:27:46 +01:00
Andy Wilkinson
f6727e786a Polish "Fix JsonContentAssert type safety warnings"
- Format code
- Update an existing test to use the contains method that would
  previously have triggered a type safety warning

Closes gh-9675
2017-07-21 15:14:53 +01:00
Phillip Webb
24d086066b Rework ApplicationContext test helper
Rename `ContextLoader` to `ApplicationContextTester` and provide
distinct subclasses for standard, web and reactive application contexts.

Context callbacks now return AssertJ compatible contexts, allowing
tests to run directly on context. For example:

	context.run((loaded) -> assertThat(loaded).hasBean("foo"));

The returned context can now also represent a context that has failed
to start (meaning that the `loadAndFail` methods are no longer needed):

	context.run((loaded) -> assertThat(loaded).hasFailed());

Configuration classes are loaded via the recently introduced
`Configurations` class. This means that the tester no longer needs to
be directly aware of auto-configuration concepts.

See gh-9634
2017-07-19 12:16:12 -07:00
Phillip Webb
c6f55ef46d Add system property support to TestPropertyValues
Update `TestPropertyValues` so that it can also be used to update
system properties.  Properties are set before the call is made and
restored to their previous value afterwards.

Fixes gh-9792
2017-07-19 12:14:26 -07:00
Stephane Nicoll
e844c92465 Expose AssertionErrors as is
Closes gh-9760
2017-07-14 18:19:03 +02:00
Stephane Nicoll
ef5c2afcc9 Polish 2017-07-07 11:11:16 +01:00
Andy Wilkinson
dd0ce54425 Improve the type-safety of ContextLoader for servlet and reactive web 2017-07-07 11:11:16 +01:00
Stephane Nicoll
0fcf6a0e51 Allow to specify multiple auto-configs in autoConfigFirst 2017-06-30 14:52:31 +02:00
Stephane Nicoll
18ba414000 Add test helper to manipulate the ApplicationContext
This commit adds ContextLoader, a test helper that configures an
ApplicationContext that is meant to simulate a particular
auto-configuration scenario.

The auto-configuration, user configuration and environment can be
customized. The loader invokes a ContextConsumer to assert the context
and automatically close the context once it is done.

Concretely, tests can create a shared field instance of that helper with
the shared configuration to increase its visibility and tune the context
further in each test.

If the context is expected to fail, `loadAndFail` allows to optionally
assert the root exception and consume it for further assertions.

This commit also migrates some tests to illustrate the practical use of
the helper

Closes gh-9634
2017-06-29 15:34:10 +02:00
Andy Wilkinson
991314c63d Merge branch '1.5.x' 2017-06-16 09:13:42 +01:00
Phillip Webb
b94bb00fa1 Remove need for attached test-jar artifacts
Remove test-jar artifacts from Maven projects and relocate classes. The
majority of utilities now live in the `spring-boot-testsupport` module.

This update will help us to deploy artifacts using the standard Maven
deploy plugin in the future (which doesn't support the filtering of
individual artifacts).

Fixes gh-9493
2017-06-12 21:11:35 -07:00
Andy Wilkinson
61a1798296 Merge branch '1.5.x' 2017-06-06 21:39:09 +01:00
Andy Wilkinson
21a5ab7875 Log a warning during tests when multiple JSONOjects on the class path
Closes gh-9248
2017-06-06 21:35:33 +01:00
Phillip Webb
2c7dd9f519 Polish 2017-06-02 16:00:39 -07:00
Stephane Nicoll
9332a3a4ae Merge branch '1.5.x' 2017-05-28 17:46:00 +02:00
Stephane Nicoll
b5709fd618 Polish
See gh-9330
2017-05-28 17:44:58 +02:00
Madhura Bhave
05254fe322 Deprecate EnvironmentTestUtils in favor of TestPropertyValues
Fixes gh-9253
2017-05-24 14:58:40 -07:00
Andy Wilkinson
b71daac58a Remove redundant logic for uninstalling Tomcat's URL stream handler factory
Closes gh-8622
2017-05-11 17:22:15 +01:00
Phillip Webb
931ce15d7f Update copyright header dates 2017-05-09 21:43:52 -07:00
Phillip Webb
06558675bb Polish 2017-04-25 09:45:14 -07:00
Phillip Webb
81fef71fcb Merge branch '1.5.x' 2017-04-19 22:48:46 -07:00
Phillip Webb
5abc050a96 Support detection and with test initializers
Relax `SpringBootTestContextBootstrapper` rules so that a test can
specify an `ApplicationContextInitializer` and still have
`@SpringBootConfiguration` detected.

Prior to this commit detection would not occur because it's possible
that an initializer _could_ register configuration. This scenario is
actually quite unlikely to occur, certainly less likely than wanting to
use an initializer in combination with auto-detection.

Fixes gh-8483
2017-04-19 22:18:12 -07:00
Phillip Webb
850517a8db Fix merge issue 2017-04-18 21:57:33 -07:00
Phillip Webb
94209e2883 Merge branch '1.5.x' 2017-04-18 15:06:43 -07:00
Phillip Webb
393c17b68b Support @SpringBootTest with @ContextHierarchy
Update SpringBootTestContextBootstrapper to detect `@ContextHierarchy`
annotations so that only the last child creates a
`WebApplicationContext`.

Prior to this commit a context hierarchy would start two embedded web
servers which is inconsistent with the `SpringApplicationBuilder`
behavior.

Fixes gh-8311
2017-04-18 14:56:12 -07:00
Phillip Webb
8eb79b3c0f Polish 2017-04-18 11:13:12 -07:00
Phillip Webb
383640d5ec Merge branch '1.5.x' 2017-04-17 22:15:33 -07:00
Phillip Webb
f46d799f31 Polish 2017-04-17 22:08:51 -07:00
Madhura Bhave
ed072abaef Merge branch '1.5.x' 2017-04-17 11:42:02 -07:00
Madhura Bhave
9e2d54feae Support json view with JacksonTester
Closes gh-8672
2017-04-17 11:14:26 -07:00
Phillip Webb
700f0ea93c Fix WebClientTest calls
Update calls to WebClientTest following upstream changes.
2017-04-14 16:26:01 -07:00
Andy Wilkinson
ef72c22563 Update HtmlUnitDriver tests to align with HtmlUnit 2.26
See gh-8853 and cb34189c66
2017-04-07 12:10:39 +01:00
Stephane Nicoll
6d6d76ca06 Polish
See gh-8543
2017-03-16 09:54:06 +01:00
Madhura Bhave
0b1d32e762 Add tests for TestRestTemplate in reactive env
Closes gh-8543
2017-03-15 14:46:44 -07:00
Phillip Webb
b76ca0bf8f Restructure web auto-configuration
Restructure `org.springframework.boot.autoconfigure.web` to better align
with the new package structure in `spring-boot`.

Auto-configuration is now split into client, servlet and reactive
sub-packages. In addition a new `http` package now handles common
HTTP concerns.

Fixes gh-8616
2017-03-14 22:06:28 -07:00
Phillip Webb
67556ba8ea Restructure embedded web server packages
Rework `org.springframework.boot.context.embedded` to relocate classes
to `org.springframework.boot.web`. Packages are now organized around
the following areas:

Packages for shared concerns, for example the `WebServer` interface
to start/stop a server and the common configuration elements:
- org.springframework.boot.web.context
- org.springframework.boot.web.server

Servlet specific packages:
- org.springframework.boot.web.servlet.server
- org.springframework.boot.web.servlet.context
- org.springframework.boot.web.servlet.filter

Reactive specific packages:
- org.springframework.boot.web.reactive.context
- org.springframework.boot.web.reactive.server

Embedded server implementations (both reactive and servlet):
- org.springframework.boot.web.embedded

In addition:

- Rename `EmbeddedServletContainerFactory` to `ServletWebServerFactory`
  to align with the `ReactiveWebServerFactory`.
- Rename `EmbeddedWebApplicationContext` to
  `ServletWebServerApplicationContext` and
- Rename `EmbeddedReactiveWebApplicationContext` to
  `ReactiveWebServerApplicationContext`.
- Add checkstyle rules to restrict imports.
- Fixup all affected code to use the correct imports and local names.

Fixes gh-8532
2017-03-12 21:08:25 -07:00
Andy Wilkinson
62de505e43 Update tests to align with slight change in HtmlUnit's behaviour
See gh-8515
2017-03-10 09:45:10 +00:00
Stephane Nicoll
361ad69a4b Merge branch '1.5.x' 2017-03-10 09:55:11 +01:00
Stephane Nicoll
c8ac94b75d Polish contribution
Closes gh-8490
2017-03-10 09:51:35 +01:00