Commit Graph

13182 Commits

Author SHA1 Message Date
Sam Brannen e822e4cbe8 Improve exception msg for inactive test ApplicationContext
This commit improves the exception message thrown when a test's
ApplicationContext is no longer active by explaining that the cause
may be due to parallel test execution.

Issue: SPR-5863
2016-09-05 13:39:21 +02:00
Sam Brannen fbfad8695e Further improve thread safety for attributes in DefaultTestContext
Issue: SPR-5863
2016-09-05 13:34:25 +02:00
Sebastien Deleuze 5755b67325 Upgrade to Reactor Core 3.0.2 2016-09-03 16:19:52 +02:00
Violeta Georgieva 00617d74de Fix AbstractRequestBodyPublisher to comply with the spec
As per specification "The Subscription MUST allow the Subscriber to
call Subscription.request synchronously from within onNext or
onSubscribe". With the current implementation if Subscription.request
is called more than once when Subscriber.onSubscribe ISE will be
thrown - java.lang.IllegalStateException: DEMAND.
With this fix the implementation will not throw ISE and will allow
many invocations of Subscription.request when
Subscriber.onSubscribe.
2016-09-02 23:37:20 +02:00
Brian Clozel 01bd8b9e01 Fix null body handling in ResponseEntityResultHandler
This commit fixes `ResponseEntityResultHandler` so that it only tries to
call `writeBody` if the `ResponseEntity` is not null. In case the
response entity body is null, the response is flushed right away and the
request is signaled as handled.

Issue: SPR-14663
2016-09-02 23:01:16 +02:00
Sam Brannen a10a8e56df Support concurrent execution in TestContextManager & DefaultTestContext
Prior to this commit, executing tests concurrently in the TestContext
Framework (TCF) was unsupported and typically lead to unpredictable
results.

This commit addresses this core issue by supporting concurrent
execution in the TestContextManager and the DefaultTestContext.

Specifically, the TestContextManager now uses ThreadLocal storage for
the current TestContext, thereby ensuring that any registered
TestExecutionListeners and the TestContextManager itself operate on a
TestContext specific to the current thread.

In order to avoid repeatedly incurring the costs of the overhead of the
TCF bootstrapping process, the original TestContext built by the
TestContextBootstrapper is used as a template which is then passed to
the copy constructor of the concrete implementation of the TestContext
to create the context for the current thread. DefaultTestContext now
implements such a copy constructor, and all concrete implementations of
TestContext are encouraged to do the same.

If the TestContext built by the TestContextBootstrapper does not
provide a copy constructor, thread-safety and support for concurrency
are left completely to the implementation of the concrete TestContext.

Note, however, that this commit does not address any thread-safety or
concurrency issues in the ContextLoader SPI or its implementations.

Issue: SPR-5863
2016-09-02 20:28:02 +02:00
Sam Brannen ec7aefa858 Improve concurrency in DefaultTestContext regarding attributes
This commit inlines the basic implementation of AttributeAccessorSupport
and converts the LinkedHashMap to a ConcurrentHashMap.

In addition, attributes are now included in toString().

Issue: SPR-5863
2016-09-02 19:14:31 +02:00
Sam Brannen 5fe3bcf8f9 Polishing 2016-09-02 18:39:31 +02:00
Rossen Stoyanchev c813405ca3 Add @since tags 2016-09-02 12:19:50 -04:00
Rossen Stoyanchev a1ac51256a Add MockServerHttpRequest/Response to spring-test
Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev 73752c295d Refactor location of MockServerHttpRequest/Response
This change puts the MockHttpServerRequest/Response under
org.springframework.mock.http.server.reactive.test which
mirrors the arrangement we have with the Servlet mock equivalents
and sets up the addition of MockHttpServerRequest/Response in
spring-test.

Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev e17132c217 Polish MockServerHttpRequest
Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Sebastien Deleuze 2cd3135c3b Upgrade to Reactor Core 3.0.1 and Reactor Netty 0.5.1 2016-09-02 15:47:11 +02:00
Rossen Stoyanchev f3dd554dbe Fix typos in docs and polish 2016-09-02 09:26:15 -04:00
Rob Winch 7788879c5a Remove stray `
Remove stray ` in import-into-idea.md
2016-09-02 08:12:06 -05:00
Rossen Stoyanchev 08b2b0ba2a Merge pull request #1150 from neetkee/patch-1 2016-09-02 09:04:13 -04:00
Rossen Stoyanchev 833a3a0566 Polish import into IntelliJ instructions 2016-09-02 09:03:34 -04:00
Artem Yakshin 409fe478bd Update import-into-idea.md
Changes, according the latest information.
2016-09-02 08:52:53 -04:00
Brian Clozel a8ba065a6e Mention AntPathMatcher regexp support
This commit documents the regexp support in `AntPathMatcher` when
matching for URL patterns. This support is also mentioned in places
where developers can register patterns for ViewControllers or resource
handlers.

