Search in sources :

Example 16 with CacheManagerCallable

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();
        }
    });
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DummyInMemoryStoreConfigurationBuilder(org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder) CacheManagerCallable(org.infinispan.test.CacheManagerCallable) Test(org.testng.annotations.Test) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest)

Example 17 with CacheManagerCallable

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;
        }
    });
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CacheManagerCallable(org.infinispan.test.CacheManagerCallable) Cache(org.infinispan.Cache)

Example 18 with CacheManagerCallable

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();
        }
    });
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) CacheManagerCallable(org.infinispan.test.CacheManagerCallable) Cache(org.infinispan.Cache)

Example 19 with CacheManagerCallable

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();
        }
    });
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheManagerCallable(org.infinispan.test.CacheManagerCallable) EmbeddedTransactionManagerLookup(org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup) Cache(org.infinispan.Cache)

Example 20 with CacheManagerCallable

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");
        }
    });
}
Also used : ConfigurationBuilderHolder(org.infinispan.configuration.parsing.ConfigurationBuilderHolder) CacheManagerCallable(org.infinispan.test.CacheManagerCallable)

Aggregations

CacheManagerCallable (org.infinispan.test.CacheManagerCallable)54 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)38 Cache (org.infinispan.Cache)26 Test (org.testng.annotations.Test)20 AbstractInfinispanTest (org.infinispan.test.AbstractInfinispanTest)19 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)18 AdvancedCache (org.infinispan.AdvancedCache)10 DummyInMemoryStoreConfigurationBuilder (org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder)10 Configuration (org.infinispan.configuration.cache.Configuration)8 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)6 InputStream (java.io.InputStream)4 MultiCacheManagerCallable (org.infinispan.test.MultiCacheManagerCallable)4 Cache (javax.cache.Cache)3 MutableConfiguration (javax.cache.configuration.MutableConfiguration)3 JCacheManager (org.infinispan.jcache.embedded.JCacheManager)3 InMemoryJCacheLoader (org.infinispan.jcache.util.InMemoryJCacheLoader)3 EncoderRegistry (org.infinispan.marshall.core.EncoderRegistry)3 InfinispanDefaultCacheFactoryBean (org.infinispan.spring.embedded.InfinispanDefaultCacheFactoryBean)3 Person (org.infinispan.test.data.Person)3 File (java.io.File)2