@BeforeMethod public void setUp() throws InterruptedException, ExecutionException { GlobalConfiguration gc = new GlobalConfigurationBuilder().build(); Configuration c = new ConfigurationBuilder().build(); Set<String> cachesSet = new HashSet<String>(); EmbeddedCacheManager cm = mock(EmbeddedCacheManager.class); AdvancedCache cache = mock(AdvancedCache.class); gcr = new GlobalComponentRegistry(gc, cm, cachesSet); cr1 = new ComponentRegistry("cache", c, cache, gcr, ComponentRegistryTest.class.getClassLoader()); cr2 = new ComponentRegistry("cache", c, cache, gcr, ComponentRegistryTest.class.getClassLoader()); control = new TestDelayFactory.Control(); gcr.registerComponent(control, TestDelayFactory.Control.class); }
private static Cache mockCache(String nodeName, Configuration configuration, TimeService timeService) { String cacheName = "mock-cache"; AdvancedCache cache = mock(AdvancedCache.class, RETURNS_DEEP_STUBS); GlobalConfiguration gc = new GlobalConfigurationBuilder() .transport().nodeName(nodeName) .build(); Set<String> cachesSet = new HashSet<>(); EmbeddedCacheManager cm = mock(EmbeddedCacheManager.class); when(cm.getCacheManagerConfiguration()).thenReturn(gc); GlobalComponentRegistry gcr = new GlobalComponentRegistry(gc, cm, cachesSet); BasicComponentRegistry gbcr = gcr.getComponent(BasicComponentRegistry.class); gbcr.replaceComponent(TimeService.class.getName(), timeService, true); ComponentRegistry registry = new ComponentRegistry(cacheName, configuration, cache, gcr, configuration.getClass().getClassLoader()); when(cache.getClassLoader()).thenReturn(PersistenceMockUtil.class.getClassLoader()); when(cache.getCacheManager().getCacheManagerConfiguration()) .thenReturn(gc); when(cache.getName()).thenReturn(cacheName); when(cache.getAdvancedCache()).thenReturn(cache); when(cache.getComponentRegistry()).thenReturn(registry); when(cache.getStatus()).thenReturn(ComponentStatus.RUNNING); when(cache.getCacheConfiguration()).thenReturn(configuration); return cache; }