use of org.infinispan.test.CacheManagerCallable in project infinispan by infinispan.
the class ConfigurationUnitTest method testInvalidRecoveryWithNonTransactional.
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN(\\d)*: Recovery not supported with non transactional cache")
public void testInvalidRecoveryWithNonTransactional() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
builder.transaction().useSynchronization(false);
builder.transaction().recovery().enable();
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager(builder)) {
@Override
public void call() {
cm.getCache();
}
});
}
use of org.infinispan.test.CacheManagerCallable in project infinispan by infinispan.
the class CustomInterceptorConfigTest method testCustomInterceptors.
public void testCustomInterceptors() {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<infinispan>" + "<cache-container name=\"custom\" default-cache=\"default-cache\">" + "<transport />" + "<local-cache name=\"default-cache\"><custom-interceptors> \n" + "<interceptor after=\"" + InvocationContextInterceptor.class.getName() + "\" class=\"" + DummyInterceptor.class.getName() + "\"/> \n" + "</custom-interceptors> </local-cache>" + "<local-cache name=\"x\">" + "<custom-interceptors>\n" + " <interceptor position=\"first\" class=\"" + CustomInterceptor1.class.getName() + "\" />" + " <interceptor" + " position=\"last\"" + " class=\"" + CustomInterceptor2.class.getName() + "\"" + " />" + "</custom-interceptors>" + "</local-cache>" + "</cache-container>" + "</infinispan>";
InputStream stream = new ByteArrayInputStream(xml.getBytes());
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.fromStream(stream)) {
@Override
public void call() {
Cache c = cm.getCache();
DummyInterceptor i = TestingUtil.findInterceptor(c, DummyInterceptor.class);
assert i != null;
Cache<Object, Object> namedCacheX = cm.getCache("x");
assert TestingUtil.findInterceptor(namedCacheX, CustomInterceptor1.class) != null;
assert TestingUtil.findInterceptor(namedCacheX, CustomInterceptor2.class) != null;
}
});
}
use of org.infinispan.test.CacheManagerCallable in project infinispan by infinispan.
the class TransactionalCacheConfigTest method testBatchingAndTransactionalCache.
public void testBatchingAndTransactionalCache() {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.invocationBatching().enable();
final Configuration c = cb.build();
assert c.invocationBatching().enabled();
assert c.transaction().transactionMode().isTransactional();
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager(new ConfigurationBuilder())) {
@Override
public void call() {
assert !cm.getCache().getCacheConfiguration().transaction().transactionMode().isTransactional();
cm.defineConfiguration("a", c);
final Cache<Object, Object> a = cm.getCache("a");
assert a.getCacheConfiguration().invocationBatching().enabled();
assert a.getCacheConfiguration().transaction().transactionMode().isTransactional();
}
});
}
use of org.infinispan.test.CacheManagerCallable in project infinispan by infinispan.
the class TransactionalCacheConfigTest method testOverride.
public void testOverride() {
final ConfigurationBuilder c = new ConfigurationBuilder();
c.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(new EmbeddedTransactionManagerLookup());
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager()) {
@Override
public void call() {
cm.defineConfiguration("transactional", c.build());
Cache<?, ?> cache = cm.getCache("transactional");
assert cache.getCacheConfiguration().transaction().transactionMode().isTransactional();
}
});
}
use of org.infinispan.test.CacheManagerCallable in project infinispan by infinispan.
the class ExtendedParserTest method assertCacheConfiguration.
private void assertCacheConfiguration(String config) throws IOException {
ConfigurationBuilderHolder holder = parseToHolder(config);
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createClusteredCacheManager(holder)) {
@Override
public void call() {
Assert.assertEquals(cm.getDefaultCacheConfiguration().module(MyModuleConfiguration.class).attribute(), "test-value");
}
});
}
Aggregations