1 |
|
/* |
2 |
< |
* Written by members of JCP JSR-166 Expert Group and released to the |
3 |
< |
* public domain. Use, modify, and redistribute this code in any way |
4 |
< |
* without acknowledgement. Other contributors include Andrew Wright, |
5 |
< |
* Jeffrey Hayes, Pat Fischer, Mike Judd. |
2 |
> |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
> |
* Expert Group and released to the public domain, as explained at |
4 |
> |
* http://creativecommons.org/licenses/publicdomain |
5 |
> |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
> |
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
|
import java.util.*; |
11 |
|
import java.util.concurrent.*; |
12 |
|
import java.io.*; |
13 |
< |
|
13 |
> |
import java.security.*; |
14 |
|
|
15 |
|
/** |
16 |
|
* Base class for JSR166 Junit TCK tests. Defines some constants, |
99 |
|
public static Test suite ( ) { |
100 |
|
TestSuite suite = new TestSuite("JSR166 Unit Tests"); |
101 |
|
|
102 |
+ |
suite.addTest(new TestSuite(AbstractExecutorServiceTest.class)); |
103 |
+ |
suite.addTest(new TestSuite(AbstractQueuedSynchronizerTest.class)); |
104 |
|
suite.addTest(new TestSuite(ArrayBlockingQueueTest.class)); |
105 |
|
suite.addTest(new TestSuite(AtomicBooleanTest.class)); |
106 |
|
suite.addTest(new TestSuite(AtomicIntegerArrayTest.class)); |
114 |
|
suite.addTest(new TestSuite(AtomicReferenceFieldUpdaterTest.class)); |
115 |
|
suite.addTest(new TestSuite(AtomicReferenceTest.class)); |
116 |
|
suite.addTest(new TestSuite(AtomicStampedReferenceTest.class)); |
114 |
– |
suite.addTest(new TestSuite(CancellableTaskTest.class)); |
117 |
|
suite.addTest(new TestSuite(ConcurrentHashMapTest.class)); |
118 |
|
suite.addTest(new TestSuite(ConcurrentLinkedQueueTest.class)); |
119 |
|
suite.addTest(new TestSuite(CopyOnWriteArrayListTest.class)); |
123 |
|
suite.addTest(new TestSuite(DelayQueueTest.class)); |
124 |
|
suite.addTest(new TestSuite(ExchangerTest.class)); |
125 |
|
suite.addTest(new TestSuite(ExecutorsTest.class)); |
126 |
< |
suite.addTest(new TestSuite(FairSemaphoreTest.class)); |
126 |
> |
suite.addTest(new TestSuite(ExecutorCompletionServiceTest.class)); |
127 |
|
suite.addTest(new TestSuite(FutureTaskTest.class)); |
128 |
|
suite.addTest(new TestSuite(LinkedBlockingQueueTest.class)); |
129 |
|
suite.addTest(new TestSuite(LinkedListTest.class)); |
323 |
|
static final Integer m10 = new Integer(-10); |
324 |
|
|
325 |
|
|
326 |
+ |
/** |
327 |
+ |
* A security policy where new permissions can be dynamically added |
328 |
+ |
* or all cleared. |
329 |
+ |
*/ |
330 |
+ |
static class AdjustablePolicy extends java.security.Policy { |
331 |
+ |
Permissions perms = new Permissions(); |
332 |
+ |
AdjustablePolicy() { } |
333 |
+ |
void addPermission(Permission perm) { perms.add(perm); } |
334 |
+ |
void clearPermissions() { perms = new Permissions(); } |
335 |
+ |
public PermissionCollection getPermissions(CodeSource cs) { |
336 |
+ |
return perms; |
337 |
+ |
} |
338 |
+ |
public PermissionCollection getPermissions(ProtectionDomain pd) { |
339 |
+ |
return perms; |
340 |
+ |
} |
341 |
+ |
public boolean implies(ProtectionDomain pd, Permission p) { |
342 |
+ |
return perms.implies(p); |
343 |
+ |
} |
344 |
+ |
public void refresh() {} |
345 |
+ |
} |
346 |
+ |
|
347 |
+ |
|
348 |
|
// Some convenient Runnable classes |
349 |
|
|
350 |
|
static class NoOpRunnable implements Runnable { |
355 |
|
public Object call() { return Boolean.TRUE; } |
356 |
|
} |
357 |
|
|
358 |
+ |
static final String TEST_STRING = "a test string"; |
359 |
+ |
|
360 |
+ |
static class StringTask implements Callable<String> { |
361 |
+ |
public String call() { return TEST_STRING; } |
362 |
+ |
} |
363 |
+ |
|
364 |
+ |
static class NPETask implements Callable<String> { |
365 |
+ |
public String call() { throw new NullPointerException(); } |
366 |
+ |
} |
367 |
+ |
|
368 |
+ |
static class CallableOne implements Callable<Integer> { |
369 |
+ |
public Integer call() { return one; } |
370 |
+ |
} |
371 |
+ |
|
372 |
|
class ShortRunnable implements Runnable { |
373 |
|
public void run() { |
374 |
|
try { |
468 |
|
} |
469 |
|
} |
470 |
|
|
471 |
+ |
class LongPossiblyInterruptedRunnable implements Runnable { |
472 |
+ |
public void run() { |
473 |
+ |
try { |
474 |
+ |
Thread.sleep(LONG_DELAY_MS); |
475 |
+ |
} |
476 |
+ |
catch(InterruptedException success) { |
477 |
+ |
} |
478 |
+ |
} |
479 |
+ |
} |
480 |
+ |
|
481 |
|
/** |
482 |
|
* For use as ThreadFactory in constructors |
483 |
|
*/ |
539 |
|
} |
540 |
|
} |
541 |
|
|
542 |
+ |
|
543 |
|
/** |
544 |
|
* For use as RejectedExecutionHandler in constructors |
545 |
|
*/ |