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 #181 provides default helperPublisher for subscriber tests
+ When subscriber verifications are extended using Integer
we can use the existing publisher implementations from examples
to drive the tests. This allows implementers who only care about
implementing Subscribers to not care at all about implementing
Publishers
+ In case the subscriber verification is extended using a custom signal
type (defined as "not Integer") we do not magically generate a
Publisher of this type, but instead fail the tests telling the
implementer that he/she will need to implement a custom helperPublisher
which is exactly what we have up until now always demanded from
implementations.
+ We also provide tests to verify the test failures work as expected,
and that the messages are indeed helpful.
+ Updated TCK README.md to clarify when to implement a custom publisher
+ fixed mistakenly added `<T>` on NumberPublisher - it is bound to Ints
+ TCK now depends on examples, as it uses the well documented async
publisher to provide the default publisher for numbers. As well as
in order to allow implementers to reuse those publishers when
implementing custom Publishers to drive their Subscriber specs.
! Moved away from createHelper to createElement style of testing
subscribers
Copy file name to clipboardExpand all lines: tck/README.md
+30-10
Original file line number
Diff line number
Diff line change
@@ -180,6 +180,36 @@ Subscriber rules Verification is split up into two files (styles) of tests.
180
180
181
181
The Blackbox Verification tests do not require the implementation under test to be modified at all, yet they are *not* able to verify most rules. In Whitebox Verification, more control over `request()` calls etc. is required in order to validate rules more precisely.
182
182
183
+
### Helper Publisher implementations
184
+
Since testing a `Subscriber` is not possible without a corresponding `Publisher` the TCK Subscriber Verifications
185
+
both provide a default "helper publisher" to drive its test and also alow to replace this Publisher with a custom implementation.
186
+
187
+
For simple Subscribers which are able to consume elements of *any type*, it is **highly recommmended** to extend the
188
+
SubscriberVerification (described below) classes providing the element type `java.lang.Integer`, like so: `... extends SubscriberBlackboxVerification<Integer>`.
189
+
The reason for this is, that the TCK contains a default Publisher implementation which is able to signal `Integer` elements,
190
+
thus alowing the implementer to strictly focus on only implementing a proper `Subscriber`, instead of having to implement
191
+
an additional Publisher only in order to drive the Subscribers tests. This is especially important for library implementers
192
+
which only want to implement a Subscriber – and do not want to spend time or thought on implementing a valid Publisher.
193
+
194
+
If however any SubscriberVerification class is extended using a custom element type, e.g. like this `... extends SubscriberBlackboxVerification<Message>`,
195
+
*the TCK will immediatly fail the entire subscriber test class* as it is unable to properly create signals of type `Message`
196
+
(which can be some custom message type the `Subscriber` is able to consume). The exception thrown (`UnableToProvidePublisherException`)
197
+
contains some information and directs the implementer towards implementing a custom helper publisher,
198
+
which is done by overriding the `Publisher<T> createHelperPublisher(long elements)` method:
returnnewPublisher<Message>() { /* IMPL HERE */ };
203
+
}
204
+
```
205
+
206
+
Summing up, we recommend implementing Subscribers which are able to consume any type of element, in this case the TCK
207
+
should be driven using `Integer` elements as default publishers are already implemented for this type. If the
208
+
`Subscriber` is unable to consume `Integer` elements, the implementer MUST implement a custom `Publisher<T>` that will
209
+
be able to signal the required element types. It is of course both possible and recommended to re-use existing
210
+
implemenations (which can be seen in the examples sub-project) to create these custom Publishers – an example of
211
+
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)
212
+
183
213
### Subscriber Blackbox Verification
184
214
185
215
Blackbox Verification does not require any additional work except from providing a `Subscriber` and `Publisher` instances to the TCK:
@@ -205,11 +235,6 @@ public class MySubscriberBlackboxVerificationTest extends SubscriberBlackboxVeri
0 commit comments