Commit Graph

70 Commits (687199e6887f83cc63a62cc837b9f1f4d826c656)

Author SHA1 Message Date
Andy Wilkinson 92bb24e365 Avoid synchronizing on this and use an internal monitor instead
Where possible, code that previously synchronized on this (or on the
class in the case of static methods) has been updated to use an
internal monitor object instead. This allows the locking model that's
employed to be an implementation detail rather than part of the
class's API.

Classes that override a synchronized method continue to declare
the overriding method as synchronized. This ensures that locking
is consistent across the superclass and its subclass.

Closes gh-6262
9 years ago
Phillip Webb be884d4e33 Polish 9 years ago
Stephane Nicoll 669da59b4a Polish 9 years ago
Johnny Lim 5bc9d5b380 Polish
Closes gh-6244
9 years ago
Stephane Nicoll f54bec835d Move BasicAuthorizationInterceptor
`BasicAuthorizationInterceptor` is now available in the core framework
and this commit uses that instead of the outdated copy in Boot.

Closes gh-6237
9 years ago
Andy Wilkinson f28e3d54c5 Upgrade to Tomcat 8.5.3
This commit changes the default version of Tomcat to 8.5.3 while
also retaining support for Tomcat 8.0 and 7.0. The main difference
in 8.5 is that the ServerSocketFactory abstraction that allowed the
TrustStore and KeyStore to be configured programatically no longer
exists. This logic has been replaced with the use of a custom URL
protocol (springbootssl) that provides access to the key store and
trust store of an SslStoreProvider. In addition to working with 8.5,
this approach has the advantage of also working with 8.0 and 7.0.

Closes gh-6164
9 years ago
Johnny Lim a70a8635f9 Polish
Closes gh-6155
9 years ago
Phillip Webb 99c6194e17 Don't use MockitoJUnitRunner
Replace `@RunWith(MockitoJUnitRunner.class)` with direct Mockito
initialization since the running doesn't support parallel test
execution.
9 years ago
Johnny Lim 5de9516255 Fix typos
Closes gh-6114
9 years ago
Phillip Webb 433f5e7930 Configure TestRestTemplate using builder
Update SpringBootTestContextCustomizer to create the TestRestTemplate
using the RestTemplateBuilder whenever possible.

Fixes gh-5509
9 years ago
Phillip Webb 2eafb3d887 Add @RestClientTest support
Add @RestClientTest annotation that can be used when testing REST
clients. Provides auto-configuration for a MockRestServiceServer which
can be used when the bean under test builds a single RestTemplate
via the auto-configured RestTemplateBuilder.

Closes gh-6030
9 years ago
Phillip Webb b641e63466 Add RestTemplateBuilder support
Add a RestTemplateBuilder that allows RestTemplates to be easily created
and configured.

See gh-5507
9 years ago
Johnny Lim 70adefc87b Polish
Closes gh-6046
9 years ago
Phillip Webb f0b6d346d7 Filter scoped target proxy beans from Mockito
Update MockitoPostProcessor to filter bean names that match
`ScopedProxyUtils.isScopedTarget` from the candidates list.

Fixes gh-5724
9 years ago
Johnny Lim 5759f685e5 Fix Mockito tests to align with name and comments
Fixup Mockto tests where the test implementation didn't align with the
name of the test or the test Javadoc.

Closes gh-5972
9 years ago
Phillip Webb 2fc86b2d5a Only attempt mock reset on instantiated singletons
Update ResetMocksTestExecutionListener to only attempt a mock reset when
a singleton has actually been created.

Fixes gh-5870
9 years ago
Phillip Webb bcfa2e6676 Make TestRestTemplate not extend RestTemplate
Update TestRestTemplate so that it no longer directly extends
RestTemplate. Prior to this commit it was possible that TestRestTemplate
could interfere with user defined RestTemplate beans.

TestRestTemplate offers the same methods as RestTemplate so should be
a drop-in replacement. If access is needed to the actual underlying
template the `getRestTemplate()` method should be used.

Fixes gh-5915
9 years ago
Johnny Lim 29898c73d3 Remove superflous `if` in MockitoPostProcessor
The `if` in registerSpies() is not required as it's covered by the
Assert check.

Closes gh-5889
9 years ago
Johnny Lim 7a62b7d066 Polish
Closes gh-5936
9 years ago
Phillip Webb cdfbf28099 Allow @MockBean/@SpyBean on Spring AOP proxies
Update Mockito support so that AOP Proxies automatically get additional
`Advice` that allows them to work with Mockito. Prior to this commit a
call to `verify` would fail because exiting AOP advice would confuse
Mockito and an `UnfinishedVerificationException` would be thrown.

The `MockitoAopProxyTargetInterceptor` works by detecting calls to a
mock that have been proceeded by `verify()` and bypassing AOP to
directly call the mock.

The order that `@SpyBean` creation occurs has also been updated to
ensure that that the spy is created before AOP advice is applied.
Without this, the creation of a spy would fail because Mockito copies
'state' to the newly created spied instance. Unfortunately, in the case
of AOP proxies, 'state' includes cglib interceptor fields. This means
that Mockito's own interceptors are clobbered by Spring's AOP
interceptors.

Fixes gh-5837
9 years ago
Phillip Webb cf6212b955 Polish 9 years ago
Johnny Lim 38dc9ec441 Polish 9 years ago
Andy Wilkinson 0a765e36f1 Protect against stack overflow when searching meta annotations
It is legal for an annotation to be annotated with itself. Previously,
when searching for meta annotations this could lead to a stack overflow.
This was likely to occur when using Kotlin as, like Java, its Target
annotation is annotated with itself. A stack overflow doesn’t occur
with Java’s Target annotation due to some short-circuiting logic for
annotations in java.lang.

