diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java index f48d77acf8..2b4868fbdc 100755 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java @@ -102,10 +102,6 @@ public class TransactionalAccessDelegate { cache.clear(); } -// public void evict(Object key) throws CacheException { -// cache.evict(key); -// } - public void evictAll() throws CacheException { evictOrRemoveAll(); } diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java index 2c8b7ff08f..41a00deaf5 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java @@ -17,7 +17,7 @@ import org.infinispan.Cache; */ public class CollectionRegionImpl extends BaseTransactionalDataRegion implements CollectionRegion { - public CollectionRegionImpl(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) { + public CollectionRegionImpl(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) { super(cache, name, metadata, transactionManager); } diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java index 89d578a49a..7fe5d1acf6 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java @@ -25,7 +25,6 @@ class TransactionalAccess implements CollectionRegionAccessStrategy { } public void evict(Object key) throws CacheException { -// delegate.evict(key); delegate.remove(key); } diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java index 187b575001..58d4dd5b68 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java @@ -17,7 +17,7 @@ import org.infinispan.Cache; */ public class EntityRegionImpl extends BaseTransactionalDataRegion implements EntityRegion { - public EntityRegionImpl(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) { + public EntityRegionImpl(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) { super(cache, name, metadata, transactionManager); } diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java index 8ef8dd4042..9661a75f45 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java @@ -15,7 +15,7 @@ import org.infinispan.Cache; */ public abstract class BaseGeneralDataRegion extends BaseRegion implements GeneralDataRegion { - public BaseGeneralDataRegion(Cache cache, String name, TransactionManager transactionManager) { + public BaseGeneralDataRegion(Cache cache, String name, TransactionManager transactionManager) { super(cache, name, transactionManager); } diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java index f1da7e29b6..5202d84847 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java @@ -137,44 +137,5 @@ public abstract class BaseRegion implements Region { throw new CacheException("Could not resume transaction", e); } } - -// /** -// * HACKY WAY TO GET THE TRANSACTION MANAGER, TODO: resolve it! -// */ -// private static TransactionManager getTransactionManager(Properties properties) { -//// return cache == null ? null : extractComponent(cache, TransactionManager.class); -// return TransactionManagerLookupFactory.getTransactionManager(properties); -// } -// -// public static T extractComponent(Cache cache, Class componentType) { -// ComponentRegistry cr = extractComponentRegistry(cache); -// return cr.getComponent(componentType); -// } -// -// public static ComponentRegistry extractComponentRegistry(Cache cache) { -// return (ComponentRegistry) extractField(cache, "componentRegistry"); -// } -// -// public static Object extractField(Object target, String fieldName) { -// return extractField(target.getClass(), target, fieldName); -// } -// -// public static Object extractField(Class type, Object target, String fieldName) { -// Field field; -// try { -// field = type.getDeclaredField(fieldName); -// field.setAccessible(true); -// return field.get(target); -// } -// catch (Exception e) { -// if (type.equals(Object.class)) { -// e.printStackTrace(); -// return null; -// } else { -// // try with superclass!! -// return extractField(type.getSuperclass(), target, fieldName); -// } -// } -// } } \ No newline at end of file diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java index 79fac91d95..f4949919be 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java @@ -17,7 +17,7 @@ public abstract class BaseTransactionalDataRegion extends BaseRegion implements private final CacheDataDescription metadata; - public BaseTransactionalDataRegion(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) { + public BaseTransactionalDataRegion(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) { super(cache, name, transactionManager); this.metadata = metadata; } diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java index 299a526f5d..fe2415cb4c 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java @@ -19,7 +19,7 @@ import org.infinispan.context.Flag; public class QueryResultsRegionImpl extends BaseTransactionalDataRegion implements QueryResultsRegion { private boolean localOnly; - public QueryResultsRegionImpl(Cache cache, String name, Properties properties, TransactionManager transactionManager) { + public QueryResultsRegionImpl(Cache cache, String name, Properties properties, TransactionManager transactionManager) { super(cache, name, null, transactionManager); // If Infinispan is using INVALIDATION for query cache, we don't want to propagate changes. diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java index 47fc706805..2609ff6f85 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java @@ -31,7 +31,7 @@ public class TimestampsRegionImpl extends BaseGeneralDataRegion implements Times private Map localCache = new ConcurrentHashMap(); - public TimestampsRegionImpl(Cache cache, String name, TransactionManager transactionManager) { + public TimestampsRegionImpl(Cache cache, String name, TransactionManager transactionManager) { super(cache, name, transactionManager); cache.addListener(this); populateLocalCache(); @@ -99,14 +99,6 @@ public class TimestampsRegionImpl extends BaseGeneralDataRegion implements Times public void nodeRemoved(CacheEntryRemovedEvent event) { if (event.isPre()) return; localCache.remove(event.getKey()); -// Fqn fqn = event.getFqn(); -// Fqn regFqn = getRegionFqn(); -// if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) { -// Object key = fqn.get(regFqn.size()); -// localCache.remove(key); -// } else if (fqn.equals(regFqn)) { -// localCache.clear(); -// } } /** diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java index cb243d60a5..d9fdda2455 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java @@ -36,18 +36,11 @@ import org.slf4j.LoggerFactory; /** * Helper for dealing with Infinisan cache instances. * - * @author Steve Ebersole - * @author Brian Stansberry * @author Galder ZamarreƱo * @since 3.5 */ public class CacheHelper { - /** Key under which items are cached */ - public static final String ITEM = "item"; - /** Key and value used in a hack to create region root nodes */ - public static final String DUMMY = "dummy"; - private static final Logger log = LoggerFactory.getLogger(CacheHelper.class); /** @@ -368,14 +361,6 @@ public class CacheHelper { } } -// public static void evict(Cache cache, Object key) throws CacheException { -// try { -// cache.evict(key); -// } catch (Exception e) { -// throw new CacheException(e); -// } -// } - public static boolean containsKey(Cache cache, Object key, Flag... flags) { try { return cache.getAdvancedCache().containsKey(key, flags); @@ -384,64 +369,4 @@ public class CacheHelper { } } -// public static Node addNode(Cache cache, Fqn fqn, boolean localOnly, boolean resident) throws CacheException { -// try { -// Option option = null; -// if (localOnly) { -// option = new Option(); -// option.setCacheModeLocal(localOnly); -// } -// -// Node root = cache.getRoot(); -// setInvocationOption(cache, option); -// // FIXME hack to work around fact that calling -// // Node added = root.addChild( fqn ); doesn't -// // properly set the version on the node -// Node added = null; -// if (version == null) { -// added = root.addChild(fqn); -// } else { -// cache.put(fqn, DUMMY, DUMMY); -// added = root.getChild(fqn); -// } -// if (resident) -// added.setResident(true); -// return added; -// } catch (Exception e) { -// throw new CacheException(e); -// } -// } - - /** -// * Assigns the given Option to the cache's {@link InvocationContext}. Does nothing if -// * option is null. -// * -// * @param cache -// * the cache. Cannot be null. -// * @param option -// * the option. May be null. -// * -// * @see {@link Cache#getInvocationContext()} -// * @see {@link InvocationContext#setOptionOverrides(Option)} -// */ -// public static void setInvocationOption(Cache cache, Option option) { -// if (option != null) { -// cache.getInvocationContext().setOptionOverrides(option); -// } -// } - -// /** -// * Creates an {@link Option} using the given {@link DataVersion} and passes it to -// * {@link #setInvocationOption(Cache, Option)}. -// * -// * @param cache -// * the cache to set the Option on. Cannot be null. -// * @param version -// * the DataVersion to set. Cannot be null. -// */ -// public static void setDataVersionOption(Cache cache, DataVersion version) { -// Option option = new Option(); -// option.setDataVersion(version); -// setInvocationOption(cache, option); -// } } diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java index 5f8b7487bd..c196a1e9dc 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java @@ -42,87 +42,68 @@ import org.hibernate.test.cache.infinispan.util.CacheTestUtil; */ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractRegionImplTestCase { - /** - * Create a new EntityCollectionRegionTestCaseBase. - * - * @param name - */ - public AbstractEntityCollectionRegionTestCase(String name) { - super(name); - } - - /** - * Creates a Region backed by an PESSIMISTIC locking JBoss Cache, and then - * ensures that it handles calls to buildAccessStrategy as expected when - * all the various {@link AccessType}s are passed as arguments. - */ - public void testSupportedAccessTypes() throws Exception { - supportedAccessTypeTest(); - } - - private void supportedAccessTypeTest() throws Exception { - Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); - String entityCfg = "entity"; - cfg.setProperty(InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg); - InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); - supportedAccessTypeTest(regionFactory, cfg.getProperties()); - } - - /** - * Creates a Region using the given factory, and then ensure that it - * handles calls to buildAccessStrategy as expected when all the - * various {@link AccessType}s are passed as arguments. - */ - protected abstract void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties); - - /** - * Test that the Region properly implements - * {@link TransactionalDataRegion#isTransactionAware()}. - * - * @throws Exception - */ - public void testIsTransactionAware() throws Exception { - Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); -// cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, CacheTestUtil.LOCAL_PESSIMISTIC_CACHE); + /** + * Create a new EntityCollectionRegionTestCaseBase. + * + * @param name + */ + public AbstractEntityCollectionRegionTestCase(String name) { + super(name); + } - InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); - - TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); - - assertTrue("Region is transaction-aware", region.isTransactionAware()); - - CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport()); - - cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); -// cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, CacheTestUtil.LOCAL_PESSIMISTIC_CACHE); - // Make it non-transactional - cfg.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY); - - regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); - - region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); - - assertFalse("Region is not transaction-aware", region.isTransactionAware()); - - CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport()); - } - - public void testGetCacheDataDescription() throws Exception { - Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); -// cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, CacheTestUtil.LOCAL_PESSIMISTIC_CACHE); - - InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); - - TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); - - CacheDataDescription cdd = region.getCacheDataDescription(); - - assertNotNull(cdd); - - CacheDataDescription expected = getCacheDataDescription(); - assertEquals(expected.isMutable(), cdd.isMutable()); - assertEquals(expected.isVersioned(), cdd.isVersioned()); - assertEquals(expected.getVersionComparator(), cdd.getVersionComparator()); - - } + /** + * Creates a Region backed by an PESSIMISTIC locking JBoss Cache, and then ensures that it + * handles calls to buildAccessStrategy as expected when all the various {@link AccessType}s are + * passed as arguments. + */ + public void testSupportedAccessTypes() throws Exception { + supportedAccessTypeTest(); + } + + private void supportedAccessTypeTest() throws Exception { + Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); + String entityCfg = "entity"; + cfg.setProperty(InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg); + InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); + supportedAccessTypeTest(regionFactory, cfg.getProperties()); + } + + /** + * Creates a Region using the given factory, and then ensure that it handles calls to + * buildAccessStrategy as expected when all the various {@link AccessType}s are passed as + * arguments. + */ + protected abstract void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties); + + /** + * Test that the Region properly implements {@link TransactionalDataRegion#isTransactionAware()}. + * + * @throws Exception + */ + public void testIsTransactionAware() throws Exception { + Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); + InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); + TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); + assertTrue("Region is transaction-aware", region.isTransactionAware()); + CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport()); + cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); + // Make it non-transactional + cfg.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY); + regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); + region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); + assertFalse("Region is not transaction-aware", region.isTransactionAware()); + CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport()); + } + + public void testGetCacheDataDescription() throws Exception { + Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false); + InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); + TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()); + CacheDataDescription cdd = region.getCacheDataDescription(); + assertNotNull(cdd); + CacheDataDescription expected = getCacheDataDescription(); + assertEquals(expected.isMutable(), cdd.isMutable()); + assertEquals(expected.isVersioned(), cdd.isVersioned()); + assertEquals(expected.getVersionComparator(), cdd.getVersionComparator()); + } } diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java index 3e4b0811b9..2103b629b3 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java @@ -124,7 +124,6 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); Cache localCache = getInfinispanCache(regionFactory); -// boolean invalidation = CacheHelper.isClusteredInvalidation(localCache); // Sleep a bit to avoid concurrent FLUSH problem avoidConcurrentFlush(); @@ -141,7 +140,6 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null); -// String regionName = REGION_PREFIX; Set children = CacheHelper.getKeySet(localCache); assertEquals("No children in " + children, 0, children.size()); diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java index 7a7fa18ba4..51557fa811 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/AbstractCollectionRegionAccessStrategyTestCase.java @@ -402,18 +402,8 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs final String KEY = KEY_BASE + testCount++; - // Fqn regionFqn = getRegionFqn(REGION_NAME, REGION_PREFIX); - // - // Node regionRoot = localCache.getRoot().getChild(regionFqn); - // assertFalse(regionRoot == null); - // assertEquals(0, getValidChildrenCount(regionRoot)); - // assertTrue(regionRoot.isResident()); assertEquals(0, localCache.keySet().size()); - // regionRoot = remoteCache.getRoot().getChild(regionFqn); - // assertFalse(regionRoot == null); - // assertEquals(0, getValidChildrenCount(regionRoot)); - // assertTrue(regionRoot.isResident()); assertEquals(0, remoteCache.keySet().size()); assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis())); @@ -435,37 +425,18 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs // This should re-establish the region root node assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); - // regionRoot = localCache.getRoot().getChild(regionFqn); - // assertFalse(regionRoot == null); - // assertEquals(0, getValidChildrenCount(regionRoot)); - // assertTrue(regionRoot.isValid()); - // assertTrue(regionRoot.isResident()); assertEquals(0, localCache.keySet().size()); // Re-establishing the region root on the local node doesn't // propagate it to other nodes. Do a get on the remote node to re-establish assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - // regionRoot = remoteCache.getRoot().getChild(regionFqn); - // assertFalse(regionRoot == null); - // assertTrue(regionRoot.isValid()); - // assertTrue(regionRoot.isResident()); - // - // assertEquals(0, getValidChildrenCount(regionRoot)); - // Not invalidation, so we didn't insert a child above assertEquals(0, remoteCache.keySet().size()); // Test whether the get above messes up the optimistic version remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - // regionRoot = remoteCache.getRoot().getChild(regionFqn); - // assertFalse(regionRoot == null); - // assertTrue(regionRoot.isValid()); - // assertTrue(regionRoot.isResident()); - // // Region root should have 1 child -- the one we added above - // assertEquals(1, getValidChildrenCount(regionRoot)); - // Revalidate the region root assertEquals(1, remoteCache.keySet().size()); // Wait for async propagation of the putFromLoad diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java index 15e2ec8791..8cde37e781 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractEntityRegionAccessStrategyTestCase.java @@ -415,14 +415,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac inserter.start(); reader.start(); -// if (!isBlockingReads()) - assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS)); -// else { -// // Reader should be blocking for lock -// assertFalse("Threads completed", completionLatch.await(250, TimeUnit.MILLISECONDS)); -// commitLatch.countDown(); -// assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS)); -// } + assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS)); assertThreadsRanCleanly(); @@ -496,10 +489,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac readLatch.await(); log.debug("Read latch acquired, verify local access strategy"); - // This will block w/ pessimistic locking and then - // read the new value; w/ optimistic it shouldn't - // block and will read the old value -// Object expected = !isBlockingReads() ? VALUE1 : VALUE2; + // This won't block w/ mvc and will read the old value Object expected = VALUE1; assertEquals("Correct value", expected, localAccessStrategy.get(KEY, txTimestamp)); @@ -524,16 +514,8 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac updater.start(); reader.start(); -// if (!isBlockingReads()) - // Should complete promptly - assertTrue(completionLatch.await(2, TimeUnit.SECONDS)); -// else { -// // Reader thread should be blocking -// assertFalse(completionLatch.await(250, TimeUnit.MILLISECONDS)); -// // Let the writer commit down -// commitLatch.countDown(); -// assertTrue(completionLatch.await(1, TimeUnit.SECONDS)); -// } + // Should complete promptly + assertTrue(completionLatch.await(2, TimeUnit.SECONDS)); assertThreadsRanCleanly(); @@ -599,8 +581,6 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac assertEquals(null, localAccessStrategy.get(KEY, System.currentTimeMillis())); - // sleep(1000); - assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); } @@ -608,17 +588,8 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac final String KEY = KEY_BASE + testCount++; -// Fqn regionFqn = getRegionFqn(REGION_NAME, REGION_PREFIX); -// -// Node regionRoot = localCache.getRoot().getChild(regionFqn); -// assertFalse(regionRoot == null); assertEquals(0, localCache.keySet().size()); -// assertTrue(regionRoot.isResident()); - -// regionRoot = remoteCache.getRoot().getChild(regionFqn); -// assertFalse(regionRoot == null); assertEquals(0, remoteCache.keySet().size()); -// assertTrue(regionRoot.isResident()); assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis())); assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis())); @@ -643,36 +614,18 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac // This should re-establish the region root node in the optimistic case assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); -// regionRoot = localCache.getRoot().getChild(regionFqn); -// assertFalse(regionRoot == null); -// assertEquals(0, getValidChildrenCount(regionRoot)); -// assertTrue(regionRoot.isValid()); -// assertTrue(regionRoot.isResident()); assertEquals(0, localCache.keySet().size()); // Re-establishing the region root on the local node doesn't // propagate it to other nodes. Do a get on the remote node to re-establish assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); -// regionRoot = remoteCache.getRoot().getChild(regionFqn); -// assertFalse(regionRoot == null); -// assertTrue(regionRoot.isValid()); -// assertTrue(regionRoot.isResident()); -// // Not invalidation, so we didn't insert a child above -// assertEquals(0, getValidChildrenCount(regionRoot)); assertEquals(0, remoteCache.keySet().size()); // Test whether the get above messes up the optimistic version remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - // Revalidate the region root -// regionRoot = remoteCache.getRoot().getChild(regionFqn); -// assertFalse(regionRoot == null); -// assertTrue(regionRoot.isValid()); -// assertTrue(regionRoot.isResident()); -// // Region root should have 1 child -- the one we added above -// assertEquals(1, getValidChildrenCount(regionRoot)); assertEquals(1, remoteCache.keySet().size()); // Wait for async propagation @@ -720,11 +673,9 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac localCfg = createConfiguration(configName); localRegionFactory = CacheTestUtil.startRegionFactory(localCfg); -// localCache = localRegionFactory.getCacheManager().getCache("entity"); remoteCfg = createConfiguration(configName); remoteRegionFactory = CacheTestUtil.startRegionFactory(remoteCfg); -// remoteCache = remoteRegionFactory.getCacheManager().getCache("entity"); } @Override diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java index 9d87abff76..d3bee8471d 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java @@ -28,7 +28,6 @@ public abstract class AbstractFunctionalTestCase extends FunctionalTestCase { } public void testEmptySecondLevelCacheEntry() throws Exception { -// getSessions().evictEntity(Item.class.getName()); getSessions().getCache().evictEntityRegion(Item.class.getName()); Statistics stats = getSessions().getStatistics(); stats.clear(); diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java index 061047313d..3efebe21cb 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java @@ -69,13 +69,11 @@ public class BulkOperationsTestCase extends FunctionalTestCase { } protected Class getConnectionProviderClass() { -// return org.hibernate.test.tm.ConnectionProviderImpl.class; return org.hibernate.test.cache.infinispan.tm.XaConnectionProvider.class; } protected Class getTransactionManagerLookupClass() { return org.hibernate.test.cache.infinispan.tm.XaTransactionManagerLookup.class; -// return org.hibernate.test.tm.TransactionManagerLookupImpl.class; } public void configure(Configuration cfg) { @@ -245,25 +243,6 @@ public class BulkOperationsTestCase extends FunctionalTestCase { } } -// public void cleanup() throws Exception { -// String deleteContactHQL = "delete from Contact"; -// String deleteCustomerHQL = "delete from Customer"; -// tm.begin(); -// try { -// Session session = getSessions().getCurrentSession(); -// session.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate(); -// session.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate(); -// tm.commit(); -// } catch (Exception e) { -// try { -// tm.rollback(); -// } catch (Exception ee) { -// // ignored -// } -// throw e; -// } -// } - public void cleanup(boolean ignore) throws Exception { String deleteContactHQL = "delete from Contact"; String deleteCustomerHQL = "delete from Customer"; diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/CacheAccessListener.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/CacheAccessListener.java index 04712bbcf1..528dcd57b6 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/CacheAccessListener.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/CacheAccessListener.java @@ -40,8 +40,6 @@ import org.slf4j.LoggerFactory; public class CacheAccessListener { protected final Logger log = LoggerFactory.getLogger(getClass()); -// HashSet> modified = new HashSet>(); -// HashSet> accessed = new HashSet>(); HashSet modified = new HashSet(); HashSet accessed = new HashSet(); @@ -107,19 +105,6 @@ public class CacheAccessListener { return true; } return false; -// boolean saw = false; -// for (Object key : sawEvents) { -// -// } -// Fqn fqn = Fqn.fromString(regionName); -// for (Iterator> it = sawEvent.iterator(); it.hasNext();) { -// Fqn modified = (Fqn) it.next(); -// if (modified.isChildOf(fqn)) { -// it.remove(); -// saw = true; -// } -// } -// return saw; - } + } } \ No newline at end of file diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/IsolatedCacheTestSetup.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/IsolatedCacheTestSetup.java index 667303bc74..125be92846 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/IsolatedCacheTestSetup.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/IsolatedCacheTestSetup.java @@ -16,21 +16,16 @@ package org.hibernate.test.cache.infinispan.functional.classloader; -import org.hibernate.cache.infinispan.InfinispanRegionFactory; -import org.hibernate.test.cache.infinispan.functional.cluster.AbstractDualNodeTestCase; import org.hibernate.test.cache.infinispan.functional.cluster.ClusterAwareRegionFactory; import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl; -import org.hibernate.util.PropertiesHelper; -import org.infinispan.manager.CacheManager; -import org.infinispan.manager.DefaultCacheManager; import junit.framework.Test; /** * A TestSetup that uses SelectedClassnameClassLoader to ensure that certain classes are not visible - * to JBoss Cache or JGroups' classloader. + * to Infinispan or JGroups' classloader. * - * @author Brian Stansberry + * @author Galder ZamarreƱo */ public class IsolatedCacheTestSetup extends SelectedClassnameClassLoaderTestSetup { @@ -43,42 +38,16 @@ public class IsolatedCacheTestSetup extends SelectedClassnameClassLoaderTestSetu public IsolatedCacheTestSetup(Test test, String[] isolatedClasses) { super(test, null, null, isolatedClasses); this.isolatedClasses = isolatedClasses; -// this.cacheConfig = cacheConfig; } @Override protected void setUp() throws Exception { super.setUp(); -// // At this point the TCCL cannot see the isolatedClasses -// // We want the caches to use this CL as their default classloader - + // At this point the TCCL cannot see the isolatedClasses + // We want the caches to use this CL as their default classloader ClassLoader tccl = Thread.currentThread().getContextClassLoader(); -// org.jgroups.ChannelFactory cf = new org.jgroups.JChannelFactory(); -// cf.setMultiplexerConfig(DEF_JGROUPS_RESOURCE); -// -// // Use a CacheManager that will inject the desired defaultClassLoader into our caches -// CustomClassLoaderCacheManager cm = new CustomClassLoaderCacheManager(DEF_CACHE_FACTORY_RESOURCE, cf, tccl); -// cm.start(); - -// CacheManager manager = new DefaultCacheManager("org/hibernate/test/cache/infinispan/functional/classloader/infinispan-configs.xml"); -// ClusterAwareRegionFactory.addCacheManager(AbstractDualNodeTestCase.LOCAL, manager); -// ClusterAwareRegionFactory.addCacheManager(AbstractDualNodeTestCase.REMOTE, manager); - -// cm.getCache(cacheConfig, true); -// -// // Repeat for the "remote" cache -// -// cf = new org.jgroups.JChannelFactory(); -// cf.setMultiplexerConfig(DEF_JGROUPS_RESOURCE); -// -// cm = new CustomClassLoaderCacheManager(DEF_CACHE_FACTORY_RESOURCE, cf, tccl); -// cm.start(); -// TestCacheInstanceManager.addTestCacheManager(DualNodeTestUtil.REMOTE, cm); -// -// cm.getCache(cacheConfig, true); - // Now make the isolatedClasses visible to the test driver itself SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(isolatedClasses, null, null, tccl); Thread.currentThread().setContextClassLoader(visible); diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoader.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoader.java index 0e23706673..33623ddb83 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoader.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoader.java @@ -33,31 +33,26 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * A ClassLoader that loads classes whose classname begins with one of a - * given set of strings, without attempting first to delegate to its - * parent loader. + * A ClassLoader that loads classes whose classname begins with one of a given set of strings, + * without attempting first to delegate to its parent loader. *

