7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
+ |
import java.util.Arrays; |
11 |
+ |
import java.util.NoSuchElementException; |
12 |
|
import java.util.PropertyPermission; |
13 |
|
import java.util.concurrent.*; |
14 |
|
import java.util.concurrent.atomic.AtomicReference; |
262 |
|
SHORT_DELAY_MS = getShortDelay(); |
263 |
|
SMALL_DELAY_MS = SHORT_DELAY_MS * 5; |
264 |
|
MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10; |
265 |
< |
LONG_DELAY_MS = SHORT_DELAY_MS * 50; |
265 |
> |
LONG_DELAY_MS = SHORT_DELAY_MS * 200; |
266 |
|
} |
267 |
|
|
268 |
|
/** |
291 |
|
* earlier by threadRecordFailure. |
292 |
|
*/ |
293 |
|
public void tearDown() throws Exception { |
294 |
< |
Throwable t = threadFailure.getAndSet(null); |
294 |
> |
Throwable t = threadFailure.getAndSet(null); |
295 |
|
if (t != null) { |
296 |
|
if (t instanceof Error) |
297 |
|
throw (Error) t; |
449 |
|
try { |
450 |
|
exec.shutdown(); |
451 |
|
assertTrue("ExecutorService did not terminate in a timely manner", |
452 |
< |
exec.awaitTermination(LONG_DELAY_MS, MILLISECONDS)); |
452 |
> |
exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)); |
453 |
|
} catch (SecurityException ok) { |
454 |
|
// Allowed in case test doesn't have privs |
455 |
|
} catch (InterruptedException ie) { |
1009 |
|
} |
1010 |
|
} |
1011 |
|
|
1012 |
+ |
public void checkEmpty(BlockingQueue q) { |
1013 |
+ |
try { |
1014 |
+ |
assertTrue(q.isEmpty()); |
1015 |
+ |
assertEquals(0, q.size()); |
1016 |
+ |
assertNull(q.peek()); |
1017 |
+ |
assertNull(q.poll()); |
1018 |
+ |
assertNull(q.poll(0, MILLISECONDS)); |
1019 |
+ |
assertEquals(q.toString(), "[]"); |
1020 |
+ |
assertTrue(Arrays.equals(q.toArray(), new Object[0])); |
1021 |
+ |
assertFalse(q.iterator().hasNext()); |
1022 |
+ |
try { |
1023 |
+ |
q.element(); |
1024 |
+ |
shouldThrow(); |
1025 |
+ |
} catch (NoSuchElementException success) {} |
1026 |
+ |
try { |
1027 |
+ |
q.iterator().next(); |
1028 |
+ |
shouldThrow(); |
1029 |
+ |
} catch (NoSuchElementException success) {} |
1030 |
+ |
try { |
1031 |
+ |
q.remove(); |
1032 |
+ |
shouldThrow(); |
1033 |
+ |
} catch (NoSuchElementException success) {} |
1034 |
+ |
} catch (InterruptedException ie) { |
1035 |
+ |
threadUnexpectedException(ie); |
1036 |
+ |
} |
1037 |
+ |
} |
1038 |
+ |
|
1039 |
|
} |