This commit changes the default value of bootstrap-mode to "default"
rather than "deferred" so that the JPA infrastructure starts in the
main thread rather than asynchronously.
Closes gh-24249
Previously, when an embedded test database was being auto-configured
any schema username and password specified by the user would result
in a separate embedded test database being created to load the schema.
This then left the actual test database without the schema causing
test failures.
This commit updates the test database auto-configuration to set the
schema username to an empty string in a property source that's added
first to the environment's property sources. This causes any schema
username configured by the user to be ignored, preventing the creation
of a separate database for schema.sql processing.
Fixes gh-19321
Update `AnnotationsPropertySource` so that nested annotations are
supported. Prior to this commit, annotations annotated with
`@PropertyMapping` that contained nested annotation attributes would
result in instances of `TypeMappedAnnotation` being used as properties.
This usually led to errors due to not being able to convert those to
Strings. This commit makes it so that nested annotations are recursively
mapped to properties. This should allow for more complex configuration
to be mapped from annotations.
See gh-23146
Prior to this commit, tests using the `@WebMvcTest` annotation would not
include the `HttpEncodingAutoConfiguration`. This means that, even if
configured, the encoding filter would not be configured in MVC tests,
resulting in an inconsistency with `@SpringBootTest` tests.
This commit ensures that the `HttpEncodingAutoConfiguration` is included
when `@WebMvcTest` is used.
Fixes gh-23749
This commit adapts the auto-configuration for the new core r2dbc support
in Spring Framework and provides auto-configuration for
R2dbcEntityOperations.
Closes gh-22708
This commit introduces a new property to globally disable metrics
export. In integration tests, this property is automatically set to
disable everything but in-memory metrics.
This commit also introduces a `@AutoConfigureMetrics` annotation that
can be used for integration tests that require metrics export to operate
as they would in an application.
See gh-21658
Previously, AutoConfigureMockMvc used Spring Security's default filter
ordering, ignoring the value configured by SecurityProperties that is
used at runtime. This resulted in different ordering at runtime and in
tests.
This commit updates the configuration for AutoConfigureMockMvc to
import the Spring Security filter auto-configuration, thereby ensuring
that the ordering configured via SecurityProperties is applied.
Fixes gh-21801
This commit adds a test slice for Spring Data R2DBC. When
`DataR2dbcTest` is added on a test, only Spring Data R2DBC repositories
and the infrastructure that they need is auto-configured.
Contrary to the JDBC counterpart, the `ConnectionFactory` is not swapped
by an embedded database.
See gh-19988
Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Change the default `BootstrapMode` for auto-configured `JpaRepositories`
to `BootstrapMode.DEFERRED` to allow the initialization of
`EntityManagerFactory` to be parallelized for increased startup efficiency.
Prior to this change, the default BootstrapMode for all auto-configured
Spring Data repositories was `BootstrapMode.DEFAULT`.
Closes gh-16230
In 2.2.0, @ConfigurationPropertiesScan was enabled by default.
Unfortunately, this had the unexpected side-effect of breaking
conditional enablement of a @ConfigurationProperties class via
@EnableConfigurationProperties if the @ConfigurationProperties class
was in a package covered by scanning.
This commit remove @ConfigurationPropertiesScan from
@SpringBootApplication so that it is no longer enabled by default.
2.1.x users who rely upon such conditional enablement of
@ConfigurationProperties classes can now upgrade to 2.2.x without
having to make any changes. Users who do not have such a need and are
in a position to use configuration properties scanning can now opt-in
by adding @ConfigurationPropertiesScan to their main application class
alongside @SpringBootApplication.
Closes gh-18674
Previously, all of the type exclude filters in
spring-boot-test-autoconfigure were package-private. This prevent a
user who was creating their own test slice from composing their own
TypeExcludeFilter with one of Boot's.
This commit updates all of the TypeExcludeFilters in the
test-autoconfigure module to make them public. The intention is only
to allow them to be composed with other type exclude filters when
referenced in a @TypeExcludeFilters annotation. Therefore, each
filter class is declared final and their constructors remain
package-private.
Closes gh-18746
Update `@ConfigurationProperties` constructor binding support to only
apply when a `@ConstructorBinding` annotation is present on either the
type or the specific constructor to use.
Prior to this commit we didn't have a good way to tell when constructor
binding should be used vs regular autowiring.
For convenience, an `@ImmutableConfigurationProperties` meta-annotation
has also been added which is composed of `@ConfigurationProperties` and
`@ConstructorBinding`.
Closes gh-18469
Previously, the deferred line writing that is used, to print MockMvc
results to the console assumed that each DeferredLinesWriter would
only be used by a single thread at a time. This assumption does not
hold true when using JUnit 5's parallel test exection if the tests
running in parallel share an application context. This resulted in
a concurrent modification exception if one thread was adding lines
to the output while another was iterating over them.
This commit updates DeferredLinesWriter so that it uses thread local
storage for the deferred lines. This ensures that each List of lines
is only ever accessed by a single thread.
Closes gh-16179
Previously, DeferredLinesWriter would collect MockMvc output from
every test that has executed. If a test eventually failed, the
output from every test up to including the one that had failed would
be output, rather than just the output for the test that has just
failed.
This commit clears the deferred lines after each test, thereby
ensuring that when a failure occurs only the lines from the failing
test are output.
Fixes gh-17551
This commit updates ConfigurationPropertiesScanRegistrar to apply the
same component scan filters than the ones applied on standard classpath
scanning.
As a result, configuration properties scanning is automatically disabled
in slice tests and can be included by an explicit import or a dedicated
TypeFilter implementation if necessary.
Closes gh-16659
Meta-annotate `ClassPathExclusions` and `ClassPathOverrides` with
so that the `ModifiedClassPathExtension` no longer needs to be
used directly.
See gh-17491
Replace any direct `junit-platform-launcher` dependencies and instead
rely on the test runner providing it. Launcher related class are not
handled via reflection.
This update allows us to workaround SUREFIRE-1679.
Closes gh-17517
Apply checkstyle rule to ensure that private and package private
classes do not have unnecessary public methods. Test classes have
also been unified as much as possible to use default scoped
inner-classes.
Closes gh-7316