Skip to content

1.0.2-RC1: Fix the IdentityFlowProcessorVerification class #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

package org.reactivestreams.tck.flow;

import org.reactivestreams.Processor;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.*;
import org.reactivestreams.tck.IdentityProcessorVerification;
import org.reactivestreams.tck.TestEnvironment;
import org.reactivestreams.tck.flow.support.SubscriberWhiteboxVerificationRules;
import org.reactivestreams.tck.flow.support.PublisherVerificationRules;

import java.util.concurrent.Flow;

public abstract class IdentityFlowProcessorVerification<T> extends IdentityProcessorVerification<T>
implements SubscriberWhiteboxVerificationRules, PublisherVerificationRules {

Expand All @@ -34,39 +34,33 @@ public IdentityFlowProcessorVerification(TestEnvironment env, long publisherRefe
super(env, publisherReferenceGCTimeoutMillis, processorBufferSize);
}

protected abstract Publisher<T> createFailedFlowPublisher();

protected abstract Processor<T,T> createIdentityFlowProcessor(int bufferSize);

protected abstract Subscriber<T> createFlowSubscriber(FlowSubscriberWhiteboxVerification.WhiteboxSubscriberProbe<T> probe);

protected abstract Publisher<T> createFlowHelperPublisher(long elements);

protected abstract Publisher<T> createFlowPublisher(long elements);

@Override
public final Publisher<T> createHelperPublisher(long elements) {
return createFlowHelperPublisher(elements);
}
/**
* By implementing this method, additional TCK tests concerning a "failed" Flow publishers will be run.
*
* The expected behaviour of the {@link Flow.Publisher} returned by this method is hand out a subscription,
* followed by signalling {@code onError} on it, as specified by Rule 1.9.
*
* If you want to ignore these additional tests, return {@code null} from this method.
*/
protected abstract Flow.Publisher<T> createFailedFlowPublisher();

/**
* This is the main method you must implement in your test incarnation.
* It must create a {@link Flow.Processor}, which simply forwards all stream elements from its upstream
* to its downstream. It must be able to internally buffer the given number of elements.
*
* @param bufferSize number of elements the processor is required to be able to buffer.
*/
protected abstract Flow.Processor<T,T> createIdentityFlowProcessor(int bufferSize);

@Override
public final Processor<T, T> createIdentityProcessor(int bufferSize) {
return createIdentityFlowProcessor(bufferSize);
return FlowAdapters.toProcessor(createIdentityFlowProcessor(bufferSize));
}

@Override
public final Publisher<T> createFailedPublisher() {
return createFailedFlowPublisher();
}

@Override
public final Publisher<T> createPublisher(long elements) {
return createFlowPublisher(elements);
}

@Override
public final Subscriber<T> createSubscriber(FlowSubscriberWhiteboxVerification.WhiteboxSubscriberProbe<T> probe) {
return createFlowSubscriber(probe);
return FlowAdapters.toPublisher(createFailedFlowPublisher());
}

}
Loading