Skip to content

Commit d503210

Browse files
committed
+tck reactive-streams#232 explain which tests are mendatory to be "compliant"
1 parent 78c1dd4 commit d503210

File tree

1 file changed

+39
-16
lines changed

1 file changed

+39
-16
lines changed

tck/README.md

+39-16
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ In order to inform the TCK your Publisher is only able to signal up to `2` eleme
112112
}
113113
```
114114

115-
The TCK also supports Publishers which are not able to signal completion. For example you might have a Publisher being backed by a timer.
116-
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
117-
"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
118-
Publisher we initially wanted to test. We suggest testing such unbouded Publishers either way - using a "TakeNElementsProcessor" or by informing the TCK
115+
The TCK also supports Publishers which are not able to signal completion. For example you might have a Publisher being
116+
backed by a timer. Such Publisher does not have a natural way to "complete" after some number of ticks. It would be
117+
possible to implement a Processor which would "take n elements from the TickPublisher and then signal completion to the
118+
downstream", but this adds a layer of indirection between the TCK and the Publisher one initially wanted to test.
119+
It is suggested to test such unbouded Publishers either way - using a "TakeNElementsProcessor" or by informing the TCK
119120
that the publisher is not able to signal completion. The TCK will then skip all tests which require `onComplete` signals to be emitted.
120121

121122
In order to inform the TCK that your Publiher is not able to signal completion, override the `maxElementsFromPublisher` method like this:
@@ -261,12 +262,13 @@ In case an implementation needs to work on a specific type, the verification cla
261262

262263
While the `Publisher` implementation is provided, creating the signal elements is not – this is because a given Subscriber
263264
may for example only work with `HashedMessage` or some other specific kind of signal. The TCK is unable to generate such
264-
special messages automatically, so we provide the `T createElement(Integer id)` method to be implemented as part of
265+
special messages automatically, so the TCK provides the `T createElement(Integer id)` method to be implemented as part of
265266
Subscriber Verifications which should take the given ID and return an element of type `T` (where `T` is the type of
266267
elements flowing into the `Subscriber<T>`, as known thanks to `... extends SubscriberWhiteboxVerification<T>`) representing
267268
an element of the stream that will be passed on to the Subscriber.
268269

269-
The simplest valid implemenation is to return the incoming `id` *as the element* in a verification using `Integer`s as element types:
270+
The simplest valid implemenation is to return the incoming `id` *as the element* in a verification using `Integer`s as
271+
element types:
270272

271273
```java
272274
public class MySubscriberTest extends SubscriberBlackboxVerification<Integer> {
@@ -282,13 +284,13 @@ public class MySubscriberTest extends SubscriberBlackboxVerification<Integer> {
282284
The `createElement` method MAY be called concurrently from multiple threads,
283285
so in case of more complicated implementations, please be aware of this fact.
284286

285-
**Very Advanced**: While we do not expect many implementations having to do so, it is possible to take full control of the `Publisher`
286-
which will be driving the TCKs test. This can be achieved by implementing the `createHelperPublisher` method in which you can implement your
287-
own Publisher which will then be used by the TCK to drive your Subscriber tests:
287+
**Very Advanced**: While it is not expected for many implementations having to do so, it is possible to take full
288+
which will be driving the TCKs test. This can be achieved by implementing the `createHelperPublisher` method in which one can implement the
289+
`createHelperPublisher` method by returning a custom Publisher implementation which will then be used by the TCK to drive your Subscriber tests:
288290

289291
```java
290292
@Override public Publisher<Message> createHelperPublisher(long elements) {
291-
return new Publisher<Message>() { /* IMPL HERE */ };
293+
return new Publisher<Message>() { /* CUSTOM IMPL HERE */ };
292294
}
293295
```
294296

@@ -439,11 +441,14 @@ Note that hard-coded values *take precedence* over environment set values (!).
439441

440442
## Subscription Verification
441443

442-
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.
444+
Please note that while `Subscription` does **not** have it's own test class, it's rules are validated inside of the
445+
`Publisher` and `Subscriber` tests – depending if the Rule demands specific action to be taken by the publishing, or
446+
subscribing side of the subscription contract.
443447

444448
## Identity Processor Verification
445449

446-
An `IdentityProcessorVerification` tests the given `Processor` for all `Subscriber`, `Publisher` as well as `Subscription` rules. Internally the `WhiteboxSubscriberVerification` is used for `Subscriber` rules.
450+
An `IdentityProcessorVerification` tests the given `Processor` for all `Subscriber`, `Publisher` as well as
451+
`Subscription` rules. Internally the `WhiteboxSubscriberVerification` is used for `Subscriber` rules.
447452

448453
```java
449454
package com.example.streams;
@@ -502,12 +507,14 @@ public class MyIdentityProcessorVerificationTest extends IdentityProcessorVerifi
502507

503508
The additional configuration options reflect the options available in the Subscriber and Publisher Verifications.
504509

505-
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.
510+
The `IdentityProcessorVerification` also runs additional sanity verifications, which are not directly mapped to
511+
Specification rules, but help to verify that a Processor won't "get stuck" or face similar problems. Please refer to the
512+
sources for details on the tests included.
506513

507514
## Ignoring tests
508-
Since you inherit these tests instead of defining them yourself it's not possible to use the usual `@Ignore` annotations to skip certain tests
509-
(which may be perfectly reasonable if your implementation has some know constraints on what it cannot implement). We recommend the below pattern
510-
to skip tests inherited from the TCK's base classes:
515+
Since you inherit these tests instead of defining them yourself it's not possible to use the usual `@Ignore` annotations
516+
to skip certain tests (which may be perfectly reasonable if your implementation has some know constraints on what it
517+
cannot implement). We recommend the below pattern to skip tests inherited from the TCK's base classes:
511518

512519
```java
513520
package com.example.streams;
@@ -561,6 +568,22 @@ public class MyIdentityProcessorTest extends IdentityProcessorVerification<Integ
561568
}
562569
```
563570

571+
## Which verifications must be implemented by a compliant implementation?
572+
In order to be considered an Reactive Streams compliant require implementations to cover their
573+
Publishers and Subscribers with TCK verifications. If a library is only including
574+
Subscribers, it does not have to implement Publisher tests. The same applies to `IdentityProcessorVerification` -
575+
you do not need to implement it if the library does not contain Processors.
576+
577+
In the case of Subscriber Verification are two styles of verifications to available: Blackbox or Whitebox.
578+
It is *strongly* recommend to test `Subscriber` implementations with the `SubscriberWhiteboxVerification` as it is able to
579+
verify most of the specification. The `SubscriberBlackboxVerification` should only be used as a fallback,
580+
once you are sure implementing the whitebox version will not be possible for your implementation - if that happens
581+
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
582+
implementing the whitebox verification.
583+
584+
In summary: implementations are required to use Verifications for the parts of the specification that they implement,
585+
and suggest using the whitebox verification over blackbox for the subscriber whenever possible.
586+
564587
## Upgrading the TCK to newer versions
565588
While we do not expect the Reactive Streams specification to change in the forseeable future,
566589
it *may happen* that some semantics may need to change at some point. In this case you should expect test

0 commit comments

Comments
 (0)