|
4 | 4 | import org.reactivestreams.Subscriber;
|
5 | 5 | import org.reactivestreams.Subscription;
|
6 | 6 | import org.reactivestreams.tck.TestEnvironment.*;
|
7 |
| -import org.reactivestreams.tck.support.Function; |
8 | 7 | import org.reactivestreams.tck.support.Optional;
|
9 |
| -import org.reactivestreams.tck.support.TestException; |
10 | 8 | import org.reactivestreams.tck.support.SubscriberWhiteboxVerificationRules;
|
| 9 | +import org.reactivestreams.tck.support.TestException; |
11 | 10 | import org.testng.SkipException;
|
12 | 11 | import org.testng.annotations.AfterClass;
|
13 | 12 | import org.testng.annotations.BeforeClass;
|
|
17 | 16 | import java.util.concurrent.ExecutorService;
|
18 | 17 | import java.util.concurrent.Executors;
|
19 | 18 |
|
20 |
| -import static org.testng.Assert.assertEquals; |
21 | 19 | import static org.testng.Assert.assertTrue;
|
22 | 20 |
|
23 | 21 | /**
|
@@ -343,6 +341,86 @@ public void untested_spec213_failingOnSignalInvocation() throws Exception {
|
343 | 341 | notVerified(); // cannot be meaningfully tested, or can it?
|
344 | 342 | }
|
345 | 343 |
|
| 344 | + // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.13 |
| 345 | + @Override @Test |
| 346 | + public void required_spec213_onSubscribe_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { |
| 347 | + subscriberTest(new TestStageTestRun() { |
| 348 | + @Override |
| 349 | + public void run(WhiteboxTestStage stage) throws Throwable { |
| 350 | + |
| 351 | + { |
| 352 | + final Subscriber<T> sub = createSubscriber(stage.probe()); |
| 353 | + boolean gotNPE = false; |
| 354 | + try { |
| 355 | + sub.onSubscribe(null); |
| 356 | + } catch(final NullPointerException expected) { |
| 357 | + gotNPE = true; |
| 358 | + } |
| 359 | + assertTrue(gotNPE, "onSubscribe(null) did not throw NullPointerException"); |
| 360 | + } |
| 361 | + |
| 362 | + env.verifyNoAsyncErrors(); |
| 363 | + } |
| 364 | + }); |
| 365 | + }// Verifies rule: https://github.com/reactive-streams/reactive-streams#2.13 |
| 366 | + @Override @Test |
| 367 | + public void required_spec213_onNext_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { |
| 368 | + subscriberTest(new TestStageTestRun() { |
| 369 | + @Override |
| 370 | + public void run(WhiteboxTestStage stage) throws Throwable { |
| 371 | + |
| 372 | + final Subscription subscription = new Subscription() { |
| 373 | + @Override public void request(final long elements) {} |
| 374 | + @Override public void cancel() {} |
| 375 | + }; |
| 376 | + |
| 377 | + { |
| 378 | + final Subscriber<T> sub = createSubscriber(stage.probe()); |
| 379 | + boolean gotNPE = false; |
| 380 | + sub.onSubscribe(subscription); |
| 381 | + try { |
| 382 | + sub.onNext(null); |
| 383 | + } catch(final NullPointerException expected) { |
| 384 | + gotNPE = true; |
| 385 | + } |
| 386 | + assertTrue(gotNPE, "onNext(null) did not throw NullPointerException"); |
| 387 | + } |
| 388 | + |
| 389 | + env.verifyNoAsyncErrors(); |
| 390 | + } |
| 391 | + }); |
| 392 | + } |
| 393 | + |
| 394 | + // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.13 |
| 395 | + @Override @Test |
| 396 | + public void required_spec213_onError_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { |
| 397 | + subscriberTest(new TestStageTestRun() { |
| 398 | + @Override |
| 399 | + public void run(WhiteboxTestStage stage) throws Throwable { |
| 400 | + |
| 401 | + final Subscription subscription = new Subscription() { |
| 402 | + @Override public void request(final long elements) {} |
| 403 | + @Override public void cancel() {} |
| 404 | + }; |
| 405 | + |
| 406 | + { |
| 407 | + final Subscriber<T> sub = createSubscriber(stage.probe()); |
| 408 | + boolean gotNPE = false; |
| 409 | + sub.onSubscribe(subscription); |
| 410 | + try { |
| 411 | + sub.onError(null); |
| 412 | + } catch(final NullPointerException expected) { |
| 413 | + gotNPE = true; |
| 414 | + } |
| 415 | + assertTrue(gotNPE, "onError(null) did not throw NullPointerException"); |
| 416 | + } |
| 417 | + |
| 418 | + env.verifyNoAsyncErrors(); |
| 419 | + } |
| 420 | + }); |
| 421 | + } |
| 422 | + |
| 423 | + |
346 | 424 | ////////////////////// SUBSCRIPTION SPEC RULE VERIFICATION //////////////////
|
347 | 425 |
|
348 | 426 | // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.1
|
|
0 commit comments