Top Description Fields Constructors Methods
org.eclipse.jgit.junit.time

public Class MonotonicFakeClock

extends Object
implements MonotonicClock
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.util.time.MonotonicClock
Imports
java.time.Duration, java.util.concurrent.TimeUnit, org.eclipse.jgit.util.time.MonotonicClock, .ProposedTimestamp

Fake org.eclipse.jgit.util.time.MonotonicClock for testing code that uses Clock.
Since
4.6

Field Summary

Modifier and TypeField and Description
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ProposedTimestamp
propose()

Implements org.eclipse.jgit.util.time.MonotonicClock.propose.

Obtain a timestamp close to "now".

public void
tick(long
amount of time to add; must be > 0.
add
,
TimeUnit
unit of add.
unit
)

Advance the time returned by future calls to propose().

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nowback to summary
private long now

Constructor Detail

MonotonicFakeClockback to summary
public MonotonicFakeClock()

Method Detail

proposeback to summary
public ProposedTimestamp propose()

Implements org.eclipse.jgit.util.time.MonotonicClock.propose.

Doc from org.eclipse.jgit.util.time.MonotonicClock.propose.

Obtain a timestamp close to "now".

Proposed times are close to "now", but may not yet be certainly in the past. This allows the calling thread to interleave other useful work while waiting for the clock instance to create an assurance it will never in the future propose a time earlier than the returned time.

A hypothetical implementation could read the local system clock (managed by NTP) and return that proposal, concurrently sending network messages to closely collaborating peers in the same cluster to also ensure their system clocks are ahead of this time. In such an implementation the org.eclipse.jgit.util.time.ProposedTimestamp#blockUntil(Duration) method would wait for replies from the peers indicating their own system clocks have moved past the proposed time.

Returns:ProposedTimestamp

a org.eclipse.jgit.util.time.ProposedTimestamp object.

Annotations
@Override
tickback to summary
public void tick(long add, TimeUnit unit)

Advance the time returned by future calls to propose().

Parameters
add:long

amount of time to add; must be > 0.

unit:TimeUnit

unit of add.