Exemplo n.º 1
0
 /**
  * A new SubmissionPublisher has no subscribers, is not closed, has the given buffer size, and
  * uses the given executor
  */
 public void testConstructor2() {
   Executor e = Executors.newFixedThreadPool(1);
   SubmissionPublisher<Integer> p = new SubmissionPublisher<Integer>(e, 8);
   checkInitialState(p);
   assertSame(p.getExecutor(), e);
   assertEquals(8, p.getMaxBufferCapacity());
 }
Exemplo n.º 2
0
 /**
  * A default-constructed SubmissionPublisher has no subscribers, is not closed, has default buffer
  * size, and uses the defaultExecutor
  */
 public void testConstructor1() {
   SubmissionPublisher<Integer> p = new SubmissionPublisher<Integer>();
   checkInitialState(p);
   assertEquals(p.getMaxBufferCapacity(), Flow.defaultBufferSize());
   Executor e = p.getExecutor(), c = ForkJoinPool.commonPool();
   if (ForkJoinPool.getCommonPoolParallelism() > 1) assertSame(e, c);
   else assertNotSame(e, c);
 }
Exemplo n.º 3
0
 /**
  * A new SubmissionPublisher has no subscribers, a non-null executor, a power-of-two capacity, is
  * not closed, and reports zero demand and lag
  */
 void checkInitialState(SubmissionPublisher<?> p) {
   assertFalse(p.hasSubscribers());
   assertEquals(0, p.getNumberOfSubscribers());
   assertTrue(p.getSubscribers().isEmpty());
   assertFalse(p.isClosed());
   assertNull(p.getClosedException());
   int n = p.getMaxBufferCapacity();
   assertTrue((n & (n - 1)) == 0); // power of two
   assertNotNull(p.getExecutor());
   assertEquals(0, p.estimateMinimumDemand());
   assertEquals(0, p.estimateMaximumLag());
 }