Issue: SPR-14652
2016-09-02 11:35:58 +02:00
Rossen Stoyanchev 0681519255 Add checkNotModified support for view resolution
Issue: SPR-14522
2016-09-01 18:07:23 -04:00
Rossen Stoyanchev 6071e01168 Add checkNotModified support in ServerWebExchange
Issue: SPR-14522
2016-09-01 17:44:51 -04:00
Rossen Stoyanchev 638e6cc7f8 Add checkNotModified support for ResponseEntity
Issue: SPR-14522
2016-09-01 17:44:51 -04:00
Rossen Stoyanchev 9f8791ac01 Add ServerWebExchangeArgumentResolver
Issue: SPR-14658
2016-09-01 17:44:51 -04:00
Sebastien Deleuze 02bed0a34b Polishing 2016-09-01 17:15:50 +02:00
Sebastien Deleuze 06d4bb6a1a Let users control SSE stream completion
This commit avoid merging automatically the SSE stream with
Flux.never(). Since browsers automatically reconnect when
the HTTP connection is closed, it is now the user responsability
to optionally perform a concatWith(Flux.never()) on streams that
complete in order to avoid receiving the data multiple times on
client side.

The behavior with hot streams that never complete does not change.

Issue: SPR-14578
2016-09-01 17:14:24 +02:00
Sam Brannen 1af2fbfbbb Delete unused imports in spring-context-indexer 2016-09-01 16:41:49 +02:00
Sam Brannen 5202250179 Polish SpringClassRule and SpringMethodRule 2016-09-01 16:34:03 +02:00
Stephane Nicoll 749ee6065c Merge pull request #1151 from sylvainlaurent:patch-1
* pr/1151:
  Fix class literal in instanceof
2016-09-01 16:23:08 +02:00
sylvainlaurent dc3f62d576 Fix class literal in instanceof
Closes gh-1151
2016-09-01 16:22:39 +02:00
Sebastien Deleuze 76ed101a23 Update Web Reactive documentation 2016-09-01 15:42:50 +02:00
Stephane Nicoll dcade06fa0 Support for candidate components index
This commit adds a "spring-context-indexer" module that can be added to
any project in order to generate an index of candidate components defined
in the project.

`CandidateComponentsIndexer` is a standard annotation processor that
looks for source files with target annotations (typically `@Component`)
and references them in a `META-INF/spring.components` generated file.

Each entry in the index is the fully qualified name of a candidate
component and the comma-separated list of stereotypes that apply to that
candidate. A typical example of a stereotype is `@Component`. If a
project has a `com.example.FooService` annotated with `@Component` the
following `META-INF/spring.components` file is generated at compile time:

```
com.example.FooService=org.springframework.stereotype.Component
```

A new `@Indexed` annotation can be added on any annotation to instructs
the scanner to include a source file that contains that annotation. For
instance, `@Component` is meta-annotated with `@Indexed` now and adding
`@Indexed` to more annotation types will transparently improve the index
with additional information. This also works for interaces or parent
classes: adding `@Indexed` on a `Repository` base interface means that
the indexed can be queried for its implementation by using the fully
qualified name of the `Repository` interface.

The indexer also adds any class or interface that has a type-level
annotation from the `javax` package. This includes obviously JPA
(`@Entity` and related) but also CDI (`@Named`, `@ManagedBean`) and
servlet annotations (i.e. `@WebFilter`). These are meant to handle
cases where a component needs to identify candidates and use classpath
scanning currently.

If a `package-info.java` file exists, the package is registered using
a "package-info" stereotype.

Such files can later be reused by the `ApplicationContext` to avoid
using component scan. A global `CandidateComponentsIndex` can be easily
loaded from the current classpath using `CandidateComponentsIndexLoader`.

The core framework uses such infrastructure in two areas: to retrieve
the candidate `@Component`s and to build a default `PersistenceUnitInfo`.
Rather than scanning the classpath and using ASM to identify candidates,
the index is used if present.

As long as the include filters refer to an annotation that is directly
annotated with `@Indexed` or an assignable type that is directly
annotated with `@Indexed`, the index can be used since a dedicated entry
wil be present for that type. If any other unsupported include filter is
specified, we fallback on classpath scanning.

In case the index is incomplete or cannot be used, The
`spring.index.ignore` system property can be set to `true` or,
alternatively, in a "spring.properties" at the root of the classpath.

Issue: SPR-11890
2016-09-01 15:30:47 +02:00
Sebastien Deleuze 48d67a245b Add support for RxJava 2
This commit adds support for RxJava 2 Completable,
Single, Observable and Flowable types (io.reactivex package).

Issue: SPR-14628
2016-09-01 14:48:16 +02:00
Sebastien Deleuze b4641b2306 Polishing 2016-09-01 14:48:16 +02:00
Arjen Poutsma f1319f58ec Introduce new functional web API
This commit introduces a new, functional web programming model in the
org.springframework.web.reactive.function package. The key types
are:

 - Request and Response are new Java 8-DSLs for access to the HTTP
   request and response
 - HandlerFunction represents a function to handle a request to a
   response
 - RoutingFunction maps a request to a HandlerFunction
 - FilterFunction filters a routing as defined by a RoutingFunction
 - RequestPredicate is used by Router to create RoutingFunctions
 - RequestPredicates offers common RequestPredicate instances
