private ClusterStreamManager replaceWithSpy(Cache<?,?> cache) { ClusterStreamManager component = TestingUtil.extractComponent(cache, ClusterStreamManager.class); ClusterStreamManager clusterStreamManager = spy(component); TestingUtil.replaceComponent(cache, ClusterStreamManager.class, clusterStreamManager, false); return clusterStreamManager; }
public static <T, W extends T> W wrapComponent(Cache<?, ?> cache, Class<T> tClass, Function<T, W> ctor) { T current = extractComponent(cache, tClass); W wrap = ctor.apply(current); replaceComponent(cache, tClass, wrap, true); return wrap; }
public static <T extends PerCacheInboundInvocationHandler> T wrapInboundInvocationHandler(Cache cache, Function<PerCacheInboundInvocationHandler, T> ctor) { PerCacheInboundInvocationHandler current = extractComponent(cache, PerCacheInboundInvocationHandler.class); T wrap = ctor.apply(current); replaceComponent(cache, PerCacheInboundInvocationHandler.class, wrap, true); return wrap; }
@BeforeMethod public void setUp() { cm = TestCacheManagerFactory.createCacheManager(false); timeService = new ControlledTimeService(); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); }
private CacheContainer createTransactionalCacheContainer() { CacheContainer cc = TestCacheManagerFactory.createCacheManager( TestCacheManagerFactory.getDefaultCacheConfiguration(true)); TestingUtil.replaceComponent(cc, TimeService.class, timeService, true); return cc; }
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); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); c = cm.getCache(); return cm; }
private void replaceRpcManagerInCache(Cache cache) { RpcManager rpcManager = TestingUtil.extractComponent(cache, RpcManager.class); TestControllerRpcManager testControllerRpcManager = new TestControllerRpcManager(rpcManager); TestingUtil.replaceComponent(cache, RpcManager.class, testControllerRpcManager, true); }
private CountingRpcManager replaceRpcManager(Cache cache) { RpcManager current = TestingUtil.extractComponent(cache, RpcManager.class); if (current instanceof CountingRpcManager) { return (CountingRpcManager) current; } CountingRpcManager countingRpcManager = new CountingRpcManager(current); TestingUtil.replaceComponent(cache, RpcManager.class, countingRpcManager, true); return countingRpcManager; } }
public static <T, W extends T> W wrapGlobalComponent(CacheContainer cacheContainer, Class<T> tClass, WrapFactory<T, W, CacheContainer> factory, boolean rewire) { T current = extractGlobalComponent(cacheContainer, tClass); W wrap = factory.wrap(cacheContainer, current); replaceComponent(cacheContainer, tClass, wrap, rewire); return wrap; }
public static <T, W extends T> W wrapComponent(Cache<?, ?> cache, Class<T> tClass, WrapFactory<T, W, Cache<?, ?>> factory, boolean rewire) { T current = extractComponent(cache, tClass); W wrap = factory.wrap(cache, current); replaceComponent(cache, tClass, wrap, rewire); return wrap; }
static XSiteStateProviderControl replaceInCache(Cache<?, ?> cache) { XSiteStateProvider current = extractComponent(cache, XSiteStateProvider.class); XSiteStateProviderControl control = new XSiteStateProviderControl(current); replaceComponent(cache, XSiteStateProvider.class, control, true); return control; }
static CounterBackupReceiverRepository replaceOn(CacheContainer cacheContainer) { BackupReceiverRepository delegate = extractGlobalComponent(cacheContainer, BackupReceiverRepository.class); CounterBackupReceiverRepository wrapper = new CounterBackupReceiverRepository(delegate); replaceComponent(cacheContainer, BackupReceiverRepository.class, wrapper, true); return wrapper; } }
private void replaceInboundInvocationHandler(EmbeddedCacheManager cm, CheckPoint checkPoint, int index) { InboundInvocationHandler handler = extractGlobalComponent(cm, InboundInvocationHandler.class); BlockingInboundInvocationHandler ourHandler = new BlockingInboundInvocationHandler(handler, checkPoint, index); replaceComponent(cm, InboundInvocationHandler.class, ourHandler, true); }
private ReorderResponsesRpcManager injectReorderResponseRpcManager(Cache toInject, Cache lastResponse) { RpcManager rpcManager = TestingUtil.extractComponent(toInject, RpcManager.class); ReorderResponsesRpcManager newRpcManager = new ReorderResponsesRpcManager(address(lastResponse), rpcManager); TestingUtil.replaceComponent(toInject, RpcManager.class, newRpcManager, true); return newRpcManager; }
protected void replaceComponent() { if (ourHandler == null) { originalComponent = cacheManager.getGlobalComponentRegistry().getComponent(componentClass); if (originalComponent == null) { throw new IllegalStateException("Attempting to wrap a non-existing global component: " + componentClass); } ourHandler = new ProxyInvocationHandler(originalComponent, stateSequencer, matcher); T componentProxy = createComponentProxy(componentClass, ourHandler); TestingUtil.replaceComponent(cacheManager, componentClass, componentProxy, true); } }
public static BlockingLocalTopologyManager replaceTopologyManager(EmbeddedCacheManager cacheContainer, String cacheName) { LocalTopologyManager manager = TestingUtil.extractGlobalComponent(cacheContainer, LocalTopologyManager.class); BlockingLocalTopologyManager controlledLocalTopologyManager = new BlockingLocalTopologyManager(manager, cacheContainer.getAddress(), cacheName); TestingUtil.replaceComponent(cacheContainer, LocalTopologyManager.class, controlledLocalTopologyManager, true); return controlledLocalTopologyManager; }
protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); configure(builder); EmbeddedCacheManager cm = createCacheManager(builder); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); cache = cm.getCache(); afterCacheCreated(cm); return cm; }
@BeforeMethod public void setUp() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(true); builder.transaction().autoCommit(false) .clustering().cacheMode(CacheMode.LOCAL) .locking().isolationLevel(IsolationLevel.REPEATABLE_READ); cm = TestCacheManagerFactory.createCacheManager(builder); cache = cm.getCache(); tm = TestingUtil.getTransactionManager(cache); mockNotifier = mock(CacheNotifier.class); origNotifier = TestingUtil.replaceComponent(cache, CacheNotifier.class, mockNotifier, true); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); builder.persistence().addStore(SimpleLoaderConfigurationBuilder.class); // Effectively disabling reaper builder.expiration().wakeUpInterval(1, TimeUnit.DAYS); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(builder); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); cache = cm.getCache(); return cm; }