Search in sources :

Example 1 with MockBasicComponentRegistry

use of org.infinispan.factories.impl.MockBasicComponentRegistry in project infinispan by infinispan.

the class CacheNotifierImplTest method setUp.

@BeforeMethod
public void setUp() {
    n = new CacheNotifierImpl();
    mockCache = mock(EncoderCache.class);
    EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class);
    when(mockCache.getCacheManager()).thenReturn(cacheManager);
    when(mockCache.getAdvancedCache()).thenReturn(mockCache);
    when(mockCache.getKeyDataConversion()).thenReturn(DataConversion.IDENTITY_KEY);
    when(mockCache.getValueDataConversion()).thenReturn(DataConversion.IDENTITY_VALUE);
    when(mockCache.getStatus()).thenReturn(ComponentStatus.INITIALIZING);
    ComponentRegistry componentRegistry = mock(ComponentRegistry.class);
    when(mockCache.getComponentRegistry()).thenReturn(componentRegistry);
    MockBasicComponentRegistry mockRegistry = new MockBasicComponentRegistry();
    when(componentRegistry.getComponent(BasicComponentRegistry.class)).thenReturn(mockRegistry);
    mockRegistry.registerMocks(RpcManager.class, CommandsFactory.class);
    mockRegistry.registerMock(KnownComponentNames.INTERNAL_MARSHALLER, StreamingMarshaller.class);
    ClusteringDependentLogic.LocalLogic cdl = new ClusteringDependentLogic.LocalLogic();
    Configuration config = new ConfigurationBuilder().build();
    cdl.init(null, config, mock(KeyPartitioner.class));
    ClusterEventManager cem = mock(ClusterEventManager.class);
    when(cem.sendEvents(any())).thenReturn(CompletableFutures.completedNull());
    BlockingManager handler = mock(BlockingManager.class);
    when(handler.continueOnNonBlockingThread(any(), any())).thenReturn(CompletableFutures.completedNull());
    TestingUtil.inject(n, mockCache, cdl, config, mockRegistry, mock(InternalEntryFactory.class), cem, mock(KeyPartitioner.class), new FakeEncoderRegistry(), TestingUtil.named(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR, new WithinThreadExecutor()), handler);
    cl = new CacheListener();
    n.start();
    addListener();
    ctx = new NonTxInvocationContext(null);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) ClusterEventManager(org.infinispan.notifications.cachelistener.cluster.ClusterEventManager) BlockingManager(org.infinispan.util.concurrent.BlockingManager) ClusteringDependentLogic(org.infinispan.interceptors.locking.ClusteringDependentLogic) NonTxInvocationContext(org.infinispan.context.impl.NonTxInvocationContext) WithinThreadExecutor(org.infinispan.util.concurrent.WithinThreadExecutor) EncoderCache(org.infinispan.cache.impl.EncoderCache) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) KeyPartitioner(org.infinispan.distribution.ch.KeyPartitioner) ComponentRegistry(org.infinispan.factories.ComponentRegistry) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) InternalEntryFactory(org.infinispan.container.impl.InternalEntryFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with MockBasicComponentRegistry

use of org.infinispan.factories.impl.MockBasicComponentRegistry in project infinispan by infinispan.

the class OnlyPrimaryOwnerTest method setUp.

@BeforeMethod
public void setUp() {
    n = new CacheNotifierImpl();
    mockCache = mock(EncoderCache.class);
    EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class);
    when(mockCache.getCacheManager()).thenReturn(cacheManager);
    when(mockCache.getAdvancedCache()).thenReturn(mockCache);
    when(mockCache.getKeyDataConversion()).thenReturn(DataConversion.IDENTITY_KEY);
    when(mockCache.getValueDataConversion()).thenReturn(DataConversion.IDENTITY_VALUE);
    when(mockCache.getStatus()).thenReturn(ComponentStatus.INITIALIZING);
    ComponentRegistry componentRegistry = mock(ComponentRegistry.class);
    when(mockCache.getComponentRegistry()).thenReturn(componentRegistry);
    MockBasicComponentRegistry mockRegistry = new MockBasicComponentRegistry();
    when(componentRegistry.getComponent(BasicComponentRegistry.class)).thenReturn(mockRegistry);
    mockRegistry.registerMocks(RpcManager.class, CommandsFactory.class, Encoder.class);
    mockRegistry.registerMock(KnownComponentNames.INTERNAL_MARSHALLER, StreamingMarshaller.class);
    Configuration config = new ConfigurationBuilder().memory().storageType(StorageType.OBJECT).build();
    ClusterEventManager cem = mock(ClusterEventManager.class);
    when(cem.sendEvents(any())).thenReturn(CompletableFutures.completedNull());
    TestingUtil.inject(n, mockCache, cdl, config, mockRegistry, mock(InternalEntryFactory.class), cem, mock(KeyPartitioner.class), mock(BlockingManager.class));
    cl = new PrimaryOwnerCacheListener();
    n.start();
    n.addListener(cl);
    ctx = new NonTxInvocationContext(null);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) ClusterEventManager(org.infinispan.notifications.cachelistener.cluster.ClusterEventManager) BlockingManager(org.infinispan.util.concurrent.BlockingManager) NonTxInvocationContext(org.infinispan.context.impl.NonTxInvocationContext) EncoderCache(org.infinispan.cache.impl.EncoderCache) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) KeyPartitioner(org.infinispan.distribution.ch.KeyPartitioner) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ComponentRegistry(org.infinispan.factories.ComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) InternalEntryFactory(org.infinispan.container.impl.InternalEntryFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with MockBasicComponentRegistry

use of org.infinispan.factories.impl.MockBasicComponentRegistry in project infinispan by infinispan.

the class BaseCacheNotifierImplInitialTransferTest method setUp.

@BeforeMethod
public void setUp() {
    n = new CacheNotifierImpl();
    mockCache = mock(EncoderCache.class);
    EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class);
    when(mockCache.getCacheManager()).thenReturn(cacheManager);
    when(mockCache.getAdvancedCache()).thenReturn(mockCache);
    when(mockCache.getKeyDataConversion()).thenReturn(DataConversion.IDENTITY_KEY);
    when(mockCache.getValueDataConversion()).thenReturn(DataConversion.IDENTITY_VALUE);
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(cacheMode).build();
    GlobalConfiguration globalConfig = GlobalConfigurationBuilder.defaultClusteredBuilder().build();
    when(mockCache.getStatus()).thenReturn(ComponentStatus.INITIALIZING);
    mockPublisherManager = mock(ClusterPublisherManager.class);
    ComponentRegistry componentRegistry = mock(ComponentRegistry.class);
    when(mockCache.getComponentRegistry()).thenReturn(componentRegistry);
    MockBasicComponentRegistry mockRegistry = new MockBasicComponentRegistry();
    when(componentRegistry.getComponent(BasicComponentRegistry.class)).thenReturn(mockRegistry);
    mockRegistry.registerMocks(RpcManager.class, CommandsFactory.class);
    mockRegistry.registerMock(KnownComponentNames.INTERNAL_MARSHALLER, StreamingMarshaller.class);
    ClusteringDependentLogic.LocalLogic cdl = new ClusteringDependentLogic.LocalLogic();
    cdl.init(null, config, mock(KeyPartitioner.class));
    ClusterEventManager cem = mock(ClusterEventManager.class);
    when(cem.sendEvents(any())).thenReturn(CompletableFutures.completedNull());
    BlockingManager handler = mock(BlockingManager.class);
    when(handler.continueOnNonBlockingThread(any(), any())).thenReturn(CompletableFutures.completedNull());
    TestingUtil.inject(n, mockCache, cdl, config, globalConfig, mockRegistry, mockPublisherManager, new InternalEntryFactoryImpl(), cem, mock(KeyPartitioner.class), handler, TestingUtil.named(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR, new WithinThreadExecutor()));
    n.start();
    ctx = new NonTxInvocationContext(null);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ClusterPublisherManager(org.infinispan.reactive.publisher.impl.ClusterPublisherManager) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) ClusterEventManager(org.infinispan.notifications.cachelistener.cluster.ClusterEventManager) BlockingManager(org.infinispan.util.concurrent.BlockingManager) ClusteringDependentLogic(org.infinispan.interceptors.locking.ClusteringDependentLogic) NonTxInvocationContext(org.infinispan.context.impl.NonTxInvocationContext) WithinThreadExecutor(org.infinispan.util.concurrent.WithinThreadExecutor) EncoderCache(org.infinispan.cache.impl.EncoderCache) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) KeyPartitioner(org.infinispan.distribution.ch.KeyPartitioner) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ComponentRegistry(org.infinispan.factories.ComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

EncoderCache (org.infinispan.cache.impl.EncoderCache)3 Configuration (org.infinispan.configuration.cache.Configuration)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 NonTxInvocationContext (org.infinispan.context.impl.NonTxInvocationContext)3 KeyPartitioner (org.infinispan.distribution.ch.KeyPartitioner)3 ComponentRegistry (org.infinispan.factories.ComponentRegistry)3 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)3 MockBasicComponentRegistry (org.infinispan.factories.impl.MockBasicComponentRegistry)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 ClusterEventManager (org.infinispan.notifications.cachelistener.cluster.ClusterEventManager)3 BlockingManager (org.infinispan.util.concurrent.BlockingManager)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 InternalEntryFactory (org.infinispan.container.impl.InternalEntryFactory)2 ClusteringDependentLogic (org.infinispan.interceptors.locking.ClusteringDependentLogic)2 WithinThreadExecutor (org.infinispan.util.concurrent.WithinThreadExecutor)2 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 InternalEntryFactoryImpl (org.infinispan.container.impl.InternalEntryFactoryImpl)1 ClusterPublisherManager (org.infinispan.reactive.publisher.impl.ClusterPublisherManager)1