|
14 | 14 | import org.testng.annotations.BeforeMethod;
|
15 | 15 | import org.testng.annotations.Test;
|
16 | 16 |
|
| 17 | +import java.lang.NullPointerException; |
| 18 | +import java.lang.Override; |
| 19 | +import java.lang.RuntimeException; |
17 | 20 | import java.util.concurrent.ExecutorService;
|
18 | 21 | import java.util.concurrent.Executors;
|
19 | 22 |
|
20 | 23 | import static org.reactivestreams.tck.SubscriberWhiteboxVerification.BlackboxSubscriberProxy;
|
| 24 | +import static org.testng.Assert.assertTrue; |
21 | 25 |
|
22 | 26 | /**
|
23 | 27 | * Provides tests for verifying {@link org.reactivestreams.Subscriber} and {@link org.reactivestreams.Subscription}
|
@@ -310,6 +314,57 @@ public void untested_spec213_blackbox_failingOnSignalInvocation() throws Excepti
|
310 | 314 | notVerified(); // cannot be meaningfully tested, or can it?
|
311 | 315 | }
|
312 | 316 |
|
| 317 | + // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.13 |
| 318 | + @Override @Test |
| 319 | + public void required_spec213_blackbox_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { |
| 320 | + blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { |
| 321 | + @Override |
| 322 | + public void run(BlackboxTestStage stage) throws Throwable { |
| 323 | + final Subscription subscription = new Subscription() { |
| 324 | + @Override public void request(final long elements) {} |
| 325 | + @Override public void cancel() {} |
| 326 | + }; |
| 327 | + |
| 328 | + { |
| 329 | + final Subscriber<T> sub = createSubscriber(); |
| 330 | + boolean gotNPE = false; |
| 331 | + try { |
| 332 | + sub.onSubscribe(null); |
| 333 | + } catch(final NullPointerException expected) { |
| 334 | + gotNPE = true; |
| 335 | + } |
| 336 | + assertTrue(gotNPE, "onSubscribe(null) did not throw NullPointerException"); |
| 337 | + } |
| 338 | + |
| 339 | + { |
| 340 | + final Subscriber<T> sub = createSubscriber(); |
| 341 | + boolean gotNPE = false; |
| 342 | + sub.onSubscribe(subscription); |
| 343 | + try { |
| 344 | + sub.onNext(null); |
| 345 | + } catch(final NullPointerException expected) { |
| 346 | + gotNPE = true; |
| 347 | + } |
| 348 | + assertTrue(gotNPE, "onNext(null) did not throw NullPointerException"); |
| 349 | + } |
| 350 | + |
| 351 | + { |
| 352 | + final Subscriber<T> sub = createSubscriber(); |
| 353 | + boolean gotNPE = false; |
| 354 | + sub.onSubscribe(subscription); |
| 355 | + try { |
| 356 | + sub.onError(null); |
| 357 | + } catch(final NullPointerException expected) { |
| 358 | + gotNPE = true; |
| 359 | + } |
| 360 | + assertTrue(gotNPE, "onError(null) did not throw NullPointerException"); |
| 361 | + } |
| 362 | + |
| 363 | + env.verifyNoAsyncErrors(); |
| 364 | + } |
| 365 | + }); |
| 366 | + } |
| 367 | + |
313 | 368 | ////////////////////// SUBSCRIPTION SPEC RULE VERIFICATION //////////////////
|
314 | 369 |
|
315 | 370 | // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.1
|
|
0 commit comments