DESY ACOP Beans Home

com.cosylab.util
Class MockTimeProvider

java.lang.Object
  extended by com.cosylab.util.MockTimeProvider
All Implemented Interfaces:
TimeProvider

public class MockTimeProvider
extends java.lang.Object
implements TimeProvider

Mock implementation of a TimeProvider, which returns pre-set time. Especially useful in unit tests. Also supports auto-advance of time (1 second by default).

Author:
Klemen Zagar, Cosylab

Constructor Summary
MockTimeProvider()
          Constructor sets the initial mock time.
 
Method Summary
 long getTimeInMillis()
           
 void setAutoAdvance(long advance)
          Set the amount of time (in milliseconds) by which return value of getTimeInMillis() will advance every time it is called.
 void setTimeInMillis(long millis)
          Set the current time, which will be returned the next time when getTimeInMillis() is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockTimeProvider

public MockTimeProvider()
Constructor sets the initial mock time.

Method Detail

setAutoAdvance

public void setAutoAdvance(long advance)
Set the amount of time (in milliseconds) by which return value of getTimeInMillis() will advance every time it is called.

Parameters:
advance - Mock time provider's auto advance (in milliseconds).

setTimeInMillis

public void setTimeInMillis(long millis)
Set the current time, which will be returned the next time when getTimeInMillis() is called.

Parameters:
millis - Current time.

getTimeInMillis

public long getTimeInMillis()
Specified by:
getTimeInMillis in interface TimeProvider


Copyright © 2010. All Rights Reserved.