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(ArrayBlockingQueueTest.class)); |
104 |
|
suite.addTest(new TestSuite(AtomicBooleanTest.class)); |
105 |
|
suite.addTest(new TestSuite(AtomicIntegerArrayTest.class)); |
113 |
|
suite.addTest(new TestSuite(AtomicReferenceFieldUpdaterTest.class)); |
114 |
|
suite.addTest(new TestSuite(AtomicReferenceTest.class)); |
115 |
|
suite.addTest(new TestSuite(AtomicStampedReferenceTest.class)); |
114 |
– |
suite.addTest(new TestSuite(CancellableTaskTest.class)); |
116 |
|
suite.addTest(new TestSuite(ConcurrentHashMapTest.class)); |
117 |
|
suite.addTest(new TestSuite(ConcurrentLinkedQueueTest.class)); |
118 |
|
suite.addTest(new TestSuite(CopyOnWriteArrayListTest.class)); |
122 |
|
suite.addTest(new TestSuite(DelayQueueTest.class)); |
123 |
|
suite.addTest(new TestSuite(ExchangerTest.class)); |
124 |
|
suite.addTest(new TestSuite(ExecutorsTest.class)); |
125 |
< |
suite.addTest(new TestSuite(FairSemaphoreTest.class)); |
125 |
> |
suite.addTest(new TestSuite(ExecutorCompletionServiceTest.class)); |
126 |
|
suite.addTest(new TestSuite(FutureTaskTest.class)); |
127 |
|
suite.addTest(new TestSuite(LinkedBlockingQueueTest.class)); |
128 |
|
suite.addTest(new TestSuite(LinkedListTest.class)); |
322 |
|
static final Integer m10 = new Integer(-10); |
323 |
|
|
324 |
|
|
325 |
+ |
/** |
326 |
+ |
* A security policy where new permissions can be dynamically added |
327 |
+ |
* or all cleared. |
328 |
+ |
*/ |
329 |
+ |
static class AdjustablePolicy extends java.security.Policy { |
330 |
+ |
Permissions perms = new Permissions(); |
331 |
+ |
AdjustablePolicy() { } |
332 |
+ |
void addPermission(Permission perm) { perms.add(perm); } |
333 |
+ |
void clearPermissions() { perms = new Permissions(); } |
334 |
+ |
public PermissionCollection getPermissions(CodeSource cs) { |
335 |
+ |
return perms; |
336 |
+ |
} |
337 |
+ |
public PermissionCollection getPermissions(ProtectionDomain pd) { |
338 |
+ |
return perms; |
339 |
+ |
} |
340 |
+ |
public boolean implies(ProtectionDomain pd, Permission p) { |
341 |
+ |
return perms.implies(p); |
342 |
+ |
} |
343 |
+ |
public void refresh() {} |
344 |
+ |
} |
345 |
+ |
|
346 |
+ |
|
347 |
|
// Some convenient Runnable classes |
348 |
|
|
349 |
|
static class NoOpRunnable implements Runnable { |
354 |
|
public Object call() { return Boolean.TRUE; } |
355 |
|
} |
356 |
|
|
357 |
+ |
static final String TEST_STRING = "a test string"; |
358 |
+ |
|
359 |
+ |
static class StringTask implements Callable<String> { |
360 |
+ |
public String call() { return TEST_STRING; } |
361 |
+ |
} |
362 |
+ |
|
363 |
+ |
static class NPETask implements Callable<String> { |
364 |
+ |
public String call() { throw new NullPointerException(); } |
365 |
+ |
} |
366 |
+ |
|
367 |
+ |
static class CallableOne implements Callable<Integer> { |
368 |
+ |
public Integer call() { return one; } |
369 |
+ |
} |
370 |
+ |
|
371 |
|
class ShortRunnable implements Runnable { |
372 |
|
public void run() { |
373 |
|
try { |
464 |
|
} |
465 |
|
catch(InterruptedException success) { |
466 |
|
} |
467 |
+ |
} |
468 |
+ |
} |
469 |
+ |
|
470 |
+ |
class LongPossiblyInterruptedRunnable implements Runnable { |
471 |
+ |
public void run() { |
472 |
+ |
try { |
473 |
+ |
Thread.sleep(LONG_DELAY_MS); |
474 |
+ |
} |
475 |
+ |
catch(InterruptedException success) { |
476 |
+ |
} |
477 |
|
} |
478 |
|
} |
479 |
|
|