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.60 by jsr166, Wed Oct 6 07:49:22 2010 UTC vs.
Revision 1.63 by jsr166, Mon Oct 11 08:30:01 2010 UTC

# Line 96 | Line 96 | public class JSR166TestCase extends Test
96      private static final boolean useSecurityManager =
97          Boolean.getBoolean("jsr166.useSecurityManager");
98  
99 +    protected static final boolean expensiveTests =
100 +        Boolean.getBoolean("jsr166.expensiveTests");
101 +
102 +    /**
103 +     * If true, report on stdout all "slow" tests, that is, ones that
104 +     * take more than profileThreshold milliseconds to execute.
105 +     */
106 +    private static final boolean profileTests =
107 +        Boolean.getBoolean("jsr166.profileTests");
108 +
109 +    /**
110 +     * The number of milliseconds that tests are permitted for
111 +     * execution without being reported, when profileTests is set.
112 +     */
113 +    private static final long profileThreshold =
114 +        Long.getLong("jsr166.profileThreshold", 100);
115 +
116 +    protected void runTest() throws Throwable {
117 +        if (profileTests)
118 +            runTestProfiled();
119 +        else
120 +            super.runTest();
121 +    }
122 +
123 +    protected void runTestProfiled() throws Throwable {
124 +        long t0 = System.nanoTime();
125 +        try {
126 +            super.runTest();
127 +        } finally {
128 +            long elapsedMillis =
129 +                (System.nanoTime() - t0) / (1000L * 1000L);
130 +            if (elapsedMillis >= profileThreshold)
131 +                System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
132 +        }
133 +    }
134 +
135      /**
136       * Runs all JSR166 unit tests using junit.textui.TestRunner
137       */
# Line 771 | Line 807 | public class JSR166TestCase extends Test
807          }
808      }
809  
810 +    public Runnable possiblyInterruptedRunnable(final long timeoutMillis) {
811 +        return new CheckedRunnable() {
812 +            protected void realRun() {
813 +                try {
814 +                    Thread.sleep(timeoutMillis);
815 +                } catch (InterruptedException ok) {}
816 +            }};
817 +    }
818 +
819      public class MediumPossiblyInterruptedRunnable extends CheckedRunnable {
820          protected void realRun() {
821              try {
# Line 796 | Line 841 | public class JSR166TestCase extends Test
841          }
842      }
843  
844 +    public interface TrackedRunnable extends Runnable {
845 +        boolean isDone();
846 +    }
847 +
848 +    public static TrackedRunnable trackedRunnable(final long timeoutMillis) {
849 +        return new TrackedRunnable() {
850 +                private volatile boolean done = false;
851 +                public boolean isDone() { return done; }
852 +                public void run() {
853 +                    try {
854 +                        Thread.sleep(timeoutMillis);
855 +                        done = true;
856 +                    } catch (InterruptedException ok) {}
857 +                }
858 +            };
859 +    }
860 +
861      public static class TrackedShortRunnable implements Runnable {
862          public volatile boolean done = false;
863          public void run() {
864              try {
865 +                Thread.sleep(SHORT_DELAY_MS);
866 +                done = true;
867 +            } catch (InterruptedException ok) {}
868 +        }
869 +    }
870 +
871 +    public static class TrackedSmallRunnable implements Runnable {
872 +        public volatile boolean done = false;
873 +        public void run() {
874 +            try {
875                  Thread.sleep(SMALL_DELAY_MS);
876                  done = true;
877              } catch (InterruptedException ok) {}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines