ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/SubmissionPublisherTest.java
(Generate patch)

Comparing jsr166/src/test/tck/SubmissionPublisherTest.java (file contents):
Revision 1.18 by jsr166, Wed Jan 4 06:09:58 2017 UTC vs.
Revision 1.23 by dl, Sun Nov 26 21:37:56 2017 UTC

# Line 169 | Line 169 | public class SubmissionPublisherTest ext
169      }
170  
171      /**
172 <     * A null Executor argument to SubmissionPublisher constructor throws NPE
172 >     * A null Executor argument to SubmissionPublisher constructor
173 >     * throws NullPointerException
174       */
175      public void testConstructor3() {
176          try {
# Line 180 | Line 181 | public class SubmissionPublisherTest ext
181  
182      /**
183       * A negative capacity argument to SubmissionPublisher constructor
184 <     * throws IAE
184 >     * throws IllegalArgumentException
185       */
186      public void testConstructor4() {
187          Executor e = Executors.newFixedThreadPool(1);
# Line 192 | Line 193 | public class SubmissionPublisherTest ext
193  
194      /**
195       * A closed publisher reports isClosed with no closedException and
196 <     * throws ISE upon attempted submission; a subsequent close or
197 <     * closeExceptionally has no additional effect.
196 >     * throws IllegalStateException upon attempted submission; a
197 >     * subsequent close or closeExceptionally has no additional
198 >     * effect.
199       */
200      public void testClose() {
201          SubmissionPublisher<Integer> p = basicPublisher();
# Line 213 | Line 215 | public class SubmissionPublisherTest ext
215  
216      /**
217       * A publisher closedExceptionally reports isClosed with the
218 <     * closedException and throws ISE upon attempted submission; a
219 <     * subsequent close or closeExceptionally has no additional
220 <     * effect.
218 >     * closedException and throws IllegalStateException upon attempted
219 >     * submission; a subsequent close or closeExceptionally has no
220 >     * additional effect.
221       */
222      public void testCloseExceptionally() {
223          SubmissionPublisher<Integer> p = basicPublisher();
# Line 400 | Line 402 | public class SubmissionPublisherTest ext
402       * Cancelling a subscription eventually causes no more onNexts to be issued
403       */
404      public void testCancel() {
405 <        SubmissionPublisher<Integer> p = basicPublisher();
405 >        SubmissionPublisher<Integer> p =
406 >            new SubmissionPublisher<Integer>(basicExecutor, 4); // must be < 20
407          TestSubscriber s1 = new TestSubscriber();
408          TestSubscriber s2 = new TestSubscriber();
409          p.subscribe(s1);
# Line 492 | Line 495 | public class SubmissionPublisherTest ext
495          s1.request = false;
496          p.subscribe(s1);
497          s1.awaitSubscribe();
498 <        assertTrue(p.estimateMinimumDemand() == 0);
498 >        assertEquals(0, p.estimateMinimumDemand());
499          TestSubscriber s2 = new TestSubscriber();
500          p.subscribe(s2);
501          p.submit(1);
# Line 533 | Line 536 | public class SubmissionPublisherTest ext
536      }
537  
538      /**
539 <     * Negative request causes error
539 >     * Non-positive request causes error
540       */
541      public void testRequest3() {
542          SubmissionPublisher<Integer> p = basicPublisher();
543          TestSubscriber s1 = new TestSubscriber();
544          TestSubscriber s2 = new TestSubscriber();
545 +        TestSubscriber s3 = new TestSubscriber();
546          p.subscribe(s1);
547          p.subscribe(s2);
548 +        p.subscribe(s3);
549 +        s3.awaitSubscribe();
550          s2.awaitSubscribe();
551          s1.awaitSubscribe();
552          s1.sn.request(-1L);
553 +        s3.sn.request(0L);
554          p.submit(1);
555          p.submit(2);
556          p.close();
# Line 553 | Line 560 | public class SubmissionPublisherTest ext
560          s1.awaitError();
561          assertEquals(1, s1.errors);
562          assertTrue(s1.lastError instanceof IllegalArgumentException);
563 +        s3.awaitError();
564 +        assertEquals(1, s3.errors);
565 +        assertTrue(s3.lastError instanceof IllegalArgumentException);
566      }
567  
568      /**
569       * estimateMinimumDemand reports 0 until request, nonzero after
570 <     * request, and zero again after delivery
570 >     * request
571       */
572      public void testEstimateMinimumDemand() {
573          TestSubscriber s = new TestSubscriber();
# Line 568 | Line 578 | public class SubmissionPublisherTest ext
578          assertEquals(0, p.estimateMinimumDemand());
579          s.sn.request(1);
580          assertEquals(1, p.estimateMinimumDemand());
571        p.submit(1);
572        s.awaitNext(1);
573        assertEquals(0, p.estimateMinimumDemand());
581      }
582  
583      /**
# Line 633 | Line 640 | public class SubmissionPublisherTest ext
640          p.subscribe(s1);
641          p.subscribe(s2);
642          for (int i = 1; i <= 20; ++i) {
636            assertTrue(p.estimateMinimumDemand() <= 1);
643              assertTrue(p.submit(i) >= 0);
644          }
645          p.close();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines