Applying test and fix for LANG-315
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@504351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
de4952beaf
commit
b16235ad10
|
@ -115,7 +115,9 @@ public class StopWatch {
|
|||
if(this.runningState != STATE_RUNNING && this.runningState != STATE_SUSPENDED) {
|
||||
throw new IllegalStateException("Stopwatch is not running. ");
|
||||
}
|
||||
stopTime = System.currentTimeMillis();
|
||||
if(this.runningState == STATE_RUNNING) {
|
||||
stopTime = System.currentTimeMillis();
|
||||
}
|
||||
this.runningState = STATE_STOPPED;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,18 @@ public class StopWatchTest extends TestCase {
|
|||
assertTrue(totalTime < 1300);
|
||||
}
|
||||
|
||||
public void testLang315() {
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start();
|
||||
try {Thread.sleep(200);} catch (InterruptedException ex) {}
|
||||
watch.suspend();
|
||||
long suspendTime = watch.getTime();
|
||||
try {Thread.sleep(200);} catch (InterruptedException ex) {}
|
||||
watch.stop();
|
||||
long totalTime = watch.getTime();
|
||||
assertTrue( suspendTime == totalTime );
|
||||
}
|
||||
|
||||
// test bad states
|
||||
public void testBadStates() {
|
||||
StopWatch watch = new StopWatch();
|
||||
|
|
Loading…
Reference in New Issue