ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.6 by dl, Sun Oct 5 23:00:40 2003 UTC vs.
Revision 1.16 by dl, Wed Jan 7 01:02:17 2004 UTC

# Line 1 | Line 1
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,
# Line 89 | Line 90 | public class JSR166TestCase extends Test
90       * Runs all JSR166 unit tests using junit.textui.TestRunner
91       */
92      public static void main (String[] args) {
93 <        junit.textui.TestRunner.run (suite());
93 >        int iters = 1;
94 >        if (args.length > 0)
95 >            iters = Integer.parseInt(args[0]);
96 >        Test s = suite();
97 >        for (int i = 0; i < iters; ++i)
98 >            junit.textui.TestRunner.run (s);
99      }
100  
101      /**
# Line 98 | Line 104 | public class JSR166TestCase extends Test
104      public static Test suite ( ) {
105          TestSuite suite = new TestSuite("JSR166 Unit Tests");
106          
107 +        suite.addTest(new TestSuite(AbstractExecutorServiceTest.class));
108 +        suite.addTest(new TestSuite(AbstractQueuedSynchronizerTest.class));
109          suite.addTest(new TestSuite(ArrayBlockingQueueTest.class));
110          suite.addTest(new TestSuite(AtomicBooleanTest.class));
111          suite.addTest(new TestSuite(AtomicIntegerArrayTest.class));
# Line 111 | Line 119 | public class JSR166TestCase extends Test
119          suite.addTest(new TestSuite(AtomicReferenceFieldUpdaterTest.class));
120          suite.addTest(new TestSuite(AtomicReferenceTest.class));
121          suite.addTest(new TestSuite(AtomicStampedReferenceTest.class));
114        suite.addTest(new TestSuite(CancellableTaskTest.class));
122          suite.addTest(new TestSuite(ConcurrentHashMapTest.class));
123          suite.addTest(new TestSuite(ConcurrentLinkedQueueTest.class));
124          suite.addTest(new TestSuite(CopyOnWriteArrayListTest.class));
# Line 121 | Line 128 | public class JSR166TestCase extends Test
128          suite.addTest(new TestSuite(DelayQueueTest.class));
129          suite.addTest(new TestSuite(ExchangerTest.class));
130          suite.addTest(new TestSuite(ExecutorsTest.class));
131 <        suite.addTest(new TestSuite(FairSemaphoreTest.class));
131 >        suite.addTest(new TestSuite(ExecutorCompletionServiceTest.class));
132          suite.addTest(new TestSuite(FutureTaskTest.class));
133          suite.addTest(new TestSuite(LinkedBlockingQueueTest.class));
134          suite.addTest(new TestSuite(LinkedListTest.class));
# Line 151 | Line 158 | public class JSR166TestCase extends Test
158  
159      /**
160       * Return the shortest timed delay. This could
161 <     * be reimplmented to use for example a Property.
161 >     * be reimplemented to use for example a Property.
162       */
163      protected long getShortDelay() {
164          return 100;
# Line 321 | Line 328 | public class JSR166TestCase extends Test
328      static final Integer m10 = new Integer(-10);
329  
330  
331 +    /**
332 +     * A security policy where new permissions can be dynamically added
333 +     * or all cleared.
334 +     */
335 +    static class AdjustablePolicy extends java.security.Policy {
336 +        Permissions perms = new Permissions();
337 +        AdjustablePolicy() { }
338 +        void addPermission(Permission perm) { perms.add(perm); }
339 +        void clearPermissions() { perms = new Permissions(); }
340 +        public PermissionCollection getPermissions(CodeSource cs) {
341 +            return perms;
342 +        }
343 +        public PermissionCollection getPermissions(ProtectionDomain pd) {
344 +            return perms;
345 +        }
346 +        public boolean implies(ProtectionDomain pd, Permission p) {
347 +            return perms.implies(p);
348 +        }
349 +        public void refresh() {}
350 +    }
351 +
352 +
353      // Some convenient Runnable classes
354  
355      static class NoOpRunnable implements Runnable {
# Line 331 | Line 360 | public class JSR166TestCase extends Test
360          public Object call() { return Boolean.TRUE; }
361      }
362  
363 +    static final String TEST_STRING = "a test string";
364 +
365 +    static class StringTask implements Callable<String> {
366 +        public String call() { return TEST_STRING; }
367 +    }
368 +
369 +    static class NPETask implements Callable<String> {
370 +        public String call() { throw new NullPointerException(); }
371 +    }
372 +
373 +    static class CallableOne implements Callable<Integer> {
374 +        public Integer call() { return one; }
375 +    }
376 +
377      class ShortRunnable implements Runnable {
378          public void run() {
379              try {
# Line 430 | Line 473 | public class JSR166TestCase extends Test
473          }
474      }
475  
476 +    class LongPossiblyInterruptedRunnable implements Runnable {
477 +        public void run() {
478 +            try {
479 +                Thread.sleep(LONG_DELAY_MS);
480 +            }
481 +            catch(InterruptedException success) {
482 +            }
483 +        }
484 +    }
485 +
486      /**
487       * For use as ThreadFactory in constructors
488       */
# Line 491 | Line 544 | public class JSR166TestCase extends Test
544          }
545      }
546  
547 +
548      /**
549       * For use as RejectedExecutionHandler in constructors
550       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines