use of org.infinispan.persistence.DummyInitializationContext in project infinispan by infinispan.
the class TableManagerTest method createConnection.
@BeforeClass
public void createConnection() throws Exception {
JdbcStringBasedStoreConfigurationBuilder storeBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false).persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
UnitTestDatabaseManager.setDialect(storeBuilder);
UnitTestDatabaseManager.buildTableManipulation(storeBuilder.table());
ConnectionFactoryConfiguration factoryConfiguration = UnitTestDatabaseManager.configureUniqueConnectionFactory(storeBuilder).create();
if (factoryConfiguration instanceof SimpleConnectionFactoryConfiguration) {
SimpleConnectionFactoryConfiguration simpleConfiguration = (SimpleConnectionFactoryConfiguration) factoryConfiguration;
connectionFactory = ConnectionFactory.getConnectionFactory(SimpleConnectionFactory.class);
connectionFactory.start(simpleConfiguration, connectionFactory.getClass().getClassLoader());
connection = connectionFactory.getConnection();
} else if (factoryConfiguration instanceof PooledConnectionFactoryConfiguration) {
PooledConnectionFactoryConfiguration pooledConfiguration = (PooledConnectionFactoryConfiguration) factoryConfiguration;
connectionFactory = ConnectionFactory.getConnectionFactory(PooledConnectionFactory.class);
connectionFactory.start(pooledConfiguration, connectionFactory.getClass().getClassLoader());
connection = connectionFactory.getConnection();
}
Cache<?, ?> cache = mock(Cache.class);
when(cache.getCacheConfiguration()).thenReturn(new ConfigurationBuilder().build());
JdbcStringBasedStoreConfiguration config = storeBuilder.create();
GlobalConfiguration globalConfiguration = mock(GlobalConfiguration.class);
when(globalConfiguration.classLoader()).thenReturn(getClass().getClassLoader());
ctx = new DummyInitializationContext(config, cache, new TestObjectStreamMarshaller(), null, null, null, globalConfiguration, null, null, null);
tableManager = TableManagerFactory.getManager(ctx, connectionFactory, config, "aName");
}
use of org.infinispan.persistence.DummyInitializationContext in project infinispan by infinispan.
the class AsyncStoreStressTest method createAsyncStore.
private AsyncNonBlockingStore<Object, Object> createAsyncStore(NonBlockingStore backendStore, StoreConfiguration storeConfiguration) throws PersistenceException {
AsyncNonBlockingStore<Object, Object> store = new AsyncNonBlockingStore<>(backendStore);
BlockingManager blockingManager = new BlockingManagerImpl();
TestingUtil.inject(blockingManager, new TestComponentAccessors.NamedComponent(KnownComponentNames.NON_BLOCKING_EXECUTOR, nonBlockingExecutor), new TestComponentAccessors.NamedComponent(KnownComponentNames.BLOCKING_EXECUTOR, blockingExecutor));
TestingUtil.startComponent(blockingManager);
Cache cacheMock = Mockito.mock(Cache.class, Mockito.RETURNS_DEEP_STUBS);
Mockito.when(cacheMock.getAdvancedCache().getComponentRegistry().getComponent(KeyPartitioner.class)).thenReturn(SingleSegmentKeyPartitioner.getInstance());
CompletionStages.join(store.start(new DummyInitializationContext(storeConfiguration, cacheMock, marshaller, new ByteBufferFactoryImpl(), new MarshalledEntryFactoryImpl(marshaller), nonBlockingExecutor, new GlobalConfigurationBuilder().globalState().persistentLocation(location).build(), blockingManager, null, new DefaultTimeService())));
return store;
}
use of org.infinispan.persistence.DummyInitializationContext 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;
}
};
}
use of org.infinispan.persistence.DummyInitializationContext in project infinispan by infinispan.
the class AbstractStringBasedCacheStore method configureCacheManager.
public EmbeddedCacheManager configureCacheManager(boolean passivation, boolean preload, boolean eviction) {
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder().nonClusteredDefault().defaultCacheName("StringBasedCache");
ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false);
JdbcStringBasedStoreConfigurationBuilder storeBuilder = builder.persistence().passivation(passivation).addStore(JdbcStringBasedStoreConfigurationBuilder.class).preload(preload);
connectionFactory = getConnectionFactory(storeBuilder);
setTableManipulation(storeBuilder);
if (eviction) {
builder.memory().evictionType(EvictionType.COUNT).size(2);
} else {
builder.memory().evictionType(EvictionType.COUNT).size(-1);
}
tableConfiguration = storeBuilder.create().table();
EmbeddedCacheManager defaultCacheManager = TestCacheManagerFactory.newDefaultCacheManager(true, gcb, builder);
String cacheName = defaultCacheManager.getCache().getName();
PersistenceMarshaller marshaller = defaultCacheManager.getCache().getAdvancedCache().getComponentRegistry().getPersistenceMarshaller();
InitializationContext ctx = new DummyInitializationContext(null, null, marshaller, null, null, null, null, null, null, null);
tableManager = TableManagerFactory.getManager(ctx, connectionFactory, storeBuilder.create(), cacheName);
return defaultCacheManager;
}
use of org.infinispan.persistence.DummyInitializationContext in project infinispan by infinispan.
the class AbstractJpaStoreTest method createCacheStore.
protected JpaStore createCacheStore(GlobalConfiguration gc) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.persistence().addStore(JpaStoreConfigurationBuilder.class).persistenceUnitName(PERSISTENCE_UNIT_NAME).entityClass(getEntityClass()).segmented(false);
JpaStore store = new JpaStore();
store.init(new DummyInitializationContext(builder.persistence().stores().get(0).create(), cm.getCache(), marshaller, null, entryFactory, new WithinThreadExecutor(), gc, blockingManager, null, cm.getGlobalComponentRegistry().getTimeService()));
store.start();
assertNotNull(store.getEntityManagerFactory());
return store;
}
Aggregations