- * This class is intended to allow emulation of 2 different types of common J2EE - * classloading situations. + * This class is intended to allow emulation of 2 different types of common J2EE classloading + * situations. *

    - *
  • Servlet-style child-first classloading, where this class is the - * child loader.
  • - *
  • Parent-first classloading where the parent does not have access to - * certain classes
  • + *
  • Servlet-style child-first classloading, where this class is the child loader.
  • + *
  • Parent-first classloading where the parent does not have access to certain classes
  • *
*

*

- * This class can also be configured to raise a ClassNotFoundException if - * asked to load certain classes, thus allowing classes on the classpath - * to be hidden from a test environment. + * This class can also be configured to raise a ClassNotFoundException if asked to load certain + * classes, thus allowing classes on the classpath to be hidden from a test environment. *

- * + * * @author Brian Stansberry */ -public class SelectedClassnameClassLoader extends ClassLoader -{ +public class SelectedClassnameClassLoader extends ClassLoader { private Logger log = LoggerFactory.getLogger(SelectedClassnameClassLoader.class); - + private String[] includedClasses = null; private String[] excludedClasses = null; private String[] notFoundClasses = null; @@ -66,115 +61,82 @@ public class SelectedClassnameClassLoader extends ClassLoader /** * Creates a new classloader that loads the given classes. - * - * @param includedClasses array of class or package names that should be - * directly loaded by this loader. Classes - * whose name starts with any of the strings - * in this array will be loaded by this class, - * unless their name appears in - * excludedClasses. - * Can be null - * @param excludedClasses array of class or package names that should NOT - * be directly loaded by this loader. Loading of - * classes whose name starts with any of the - * strings in this array will be delegated to - * parent, even if the classes - * package or classname appears in - * includedClasses. Typically this - * parameter is used to exclude loading one or - * more classes in a package whose other classes - * are loaded by this object. - * @param parent ClassLoader to which loading of classes should - * be delegated if necessary + * + * @param includedClasses + * array of class or package names that should be directly loaded by this loader. + * Classes whose name starts with any of the strings in this array will be loaded by + * this class, unless their name appears in excludedClasses. Can be + * null + * @param excludedClasses + * array of class or package names that should NOT be directly loaded by this loader. + * Loading of classes whose name starts with any of the strings in this array will be + * delegated to parent, even if the classes package or classname appears + * in includedClasses. Typically this parameter is used to exclude loading + * one or more classes in a package whose other classes are loaded by this object. + * @param parent + * ClassLoader to which loading of classes should be delegated if necessary */ - public SelectedClassnameClassLoader(String[] includedClasses, - String[] excludedClasses, - ClassLoader parent) - { + public SelectedClassnameClassLoader(String[] includedClasses, String[] excludedClasses, ClassLoader parent) { this(includedClasses, excludedClasses, null, parent); } /** * Creates a new classloader that loads the given classes. - * - * @param includedClasses array of class or package names that should be - * directly loaded by this loader. Classes - * whose name starts with any of the strings - * in this array will be loaded by this class, - * unless their name appears in - * excludedClasses. - * Can be null - * @param excludedClasses array of class or package names that should NOT - * be directly loaded by this loader. Loading of - * classes whose name starts with any of the - * strings in this array will be delegated to - * parent, even if the classes - * package or classname appears in - * includedClasses. Typically this - * parameter is used to exclude loading one or - * more classes in a package whose other classes - * are loaded by this object. - * @param notFoundClasses array of class or package names for which this - * should raise a ClassNotFoundException - * @param parent ClassLoader to which loading of classes should - * be delegated if necessary + * + * @param includedClasses + * array of class or package names that should be directly loaded by this loader. + * Classes whose name starts with any of the strings in this array will be loaded by + * this class, unless their name appears in excludedClasses. Can be + * null + * @param excludedClasses + * array of class or package names that should NOT be directly loaded by this loader. + * Loading of classes whose name starts with any of the strings in this array will be + * delegated to parent, even if the classes package or classname appears + * in includedClasses. Typically this parameter is used to exclude loading + * one or more classes in a package whose other classes are loaded by this object. + * @param notFoundClasses + * array of class or package names for which this should raise a ClassNotFoundException + * @param parent + * ClassLoader to which loading of classes should be delegated if necessary */ - public SelectedClassnameClassLoader(String[] includedClasses, - String[] excludedClasses, - String[] notFoundClasses, - ClassLoader parent) - { + public SelectedClassnameClassLoader(String[] includedClasses, String[] excludedClasses, String[] notFoundClasses, + ClassLoader parent) { super(parent); this.includedClasses = includedClasses; this.excludedClasses = excludedClasses; this.notFoundClasses = notFoundClasses; - + log.debug("created " + this); } - protected synchronized Class loadClass(String name, boolean resolve) - throws ClassNotFoundException - { + protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { log.trace("loadClass(" + name + "," + resolve + ")"); - if (isIncluded(name) && (isExcluded(name) == false)) - { + if (isIncluded(name) && (isExcluded(name) == false)) { Class c = findClass(name); - if (resolve) - { + if (resolve) { resolveClass(c); } return c; - } - else if (isNotFound(name)) - { + } else if (isNotFound(name)) { throw new ClassNotFoundException(name + " is discarded"); - } - else - { + } else { return super.loadClass(name, resolve); } } - protected Class findClass(String name) throws ClassNotFoundException - { + protected Class findClass(String name) throws ClassNotFoundException { log.trace("findClass(" + name + ")"); Class result = classes.get(name); - if (result != null) - { + if (result != null) { return result; } - if (isIncluded(name) && (isExcluded(name) == false)) - { + if (isIncluded(name) && (isExcluded(name) == false)) { result = createClass(name); - } - else if (isNotFound(name)) - { + } else if (isNotFound(name)) { throw new ClassNotFoundException(name + " is discarded"); - } - else - { + } else { result = super.findClass(name); } @@ -183,41 +145,30 @@ public class SelectedClassnameClassLoader extends ClassLoader return result; } - protected Class createClass(String name) throws ClassFormatError, ClassNotFoundException - { + protected Class createClass(String name) throws ClassFormatError, ClassNotFoundException { log.info("createClass(" + name + ")"); - try - { + try { InputStream is = getResourceAsStream(name.replace('.', '/').concat(".class")); byte[] bytes = new byte[1024]; ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); int read; - while ((read = is.read(bytes)) > -1) - { + while ((read = is.read(bytes)) > -1) { baos.write(bytes, 0, read); } bytes = baos.toByteArray(); return this.defineClass(name, bytes, 0, bytes.length); - } - catch (FileNotFoundException e) - { + } catch (FileNotFoundException e) { throw new ClassNotFoundException("cannot find " + name, e); - } - catch (IOException e) - { + } catch (IOException e) { throw new ClassNotFoundException("cannot read " + name, e); } } - protected boolean isIncluded(String className) - { + protected boolean isIncluded(String className) { - if (includedClasses != null) - { - for (int i = 0; i < includedClasses.length; i++) - { - if (className.startsWith(includedClasses[i])) - { + if (includedClasses != null) { + for (int i = 0; i < includedClasses.length; i++) { + if (className.startsWith(includedClasses[i])) { return true; } } @@ -226,15 +177,11 @@ public class SelectedClassnameClassLoader extends ClassLoader return false; } - protected boolean isExcluded(String className) - { + protected boolean isExcluded(String className) { - if (excludedClasses != null) - { - for (int i = 0; i < excludedClasses.length; i++) - { - if (className.startsWith(excludedClasses[i])) - { + if (excludedClasses != null) { + for (int i = 0; i < excludedClasses.length; i++) { + if (className.startsWith(excludedClasses[i])) { return true; } } @@ -243,15 +190,11 @@ public class SelectedClassnameClassLoader extends ClassLoader return false; } - protected boolean isNotFound(String className) - { + protected boolean isNotFound(String className) { - if (notFoundClasses != null) - { - for (int i = 0; i < notFoundClasses.length; i++) - { - if (className.startsWith(notFoundClasses[i])) - { + if (notFoundClasses != null) { + for (int i = 0; i < notFoundClasses.length; i++) { + if (className.startsWith(notFoundClasses[i])) { return true; } } @@ -259,8 +202,8 @@ public class SelectedClassnameClassLoader extends ClassLoader return false; } - - public String toString() { + + public String toString() { String s = getClass().getName(); s += "[includedClasses="; s += listClasses(includedClasses); @@ -273,9 +216,10 @@ public class SelectedClassnameClassLoader extends ClassLoader s += "]"; return s; } - + private static String listClasses(String[] classes) { - if (classes == null) return null; + if (classes == null) + return null; String s = ""; for (int i = 0; i < classes.length; i++) { if (i > 0) @@ -284,5 +228,5 @@ public class SelectedClassnameClassLoader extends ClassLoader } return s; } - + } diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoaderTestSetup.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoaderTestSetup.java index 74c12ec4ca..9b011b2b73 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoaderTestSetup.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/classloader/SelectedClassnameClassLoaderTestSetup.java @@ -20,30 +20,24 @@ import junit.extensions.TestSetup; import junit.framework.Test; /** - * A TestSetup that makes SelectedClassnameClassLoader the thread - * context classloader for the duration of the test. + * A TestSetup that makes SelectedClassnameClassLoader the thread context classloader for the + * duration of the test. * * @author Brian Stansberry * @version $Revision: 1 $ */ -public class SelectedClassnameClassLoaderTestSetup extends TestSetup -{ +public class SelectedClassnameClassLoaderTestSetup extends TestSetup { private ClassLoader originalTCCL; private String[] includedClasses; private String[] excludedClasses; private String[] notFoundClasses; - - + /** * Create a new SelectedClassnameClassLoaderTestSetup. * * @param test */ - public SelectedClassnameClassLoaderTestSetup(Test test, - String[] includedClasses, - String[] excludedClasses, - String[] notFoundClasses) - { + public SelectedClassnameClassLoaderTestSetup(Test test, String[] includedClasses, String[] excludedClasses, String[] notFoundClasses) { super(test); this.includedClasses = includedClasses; this.excludedClasses = excludedClasses; @@ -51,10 +45,9 @@ public class SelectedClassnameClassLoaderTestSetup extends TestSetup } @Override - protected void setUp() throws Exception - { + protected void setUp() throws Exception { super.setUp(); - + originalTCCL = Thread.currentThread().getContextClassLoader(); ClassLoader parent = originalTCCL == null ? getClass().getClassLoader() : originalTCCL; ClassLoader selectedTCCL = new SelectedClassnameClassLoader(includedClasses, excludedClasses, notFoundClasses, parent); @@ -62,12 +55,9 @@ public class SelectedClassnameClassLoaderTestSetup extends TestSetup } @Override - protected void tearDown() throws Exception - { + protected void tearDown() throws Exception { Thread.currentThread().setContextClassLoader(originalTCCL); super.tearDown(); } - - } diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java index 5522418939..edf1107669 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java @@ -244,17 +244,6 @@ public class EntityCollectionInvalidationTestCase extends AbstractDualNodeTestCa Customer customer = doGetCustomer(id, session, tm); customer.setName("NewJBoss"); ids.customerId = customer.getId(); - -// Set contacts = customer.getContacts(); -// for (Contact c : contacts) { -// if (c.getName().equals("Kabir")) { -// contacts.remove(c); -// } else { -// contactIds.add(c.getId()); -// } -// } -// ids.contactIds = contactIds; -// customer.setContacts(contacts); Set contacts = customer.getContacts(); for (Contact c : contacts) { contactIds.add(c.getId()); @@ -356,27 +345,6 @@ public class EntityCollectionInvalidationTestCase extends AbstractDualNodeTestCa } } } - -// @CacheEntryModified -// public void nodeModified(CacheEntryModifiedEvent event) { -// log.debug(event.toString()); -// if (!event.isPre()) { -// MarshalledValue mv = (MarshalledValue) event.getKey(); -// CacheKey cacheKey = (CacheKey) mv.get(); -// Integer primKey = (Integer) cacheKey.getKey(); -// String key = (String) cacheKey.getEntityOrRoleName() + '#' + primKey; -// log.debug("MyListener[" + name +"] - Modified key " + key); -// // String name = fqn.toString(); -// String token = ".functional."; -// int index = key.indexOf(token); -// if (index > -1) { -// index += token.length(); -// key = key.substring(index); -// log.debug("MyListener[" + name +"] - recording modification of " + key); -// visited.add(key); -// } -// } -// } } private class IdContainer { diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java index 7ac9231c8b..103ade40db 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java @@ -172,10 +172,6 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase { getDoesNotBlockPutTest(); } - // public void testGetDoesNotBlockPutPessimisticRepeatableRead() throws Exception { - // getDoesNotBlockPutTest(); - // } - private void getDoesNotBlockPutTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java index c01a2b4ea1..b68e75de6c 100644 --- a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java @@ -81,12 +81,6 @@ public class XaTransactionImpl implements Transaction { s.beforeCompletion(); } -// if (!runXaResourcePrepare()) { -// status = Status.STATUS_ROLLING_BACK; -// } else { -// status = Status.STATUS_PREPARED; -// } - status = Status.STATUS_COMMITTING; if (connection != null) { @@ -99,8 +93,6 @@ public class XaTransactionImpl implements Transaction { } } -// runXaResourceCommitTx(); - status = Status.STATUS_COMMITTED; for (int i = 0; i < synchronizations.size(); i++) { @@ -114,8 +106,6 @@ public class XaTransactionImpl implements Transaction { } public void rollback() throws IllegalStateException, SystemException { -// status = Status.STATUS_ROLLING_BACK; -// runXaResourceRollback(); status = Status.STATUS_ROLLEDBACK; if (connection != null) {