Add evict/evictAll tests for query and timestamps regions

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14109 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Brian Stansberry 2007-10-19 03:15:08 +00:00
parent c0f701cc08
commit 923ac2533f
2 changed files with 26 additions and 33 deletions

View File

@ -25,13 +25,12 @@ import junit.framework.AssertionFailedError;
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.QueryResultsRegion;
import org.hibernate.cache.Region;
import org.hibernate.cache.StandardQueryCache;
import org.hibernate.cache.jbc2.BasicRegionAdapter;
import org.hibernate.cache.jbc2.CacheInstanceManager;
import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
import org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory;
import org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.cache.jbc2.AbstractRegionImplTestCase;
import org.hibernate.test.cache.jbc2.AbstractGeneralDataRegionTestCase;
import org.hibernate.test.util.CacheTestUtil;
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
@ -46,11 +45,9 @@ import org.jboss.cache.transaction.BatchModeTransactionManager;
* @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision: 1 $
*/
public class QueryRegionImplTestCase extends AbstractRegionImplTestCase {
public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
private static final String KEY = "Key";
private static final String VALUE1 = "value1";
private static final String VALUE2 = "value2";
// protected static final String REGION_NAME = "test/" + StandardQueryCache.class.getName();
/**
* Create a new EntityRegionImplTestCase.
@ -66,6 +63,11 @@ public class QueryRegionImplTestCase extends AbstractRegionImplTestCase {
return regionFactory.buildQueryResultsRegion(regionName, properties);
}
@Override
protected String getStandardRegionName(String regionPrefix) {
return regionPrefix + "/" + StandardQueryCache.class.getName();
}
@Override
protected Cache getJBossCache(JBossCacheRegionFactory regionFactory) {
CacheInstanceManager mgr = regionFactory.getCacheInstanceManager();
@ -87,13 +89,10 @@ public class QueryRegionImplTestCase extends AbstractRegionImplTestCase {
private void putDoesNotBlockGetTest(String configName) throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", MultiplexedJBossCacheRegionFactory.class, false, true);
cfg.setProperty(MultiplexingCacheInstanceManager.QUERY_CACHE_RESOURCE_PROP, configName);
// Use the local-query config for timestamps as well to save time
cfg.setProperty(MultiplexingCacheInstanceManager.TIMESTAMP_CACHE_RESOURCE_PROP, configName);
Configuration cfg = createConfiguration(configName);
JBossCacheRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
final QueryResultsRegion region = regionFactory.buildQueryResultsRegion("test/com.foo.test", cfg.getProperties());
final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg.getProperties());
region.put(KEY, VALUE1);
assertEquals(VALUE1, region.get(KEY));
@ -178,18 +177,15 @@ public class QueryRegionImplTestCase extends AbstractRegionImplTestCase {
private void getDoesNotBlockPutTest(String configName) throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", MultiplexedJBossCacheRegionFactory.class, false, true);
cfg.setProperty(MultiplexingCacheInstanceManager.QUERY_CACHE_RESOURCE_PROP, configName);
// Use the local-query config for timestamps as well to save time
cfg.setProperty(MultiplexingCacheInstanceManager.TIMESTAMP_CACHE_RESOURCE_PROP, configName);
Configuration cfg = createConfiguration(configName);
JBossCacheRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
final QueryResultsRegion region = regionFactory.buildQueryResultsRegion("test/com.foo.test", cfg.getProperties());
final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg.getProperties());
region.put(KEY, VALUE1);
assertEquals(VALUE1, region.get(KEY));
final Fqn rootFqn = getRegionFqn("test/com.foo.test", "test");
final Fqn rootFqn = getRegionFqn(getStandardRegionName(REGION_PREFIX), REGION_PREFIX);
final Cache jbc = getJBossCache(regionFactory);
final CountDownLatch blockerLatch = new CountDownLatch(1);
@ -276,16 +272,6 @@ public class QueryRegionImplTestCase extends AbstractRegionImplTestCase {
}
}
private void rollback() {
try {
BatchModeTransactionManager.getInstance().rollback();
}
catch (Exception e) {
log.error(e.getMessage(), e);
}
}
@CacheListener
public class GetBlocker {

View File

@ -20,11 +20,12 @@ import java.util.Properties;
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.Region;
import org.hibernate.cache.UpdateTimestampsCache;
import org.hibernate.cache.jbc2.BasicRegionAdapter;
import org.hibernate.cache.jbc2.CacheInstanceManager;
import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
import org.hibernate.cache.jbc2.timestamp.TimestampsRegionImpl;
import org.hibernate.test.cache.jbc2.AbstractRegionImplTestCase;
import org.hibernate.test.cache.jbc2.AbstractGeneralDataRegionTestCase;
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
@ -34,7 +35,7 @@ import org.jboss.cache.Fqn;
* @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision: 1 $
*/
public class TimestampsRegionImplTestCase extends AbstractRegionImplTestCase {
public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
/**
* Create a new EntityRegionImplTestCase.
@ -61,5 +62,11 @@ public class TimestampsRegionImplTestCase extends AbstractRegionImplTestCase {
return BasicRegionAdapter.getTypeFirstRegionFqn(regionName, regionPrefix, TimestampsRegionImpl.TYPE);
}
@Override
protected String getStandardRegionName(String regionPrefix) {
return regionPrefix + "/" + UpdateTimestampsCache.class.getName();
}
}