Search in sources :

Example 21 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.

the class CacheEntryMutatorTestCase method mutateTransactional.

@Test
public void mutateTransactional() {
    AdvancedCache<Object, Object> cache = mock(AdvancedCache.class);
    Object id = new Object();
    Object value = new Object();
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).build();
    when(cache.getCacheConfiguration()).thenReturn(config);
    Mutator mutator = new CacheEntryMutator<>(cache, id, value);
    when(cache.getAdvancedCache()).thenReturn(cache);
    when(cache.withFlags(Flag.IGNORE_RETURN_VALUES, Flag.FAIL_SILENTLY)).thenReturn(cache);
    mutator.mutate();
    verify(cache).put(same(id), same(value));
    mutator.mutate();
    verify(cache, times(1)).put(same(id), same(value));
    mutator.mutate();
    verify(cache, times(1)).put(same(id), same(value));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Mutator(org.wildfly.clustering.ee.Mutator) Test(org.junit.Test)

Example 22 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.

the class InfinispanCachePropertiesTestCase method isMarshalling.

@Test
public void isMarshalling() {
    for (CacheMode mode : EnumSet.allOf(CacheMode.class)) {
        Configuration config = new ConfigurationBuilder().clustering().cacheMode(mode).build();
        CacheProperties configuration = new InfinispanCacheProperties(config);
        if (mode.isDistributed() || mode.isReplicated() || mode.isScattered()) {
            Assert.assertTrue(mode.name(), configuration.isMarshalling());
        } else {
            Assert.assertFalse(mode.name(), configuration.isMarshalling());
        }
    }
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).persistence().passivation(false).addSingleFileStore().build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isMarshalling());
    Configuration passivating = new ConfigurationBuilder().read(config).persistence().passivation(true).build();
    Assert.assertTrue(new InfinispanCacheProperties(passivating).isMarshalling());
    Configuration noStore = new ConfigurationBuilder().read(config).persistence().clearStores().build();
    Assert.assertFalse(new InfinispanCacheProperties(noStore).isMarshalling());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheProperties(org.wildfly.clustering.ee.cache.CacheProperties) Configuration(org.infinispan.configuration.cache.Configuration) CacheMode(org.infinispan.configuration.cache.CacheMode) Test(org.junit.Test)

Example 23 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.

the class InfinispanCachePropertiesTestCase method isLockOnWrite.

@Test
public void isLockOnWrite() {
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).lockingMode(LockingMode.PESSIMISTIC).build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isLockOnWrite());
    Configuration optimistic = config = new ConfigurationBuilder().read(config).transaction().lockingMode(LockingMode.OPTIMISTIC).build();
    Assert.assertFalse(new InfinispanCacheProperties(optimistic).isLockOnWrite());
    Configuration nonTx = new ConfigurationBuilder().read(config).transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
    Assert.assertFalse(new InfinispanCacheProperties(nonTx).isLockOnWrite());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Test(org.junit.Test)

Example 24 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.

the class InfinispanCachePropertiesTestCase method isPersistent.

@Test
public void isPersistent() {
    for (CacheMode mode : EnumSet.allOf(CacheMode.class)) {
        Configuration config = new ConfigurationBuilder().clustering().cacheMode(mode).build();
        CacheProperties configuration = new InfinispanCacheProperties(config);
        if (mode.isDistributed() || mode.isReplicated() || mode.isScattered()) {
            Assert.assertTrue(mode.name(), configuration.isPersistent());
        } else {
            Assert.assertFalse(mode.name(), configuration.isPersistent());
        }
    }
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).persistence().passivation(false).addSingleFileStore().build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isPersistent());
    Configuration passivating = new ConfigurationBuilder().read(config).persistence().passivation(true).build();
    Assert.assertFalse(new InfinispanCacheProperties(passivating).isPersistent());
    Configuration noStore = new ConfigurationBuilder().read(config).persistence().clearStores().build();
    Assert.assertFalse(new InfinispanCacheProperties(noStore).isPersistent());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheProperties(org.wildfly.clustering.ee.cache.CacheProperties) Configuration(org.infinispan.configuration.cache.Configuration) CacheMode(org.infinispan.configuration.cache.CacheMode) Test(org.junit.Test)

Example 25 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.

the class DefaultCacheContainerTestCase method getDefaultCacheConfiguration.

@Test
public void getDefaultCacheConfiguration() {
    Configuration config = new ConfigurationBuilder().build();
    when(this.manager.getDefaultCacheConfiguration()).thenReturn(config);
    Configuration result = this.subject.getDefaultCacheConfiguration();
    assertSame(config, result);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) Test(org.junit.Test)

Aggregations

ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)53 Configuration (org.infinispan.configuration.cache.Configuration)24 Test (org.junit.Test)19 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)14 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)12 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)7 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)7 Properties (java.util.Properties)6 Map (java.util.Map)5 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)5 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)5 BeforeClass (org.junit.BeforeClass)5 AdvancedCache (org.infinispan.AdvancedCache)4 BackupConfigurationBuilder (org.infinispan.configuration.cache.BackupConfigurationBuilder)4 CacheMode (org.infinispan.configuration.cache.CacheMode)4 SitesConfigurationBuilder (org.infinispan.configuration.cache.SitesConfigurationBuilder)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 HashMap (java.util.HashMap)2 Consumer (java.util.function.Consumer)2 CacheProducer (org.commonjava.indy.subsys.infinispan.CacheProducer)2