Commit Graph

324 Commits (dff9fb12aa3063c5c7af16fc78dfab19aab331ec)

Author SHA1 Message Date
Johnny Lim bd27d147d7 Polish
Closes gh-9827
7 years ago
Andy Wilkinson 20577657ee Merge branch '1.5.x' 7 years ago
Andy Wilkinson ece66e1d4a Polish javadoc in JsonContentAssert
See gh-9675
7 years ago
Andy Wilkinson ee3525aa47 Merge branch '1.5.x' 7 years ago
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
7 years ago
Mihhail Lapushkin ae91c8460f Fix JsonContentAssert type safety warnings
Previously, JsonContentAssert returns AbstractMapAssert from
extractingJsonPathMapValue. This could lead to type safety warnings
when calling one of the assert's methods with a generic varargs
parameter such as
contains(Entry<? extends Object, ? extends Object>...).

This commit replaces the use of both AbstractMapAssert and
AbstractListAssert with MapAssert and ListAssert respectively. These
classes use final methods and @SafeVargs args to prevent the
above-described problem from occurring.

See gh-9675
7 years ago
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
7 years ago
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
7 years ago
Stephane Nicoll e844c92465 Expose AssertionErrors as is
Closes gh-9760
7 years ago
Andy Wilkinson 3fb1bdef85 Add support to ContextLoader for configuring context's parent
Closes gh-9749
7 years ago
Phillip Webb 8e3baf3130 Polish 7 years ago
Stephane Nicoll ef5c2afcc9 Polish 7 years ago
Andy Wilkinson dd0ce54425 Improve the type-safety of ContextLoader for servlet and reactive web 7 years ago
Andy Wilkinson 19ddfad63e Migrate some more tests to the new ContextLoader 7 years ago
Andy Wilkinson e91b4d0bb3 Polish ContextLoader 7 years ago
Brian Clozel f2e77e46cd Auto-configure codecs in WebTestClient
This commit applies what's been done in gh-9166 for WebFlux client and
server, but for the `WebTestClient` auto-configuration.

`WebTestClient` can be configured for mock or integration tests and this
change applies `CodecCustomizer` beans to the client being built.

Closes gh-9577
7 years ago
Stephane Nicoll 0fcf6a0e51 Allow to specify multiple auto-configs in autoConfigFirst 7 years ago
Stephane Nicoll 5ecdee0e1b Polish 7 years ago
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
7 years ago
Andy Wilkinson 991314c63d Merge branch '1.5.x' 8 years ago
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
8 years ago
Spring Buildmaster 05d4d0281c Next Development Version 8 years ago
Andy Wilkinson 563c9dc58c Merge branch '1.5.x' 8 years ago
Andy Wilkinson 84721666c5 Stop DuplicateJsonObjectContextCustomizer breaking context caching
See gh-9248
8 years ago
Andy Wilkinson 61a1798296 Merge branch '1.5.x' 8 years ago
Andy Wilkinson 21a5ab7875 Log a warning during tests when multiple JSONOjects on the class path
Closes gh-9248
8 years ago
Phillip Webb 2c7dd9f519 Polish 8 years ago
Stephane Nicoll 9332a3a4ae Merge branch '1.5.x' 8 years ago
Stephane Nicoll b5709fd618 Polish
See gh-9330
8 years ago
Madhura Bhave d745b69630 Replace usages of EnvironmentTestUtils 8 years ago
Madhura Bhave 05254fe322 Deprecate EnvironmentTestUtils in favor of TestPropertyValues
Fixes gh-9253
8 years ago
Phillip Webb 889d43ddc4 Refine SpringApplication source types
Update `SpringApplication` so that the `run` methods and constructors
now require `Class<?>` arguments, rather than `Objects`. String based
sources can still be loaded, but must now be set on the `getSources()`
collections. `Package` and `Resource` types are no longer directly
supported.

This change should help IDEs offer better content assist, and will
help integrations with alternative languages such as Ceylon.

Users currently passing in Class references or using the
`spring.main.sources` property should not be affected by this change. If
an XML resource is being used, some refactoring may be required (see the
changes to `SampleSpringXmlApplication` in this commit).

Fixes gh-9170
8 years ago
Stephane Nicoll e007f20725 Merge branch '1.5.x' 8 years ago
Stephane Nicoll a22b3d9515 Merge branch '1.4.x' into 1.5.x 8 years ago
Stevo Slavić 6e1d99aa10 Fix typo in javadoc
Closes gh-9212
8 years ago
Andy Wilkinson b71daac58a Remove redundant logic for uninstalling Tomcat's URL stream handler factory
Closes gh-8622
8 years ago
Phillip Webb fa4de13519 Rework ConfigurationPropertySources
Rework the ConfigurationPropertySources and related adapter classes to
help with performance. The ConfigurationPropertySources class now only
monitors for updates when `.attach` is used. The `.get` methods now
return the adapted version, but no longer checks to see if sources have
been added or removed on each call.

This commit also fixes a few caching issues and makes both the
`PropertyMapper` implementations true static singletons.

See gh-9000
8 years ago
Phillip Webb 931ce15d7f Update copyright header dates 8 years ago
Madhura Bhave c0d4a771c9 Use new configuration properties in spring-boot-test
Update `spring-boot-test` to use the new configuration properties
support.

See gh-9000
8 years ago
Phillip Webb 06558675bb Polish 8 years ago
Spring Buildmaster 9768b0a8c2 Next Development Version 8 years ago
Spring Buildmaster d719d2cbbc Next Development Version 8 years ago
Phillip Webb 81fef71fcb Merge branch '1.5.x' 8 years ago
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
8 years ago
Phillip Webb 850517a8db Fix merge issue 8 years ago
Phillip Webb 94209e2883 Merge branch '1.5.x' 8 years ago
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
8 years ago
Phillip Webb 8eb79b3c0f Polish 8 years ago
Phillip Webb 383640d5ec Merge branch '1.5.x' 8 years ago
Phillip Webb f46d799f31 Polish 8 years ago