You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+tck 2.9 blackbox verification should fully drive publisher
It should not use the helper publisher as it may signal asynchronously
as well as onComplete in undefined ways - we need to control the
publisher in this case because of the very specific test scenario
Copy file name to clipboardExpand all lines: tck/README.md
+15-21
Original file line number
Diff line number
Diff line change
@@ -180,34 +180,28 @@ The Blackbox Verification tests do not require the implementation under test to
180
180
181
181
### Helper Publisher implementations
182
182
Since testing a `Subscriber` is not possible without a corresponding `Publisher` the TCK Subscriber Verifications
183
-
both provide a default "helper publisher" to drive its test and also alow to replace this Publisher with a custom implementation.
184
-
185
-
For simple Subscribers which are able to consume elements of *any type*, it is **highly recommmended** to extend the
186
-
SubscriberVerification (described below) classes providing the element type `java.lang.Integer`, like so: `... extends SubscriberBlackboxVerification<Integer>`.
187
-
The reason for this is, that the TCK contains a default Publisher implementation which is able to signal `Integer` elements,
188
-
thus alowing the implementer to strictly focus on only implementing a proper `Subscriber`, instead of having to implement
189
-
an additional Publisher only in order to drive the Subscribers tests. This is especially important for library implementers
190
-
which only want to implement a Subscriber – and do not want to spend time or thought on implementing a valid Publisher.
191
-
192
-
If however any SubscriberVerification class is extended using a custom element type, e.g. like this `... extends SubscriberBlackboxVerification<Message>`,
193
-
*the TCK will immediatly fail the entire subscriber test class* as it is unable to properly create signals of type `Message`
194
-
(which can be some custom message type the `Subscriber` is able to consume). The exception thrown (`UnableToProvidePublisherException`)
195
-
contains some information and directs the implementer towards implementing a custom helper publisher,
196
-
which is done by overriding the `Publisher<T> createHelperPublisher(long elements)` method:
183
+
both provide a default "*helper publisher*" to drive its test and also alow to replace this Publisher with a custom implementation.
184
+
The helper publisher is an asynchronous publisher by default - meaning that your subscriber can not blindly assume single threaded execution.
185
+
186
+
While the `Publisher` implementation is provided, creating the signal elements is not – this is because a given Subscriber
187
+
may for example only work with `HashedMessage` or some other specific kind of signal. The TCK is unable to generate such
188
+
special messages automatically, so we provide the `T createElement(Integer id)` method to be implemented as part of
189
+
Subscriber Verifications which should take the given ID and return an element of type `T` (where `T` is the type of
190
+
elements flowing into the `Subscriber<T>`, as known thanks to `... extends WhiteboxSubscriberVerification<T>`) representing
191
+
an element of the stream that will be passed on to the Subscriber. The simplest valid implemenation is to return the incoming
192
+
`id`*as the element* in a verification using `Integer`s as element types. The `createElement` method MAY be called from multiple
193
+
threads, so in case of more complicated implementations, please be aware of this fact.
194
+
195
+
**Very Advanced**: While we do not expect many implementations having to do so, it is possible to take full control of the `Publisher`
196
+
which will be driving the TCKs test. You can do this by implementing the `createHelperPublisher` method in which you can implement your
197
+
own Publisher which will then be used by the TCK to drive your Subscriber tests:
returnnewPublisher<Message>() { /* IMPL HERE */ };
201
202
}
202
203
```
203
204
204
-
Summing up, we recommend implementing Subscribers which are able to consume any type of element, in this case the TCK
205
-
should be driven using `Integer` elements as default publishers are already implemented for this type. If the
206
-
`Subscriber` is unable to consume `Integer` elements, the implementer MUST implement a custom `Publisher<T>` that will
207
-
be able to signal the required element types. It is of course both possible and recommended to re-use existing
208
-
implemenations (which can be seen in the examples sub-project) to create these custom Publishers – an example of
209
-
such re-use can be found in [ProvidedHelperPublisherForSubscriberVerificationTest#createStringPublisher](https://github.com/reactive-streams/reactive-streams/blob/master/tck/src/test/java/org/reactivestreams/tck/ProvidedHelperPublisherForSubscriberVerificationTest.java#L215)
210
-
211
205
### Subscriber Blackbox Verification
212
206
213
207
Blackbox Verification does not require any additional work except from providing a `Subscriber` and `Publisher` instances to the TCK:
0 commit comments