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
Copy file name to clipboardExpand all lines: tck/README.md
+42-18
Original file line number
Diff line number
Diff line change
@@ -102,10 +102,11 @@ In order to inform the TCK your Publisher is only able to signal up to `2` eleme
102
102
}
103
103
```
104
104
105
-
The TCK also supports Publishers which are not able to signal completion. For example you might have a Publisher being backed by a timer.
106
-
Such Publisher does not have a natural way to "complete" after some number of ticks. It would be possible to implement a Processor which would
107
-
"take n elements from the TickPublisher and then signal completion to the downstream", but this adds a layer of indirection between the TCK and the
108
-
Publisher we initially wanted to test. We suggest testing such unbouded Publishers either way - using a "TakeNElementsProcessor" or by informing the TCK
105
+
The TCK also supports Publishers which are not able to signal completion. For example you might have a Publisher being
106
+
backed by a timer. Such Publisher does not have a natural way to "complete" after some number of ticks. It would be
107
+
possible to implement a Processor which would "take n elements from the TickPublisher and then signal completion to the
108
+
downstream", but this adds a layer of indirection between the TCK and the Publisher one initially wanted to test.
109
+
It is suggested to test such unbouded Publishers either way - using a "TakeNElementsProcessor" or by informing the TCK
109
110
that the publisher is not able to signal completion. The TCK will then skip all tests which require `onComplete` signals to be emitted.
110
111
111
112
In order to inform the TCK that your Publiher is not able to signal completion, override the `maxElementsFromPublisher` method like this:
@@ -217,12 +218,13 @@ The helper publisher is an asynchronous publisher by default - meaning that your
217
218
218
219
While the `Publisher` implementation is provided, creating the signal elements is not – this is because a given Subscriber
219
220
may for example only work with `HashedMessage` or some other specific kind of signal. The TCK is unable to generate such
220
-
special messages automatically, so we provide the `T createElement(Integer id)` method to be implemented as part of
221
+
special messages automatically, so the TCK provides the `T createElement(Integer id)` method to be implemented as part of
221
222
Subscriber Verifications which should take the given ID and return an element of type `T` (where `T` is the type of
222
223
elements flowing into the `Subscriber<T>`, as known thanks to `... extends WhiteboxSubscriberVerification<T>`) representing
223
224
an element of the stream that will be passed on to the Subscriber.
224
225
225
-
The simplest valid implemenation is to return the incoming `id`*as the element* in a verification using `Integer`s as element types:
226
+
The simplest valid implemenation is to return the incoming `id`*as the element* in a verification using `Integer`s as
returnnewPublisher<Message>() { /* IMPL HERE */ };
250
+
returnnewPublisher<Message>() { /*CUSTOM IMPL HERE */ };
248
251
}
249
252
```
250
253
@@ -387,11 +390,14 @@ Note that hard-coded values *take precedence* over environment set values (!).
387
390
388
391
## Subscription Verification
389
392
390
-
Please note that while `Subscription` does **not** have it's own test class, it's rules are validated inside of the `Publisher` and `Subscriber` tests – depending if the Rule demands specific action to be taken by the publishing, or subscribing side of the subscription contract.
393
+
Please note that while `Subscription` does **not** have it's own test class, it's rules are validated inside of the
394
+
`Publisher` and `Subscriber` tests – depending if the Rule demands specific action to be taken by the publishing, or
395
+
subscribing side of the subscription contract.
391
396
392
397
## Identity Processor Verification
393
398
394
-
An `IdentityProcessorVerification` tests the given `Processor` for all `Subscriber`, `Publisher` as well as `Subscription` rules. Internally the `WhiteboxSubscriberVerification` is used for `Subscriber` rules.
399
+
An `IdentityProcessorVerification` tests the given `Processor` for all `Subscriber`, `Publisher` as well as
400
+
`Subscription` rules. Internally the `WhiteboxSubscriberVerification` is used for `Subscriber` rules.
395
401
396
402
```java
397
403
packagecom.example.streams;
@@ -448,12 +454,14 @@ public class MyIdentityProcessorVerificationTest extends IdentityProcessorVerifi
448
454
449
455
The additional configuration options reflect the options available in the Subscriber and Publisher Verifications.
450
456
451
-
The `IdentityProcessorVerification` also runs additional sanity verifications, which are not directly mapped to Specification rules, but help to verify that a Processor won't "get stuck" or face similar problems. Please refer to the sources for details on the tests included.
457
+
The `IdentityProcessorVerification` also runs additional sanity verifications, which are not directly mapped to
458
+
Specification rules, but help to verify that a Processor won't "get stuck" or face similar problems. Please refer to the
459
+
sources for details on the tests included.
452
460
453
461
## Ignoring tests
454
-
Since you inherit these tests instead of defining them yourself it's not possible to use the usual `@Ignore` annotations to skip certain tests
455
-
(which may be perfectly reasonable if your implementation has some know constraints on what it cannot implement). We recommend the below pattern
456
-
to skip tests inherited from the TCK's base classes:
462
+
Since you inherit these tests instead of defining them yourself it's not possible to use the usual `@Ignore` annotations
463
+
to skip certain tests (which may be perfectly reasonable if your implementation has some know constraints on what it
464
+
cannot implement). We recommend the below pattern to skip tests inherited from the TCK's base classes:
457
465
458
466
```java
459
467
packagecom.example.streams;
@@ -479,6 +487,22 @@ public class SkippingIdentityProcessorTest extends IdentityProcessorVerification
479
487
}
480
488
```
481
489
490
+
## Which verifications must be implemented by a compliant implementation?
491
+
In order to be considered an Reactive Streams compliant require implementations to cover their
492
+
Publishers and Subscribers with TCK verifications. If a library is only including
493
+
Subscribers, it does not have to implement Publisher tests. The same applies to `IdentityProcessorVerification` -
494
+
you do not need to implement it if the library does not contain Processors.
495
+
496
+
In the case of Subscriber Verification are two styles of verifications to available: Blackbox or Whitebox.
497
+
It is *strongly* recommend to test `Subscriber` implementations with the `SubscriberWhiteboxVerification` as it is able to
498
+
verify most of the specification. The `SubscriberBlackboxVerification` should only be used as a fallback,
499
+
once you are sure implementing the whitebox version will not be possible for your implementation - if that happens
500
+
feel free to open a ticket on the [reactive-streams-jvm](https://github.com/reactive-streams/reactive-streams-jvm) project explaining what stopped you from
501
+
implementing the whitebox verification.
502
+
503
+
In summary: implementations are required to use Verifications for the parts of the specification that they implement,
504
+
and suggest using the whitebox verification over blackbox for the subscriber whenever possible.
505
+
482
506
## Upgrade story
483
507
484
508
**TODO** - What is our story about updating the TCK? How do we make sure that implementations don't accidentally miss some change in the spec, if the TCK is unable to fail verify the new behavior? Comments are very welcome, discussion about this is under-way in [Issue #99 – TCK Upgrade Story](https://github.com/reactive-streams/reactive-streams/issues/99).
0 commit comments