HHH-7553 Upgrade to Infinispan 5.2.0.Beta2 and fix testsuite

This commit is contained in:
Galder Zamarreño 2012-10-23 09:27:27 +02:00
parent d7e58c794d
commit cf9ef94f8e
18 changed files with 726 additions and 524 deletions

View File

@ -23,8 +23,8 @@ test {
systemProperties['jgroups.udp.enable_bundling'] = false
systemProperties['jgroups.bind_addr'] = 'localhost'
// Use Infinispan's test JGroups stack that uses TEST_PING
systemProperties['hibernate.cache.infinispan.jgroups_cfg'] = 'stacks/tcp.xml'
// systemProperties['log4j.configuration'] = 'file:/log4j/log4j-infinispan.xml'
systemProperties['hibernate.cache.infinispan.jgroups_cfg'] = '2lc-test-tcp.xml'
// systemProperties['log4j.configuration'] = 'file:/log4j/log4j-infinispan.xml'
enabled = true
}

View File

@ -394,17 +394,23 @@ public class InfinispanRegionFactory implements RegionFactory {
ConfigurationBuilderHolder holder = parserRegistry.parse(is);
// Override global jmx statistics exposure
String globalStats = extractProperty(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
String globalStats = extractProperty(
INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
if (globalStats != null)
holder.getGlobalConfigurationBuilder().globalJmxStatistics()
.enabled(Boolean.parseBoolean(globalStats));
return new DefaultCacheManager(holder, true);
return createCacheManager(holder);
} catch (IOException e) {
throw new CacheException("Unable to create default cache manager", e);
}
}
protected EmbeddedCacheManager createCacheManager(
ConfigurationBuilderHolder holder) {
return new DefaultCacheManager(holder, true);
}
private void startRegion(BaseRegion region, String regionName) {
regionNames.add(regionName);
getCacheCommandFactory(region.getCache()).addRegion(regionName, region);

View File

@ -12,7 +12,7 @@
<properties>
<!--<property name="configurationFile" value="jgroups-tcp.xml"/>-->
<property name="configurationFile"
value="${hibernate.cache.infinispan.jgroups_cfg:tcp.xml}"/>
value="${hibernate.cache.infinispan.jgroups_cfg:jgroups-tcp.xml}"/>
</properties>
<!-- See the JGroupsTransport javadocs for more flags -->
</transport>

View File

@ -56,7 +56,7 @@ public abstract class AbstractNonFunctionalTestCase extends org.hibernate.testin
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
System.setProperty(PREFER_IPV4STACK, "true");
jgroupsCfgFile = System.getProperty(JGROUPS_CFG_FILE);
System.setProperty(JGROUPS_CFG_FILE, "stacks/tcp.xml");
System.setProperty(JGROUPS_CFG_FILE, "2lc-test-tcp.xml");
testSupport.setUp();
}

View File

@ -24,9 +24,11 @@ package org.hibernate.test.cache.infinispan;
import java.util.Properties;
import javax.transaction.TransactionManager;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
import org.infinispan.AdvancedCache;
import org.infinispan.config.Configuration;
import org.infinispan.config.Configuration.CacheMode;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.eviction.EvictionStrategy;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
@ -58,6 +60,7 @@ import static org.junit.Assert.fail;
* @since 3.5
*/
public class InfinispanRegionFactoryTestCase {
@Test
public void testConfigurationProcessing() {
final String person = "com.acme.Person";
@ -73,31 +76,35 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.lifespan", "120000");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.max_idle", "60000");
p.setProperty("hibernate.cache.infinispan.query.cfg", "my-query-cache");
p.setProperty("hibernate.cache.infinispan.query.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.query.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.query.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.query.eviction.max_entries", "10000");
InfinispanRegionFactory factory = createRegionFactory(p);
assertEquals("entity", factory.getTypeOverrides().get("entity").getCacheName());
assertEquals("entity", factory.getTypeOverrides().get("collection").getCacheName());
assertEquals("timestamps", factory.getTypeOverrides().get("timestamps").getCacheName());
try {
assertEquals("entity", factory.getTypeOverrides().get("entity").getCacheName());
assertEquals("entity", factory.getTypeOverrides().get("collection").getCacheName());
assertEquals("timestamps", factory.getTypeOverrides().get("timestamps").getCacheName());
assertEquals("person-cache", factory.getTypeOverrides().get(person).getCacheName());
assertEquals(EvictionStrategy.LRU, factory.getTypeOverrides().get(person).getEvictionStrategy());
assertEquals(2000, factory.getTypeOverrides().get(person).getEvictionWakeUpInterval());
assertEquals(5000, factory.getTypeOverrides().get(person).getEvictionMaxEntries());
assertEquals(60000, factory.getTypeOverrides().get(person).getExpirationLifespan());
assertEquals(30000, factory.getTypeOverrides().get(person).getExpirationMaxIdle());
assertEquals("person-cache", factory.getTypeOverrides().get(person).getCacheName());
assertEquals(EvictionStrategy.LRU, factory.getTypeOverrides().get(person).getEvictionStrategy());
assertEquals(2000, factory.getTypeOverrides().get(person).getEvictionWakeUpInterval());
assertEquals(5000, factory.getTypeOverrides().get(person).getEvictionMaxEntries());
assertEquals(60000, factory.getTypeOverrides().get(person).getExpirationLifespan());
assertEquals(30000, factory.getTypeOverrides().get(person).getExpirationMaxIdle());
assertEquals("person-addresses-cache", factory.getTypeOverrides().get(addresses).getCacheName());
assertEquals(120000, factory.getTypeOverrides().get(addresses).getExpirationLifespan());
assertEquals(60000, factory.getTypeOverrides().get(addresses).getExpirationMaxIdle());
assertEquals("person-addresses-cache", factory.getTypeOverrides().get(addresses).getCacheName());
assertEquals(120000, factory.getTypeOverrides().get(addresses).getExpirationLifespan());
assertEquals(60000, factory.getTypeOverrides().get(addresses).getExpirationMaxIdle());
assertEquals("my-query-cache", factory.getTypeOverrides().get("query").getCacheName());
assertEquals(EvictionStrategy.FIFO, factory.getTypeOverrides().get("query").getEvictionStrategy());
assertEquals(3000, factory.getTypeOverrides().get("query").getEvictionWakeUpInterval());
assertEquals(10000, factory.getTypeOverrides().get("query").getEvictionMaxEntries());
assertEquals("my-query-cache", factory.getTypeOverrides().get("query").getCacheName());
assertEquals(EvictionStrategy.LIRS, factory.getTypeOverrides().get("query").getEvictionStrategy());
assertEquals(3000, factory.getTypeOverrides().get("query").getEvictionWakeUpInterval());
assertEquals(10000, factory.getTypeOverrides().get("query").getEvictionMaxEntries());
} finally {
factory.stop();
}
}
@Test
@ -116,11 +123,11 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.lifespan", "60000");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000");
p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache");
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "20000");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.cfg", "addresses-cache");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.wake_up_interval", "2500");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.max_entries", "5500");
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.lifespan", "65000");
@ -130,9 +137,10 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "25000");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
EmbeddedCacheManager manager = factory.getCacheManager();
assertFalse(manager.getCacheManagerConfiguration()
.globalJmxStatistics().enabled());
assertNotNull(factory.getTypeOverrides().get(person));
assertFalse(factory.getDefinedConfigurations().contains(person));
assertNotNull(factory.getTypeOverrides().get(addresses));
@ -144,70 +152,71 @@ public class InfinispanRegionFactoryTestCase {
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(address));
cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(2000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(5000, cacheCfg.getEvictionMaxEntries());
assertEquals(60000, cacheCfg.getExpirationLifespan());
assertEquals(30000, cacheCfg.getExpirationMaxIdle());
assertFalse(cacheCfg.isExposeJmxStatistics());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(2000, cacheCfg.expiration().wakeUpInterval());
assertEquals(5000, cacheCfg.eviction().maxEntries());
assertEquals(60000, cacheCfg.expiration().lifespan());
assertEquals(30000, cacheCfg.expiration().maxIdle());
assertFalse(cacheCfg.jmxStatistics().enabled());
region = (EntityRegionImpl) factory.buildEntityRegion(address, p, null);
assertNotNull(factory.getTypeOverrides().get(person));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(address));
cache = region.getCache();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(20000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
assertEquals(20000, cacheCfg.eviction().maxEntries());
assertFalse(cacheCfg.jmxStatistics().enabled());
region = (EntityRegionImpl) factory.buildEntityRegion(car, p, null);
assertNotNull(factory.getTypeOverrides().get(person));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(address));
cache = region.getCache();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(20000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
assertEquals(20000, cacheCfg.eviction().maxEntries());
assertFalse(cacheCfg.jmxStatistics().enabled());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(addresses, p, null);
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
factory.buildCollectionRegion(addresses, p, null);
assertNotNull(factory.getTypeOverrides().get(addresses));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(parts));
cache = collectionRegion .getCache();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(2500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(5500, cacheCfg.getEvictionMaxEntries());
assertEquals(65000, cacheCfg.getExpirationLifespan());
assertEquals(35000, cacheCfg.getExpirationMaxIdle());
assertFalse(cacheCfg.isExposeJmxStatistics());
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(2500, cacheCfg.expiration().wakeUpInterval());
assertEquals(5500, cacheCfg.eviction().maxEntries());
assertEquals(65000, cacheCfg.expiration().lifespan());
assertEquals(35000, cacheCfg.expiration().maxIdle());
assertFalse(cacheCfg.jmxStatistics().enabled());
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
assertNotNull(factory.getTypeOverrides().get(addresses));
assertTrue(factory.getDefinedConfigurations().contains(addresses));
assertNull(factory.getTypeOverrides().get(parts));
cache = collectionRegion.getCache();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(25000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
assertEquals(25000, cacheCfg.eviction().maxEntries());
assertFalse(cacheCfg.jmxStatistics().enabled());
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
assertNotNull(factory.getTypeOverrides().get(addresses));
assertTrue(factory.getDefinedConfigurations().contains(addresses));
assertNull(factory.getTypeOverrides().get(parts));
cache = collectionRegion.getCache();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(25000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
assertEquals(25000, cacheCfg.eviction().maxEntries());
assertFalse(cacheCfg.jmxStatistics().enabled());
} finally {
factory.stop();
}
@ -217,32 +226,33 @@ public class InfinispanRegionFactoryTestCase {
public void testBuildEntityCollectionRegionOverridesOnly() {
AdvancedCache cache;
Properties p = new Properties();
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "30000");
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "35000");
InfinispanRegionFactory factory = createRegionFactory(p);
factory.getCacheManager();
try {
factory.getCacheManager();
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
assertNull(factory.getTypeOverrides().get("com.acme.Address"));
cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(30000, cacheCfg.getEvictionMaxEntries());
assertEquals(100000, cacheCfg.getExpirationMaxIdle());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
assertEquals(30000, cacheCfg.eviction().maxEntries());
assertEquals(100000, cacheCfg.expiration().maxIdle());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
assertNull(factory.getTypeOverrides().get("com.acme.Person.addresses"));
cache = collectionRegion.getCache();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(35000, cacheCfg.getEvictionMaxEntries());
assertEquals(100000, cacheCfg.getExpirationMaxIdle());
cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
assertEquals(35000, cacheCfg.eviction().maxEntries());
assertEquals(100000, cacheCfg.expiration().maxIdle());
} finally {
factory.stop();
}
@ -260,87 +270,89 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
factory.getCacheManager();
assertNotNull(factory.getTypeOverrides().get(person));
assertFalse(factory.getDefinedConfigurations().contains(person));
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, null);
assertNotNull(factory.getTypeOverrides().get(person));
assertTrue(factory.getDefinedConfigurations().contains(person));
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(10000, cacheCfg.getEvictionMaxEntries());
assertEquals(60000, cacheCfg.getExpirationLifespan());
assertEquals(30000, cacheCfg.getExpirationMaxIdle());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
assertEquals(10000, cacheCfg.eviction().maxEntries());
assertEquals(60000, cacheCfg.expiration().lifespan());
assertEquals(30000, cacheCfg.expiration().maxIdle());
} finally {
factory.stop();
}
}
@Test
public void testTimestampValidation() {
Properties p = new Properties();
final DefaultCacheManager manager = new DefaultCacheManager();
InfinispanRegionFactory factory = createRegionFactory(manager, p);
Configuration config = new Configuration();
config.setCacheMode(CacheMode.INVALIDATION_SYNC);
manager.defineConfiguration("timestamps", config);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
manager.defineConfiguration("timestamps", builder.build());
try {
factory.start(null, p);
fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
} catch(CacheException ce) {
}
}
@Test
@Test
public void testBuildDefaultTimestampsRegion() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Properties p = new Properties();
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
assertTrue(factory.getDefinedConfigurations().contains("timestamps"));
assertTrue(factory.getTypeOverrides().get("timestamps").getCacheName().equals("timestamps"));
Configuration config = new Configuration();
config.setFetchInMemoryState(false);
manager.defineConfiguration("timestamps", config);
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
assertTrue(factory.getTypeOverrides().get("timestamps")
.getCacheName().equals("timestamps"));
TimestampsRegionImpl region = (TimestampsRegionImpl)
factory.buildTimestampsRegion(timestamps, p);
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.NONE, cacheCfg.getEvictionStrategy());
assertEquals(CacheMode.REPL_ASYNC, cacheCfg.getCacheMode());
assertTrue(cacheCfg.isUseLazyDeserialization());
assertFalse(cacheCfg.isExposeJmxStatistics());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
assertEquals(CacheMode.REPL_ASYNC, cacheCfg.clustering().cacheMode());
assertTrue(cacheCfg.storeAsBinary().enabled());
assertFalse(cacheCfg.jmxStatistics().enabled());
} finally {
factory.stop();
}
}
@Test
public void testBuildDiffCacheNameTimestampsRegion() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Properties p = new Properties();
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "unrecommended-timestamps");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
EmbeddedCacheManager manager = factory.getCacheManager();
assertFalse(factory.getDefinedConfigurations().contains("timestamp"));
assertTrue(factory.getDefinedConfigurations().contains("unrecommended-timestamps"));
assertTrue(factory.getTypeOverrides().get("timestamps").getCacheName().equals("unrecommended-timestamps"));
Configuration config = new Configuration();
config.setFetchInMemoryState(false);
config.setCacheMode(CacheMode.REPL_SYNC);
manager.defineConfiguration("unrecommended-timestamps", config);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().stateTransfer().fetchInMemoryState(true);
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
manager.defineConfiguration("unrecommended-timestamps", builder.build());
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.NONE, cacheCfg.getEvictionStrategy());
assertEquals(CacheMode.REPL_SYNC, cacheCfg.getCacheMode());
assertFalse(cacheCfg.isUseLazyDeserialization());
assertFalse(cacheCfg.isExposeJmxStatistics());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
assertEquals(CacheMode.REPL_SYNC, cacheCfg.clustering().cacheMode());
assertFalse(cacheCfg.storeAsBinary().enabled());
assertFalse(cacheCfg.jmxStatistics().enabled());
} finally {
factory.stop();
}
}
@Test
public void testBuildTimestamRegionWithCacheNameOverride() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
@ -354,6 +366,7 @@ public class InfinispanRegionFactoryTestCase {
factory.stop();
}
}
@Test
public void testBuildTimestamRegionWithFifoEvictionOverride() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
@ -373,6 +386,7 @@ public class InfinispanRegionFactoryTestCase {
if (factory != null) factory.stop();
}
}
@Test
public void testBuildTimestamRegionWithNoneEvictionOverride() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
@ -382,8 +396,6 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "10000");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
manager.getGlobalConfiguration().setTransportClass(null);
try {
factory.buildTimestampsRegion(timestamps, p);
assertTrue(factory.getDefinedConfigurations().contains("timestamps-none-eviction"));
@ -391,45 +403,43 @@ public class InfinispanRegionFactoryTestCase {
factory.stop();
}
}
@Test
public void testBuildQueryRegion() {
final String query = "org.hibernate.cache.internal.StandardQueryCache";
Properties p = new Properties();
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
manager.getGlobalConfiguration().setTransportClass(null);
try {
assertTrue(factory.getDefinedConfigurations().contains("local-query"));
QueryResultsRegionImpl region = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(CacheMode.LOCAL, cacheCfg.getCacheMode());
assertFalse(cacheCfg.isExposeJmxStatistics());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(CacheMode.LOCAL, cacheCfg.clustering().cacheMode());
assertFalse(cacheCfg.jmxStatistics().enabled());
} finally {
factory.stop();
}
}
@Test
public void testBuildQueryRegionWithCustomRegionName() {
final String queryRegionName = "myquery";
Properties p = new Properties();
p.setProperty("hibernate.cache.infinispan.myquery.cfg", "timestamps-none-eviction");
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "FIFO");
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "LIRS");
p.setProperty("hibernate.cache.infinispan.myquery.eviction.wake_up_interval", "2222");
p.setProperty("hibernate.cache.infinispan.myquery.eviction.max_entries", "11111");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
manager.getGlobalConfiguration().setTransportClass(null);
try {
assertTrue(factory.getDefinedConfigurations().contains("local-query"));
QueryResultsRegionImpl region = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(queryRegionName, p);
assertNotNull(factory.getTypeOverrides().get(queryRegionName));
assertTrue(factory.getDefinedConfigurations().contains(queryRegionName));
AdvancedCache cache = region.getCache();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(2222, cacheCfg.getEvictionWakeUpInterval());
assertEquals(11111, cacheCfg.getEvictionMaxEntries());
Configuration cacheCfg = cache.getCacheConfiguration();
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
assertEquals(2222, cacheCfg.expiration().wakeUpInterval());
assertEquals(11111, cacheCfg.eviction().maxEntries());
} finally {
factory.stop();
}
@ -445,42 +455,46 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
assertTrue(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
EmbeddedCacheManager manager = factory.getCacheManager();
assertTrue(manager.getCacheManagerConfiguration().globalJmxStatistics().enabled());
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
AdvancedCache cache = region.getCache();
assertTrue(factory.getTypeOverrides().get("entity").isExposeStatistics());
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
cache = region.getCache();
assertTrue(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
final String query = "org.hibernate.cache.internal.StandardQueryCache";
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl)
factory.buildQueryResultsRegion(query, p);
cache = queryRegion.getCache();
assertTrue(factory.getTypeOverrides().get("query").isExposeStatistics());
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Configuration config = new Configuration();
config.setFetchInMemoryState(false);
manager.defineConfiguration("timestamps", config);
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().stateTransfer().fetchInMemoryState(true);
manager.defineConfiguration("timestamps", builder.build());
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl)
factory.buildTimestampsRegion(timestamps, p);
cache = timestampsRegion.getCache();
assertTrue(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
cache = collectionRegion.getCache();
assertTrue(factory.getTypeOverrides().get("collection").isExposeStatistics());
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
} finally {
factory.stop();
}
}
@Test
public void testDisableStatistics() {
Properties p = new Properties();
@ -492,38 +506,38 @@ public class InfinispanRegionFactoryTestCase {
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
InfinispanRegionFactory factory = createRegionFactory(p);
EmbeddedCacheManager manager = factory.getCacheManager();
try {
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
AdvancedCache cache = region.getCache();
assertFalse(factory.getTypeOverrides().get("entity").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
cache = region.getCache();
assertFalse(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
final String query = "org.hibernate.cache.internal.StandardQueryCache";
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
cache = queryRegion.getCache();
assertFalse(factory.getTypeOverrides().get("query").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Configuration config = new Configuration();
config.setFetchInMemoryState(false);
manager.defineConfiguration("timestamps", config);
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().stateTransfer().fetchInMemoryState(true);
factory.getCacheManager().defineConfiguration("timestamps", builder.build());
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl)
factory.buildTimestampsRegion(timestamps, p);
cache = timestampsRegion.getCache();
assertFalse(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
cache = collectionRegion.getCache();
assertFalse(factory.getTypeOverrides().get("collection").isExposeStatistics());
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
} finally {
factory.stop();
}
@ -534,7 +548,8 @@ public class InfinispanRegionFactoryTestCase {
}
private InfinispanRegionFactory createRegionFactory(final EmbeddedCacheManager manager, Properties p) {
final InfinispanRegionFactory factory = new InfinispanRegionFactory() {
final InfinispanRegionFactory factory = new SingleNodeTestCase.TestInfinispanRegionFactory() {
@Override
protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(Settings settings, Properties properties) {
return new HibernateTransactionManagerLookup(null, null) {
@ -554,7 +569,9 @@ public class InfinispanRegionFactoryTestCase {
else
return super.createCacheManager(properties);
}
};
factory.start(null, p);
return factory;
}

View File

@ -34,7 +34,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.transaction.TransactionManager;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.test.CacheManagerCallable;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -42,6 +46,7 @@ import org.junit.Test;
import org.hibernate.cache.infinispan.access.PutFromLoadValidator;
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl;
import static org.infinispan.test.TestingUtil.withCacheManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@ -56,6 +61,10 @@ import static org.junit.Assert.fail;
* @version $Revision: $
*/
public class PutFromLoadValidatorUnitTestCase {
private static final Log log = LogFactory.getLog(
PutFromLoadValidatorUnitTestCase.class);
private Object KEY1 = "KEY1";
private TransactionManager tm;
@ -85,22 +94,32 @@ public class PutFromLoadValidatorUnitTestCase {
nakedPutTest(true);
}
private void nakedPutTest(boolean transactional) throws Exception {
PutFromLoadValidator testee = new PutFromLoadValidator(
new DefaultCacheManager(), transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (transactional) {
tm.begin();
}
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
private void nakedPutTest(final boolean transactional) throws Exception {
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
try {
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (transactional) {
tm.begin();
}
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
}
@Test
public void testRegisteredPut() throws Exception {
@ -111,23 +130,34 @@ public class PutFromLoadValidatorUnitTestCase {
registeredPutTest(true);
}
private void registeredPutTest(boolean transactional) throws Exception {
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
private void registeredPutTest(final boolean transactional) throws Exception {
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
try {
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
}
@Test
public void testNakedPutAfterKeyRemoval() throws Exception {
@ -146,28 +176,40 @@ public class PutFromLoadValidatorUnitTestCase {
nakedPutAfterRemovalTest(true, true);
}
private void nakedPutAfterRemovalTest(boolean transactional, boolean removeRegion)
throws Exception {
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
if (transactional) {
tm.begin();
}
private void nakedPutAfterRemovalTest(final boolean transactional,
final boolean removeRegion) throws Exception {
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
try {
if (transactional) {
tm.begin();
}
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertFalse(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertFalse(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
}
@Test
public void testRegisteredPutAfterKeyRemoval() throws Exception {
@ -186,29 +228,41 @@ public class PutFromLoadValidatorUnitTestCase {
registeredPutAfterRemovalTest(true, true);
}
private void registeredPutAfterRemovalTest(boolean transactional, boolean removeRegion)
throws Exception {
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
private void registeredPutAfterRemovalTest(final boolean transactional,
final boolean removeRegion) throws Exception {
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
try {
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
}
@Test
public void testRegisteredPutWithInterveningKeyRemoval() throws Exception {
@ -227,29 +281,41 @@ public class PutFromLoadValidatorUnitTestCase {
registeredPutWithInterveningRemovalTest(true, true);
}
private void registeredPutWithInterveningRemovalTest(boolean transactional, boolean removeRegion)
private void registeredPutWithInterveningRemovalTest(
final boolean transactional, final boolean removeRegion)
throws Exception {
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
try {
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertFalse(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertFalse(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
}
@Test
public void testDelayedNakedPutAfterKeyRemoval() throws Exception {
@ -268,87 +334,114 @@ public class PutFromLoadValidatorUnitTestCase {
delayedNakedPutAfterRemovalTest(true, true);
}
private void delayedNakedPutAfterRemovalTest(boolean transactional, boolean removeRegion)
private void delayedNakedPutAfterRemovalTest(
final boolean transactional, final boolean removeRegion)
throws Exception {
PutFromLoadValidator testee = new TestValidator(transactional ? tm : null, 100);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
if (transactional) {
tm.begin();
}
Thread.sleep(110);
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
PutFromLoadValidator testee = new TestValidator(cm,
transactional ? tm : null, 100);
if (removeRegion) {
testee.invalidateRegion();
} else {
testee.invalidateKey(KEY1);
}
try {
if (transactional) {
tm.begin();
}
Thread.sleep(110);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
try {
assertTrue(lockable);
}
finally {
if (lockable) {
testee.releasePutFromLoadLock(KEY1);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
}
@Test
public void testMultipleRegistrations() throws Exception {
multipleRegistrationtest(false);
}
@Test
public void testMultipleRegistrationsTransactional() throws Exception {
multipleRegistrationtest(true);
}
private void multipleRegistrationtest(final boolean transactional) throws Exception {
final PutFromLoadValidator testee = new PutFromLoadValidator(
new DefaultCacheManager(), transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
final PutFromLoadValidator testee = new PutFromLoadValidator(cm,
transactional ? tm : null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
final CountDownLatch registeredLatch = new CountDownLatch(3);
final CountDownLatch finishedLatch = new CountDownLatch(3);
final AtomicInteger success = new AtomicInteger();
final CountDownLatch registeredLatch = new CountDownLatch(3);
final CountDownLatch finishedLatch = new CountDownLatch(3);
final AtomicInteger success = new AtomicInteger();
Runnable r = new Runnable() {
public void run() {
try {
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
registeredLatch.countDown();
registeredLatch.await(5, TimeUnit.SECONDS);
if (testee.acquirePutFromLoadLock(KEY1)) {
Runnable r = new Runnable() {
public void run() {
try {
success.incrementAndGet();
if (transactional) {
tm.begin();
}
testee.registerPendingPut(KEY1);
registeredLatch.countDown();
registeredLatch.await(5, TimeUnit.SECONDS);
if (testee.acquirePutFromLoadLock(KEY1)) {
try {
log.trace("Put from load lock acquired for key = " + KEY1);
success.incrementAndGet();
}
finally {
testee.releasePutFromLoadLock(KEY1);
}
} else {
log.trace("Unable to acquired putFromLoad lock for key = " + KEY1);
}
finishedLatch.countDown();
}
finally {
testee.releasePutFromLoadLock(KEY1);
catch (Exception e) {
e.printStackTrace();
}
}
finishedLatch.countDown();
}
catch (Exception e) {
e.printStackTrace();
};
ExecutorService executor = Executors.newFixedThreadPool(3);
// Start with a removal so the "isPutValid" calls will fail if
// any of the concurrent activity isn't handled properly
testee.invalidateRegion();
// Do the registration + isPutValid calls
executor.execute(r);
executor.execute(r);
executor.execute(r);
try {
finishedLatch.await(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertEquals("All threads succeeded", 3, success.get());
}
};
ExecutorService executor = Executors.newFixedThreadPool(3);
// Start with a removal so the "isPutValid" calls will fail if
// any of the concurrent activity isn't handled properly
testee.invalidateRegion();
// Do the registration + isPutValid calls
executor.execute(r);
executor.execute(r);
executor.execute(r);
finishedLatch.await(5, TimeUnit.SECONDS);
assertEquals("All threads succeeded", 3, success.get());
});
}
/**
@ -359,17 +452,23 @@ public class PutFromLoadValidatorUnitTestCase {
*/
@Test
public void testRemovalCleanup() throws Exception {
TestValidator testee = new TestValidator(null, 200);
testee.invalidateKey("KEY1");
testee.invalidateKey("KEY2");
expectRemovalLenth(2, testee, 60000l);
assertEquals(2, testee.getRemovalQueueLength());
expectRemovalLenth(2, testee, 60000l);
assertEquals(2, testee.getRemovalQueueLength());
expectRemovalLenth( 2, testee, 60000l );
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
TestValidator testee = new TestValidator(cm, null, 200);
testee.invalidateKey("KEY1");
testee.invalidateKey("KEY2");
expectRemovalLenth(2, testee, 60000l);
assertEquals(2, testee.getRemovalQueueLength());
expectRemovalLenth(2, testee, 60000l);
assertEquals(2, testee.getRemovalQueueLength());
expectRemovalLenth(2, testee, 60000l);
}
});
}
private void expectRemovalLenth(int expectedLength, TestValidator testee, long timeout) throws InterruptedException {
private void expectRemovalLenth(int expectedLength, TestValidator testee, long timeout) {
long timeoutMilestone = System.currentTimeMillis() + timeout;
while ( true ) {
int queueLength = testee.getRemovalQueueLength();
@ -381,7 +480,11 @@ public class PutFromLoadValidatorUnitTestCase {
if ( System.currentTimeMillis() > timeoutMilestone ) {
fail( "condition not reached after " + timeout + " milliseconds. giving up!" );
}
Thread.sleep(20);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
@ -397,74 +500,81 @@ public class PutFromLoadValidatorUnitTestCase {
}
private void invalidationBlocksForInProgressPutTest(final boolean keyOnly) throws Exception {
final PutFromLoadValidator testee = new PutFromLoadValidator(
new DefaultCacheManager(), null,
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
final CountDownLatch removeLatch = new CountDownLatch(1);
final CountDownLatch pferLatch = new CountDownLatch(1);
final AtomicReference<Object> cache = new AtomicReference<Object>("INITIAL");
withCacheManager(new CacheManagerCallable(
TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
final PutFromLoadValidator testee = new PutFromLoadValidator(
cm, null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
final CountDownLatch removeLatch = new CountDownLatch(1);
final CountDownLatch pferLatch = new CountDownLatch(1);
final AtomicReference<Object> cache = new AtomicReference<Object>("INITIAL");
Callable<Boolean> pferCallable = new Callable<Boolean>() {
public Boolean call() throws Exception {
testee.registerPendingPut(KEY1);
if (testee.acquirePutFromLoadLock(KEY1)) {
Callable<Boolean> pferCallable = new Callable<Boolean>() {
public Boolean call() throws Exception {
testee.registerPendingPut(KEY1);
if (testee.acquirePutFromLoadLock(KEY1)) {
try {
removeLatch.countDown();
pferLatch.await();
cache.set("PFER");
return Boolean.TRUE;
}
finally {
testee.releasePutFromLoadLock(KEY1);
}
}
return Boolean.FALSE;
}
};
Callable<Void> invalidateCallable = new Callable<Void>() {
public Void call() throws Exception {
removeLatch.await();
if (keyOnly) {
testee.invalidateKey(KEY1);
} else {
testee.invalidateRegion();
}
cache.set(null);
return null;
}
};
ExecutorService executorService = Executors.newCachedThreadPool();
Future<Boolean> pferFuture = executorService.submit(pferCallable);
Future<Void> invalidateFuture = executorService.submit(invalidateCallable);
try {
try {
removeLatch.countDown();
pferLatch.await();
cache.set("PFER");
return Boolean.TRUE;
}
finally {
testee.releasePutFromLoadLock(KEY1);
invalidateFuture.get(1, TimeUnit.SECONDS);
fail("invalidateFuture did not block");
}
catch (TimeoutException good) {}
pferLatch.countDown();
assertTrue(pferFuture.get(5, TimeUnit.SECONDS));
invalidateFuture.get(5, TimeUnit.SECONDS);
assertNull(cache.get());
} catch (Exception e) {
throw new RuntimeException(e);
}
return Boolean.FALSE;
}
};
Callable<Void> invalidateCallable = new Callable<Void>() {
public Void call() throws Exception {
removeLatch.await();
if (keyOnly) {
testee.invalidateKey(KEY1);
} else {
testee.invalidateRegion();
}
cache.set(null);
return null;
}
};
ExecutorService executorService = Executors.newCachedThreadPool();
Future<Boolean> pferFuture = executorService.submit(pferCallable);
Future<Void> invalidateFuture = executorService.submit(invalidateCallable);
try {
invalidateFuture.get(1, TimeUnit.SECONDS);
fail("invalidateFuture did not block");
}
catch (TimeoutException good) {}
pferLatch.countDown();
assertTrue(pferFuture.get(5, TimeUnit.SECONDS));
invalidateFuture.get(5, TimeUnit.SECONDS);
assertNull(cache.get());
});
}
private static class TestValidator extends PutFromLoadValidator {
protected TestValidator(TransactionManager transactionManager,
long nakedPutInvalidationPeriod) {
super(new DefaultCacheManager(),
transactionManager, nakedPutInvalidationPeriod);
protected TestValidator(EmbeddedCacheManager cm,
TransactionManager transactionManager,
long nakedPutInvalidationPeriod) {
super(cm, transactionManager, nakedPutInvalidationPeriod);
}
@Override
public int getRemovalQueueLength() {
// TODO Auto-generated method stub
return super.getRemovalQueueLength();
}

View File

@ -33,7 +33,8 @@ import javax.transaction.TransactionManager;
import junit.framework.AssertionFailedError;
import org.hibernate.cache.infinispan.util.Caches;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.test.CacheManagerCallable;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.infinispan.transaction.tm.BatchModeTransactionManager;
import org.jboss.logging.Logger;
import org.junit.After;
@ -54,6 +55,7 @@ import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
import org.hibernate.test.cache.infinispan.NodeEnvironment;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.infinispan.test.TestingUtil.withCacheManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@ -162,61 +164,70 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
final CountDownLatch pferLatch = new CountDownLatch( 1 );
final CountDownLatch removeLatch = new CountDownLatch( 1 );
final TransactionManager remoteTm = remoteCollectionRegion.getTransactionManager();
PutFromLoadValidator validator = new PutFromLoadValidator(
new DefaultCacheManager(), remoteTm, 20000) {
@Override
public boolean acquirePutFromLoadLock(Object key) {
boolean acquired = super.acquirePutFromLoadLock( key );
try {
removeLatch.countDown();
pferLatch.await( 2, TimeUnit.SECONDS );
}
catch (InterruptedException e) {
log.debug( "Interrupted" );
Thread.currentThread().interrupt();
}
catch (Exception e) {
log.error( "Error", e );
throw new RuntimeException( "Error", e );
}
return acquired;
}
};
final TransactionalAccessDelegate delegate =
new TransactionalAccessDelegate(localCollectionRegion, validator);
final TransactionManager localTm = localCollectionRegion.getTransactionManager();
Callable<Void> pferCallable = new Callable<Void>() {
public Void call() throws Exception {
delegate.putFromLoad( "k1", "v1", 0, null );
return null;
}
};
Callable<Void> removeCallable = new Callable<Void>() {
public Void call() throws Exception {
removeLatch.await();
Caches.withinTx(localTm, new Callable<Void>() {
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createLocalCacheManager(false)) {
@Override
public void call() {
PutFromLoadValidator validator = new PutFromLoadValidator(cm,
remoteTm, 20000) {
@Override
public boolean acquirePutFromLoadLock(Object key) {
boolean acquired = super.acquirePutFromLoadLock( key );
try {
removeLatch.countDown();
pferLatch.await( 2, TimeUnit.SECONDS );
}
catch (InterruptedException e) {
log.debug( "Interrupted" );
Thread.currentThread().interrupt();
}
catch (Exception e) {
log.error( "Error", e );
throw new RuntimeException( "Error", e );
}
return acquired;
}
};
final TransactionalAccessDelegate delegate =
new TransactionalAccessDelegate(localCollectionRegion, validator);
final TransactionManager localTm = localCollectionRegion.getTransactionManager();
Callable<Void> pferCallable = new Callable<Void>() {
public Void call() throws Exception {
delegate.remove("k1");
delegate.putFromLoad( "k1", "v1", 0, null );
return null;
}
});
pferLatch.countDown();
return null;
}
};
};
ExecutorService executorService = Executors.newCachedThreadPool();
Future<Void> pferFuture = executorService.submit( pferCallable );
Future<Void> removeFuture = executorService.submit( removeCallable );
Callable<Void> removeCallable = new Callable<Void>() {
public Void call() throws Exception {
removeLatch.await();
Caches.withinTx(localTm, new Callable<Void>() {
@Override
public Void call() throws Exception {
delegate.remove("k1");
return null;
}
});
pferLatch.countDown();
return null;
}
};
pferFuture.get();
removeFuture.get();
ExecutorService executorService = Executors.newCachedThreadPool();
Future<Void> pferFuture = executorService.submit( pferCallable );
Future<Void> removeFuture = executorService.submit( removeCallable );
assertFalse(localCollectionRegion.getCache().containsKey("k1"));
try {
pferFuture.get();
removeFuture.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
assertFalse(localCollectionRegion.getCache().containsKey("k1"));
}
});
}
@Test

View File

@ -44,8 +44,6 @@ import org.junit.Test;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
@ -104,11 +102,6 @@ public class ConcurrentWriteTest extends SingleNodeTestCase {
return DualNodeJtaTransactionManagerImpl.getInstance( DualNodeTestCase.LOCAL );
}
@Override
protected Class<? extends RegionFactory> getCacheRegionFactory() {
return InfinispanRegionFactory.class;
}
@Override
protected Class<? extends ConnectionProvider> getConnectionProviderClass() {
return DualNodeConnectionProviderImpl.class;

View File

@ -26,6 +26,9 @@ package org.hibernate.test.cache.infinispan.functional;
import javax.transaction.Status;
import javax.transaction.TransactionManager;
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import org.junit.Before;
@ -86,7 +89,7 @@ public abstract class SingleNodeTestCase extends BaseCoreFunctionalTestCase {
}
protected Class<? extends RegionFactory> getCacheRegionFactory() {
return InfinispanRegionFactory.class;
return TestInfinispanRegionFactory.class;
}
protected Class<? extends TransactionFactory> getTransactionFactoryClass() {
@ -148,4 +151,17 @@ public abstract class SingleNodeTestCase extends BaseCoreFunctionalTestCase {
}
}
public static class TestInfinispanRegionFactory extends InfinispanRegionFactory {
public TestInfinispanRegionFactory() {
super(); // For reflection-based instantiation
}
@Override
protected EmbeddedCacheManager createCacheManager(ConfigurationBuilderHolder holder) {
return TestCacheManagerFactory.createClusteredCacheManager(holder);
}
}
}

View File

@ -27,11 +27,11 @@ import java.util.Set;
import javax.transaction.Status;
import javax.transaction.TransactionManager;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
import org.junit.Test;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
@ -73,7 +73,7 @@ public class BulkOperationsTestCase extends BaseCoreFunctionalTestCase {
}
protected Class<? extends RegionFactory> getCacheRegionFactory() {
return InfinispanRegionFactory.class;
return SingleNodeTestCase.TestInfinispanRegionFactory.class;
}
protected Class<? extends TransactionFactory> getTransactionFactoryClass() {

View File

@ -24,6 +24,7 @@ package org.hibernate.test.cache.infinispan.functional.cluster;
import java.util.Hashtable;
import java.util.Properties;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@ -51,7 +52,8 @@ public class ClusterAwareRegionFactory implements RegionFactory {
private static final Log log = LogFactory.getLog(ClusterAwareRegionFactory.class);
private static final Hashtable<String, EmbeddedCacheManager> cacheManagers = new Hashtable<String, EmbeddedCacheManager>();
private final InfinispanRegionFactory delegate = new InfinispanRegionFactory();
private final InfinispanRegionFactory delegate =
new SingleNodeTestCase.TestInfinispanRegionFactory();
private String cacheManagerName;
private boolean locallyAdded;

View File

@ -25,6 +25,7 @@ package org.hibernate.test.cache.infinispan.timestamp;
import java.util.Properties;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
import org.infinispan.AdvancedCache;
import org.infinispan.context.Flag;
import org.infinispan.notifications.Listener;
@ -124,15 +125,11 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
return CacheTestUtil.buildConfiguration("test", MockInfinispanRegionFactory.class, false, true);
}
public static class MockInfinispanRegionFactory extends InfinispanRegionFactory {
public static class MockInfinispanRegionFactory extends SingleNodeTestCase.TestInfinispanRegionFactory {
public MockInfinispanRegionFactory() {
}
public MockInfinispanRegionFactory(Properties props) {
super(props);
}
// @Override
// protected TimestampsRegionImpl createTimestampsRegion(CacheAdapter cacheAdapter, String regionName) {
// return new MockTimestampsRegionImpl(cacheAdapter, regionName, getTransactionManager(), this);
@ -148,20 +145,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
};
}
// @Override
// protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
// try {
// EmbeddedCacheManager manager = new DefaultCacheManager(InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE);
// org.infinispan.config.Configuration ispnCfg = new org.infinispan.config.Configuration();
// ispnCfg.setCacheMode(org.infinispan.config.Configuration.CacheMode.REPL_SYNC);
// manager.defineConfiguration("timestamps", ispnCfg);
// return manager;
// } catch (IOException e) {
// throw new CacheException("Unable to create default cache manager", e);
// }
// }
@Listener
@Listener
public static class MockClassLoaderAwareListener extends ClassLoaderAwareCache.ClassLoaderAwareListener {
MockClassLoaderAwareListener(Object listener, ClassLoaderAwareCache cache) {
super(listener, cache);

View File

@ -23,8 +23,6 @@
*/
package org.hibernate.test.cache.infinispan.tm;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Properties;
import javax.naming.Context;
@ -34,10 +32,8 @@ import javax.naming.NameNotFoundException;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.transaction.Status;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.enhydra.jdbc.standard.StandardXADataSource;
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@ -62,8 +58,6 @@ import org.hibernate.stat.Statistics;
import org.hibernate.test.cache.infinispan.functional.Item;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@ -255,7 +249,8 @@ public class JBossStandaloneJtaExampleTest {
cfg.setProperty(Environment.RELEASE_CONNECTIONS, "auto");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
cfg.setProperty(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.infinispan.InfinispanRegionFactory");
cfg.setProperty(Environment.CACHE_REGION_FACTORY,
"org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase$TestInfinispanRegionFactory");
Properties envProps = Environment.getProperties();
envProps.put(AvailableSettings.JTA_PLATFORM, new JBossStandAloneJtaPlatform());

View File

@ -64,7 +64,6 @@ public class CacheTestSupport {
}
public void setUp() throws Exception {
// Try to ensure we use IPv4; otherwise cluster formation is very slow
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
System.setProperty(PREFER_IPV4STACK, "true");
@ -74,7 +73,6 @@ public class CacheTestSupport {
}
public void tearDown() throws Exception {
if (preferIPv4Stack == null)
System.clearProperty(PREFER_IPV4STACK);
else

View File

@ -23,14 +23,7 @@
*/
package org.hibernate.test.cache.infinispan.util;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cfg.AvailableSettings;
@ -38,6 +31,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Settings;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
/**
* Utilities for cache testing.
@ -46,7 +40,8 @@ import org.hibernate.service.ServiceRegistry;
*/
public class CacheTestUtil {
public static Configuration buildConfiguration(String regionPrefix, Class regionFactory, boolean use2ndLevel, boolean useQueries) {
public static Configuration buildConfiguration(String regionPrefix,
Class regionFactory, boolean use2ndLevel, boolean useQueries) {
Configuration cfg = new Configuration();
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
cfg.setProperty(Environment.USE_STRUCTURED_CACHE, "true");
@ -60,85 +55,47 @@ public class CacheTestUtil {
return cfg;
}
public static Configuration buildLocalOnlyConfiguration(String regionPrefix, boolean use2ndLevel, boolean useQueries) {
Configuration cfg = buildConfiguration(regionPrefix, InfinispanRegionFactory.class, use2ndLevel, useQueries);
cfg.setProperty(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP,
InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE);
return cfg;
}
public static Configuration buildCustomQueryCacheConfiguration(String regionPrefix, String queryCacheName) {
Configuration cfg = buildConfiguration(regionPrefix, InfinispanRegionFactory.class, true, true);
cfg.setProperty(InfinispanRegionFactory.QUERY_CACHE_RESOURCE_PROP, queryCacheName);
return cfg;
}
public static InfinispanRegionFactory startRegionFactory(
ServiceRegistry serviceRegistry,
Configuration cfg) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
public static InfinispanRegionFactory startRegionFactory(ServiceRegistry reg,
Configuration cfg){
try {
Settings settings = cfg.buildSettings(reg);
Properties properties = cfg.getProperties();
Settings settings = cfg.buildSettings( serviceRegistry );
Properties properties = cfg.getProperties();
String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryType);
InfinispanRegionFactory regionFactory = (InfinispanRegionFactory) factoryClass.newInstance();
regionFactory.start(settings, properties);
return regionFactory;
String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
Class clazz = Thread.currentThread()
.getContextClassLoader().loadClass(factoryType);
InfinispanRegionFactory regionFactory;
if (clazz == InfinispanRegionFactory.class) {
regionFactory = new SingleNodeTestCase.TestInfinispanRegionFactory();
} else {
regionFactory = (InfinispanRegionFactory) clazz.newInstance();
}
regionFactory.start(settings, properties);
return regionFactory;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static InfinispanRegionFactory startRegionFactory(
ServiceRegistry serviceRegistry,
Configuration cfg,
CacheTestSupport testSupport) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
InfinispanRegionFactory factory = startRegionFactory( serviceRegistry, cfg );
public static InfinispanRegionFactory startRegionFactory(ServiceRegistry reg,
Configuration cfg, CacheTestSupport testSupport) {
InfinispanRegionFactory factory = startRegionFactory(reg, cfg);
testSupport.registerFactory(factory);
return factory;
}
public static void stopRegionFactory(InfinispanRegionFactory factory, CacheTestSupport testSupport) {
public static void stopRegionFactory(InfinispanRegionFactory factory,
CacheTestSupport testSupport) {
factory.stop();
testSupport.unregisterFactory(factory);
}
/**
* Supports easy creation of a TestSuite where a subclass' "FailureExpected" version of a base
* test is included in the suite, while the base test is excluded. E.g. test class FooTestCase
* includes method testBar(), while test class SubFooTestCase extends FooTestCase includes method
* testBarFailureExcluded(). Passing SubFooTestCase.class to this method will return a suite that
* does not include testBar().
*
* FIXME Move this to UnitTestCase
*/
public static TestSuite createFailureExpectedSuite(Class testClass) {
TestSuite allTests = new TestSuite(testClass);
Set failureExpected = new HashSet();
Enumeration tests = allTests.tests();
while (tests.hasMoreElements()) {
Test t = (Test) tests.nextElement();
if (t instanceof TestCase) {
String name = ((TestCase) t).getName();
if (name.endsWith("FailureExpected"))
failureExpected.add(name);
}
}
TestSuite result = new TestSuite();
tests = allTests.tests();
while (tests.hasMoreElements()) {
Test t = (Test) tests.nextElement();
if (t instanceof TestCase) {
String name = ((TestCase) t).getName();
if (!failureExpected.contains(name + "FailureExpected")) {
result.addTest(t);
}
}
}
return result;
}
/**
* Prevent instantiation.
*/

View File

@ -0,0 +1,90 @@
<!--
~ JBoss, Home of Professional Open Source
~ Copyright 2012 Red Hat Inc. and/or its affiliates and other
~ contributors as indicated by the @author tags. All rights reserved.
~ See the copyright.txt in the distribution for a full listing of
~ individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups file:schema/JGroups-3.2.xsd">
<TCP bind_port="7800"
loopback="true"
port_range="30"
recv_buf_size="20000000"
send_buf_size="640000"
max_bundle_size="64000"
max_bundle_timeout="30"
enable_bundling="true"
use_send_queues="true"
sock_conn_timeout="300"
enable_diagnostics="false"
bundler_type="old"
send_queue_size="0"
thread_pool.enabled="true"
thread_pool.min_threads="1"
thread_pool.max_threads="8"
thread_pool.keep_alive_time="5000"
thread_pool.queue_enabled="false"
thread_pool.queue_max_size="100"
thread_pool.rejection_policy="Run"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="1"
oob_thread_pool.max_threads="8"
oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="Run"/>
<org.infinispan.test.fwk.TEST_PING ergonomics="false" testName=""/>
<MERGE2 max_interval="10000"
min_interval="3000"/>
<FD_SOCK/>
<!--
Note that this is an atypically short timeout and a small number of retries
configured this way to speed up unit testing, since we know all nodes run in the same JVM
and hence failure detections will be very quick.
-->
<FD timeout="3000" max_tries="3"/>
<VERIFY_SUSPECT timeout="1500"/>
<pbcast.NAKACK2
use_mcast_xmit="false"
xmit_interval="1000"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="10000"
xmit_table_max_compaction_time="10000"
max_msg_batch_size="100"
become_server_queue_size="0"/>
<UNICAST2
max_bytes="20M"
xmit_table_num_rows="20"
xmit_table_msgs_per_row="10000"
xmit_table_max_compaction_time="10000"
max_msg_batch_size="100"/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="5000"
max_bytes="400000"/>
<pbcast.GMS print_local_addr="false" join_timeout="7000" view_bundling="true"/>
<FC max_credits="2000000"
min_threshold="0.10"/>
<FRAG2 frag_size="60000"/>
</config>

View File

@ -1,5 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source
~ Copyright 2012 Red Hat Inc. and/or its affiliates and other
~ contributors as indicated by the @author tags. All rights reserved.
~ See the copyright.txt in the distribution for a full listing of
~ individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<!-- Infinispan configuration based on the AS7 standalone, single node, set up -->
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:infinispan:config:5.1"

View File

@ -31,7 +31,7 @@ ext {
junitVersion = '4.10'
h2Version = '1.2.145'
bytemanVersion = '1.5.2'
infinispanVersion = '5.1.6.FINAL'
infinispanVersion = '5.2.0.Beta2'
jnpVersion = '5.0.6.CR1'
libraries = [