This commit updates the logic for finding meta-annotations to
short-circuit when an annotation that has already been seen is
encountered.

Closes gh-5902
9 years ago
Andy Wilkinson db21bcdff6 Make SpringApplicationConfiguration use SpringApplicationContextLoader
The intention in 1.4 is for the deprecated testing functionality to
behave exactly as it did in 1.3. To help with this, this commit
updates SpringApplicationConfiguration to use
SpringApplicationContextLoader as its loader, just as it did in 1.3.

Closes gh-5882
9 years ago
Dave Syer bdc71f693c Fix checksyle 'violations' 9 years ago
Dave Syer be398741e1 Fix binary incompatibility of old TestRestTemplate
The TestRestTemplate is deprecated (so people can still use it)
but unusable because it only has constructors which depend on the
new options enum.
9 years ago
Johnny Lim 7763c2ae4c Polish
Closes gh-5843
9 years ago
Johnny Lim 06143195d0 Make json-path and selenium-api optional
Make json-path and selenium-api optional in spring-boot-test and
spring-boot-test-autoconfigure.

Fixes gh-5828
9 years ago
Johnny Lim e5715df7e3 Polish
Closes gh-5836
9 years ago
Johnny Lim 0efa0038c3 Polish
Closes gh-5815
9 years ago
Phillip Webb 609cb52cd4 Move to relocated web classes
Refactor code to move from recently deprecated classes.

Closes gh-5822
9 years ago
Phillip Webb a7cb689f95 Move @LocalServerPort annotation
Move the @LocalServerPort to org.springframework.boot.context.embedded
since it's only really useful when working with embedded servlet
containers.

See gh-5822
9 years ago
Phillip Webb 93382648ab Formatting 9 years ago
Andy Wilkinson aa19c19753 Merge branch '1.3.x' 9 years ago
Andy Wilkinson 601791c664 Configure test property sources before ConfigFileApplicationListener runs
Previously, SpringBootContextLoader configured the environment with the
test property sources using an ApplicationContextInitializer. This was
because TestPropertySourceUtils did not provide a method to directly
configure the environment using properties files, it had to be done
via an application context. An unwanted side-effect of this was that
the test property sources were not being configured before
ConfigFileApplicationListener examined the environment to determine the
name and locations of the files that it should be loading.

This commit takes advantage of a new method that was added to
TestPropertySourceUtils which allows properties files to be added
directly to the environment without using an application context. This
means that the use of the ApplicationContextInitializer can be removed
and the test property sources can be applied to the environment before
the application context is created.

Closes gh-5728
9 years ago
Stephane Nicoll 786004e297 Fix build 9 years ago
Phillip Webb cf41512e66 Don't throw checked exceptions from Assert classes
Fixes gh-5709
9 years ago
Andy Wilkinson 35270e939f Update dependency management for Selenium and its HTMLUnit Driver
Closes gh-5705
9 years ago
Johnny Lim 90d897eb9d Polish
Closes gh-5685
9 years ago
Andy Wilkinson a37ae5d556 Polish test property source changes made in 69b08291
TestPropertySourcesInitializer needs to be ordered with a high
precedence, specifically higher than
ContextIdApplicationContextInitializer, to ensure that any properties
used in setting the context’s id are available in the environment.

Closes gh-4828
9 years ago
Andy Wilkinson 69b0829199 Align precedence of @SpringBootTest properties with @TestPropertySource
This commit updates the precedence of properties configured using
@SpringBootTest to align with @TestPropertySource. Properties configured
using properties on @SpringBootTest are now added to the same property
source as those configured using properties on @TestPropertySource so
the precedence described in the javadoc of @TestPropertySource now
applies in full. Additionally, if both @TestPropertySource properties
and @SpringBootTest properties configure the same property, the value
from @TestPropertySource will win.

Closes gh-4828
9 years ago
Phillip Webb 01c9d72644 Polish 9 years ago
Johnny Lim a55315b5b5 Polish
Closes gh-5614
9 years ago
Johnny Lim 8864f85b82 Remove System.out.println() 9 years ago
Phillip Webb b398b3319c Rename @SpringApplicationTest -> @SpringBootTest
Rename @SpringApplicationTest to SpringBootTest and
@SpringApplicationContextLoader to @SpringBootContextLoader.

Fixes gh-5562
9 years ago
Phillip Webb b0b190b362 Delete @SpringApplicationConfiguration
Remove the @SpringApplicationConfiguration annotation since it offers
little value over @SpringApplicationTest.

See gh-5562
9 years ago
Stephane Nicoll 0a8975bc84 Polish 9 years ago
Phillip Webb 34070e5a8e Add Support for Mockito spies
Add a @SpyBean annotation that can be used to create spies.

Fixes gh-5538
9 years ago
Andy Wilkinson 33f0ea3480 Rework SpringApplicationTest to support web modes
Rework the new testing support so that @SpringApplicationTest can be
used for standard integration tests, web integration tests with a
mock Servlet environment and web integration tests with an embedded
servlet container. This means that it a replacement for 1.3's
@IntegrationTest and @WebIntegrationTest and allows all
SpringApplication testing to be configured using a common annotation.

The old @IntegrationTest and @WebIntegrationTest along with their
supporting classes have been reinstated to their previous form (while
remaining deprecated). This should ensure that they continue to work
in 1.4 exactly as they did in 1.3 giving users a smooth path to
@SpringApplicationTest.

See gh-5477
9 years ago
Phillip Webb 893a6c32f3 Upgrade to checkstyle 6.17
Fixes gh-5547
9 years ago