45 |
|
return t; |
46 |
|
} |
47 |
|
} |
48 |
< |
|
48 |
> |
|
49 |
|
static final Executor basicExecutor = |
50 |
|
(ForkJoinPool.getCommonPoolParallelism() > 0) ? |
51 |
|
ForkJoinPool.commonPool() : |
52 |
|
new ThreadPoolExecutor(1, 1, 60, SECONDS, |
53 |
|
new LinkedBlockingQueue<Runnable>(), |
54 |
|
new DaemonThreadFactory()); |
55 |
< |
|
55 |
> |
|
56 |
|
static SubmissionPublisher<Integer> basicPublisher() { |
57 |
|
return new SubmissionPublisher<Integer>(basicExecutor, |
58 |
|
Flow.defaultBufferSize()); |
59 |
|
} |
60 |
< |
|
60 |
> |
|
61 |
|
static class SPException extends RuntimeException {} |
62 |
|
|
63 |
|
class TestSubscriber implements Subscriber<Integer> { |
193 |
|
*/ |
194 |
|
public void testConstructor3() { |
195 |
|
try { |
196 |
< |
SubmissionPublisher<Integer> p = new SubmissionPublisher<Integer>(null, 8); |
196 |
> |
new SubmissionPublisher<Integer>(null, 8); |
197 |
|
shouldThrow(); |
198 |
< |
} catch (NullPointerException success) { |
199 |
< |
} |
198 |
> |
} catch (NullPointerException success) {} |
199 |
|
} |
200 |
|
|
201 |
|
/** |
205 |
|
public void testConstructor4() { |
206 |
|
Executor e = Executors.newFixedThreadPool(1); |
207 |
|
try { |
208 |
< |
SubmissionPublisher<Integer> p = new SubmissionPublisher<Integer>(e, -1); |
208 |
> |
new SubmissionPublisher<Integer>(e, -1); |
209 |
|
shouldThrow(); |
210 |
< |
} catch (IllegalArgumentException success) { |
212 |
< |
} |
210 |
> |
} catch (IllegalArgumentException success) {} |
211 |
|
} |
212 |
|
|
213 |
|
/** |
224 |
|
try { |
225 |
|
p.submit(1); |
226 |
|
shouldThrow(); |
227 |
< |
} |
230 |
< |
catch(IllegalStateException success) { |
231 |
< |
} |
227 |
> |
} catch (IllegalStateException success) {} |
228 |
|
Throwable ex = new SPException(); |
229 |
|
p.closeExceptionally(ex); |
230 |
|
assertTrue(p.isClosed()); |
247 |
|
try { |
248 |
|
p.submit(1); |
249 |
|
shouldThrow(); |
250 |
< |
} |
255 |
< |
catch(IllegalStateException success) { |
256 |
< |
} |
250 |
> |
} catch (IllegalStateException success) {} |
251 |
|
p.close(); |
252 |
|
assertTrue(p.isClosed()); |
253 |
|
assertSame(p.getClosedException(), ex); |
352 |
|
s.throwOnCall = true; |
353 |
|
try { |
354 |
|
p.subscribe(s); |
355 |
< |
} catch(Exception ok) { |
362 |
< |
} |
355 |
> |
} catch (Exception ok) {} |
356 |
|
s.awaitError(); |
357 |
|
assertEquals(s.nexts, 0); |
358 |
|
assertEquals(s.errors, 1); |
366 |
|
SubmissionPublisher<Integer> p = basicPublisher(); |
367 |
|
try { |
368 |
|
p.subscribe(null); |
369 |
< |
} catch(NullPointerException success) { |
370 |
< |
} |
369 |
> |
shouldThrow(); |
370 |
> |
} catch (NullPointerException success) {} |
371 |
|
checkInitialState(p); |
372 |
|
} |
373 |
|
|
605 |
|
SubmissionPublisher<Integer> p = basicPublisher(); |
606 |
|
try { |
607 |
|
p.submit(null); |
608 |
< |
} catch (NullPointerException success) { |
609 |
< |
} |
608 |
> |
shouldThrow(); |
609 |
> |
} catch (NullPointerException success) {} |
610 |
|
} |
611 |
|
|
612 |
|
/** |
661 |
|
assertEquals(s1.nexts, 20); |
662 |
|
assertEquals(s1.completes, 1); |
663 |
|
} |
664 |
< |
|
664 |
> |
|
665 |
|
static boolean noopHandle(AtomicInteger count) { |
666 |
|
count.getAndIncrement(); |
667 |
|
return false; |
688 |
|
SubmissionPublisher<Integer> p = basicPublisher(); |
689 |
|
try { |
690 |
|
p.offer(null, null); |
691 |
< |
} catch (NullPointerException success) { |
692 |
< |
} |
691 |
> |
shouldThrow(); |
692 |
> |
} catch (NullPointerException success) {} |
693 |
|
} |
694 |
|
|
695 |
|
/** |
818 |
|
SubmissionPublisher<Integer> p = basicPublisher(); |
819 |
|
try { |
820 |
|
p.offer(null, SHORT_DELAY_MS, MILLISECONDS, null); |
821 |
< |
} catch (NullPointerException success) { |
822 |
< |
} |
821 |
> |
shouldThrow(); |
822 |
> |
} catch (NullPointerException success) {} |
823 |
|
try { |
824 |
|
p.offer(1, SHORT_DELAY_MS, null, null); |
825 |
< |
} catch (NullPointerException success) { |
826 |
< |
} |
825 |
> |
shouldThrow(); |
826 |
> |
} catch (NullPointerException success) {} |
827 |
|
} |
828 |
|
|
829 |
|
/** |