use of org.infinispan.commons.time.TimeService in project infinispan by infinispan.
the class EmbeddedTimeServiceTest method testMonotonicIncrement.
public void testMonotonicIncrement() {
TimeService timeService = TIME_SERVICE;
// less or equals in all the cases because the system may not have enough precision and the methods may return
// the same value.
assertTrue(timeService.time() <= timeService.time());
assertTrue(timeService.wallClockTime() <= timeService.wallClockTime());
}
use of org.infinispan.commons.time.TimeService in project infinispan by infinispan.
the class EmbeddedTimeServiceTest method testRemainingTime.
public void testRemainingTime() {
TimeService timeService = new EmbeddedTimeService() {
@Override
public long time() {
return 10;
}
};
assertEquals(timeService.remainingTime(-1, TimeUnit.NANOSECONDS), 0);
assertEquals(timeService.remainingTime(0, TimeUnit.NANOSECONDS), 0);
assertEquals(timeService.remainingTime(9, TimeUnit.NANOSECONDS), 0);
assertEquals(timeService.remainingTime(10, TimeUnit.NANOSECONDS), 0);
assertEquals(timeService.remainingTime(11, TimeUnit.NANOSECONDS), 1);
assertEquals(timeService.remainingTime(11, TimeUnit.MICROSECONDS), 0);
assertEquals(timeService.remainingTime(11, TimeUnit.MILLISECONDS), 0);
}
use of org.infinispan.commons.time.TimeService in project infinispan by infinispan.
the class JCacheLoaderAdapterTest method setUpClass.
@BeforeClass
public static void setUpClass() {
TimeService timeService = new EmbeddedTimeService();
marshaller = new TestObjectStreamMarshaller();
MarshallableEntryFactory marshalledEntryFactory = new MarshalledEntryFactoryImpl(marshaller);
ctx = new DummyInitializationContext() {
@Override
public TimeService getTimeService() {
return timeService;
}
@Override
public MarshallableEntryFactory getMarshallableEntryFactory() {
return marshalledEntryFactory;
}
};
}
Aggregations