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));
}
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());
}
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());
}
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());
}
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);
}
Aggregations