/** * To be overridden if the store requires special time handling */ protected ControlledTimeService getTimeService() { return new ControlledTimeService(); }
protected void configureTimeService() { timeService = new ControlledTimeService(14151); TestingUtil.replaceComponent(cacheManagers.get(0), TimeService.class, timeService, true); }
@BeforeMethod public void setUp() { cm = TestCacheManagerFactory.createCacheManager(false); timeService = new ControlledTimeService(); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); }
protected void injectTimeServices() { ts0 = new ControlledTimeService(0); TestingUtil.replaceComponent(manager(0), TimeService.class, ts0, true); ts1 = new ControlledTimeService(0); TestingUtil.replaceComponent(manager(1), TimeService.class, ts1, true); ts2 = new ControlledTimeService(0); TestingUtil.replaceComponent(manager(2), TimeService.class, ts2, true); }
protected void injectTimeServices() { long now = System.currentTimeMillis(); ts0 = new ControlledTimeService(now); TestingUtil.replaceComponent(manager(0), TimeService.class, ts0, true); ts1 = new ControlledTimeService(now); TestingUtil.replaceComponent(manager(1), TimeService.class, ts1, true); ts2 = new ControlledTimeService(now); TestingUtil.replaceComponent(manager(2), TimeService.class, ts2, true); }
protected DataContainer<String, String> createContainer() { DefaultDataContainer<String, String> dc = new DefaultDataContainer<>(16); InternalEntryFactoryImpl internalEntryFactory = new InternalEntryFactoryImpl(); timeService = new ControlledTimeService(); TestingUtil.inject(internalEntryFactory, timeService); ActivationManager activationManager = mock(ActivationManager.class); doNothing().when(activationManager).onUpdate(Mockito.any(), Mockito.anyBoolean()); InternalExpirationManager expirationManager = mock(InternalExpirationManager.class); Mockito.when(expirationManager.entryExpiredInMemory(Mockito.any(), Mockito.anyLong(), Mockito.anyBoolean())).thenReturn(CompletableFutures.completedTrue()); Mockito.when(expirationManager.entryExpiredInMemoryFromIteration(Mockito.any(), Mockito.anyLong())).thenReturn(CompletableFutures.completedTrue()); TestingUtil.inject(dc, internalEntryFactory, activationManager, timeService, expirationManager); return dc; }
@Test(dependsOnMethods = "testEnableJmxStats") public void testXsiteStats() throws Exception { ControlledTimeService timeService = new ControlledTimeService(); RpcManagerImpl rpcManager = (RpcManagerImpl) TestingUtil.extractComponent(cache(0, cachename), RpcManager.class); Transport originalTransport = rpcManager.getTransport();
@BeforeMethod(alwaysRun = true) public void setup() { nextInterceptor = new ControlledNextInterceptor(); timeService = new ControlledTimeService(System.currentTimeMillis()); ctx = new SingleKeyNonTxInvocationContext(null); interceptor = new CacheMgmtInterceptor(); interceptor.setNextInterceptor(nextInterceptor); TestingUtil.inject(interceptor, timeService); interceptor.start(); interceptor.setStatisticsEnabled(true); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder cfg = getDefaultClusteredCacheConfig(cacheMode, false); configure(cfg); for (int i = 0; i < NUM_NODES; ++i) { addClusterEnabledCacheManager(cfg); } waitForClusterToForm(); timeService = new ControlledTimeService(); for (int i = 0; i < NUM_NODES; ++i) { TestingUtil.replaceComponent(manager(i), TimeService.class, timeService, true); } }
private static TestContext createNew(long minWait, int afterFailures) { ControlledTimeService t = new ControlledTimeService(); ListenerImpl l = new ListenerImpl(); TakeOfflineConfiguration c = new TakeOfflineConfigurationBuilder(null, null) .afterFailures(afterFailures) .minTimeToWait(minWait) .create(); return new TestContext(new OfflineStatus(c, t, l), t, l); }
@Override protected void createCacheManagers() throws Throwable { createCluster(new ConfigurationBuilder(), 2); timeService = new ControlledTimeService(); ConfigurationBuilder replConfig = new ConfigurationBuilder(); replConfig.clustering().cacheMode(cacheMode).hash().numSegments(4); for (EmbeddedCacheManager manager : managers()) { TestingUtil.replaceComponent(manager, TimeService.class, timeService, true); manager.defineConfiguration(CACHE_NAME, replConfig.build()); } }
protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); builder.memory().size(CACHE_SIZE).storageType(getStorageType()) .expiration().wakeUpInterval(100L).locking() .useLockStriping(false) // to minimize chances of deadlock in the unit test .invocationBatching(); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(builder); cache = cm.getCache(); evictionListener = new EvictionListener(); cache.addListener(evictionListener); TestingUtil.replaceComponent(cm, TimeService.class, timeService = new ControlledTimeService(), true); return cm; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder builder = new ConfigurationBuilder(); if (mode.isClustered()) { builder.clustering().cacheMode(mode); } builder .jmxStatistics().enable() .transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .autoCommit(autoCommit) .locking().isolationLevel(IsolationLevel.READ_COMMITTED); EmbeddedCacheManager cm = TestCacheManagerFactory.createClusteredCacheManager(builder); timeService = new ControlledTimeService(); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); return cm; }
@Override public void call() { ControlledTimeService timeService = new ControlledTimeService(); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); JCacheManager jCacheManager = createJCacheManager(cm, this);