2016-09-01 14:38:13 +02:00
Arjen Poutsma 18e491ac0a Merge pull request #1143 from poutsma/server_sent_event
* server_sent_event:
  Refactored SseEvent to ServerSentEvent
2016-09-01 13:51:25 +02:00
Arjen Poutsma 16b525f698 Refactored SseEvent to ServerSentEvent
- Renamed SseEvent to ServerSentEvent to make the name less redundant.
 - ServerSentEvent is now immutable, having a builder to create new instances.
 - Realigned the class properties to more closely match the events
   described in the spec, so that `reconnectTime` becomes `retry`, and
   `name` becomes `event`.
2016-09-01 13:47:50 +02:00
Sam Brannen d9eaa5f3ac Use Map.computeIfAbsent() in SpringClassRule
Replace manual synchronization block in SpringClassRule with Java 8's
Map.computeIfAbsent().

Issue: SPR-12421
2016-09-01 13:38:42 +02:00
Juergen Hoeller 1cf503f939 Upgrade to JSR-354 API 1.0.1 and Jackson 2.8 javadocs 2016-09-01 12:49:01 +02:00
Juergen Hoeller aff914c98e Documentation updates around configuration classes 2016-09-01 12:41:55 +02:00
Arjen Poutsma 35cf4f173b Copied getAndSub() over from Reactor
Operators.getAndSub was removed in Reactor 3.0.1, this commit copies the
implementation over to AbstractRequestBodyPublisher, which used it.
2016-09-01 11:16:01 +02:00
Sam Brannen feb02f813e Polishing 2016-08-31 20:52:39 +02:00
Sam Brannen e574820dc9 Introduce tests for @Nested tests in JUnit Jupiter
This commit introduces integration tests that verify the expected
behavior for @Nested tests in conjunction with the SpringExtension for
JUnit Jupiter, including automatic application of
TestExecutionListeners to the enclosing test instance of a @Nested
test instance.

Issue: SPR-14150
2016-08-31 20:29:08 +02:00
Sam Brannen ab7b5e5c77 Demo how to use SpringClassRule in nested test classes
Due to restrictions imposed by JUnit 4, the SpringClassRule must be
declared as a public static field, which makes it impossible to be
declared directly within a nested (i.e., inner) test class.

This commit demonstrates a work-around that makes it possible to use
the SpringClassRule and SpringMethodRule in a nested (i.e., inner) test
class when using a custom JUnit 4 runner such as the
HierarchicalContextRunner from Stefan Bechtold.

The trick is to have inner test classes extend a class that properly
declares the SpringClassRule and SpringMethodRule. The
SpringRuleConfigurer in this commit serves as an example.

Note, however, that each such nested test class must declare its own
@ContextConfiguration. Furthermore, TestExecutionListeners in the
Spring TestContext Framework are not applied to the enclosing instance
of such an inner test class, meaning that @Autowired fields in the
enclosing instance will not be injected, etc.

Issue: SPR-14150
2016-08-31 19:35:00 +02:00
Rob Winch 09f16747b5 Fix MergePlugin transitive dependencies
A little terminiology first:

* merge.from - a project that contains source that will be merged
               into merge.into
* merge.into - a project that contains source code that will have
               code from merge.from merged into it.

Previously a module that dependended on merge.into would not see
the merge.from module as a transitive dependency. This worked fine
from a Gradle build because all the code from merge.from is merged
into the merge.into jar. However, in an IDE it did not work because
the IDE does not assemble a jar.

This fix ensures that merge.from modules are automatically added
to the classpath of any module relying on the merge.into project.

Fixes SPR-14650
2016-08-31 11:38:24 -05:00
Sam Brannen 634d1c03a3 Introduce @EnabledIf support for JUnit Jupiter
This commit picks up where SPR-14614 left off by introducing a new
@EnabledIf annotation to serve as a logical companion to @DisabledIf.

In addition, this commit extracts common logic from DisabledIfCondition
into a new AbstractExpressionEvaluatingCondition base class which the
new EnabledIfCondition also extends.

An @EnabledOnMac annotation is also included in the Javadoc as well as
in the test suite to demonstrate support for custom composed annotations.

Issue: SPR-14644
2016-08-31 16:11:58 +02:00
Juergen Hoeller 1a30252fc9 ResolvableType.java.forRawClass(Class) supports isAssignableFrom(ResolvableType) as well
Issue: SPR-14648
2016-08-31 14:45:22 +02:00
Juergen Hoeller e08b1b75b6 @PathVariable supports 'required' attribute (for model attribute methods)
Issue: SPR-14646
2016-08-31 14:43:39 +02:00
Juergen Hoeller faf6e5d8fa Annotation tests should not rely on JDK-specific toString() representation
Issue: SPR-14645
2016-08-31 14:42:08 +02:00
Brian Clozel 7a88776329 Fix missing ResourceHttpRequestHandler init in registry
Issue: SPR-14577
2016-08-31 10:43:11 +02:00
Juergen Hoeller ab9fea6b8d Polishing
(cherry picked from commit 3767092)
2016-08-31 02:08:31 +02:00