90 |
|
/** |
91 |
|
* Runs all JSR166 unit tests using junit.textui.TestRunner |
92 |
|
*/ |
93 |
< |
public static void main (String[] args) { |
93 |
> |
public static void main(String[] args) { |
94 |
|
int iters = 1; |
95 |
|
if (args.length > 0) |
96 |
|
iters = Integer.parseInt(args[0]); |
97 |
|
Test s = suite(); |
98 |
|
for (int i = 0; i < iters; ++i) { |
99 |
< |
junit.textui.TestRunner.run (s); |
99 |
> |
junit.textui.TestRunner.run(s); |
100 |
|
System.gc(); |
101 |
|
System.runFinalization(); |
102 |
|
} |
106 |
|
/** |
107 |
|
* Collects all JSR166 unit tests as one suite |
108 |
|
*/ |
109 |
< |
public static Test suite ( ) { |
109 |
> |
public static Test suite() { |
110 |
|
TestSuite suite = new TestSuite("JSR166 Unit Tests"); |
111 |
|
|
112 |
|
suite.addTest(new TestSuite(ForkJoinPoolTest.class)); |
195 |
|
/** |
196 |
|
* Sets delays as multiples of SHORT_DELAY. |
197 |
|
*/ |
198 |
< |
protected void setDelays() { |
198 |
> |
protected void setDelays() { |
199 |
|
SHORT_DELAY_MS = getShortDelay(); |
200 |
|
SMALL_DELAY_MS = SHORT_DELAY_MS * 5; |
201 |
|
MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10; |
328 |
|
} catch (SecurityException ok) { |
329 |
|
// Allowed in case test doesn't have privs |
330 |
|
} catch (InterruptedException ie) { |
331 |
< |
fail("Unexpected exception"); |
331 |
> |
fail("Unexpected InterruptedException"); |
332 |
|
} |
333 |
|
} |
334 |
|
|
398 |
|
AdjustablePolicy() { } |
399 |
|
void addPermission(Permission perm) { perms.add(perm); } |
400 |
|
void clearPermissions() { perms = new Permissions(); } |
401 |
< |
public PermissionCollection getPermissions(CodeSource cs) { |
402 |
< |
return perms; |
403 |
< |
} |
404 |
< |
public PermissionCollection getPermissions(ProtectionDomain pd) { |
405 |
< |
return perms; |
406 |
< |
} |
407 |
< |
public boolean implies(ProtectionDomain pd, Permission p) { |
408 |
< |
return perms.implies(p); |
409 |
< |
} |
410 |
< |
public void refresh() {} |
401 |
> |
public PermissionCollection getPermissions(CodeSource cs) { |
402 |
> |
return perms; |
403 |
> |
} |
404 |
> |
public PermissionCollection getPermissions(ProtectionDomain pd) { |
405 |
> |
return perms; |
406 |
> |
} |
407 |
> |
public boolean implies(ProtectionDomain pd, Permission p) { |
408 |
> |
return perms.implies(p); |
409 |
> |
} |
410 |
> |
public void refresh() {} |
411 |
|
} |
412 |
|
|
413 |
|
/** |
417 |
|
void sleepTillInterrupted(long timeoutMillis) { |
418 |
|
try { |
419 |
|
Thread.sleep(timeoutMillis); |
420 |
< |
} catch (InterruptedException wakeup) { |
421 |
< |
} |
420 |
> |
} catch (InterruptedException wakeup) {} |
421 |
|
} |
422 |
|
|
423 |
|
/** |
572 |
|
void realRun() { |
573 |
|
try { |
574 |
|
Thread.sleep(SMALL_DELAY_MS); |
575 |
< |
} |
577 |
< |
catch (InterruptedException ok) { |
578 |
< |
} |
575 |
> |
} catch (InterruptedException ok) {} |
576 |
|
} |
577 |
|
} |
578 |
|
|
579 |
|
class SmallCallable extends CheckedCallable { |
580 |
< |
Object realCall() throws Throwable { |
580 |
> |
Object realCall() throws InterruptedException { |
581 |
|
Thread.sleep(SMALL_DELAY_MS); |
582 |
|
return Boolean.TRUE; |
583 |
|
} |
605 |
|
void realRun() { |
606 |
|
try { |
607 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
608 |
< |
} |
612 |
< |
catch (InterruptedException ok) { |
613 |
< |
} |
608 |
> |
} catch (InterruptedException ok) {} |
609 |
|
} |
610 |
|
} |
611 |
|
|
613 |
|
void realRun() { |
614 |
|
try { |
615 |
|
Thread.sleep(LONG_DELAY_MS); |
616 |
< |
} |
622 |
< |
catch (InterruptedException ok) { |
623 |
< |
} |
616 |
> |
} catch (InterruptedException ok) {} |
617 |
|
} |
618 |
|
} |
619 |
|
|
632 |
|
try { |
633 |
|
Thread.sleep(SMALL_DELAY_MS); |
634 |
|
done = true; |
635 |
< |
} catch (InterruptedException ok) { |
643 |
< |
} |
635 |
> |
} catch (InterruptedException ok) {} |
636 |
|
} |
637 |
|
} |
638 |
|
|
642 |
|
try { |
643 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
644 |
|
done = true; |
645 |
< |
} catch (InterruptedException ok) { |
654 |
< |
} |
645 |
> |
} catch (InterruptedException ok) {} |
646 |
|
} |
647 |
|
} |
648 |
|
|
652 |
|
try { |
653 |
|
Thread.sleep(LONG_DELAY_MS); |
654 |
|
done = true; |
655 |
< |
} catch (InterruptedException ok) { |
665 |
< |
} |
655 |
> |
} catch (InterruptedException ok) {} |
656 |
|
} |
657 |
|
} |
658 |
|
|
669 |
|
try { |
670 |
|
Thread.sleep(SMALL_DELAY_MS); |
671 |
|
done = true; |
672 |
< |
} catch (InterruptedException ok) { |
683 |
< |
} |
672 |
> |
} catch (InterruptedException ok) {} |
673 |
|
return Boolean.TRUE; |
674 |
|
} |
675 |
|
} |