fixing test failures after merge
This commit is contained in:
parent
09e5bfe4d5
commit
b859388f57
|
@ -57,17 +57,22 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
protected static final String VALUE2 = "value2";
|
||||
|
||||
protected Configuration createConfiguration() {
|
||||
return CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, false, true );
|
||||
return CacheTestUtil.buildConfiguration(
|
||||
"test",
|
||||
org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase.TestInfinispanRegionFactory.class,
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void putInRegion(Region region, Object key, Object value) {
|
||||
((GeneralDataRegion) region).put( key, value );
|
||||
( (GeneralDataRegion) region ).put( key, value );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeFromRegion(Region region, Object key) {
|
||||
((GeneralDataRegion) region).evict( key );
|
||||
( (GeneralDataRegion) region ).evict( key );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -77,7 +82,10 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
|
||||
private void evictOrRemoveTest() throws Exception {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
InfinispanRegionFactory regionFactory = null;
|
||||
InfinispanRegionFactory remoteRegionFactory = null;
|
||||
try {
|
||||
regionFactory = CacheTestUtil.startRegionFactory(
|
||||
new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).build(),
|
||||
cfg,
|
||||
getCacheTestSupport()
|
||||
|
@ -93,14 +101,14 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
);
|
||||
|
||||
cfg = createConfiguration();
|
||||
regionFactory = CacheTestUtil.startRegionFactory(
|
||||
remoteRegionFactory = CacheTestUtil.startRegionFactory(
|
||||
new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).build(),
|
||||
cfg,
|
||||
getCacheTestSupport()
|
||||
);
|
||||
|
||||
GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(
|
||||
regionFactory,
|
||||
remoteRegionFactory,
|
||||
getStandardRegionName( REGION_PREFIX ),
|
||||
cfg.getProperties(),
|
||||
null
|
||||
|
@ -109,7 +117,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
assertNull( "local is clean", localRegion.get( KEY ) );
|
||||
assertNull( "remote is clean", remoteRegion.get( KEY ) );
|
||||
|
||||
regionPut(localRegion);
|
||||
regionPut( localRegion );
|
||||
assertEquals( VALUE1, localRegion.get( KEY ) );
|
||||
|
||||
// allow async propagation
|
||||
|
@ -117,20 +125,25 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
Object expected = invalidation ? null : VALUE1;
|
||||
assertEquals( expected, remoteRegion.get( KEY ) );
|
||||
|
||||
regionEvict(localRegion);
|
||||
regionEvict( localRegion );
|
||||
|
||||
// allow async propagation
|
||||
sleep( 250 );
|
||||
assertEquals( null, localRegion.get( KEY ) );
|
||||
assertEquals( null, remoteRegion.get( KEY ) );
|
||||
}
|
||||
finally {
|
||||
CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
|
||||
CacheTestUtil.stopRegionFactory( remoteRegionFactory, getCacheTestSupport() );
|
||||
}
|
||||
}
|
||||
|
||||
protected void regionEvict(GeneralDataRegion region) throws Exception {
|
||||
region.evict(KEY);
|
||||
region.evict( KEY );
|
||||
}
|
||||
|
||||
protected void regionPut(GeneralDataRegion region) throws Exception {
|
||||
region.put(KEY, VALUE1);
|
||||
region.put( KEY, VALUE1 );
|
||||
}
|
||||
|
||||
protected abstract String getStandardRegionName(String regionPrefix);
|
||||
|
@ -191,13 +204,13 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
assertNull( "local is clean", localRegion.get( KEY ) );
|
||||
assertNull( "remote is clean", remoteRegion.get( KEY ) );
|
||||
|
||||
regionPut(localRegion);
|
||||
regionPut( localRegion );
|
||||
assertEquals( VALUE1, localRegion.get( KEY ) );
|
||||
|
||||
// Allow async propagation
|
||||
sleep( 250 );
|
||||
|
||||
regionPut(remoteRegion);
|
||||
regionPut( remoteRegion );
|
||||
assertEquals( VALUE1, remoteRegion.get( KEY ) );
|
||||
|
||||
// Allow async propagation
|
||||
|
@ -225,7 +238,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
try {
|
||||
BatchModeTransactionManager.getInstance().rollback();
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch ( Exception e ) {
|
||||
log.error( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ public class NodeEnvironment {
|
|||
.applySettings(configuration.getProperties())
|
||||
.build();
|
||||
sessionFactory = (SessionFactoryImplementor)configuration.buildSessionFactory( serviceRegistry );
|
||||
// regionFactory = CacheTestUtil.startRegionFactory(serviceRegistry, configuration);
|
||||
regionFactory = (InfinispanRegionFactory)sessionFactory.getServiceRegistry().getService( RegionFactory.class );
|
||||
}
|
||||
|
||||
|
@ -142,11 +141,6 @@ public class NodeEnvironment {
|
|||
}
|
||||
} finally {
|
||||
try {
|
||||
// if (regionFactory != null) {
|
||||
// // Currently the RegionFactory is shutdown by its registration
|
||||
// // with the CacheTestSetup from CacheTestUtil when built
|
||||
// regionFactory.stop();
|
||||
// }
|
||||
if(sessionFactory!=null){
|
||||
sessionFactory.close();
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
|
|||
|
||||
protected static Configuration createConfiguration(String configName) {
|
||||
Configuration cfg = CacheTestUtil.buildConfiguration(
|
||||
REGION_PREFIX, InfinispanRegionFactory.class, true, false
|
||||
REGION_PREFIX, org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase.TestInfinispanRegionFactory.class, true, false
|
||||
);
|
||||
cfg.setProperty( InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, configName );
|
||||
return cfg;
|
||||
|
|
|
@ -123,7 +123,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
|
|||
protected static Configuration createConfiguration(String configName) {
|
||||
Configuration cfg = CacheTestUtil.buildConfiguration(
|
||||
REGION_PREFIX,
|
||||
InfinispanRegionFactory.class,
|
||||
org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase.TestInfinispanRegionFactory.class,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
|
|
@ -136,6 +136,7 @@ public abstract class DualNodeTestCase extends BaseCoreFunctionalTestCase {
|
|||
cfg.setProperty( Environment.TRANSACTION_STRATEGY, getTransactionFactoryClass().getName() );
|
||||
cfg.setProperty( Environment.CACHE_REGION_FACTORY, getCacheRegionFactory().getName() );
|
||||
cfg.setProperty( Environment.USE_QUERY_CACHE, String.valueOf( getUseQueryCache() ) );
|
||||
cfg.setProperty( USE_NEW_METADATA_MAPPINGS, "false" );
|
||||
}
|
||||
|
||||
public class SecondNodeEnvironment {
|
||||
|
@ -173,6 +174,7 @@ public abstract class DualNodeTestCase extends BaseCoreFunctionalTestCase {
|
|||
if ( sessionFactory != null ) {
|
||||
try {
|
||||
sessionFactory.close();
|
||||
sessionFactory = null;
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
|
@ -180,6 +182,7 @@ public abstract class DualNodeTestCase extends BaseCoreFunctionalTestCase {
|
|||
if ( serviceRegistry != null ) {
|
||||
try {
|
||||
serviceRegistry.destroy();
|
||||
serviceRegistry = null;
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
|
|
|
@ -44,7 +44,10 @@ public class NaturalIdInvalidationTestCase extends DualNodeTestCase {
|
|||
private static final long SLEEP_TIME = 50l;
|
||||
private static final Integer CUSTOMER_ID = new Integer( 1 );
|
||||
private static int test = 0;
|
||||
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
return new String[]{};
|
||||
}
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
|
|
|
@ -106,7 +106,11 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
|
|||
|
||||
@Override
|
||||
protected Configuration createConfiguration() {
|
||||
return CacheTestUtil.buildCustomQueryCacheConfiguration( "test", "replicated-query" );
|
||||
Configuration cfg = super.createConfiguration();
|
||||
cfg.setProperty(InfinispanRegionFactory.QUERY_CACHE_RESOURCE_PROP, "replicated-query");
|
||||
|
||||
// return CacheTestUtil.buildCustomQueryCacheConfiguration( "test", "replicated-query" );
|
||||
return cfg;
|
||||
}
|
||||
|
||||
private void putDoesNotBlockGetTest() throws Exception {
|
||||
|
|
|
@ -57,34 +57,6 @@ public class CacheTestUtil {
|
|||
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 reg,
|
||||
Configuration cfg){
|
||||
try {
|
||||
Settings settings = cfg.buildSettings(reg);
|
||||
Properties properties = cfg.getProperties();
|
||||
|
||||
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) {
|
||||
SessionFactoryImplementor sessionFactory =(SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||
|
@ -95,7 +67,9 @@ public class CacheTestUtil {
|
|||
|
||||
public static void stopRegionFactory(InfinispanRegionFactory factory,
|
||||
CacheTestSupport testSupport) {
|
||||
testSupport.unregisterFactory(factory).close();
|
||||
if ( factory != null ) {
|
||||
testSupport.unregisterFactory( factory ).close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue