Search in sources :

Example 16 with TimeService

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());
}
Also used : TimeService(org.infinispan.commons.time.TimeService)

Example 17 with TimeService

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);
}
Also used : TimeService(org.infinispan.commons.time.TimeService)

Example 18 with TimeService

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;
        }
    };
}
Also used : DummyInitializationContext(org.infinispan.persistence.DummyInitializationContext) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) TimeService(org.infinispan.commons.time.TimeService) MarshallableEntryFactory(org.infinispan.persistence.spi.MarshallableEntryFactory) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) MarshalledEntryFactoryImpl(org.infinispan.marshall.persistence.impl.MarshalledEntryFactoryImpl) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TimeService (org.infinispan.commons.time.TimeService)18 ControlledTimeService (org.infinispan.util.ControlledTimeService)4 HashSet (java.util.HashSet)3 AdvancedCache (org.infinispan.AdvancedCache)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 EmbeddedTimeService (org.infinispan.util.EmbeddedTimeService)3 Log (org.infinispan.util.logging.Log)3 LogFactory (org.infinispan.util.logging.LogFactory)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 CompletionStage (java.util.concurrent.CompletionStage)2 TimeUnit (java.util.concurrent.TimeUnit)2 Configuration (org.infinispan.configuration.cache.Configuration)2 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)2 DataContainer (org.infinispan.container.DataContainer)2 KeyPartitioner (org.infinispan.distribution.ch.KeyPartitioner)2 DataConversion (org.infinispan.encoding.DataConversion)2