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

Comparing jsr166/src/test/tck/TimeUnitTest.java (file contents):
Revision 1.15 by jsr166, Tue Dec 1 09:48:12 2009 UTC vs.
Revision 1.20 by jsr166, Fri May 27 19:12:09 2011 UTC

# Line 1 | Line 1
1   /*
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
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
8  
9
9   import junit.framework.*;
10   import java.util.concurrent.*;
11   import java.io.*;
# Line 49 | Line 48 | public class TimeUnitTest extends JSR166
48                           TimeUnit.SECONDS.convert(1000000000L*t,
49                                                    TimeUnit.NANOSECONDS));
50  
52
51              assertEquals(1000L*t*60*60*24,
52                           TimeUnit.MILLISECONDS.convert(t,
53                                                    TimeUnit.DAYS));
# Line 279 | Line 277 | public class TimeUnitTest extends JSR166
277          }
278      }
279  
282
280      /**
281       * convert saturates positive too-large values to Long.MAX_VALUE
282       * and negative to LONG.MIN_VALUE
# Line 322 | Line 319 | public class TimeUnitTest extends JSR166
319                       TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));
320      }
321  
325
322      /**
323 <     * toString returns string containing common name of unit
323 >     * toString returns name of unit
324       */
325      public void testToString() {
326 <        String s = TimeUnit.SECONDS.toString();
331 <        assertTrue(s.indexOf("ECOND") >= 0);
326 >        assertEquals("SECONDS", TimeUnit.SECONDS.toString());
327      }
328  
329 +    /**
330 +     * name returns name of unit
331 +     */
332 +    public void testName() {
333 +        assertEquals("SECONDS", TimeUnit.SECONDS.name());
334 +    }
335  
336      /**
337 <     *  Timed wait without holding lock throws
338 <     *  IllegalMonitorStateException
337 >     * Timed wait without holding lock throws
338 >     * IllegalMonitorStateException
339       */
340      public void testTimedWait_IllegalMonitorException() throws Exception {
341          Thread t = new Thread(new CheckedRunnable() {
# Line 361 | Line 362 | public class TimeUnitTest extends JSR166
362                  Object o = new Object();
363  
364                  TimeUnit tu = TimeUnit.MILLISECONDS;
365 <                synchronized(o) {
365 >                synchronized (o) {
366                      tu.timedWait(o,MEDIUM_DELAY_MS);
367                  }
368              }});
# Line 371 | Line 372 | public class TimeUnitTest extends JSR166
372          t.join();
373      }
374  
374
375      /**
376       * timedJoin throws InterruptedException when interrupted
377       */
# Line 384 | Line 384 | public class TimeUnitTest extends JSR166
384              public void realRun() throws InterruptedException {
385                  TimeUnit tu = TimeUnit.MILLISECONDS;
386                  tu.timedJoin(s, MEDIUM_DELAY_MS);
387 <            }});;
387 >            }});
388          s.start();
389          t.start();
390          Thread.sleep(SHORT_DELAY_MS);
# Line 395 | Line 395 | public class TimeUnitTest extends JSR166
395      }
396  
397      /**
398 <     *  timedSleep throws InterruptedException when interrupted
398 >     * timedSleep throws InterruptedException when interrupted
399       */
400      public void testTimedSleep() throws InterruptedException {
401          Thread t = new Thread(new CheckedInterruptedRunnable() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines