JBoss Cache SVN: r6911 - core/trunk/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 10:46:48 -0400 (Mon, 13 Oct 2008)
New Revision: 6911
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
Log:
Applied Krzysztof Sobolewski's patch for JBCACHE-1424 (JDBCCacheLoader does not close ConnectionFactory)
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-13 14:46:17 UTC (rev 6910)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-13 14:46:48 UTC (rev 6911)
@@ -311,33 +311,39 @@
@Override
public void stop()
{
- if (config.getDropTable())
+ try
{
- Connection con = null;
- Statement st = null;
- try
+ if (config.getDropTable())
{
- if (getLogger().isDebugEnabled())
+ Connection con = null;
+ Statement st = null;
+ try
{
- getLogger().debug("executing ddl: " + config.getDropTableDDL());
+ if (getLogger().isDebugEnabled())
+ {
+ getLogger().debug("executing ddl: " + config.getDropTableDDL());
+ }
+
+ con = cf.getConnection();
+ st = con.createStatement();
+ st.executeUpdate(config.getDropTableDDL());
+ safeClose(st);
}
-
- con = cf.getConnection();
- st = con.createStatement();
- st.executeUpdate(config.getDropTableDDL());
- safeClose(st);
+ catch (SQLException e)
+ {
+ getLogger().error("Failed to drop table: " + e.getMessage(), e);
+ }
+ finally
+ {
+ safeClose(st);
+ cf.close(con);
+ }
}
- catch (SQLException e)
- {
- getLogger().error("Failed to drop table: " + e.getMessage(), e);
- }
- finally
- {
- safeClose(st);
- cf.close(con);
- cf.stop();
- }
}
+ finally
+ {
+ cf.stop();
+ }
}
/**
16 years, 2 months
JBoss Cache SVN: r6910 - core/branches/2.2.X/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 10:46:17 -0400 (Mon, 13 Oct 2008)
New Revision: 6910
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
Log:
Applied Krzysztof Sobolewski's patch for JBCACHE-1424 (JDBCCacheLoader does not close ConnectionFactory)
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-13 14:02:29 UTC (rev 6909)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-13 14:46:17 UTC (rev 6910)
@@ -286,33 +286,39 @@
@Override
public void stop()
{
- if (config.getDropTable())
+ try
{
- Connection con = null;
- Statement st = null;
- try
+ if (config.getDropTable())
{
- if (log.isDebugEnabled())
+ Connection con = null;
+ Statement st = null;
+ try
{
- log.debug("executing ddl: " + config.getDropTableDDL());
+ if (log.isDebugEnabled())
+ {
+ log.debug("executing ddl: " + config.getDropTableDDL());
+ }
+
+ con = cf.getConnection();
+ st = con.createStatement();
+ st.executeUpdate(config.getDropTableDDL());
+ safeClose(st);
}
-
- con = cf.getConnection();
- st = con.createStatement();
- st.executeUpdate(config.getDropTableDDL());
- safeClose(st);
+ catch (SQLException e)
+ {
+ log.error("Failed to drop table: " + e.getMessage(), e);
+ }
+ finally
+ {
+ safeClose(st);
+ cf.close(con);
+ }
}
- catch (SQLException e)
- {
- log.error("Failed to drop table: " + e.getMessage(), e);
- }
- finally
- {
- safeClose(st);
- cf.close(con);
- cf.stop();
- }
}
+ finally
+ {
+ cf.stop();
+ }
}
/**
16 years, 2 months
JBoss Cache SVN: r6909 - in core/branches/2.2.X/src: test/java/org/jboss/cache/loader and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-13 10:02:29 -0400 (Mon, 13 Oct 2008)
New Revision: 6909
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/branches/2.2.X/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java
core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java
core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java
Log:
[JBCACHE-1423] Load data from cache loader before doing put(Fqn, Map)
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-13 13:32:12 UTC (rev 6908)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-13 14:02:29 UTC (rev 6909)
@@ -93,7 +93,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, true, false, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, true, false, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-13 13:32:12 UTC (rev 6908)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-13 14:02:29 UTC (rev 6909)
@@ -816,7 +816,27 @@
}
+ public void testPutDataMap() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ assert !cache.exists(f);
+ assert !loader.exists(f);
+ Map<Object, Object> input = new HashMap();
+ input.put("one", "one");
+ input.put("two", "two");
+ cache.put(f, input);
+ cache.evict(f);
+ Object three = "three"; // avoid some weird generics complaint
+ cache.put(f, Collections.singletonMap(three, three));
+ Map data = cache.getRoot().getChild(f).getData();
+ assertEquals("incorrect # of entries", 3, data.size());
+ assertEquals("Has key 'one", "one", data.get("one"));
+ assertEquals("Has key 'two", "two", data.get("two"));
+ assertEquals("Has key 'three", "three", data.get("three"));
+
+ }
+
public void testRemoveData()
{
String key = "/x/y/z/";
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java 2008-10-13 13:32:12 UTC (rev 6908)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java 2008-10-13 14:02:29 UTC (rev 6909)
@@ -5,6 +5,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.CacheLoaderConfig;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -89,7 +90,8 @@
protected void assertDataNotLoaded(Fqn f)
{
- assertFalse("Data should not be loaded for node " + f, cache.peek(f, false).isDataLoaded());
+ NodeSPI n = cache.peek(f, true);
+ assertFalse("Data should not be loaded for node " + f, n != null && n.isDataLoaded());
}
@@ -185,14 +187,17 @@
replay(mockCacheLoader);
cache.put(child, m);
- assertDataNotLoaded(child);
+ // FIXME Changes for JBCACHE-1423 require changing a number of asserts
+ // below from "assertDataNotLoaded" to "assertDataLoaded". This test
+ // should be revisited to confirm it still tests what it was intended to
+ assertDataLoaded(child);
// should load child data
// mockCacheLoader.expects(once()).method("get").with(eq(child));
cache.get(child, "foo");
- assertDataNotLoaded(child);
+ assertDataLoaded(child);
cache.get(child, "foo");
- assertDataNotLoaded(child);
+ assertDataLoaded(child);
cache.get(child, "foo2"); // does not exist, will trigger a load
assertDataLoaded(child);
@@ -332,15 +337,19 @@
// now evict
cache.evict(parent, false);
+ assertDataNotLoaded(parent);
+
// should not load
cache.put(parent, m);
+ // FIXME Changes for JBCACHE-1423 require changing a number of asserts
+ // below from "assertDataNotLoaded" to "assertDataLoaded". This test
+ // should be revisited to confirm it still tests what it was intended to
+ assertDataLoaded(parent);
- assertDataNotLoaded(parent);
-
// now a get for an existing key should not trigger a load!
assertEquals("v2", cache.get(parent, "k2"));
- assertDataNotLoaded(parent);
+ assertDataLoaded(parent);
// but going a get for a nonexistent key should!
assertEquals(v, cache.get(parent, k));
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java 2008-10-13 13:32:12 UTC (rev 6908)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java 2008-10-13 14:02:29 UTC (rev 6909)
@@ -30,7 +30,7 @@
assertNotNull("CacheStoreInterceptor not found.", store);
// verify cache loader statistics for entries loaded into cache
- int miss = 0;
+ int miss = 5;
int load = 0;
int stores = 5;
assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
@@ -40,8 +40,7 @@
// now try retrieving a valid attribute and an invalid attribute
assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + AUSTRIA, cache.get(AUSTRIA, AREA));
- load++; // since we did a get on a non-existent key which triggered a load
-
+
// verify statistics after retrieving entries - misses should still be same since nodes were already loaded
assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
@@ -92,6 +91,7 @@
// add a new node - this should cause a store
stores++;
+ miss++;
cache.put(POLAND, new HashMap<String, Object>());
assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
@@ -100,7 +100,6 @@
// add two attributes - this should cause two stores
// plus one load as we're doing put(k, v)
stores += 2;
- load++;
cache.put(POLAND, CAPITAL, "Warsaw");
cache.put(POLAND, CURRENCY, "Zloty");
assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java 2008-10-13 13:32:12 UTC (rev 6908)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/mgmt/PassivationTest.java 2008-10-13 14:02:29 UTC (rev 6909)
@@ -37,7 +37,7 @@
assertNotNull("PassivationInterceptor not found.", pass);
System.out.println("count of misses " + act.getCacheLoaderMisses());
- int miss = 0;
+ int miss = 5;
int activations = 0;
// was 5 in 1.3 (one per attribute)
// now just Europe/Albania and Europe/Hungary were loaded
16 years, 2 months
JBoss Cache SVN: r6908 - core/branches/flat/src/test/java/org/jboss/starobrno/profiling.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 09:32:12 -0400 (Mon, 13 Oct 2008)
New Revision: 6908
Added:
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/AbstractProfileTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java
Log:
Added profiler tests
Added: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/AbstractProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/AbstractProfileTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/AbstractProfileTest.java 2008-10-13 13:32:12 UTC (rev 6908)
@@ -0,0 +1,31 @@
+package org.jboss.starobrno.profiling;
+
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.util.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+@Test(groups = "profiling")
+public abstract class AbstractProfileTest
+{
+ protected Map cache;
+
+ @BeforeTest
+ public void setUp()
+ {
+ Configuration cfg = new Configuration();
+ cache = new DefaultCacheFactory().createCache(cfg, false);
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ TestingUtil.killCaches((Cache) cache);
+ cache = null;
+ }
+}
Added: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java 2008-10-13 13:32:12 UTC (rev 6908)
@@ -0,0 +1,311 @@
+package org.jboss.starobrno.profiling;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.util.TestingUtil;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Test to use with a profiler to profile replication. To be used in conjunction with ProfileSlaveTest.
+ * <p/>
+ * Typical usage pattern:
+ * <p/>
+ * 1. Start a single test method in ProfileSlaveTest. This will block until you kill it.
+ * 2. Start the corresponding test in this class, with the same name, in a different JVM, and attached to a profiler.
+ * 3. Profile away!
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@Test(groups = "profiling")
+public class ProfileTest extends AbstractProfileTest
+{
+ /*
+ Test configuration options
+ */
+ protected static final long NUM_OPERATIONS = 1000000; // DURATION is replaced with a fixed number of operations instead.
+ protected static final int NUM_THREADS = 25;
+ protected static final int MAX_RANDOM_SLEEP_MILLIS = 1;
+ protected static final int MAX_OVERALL_KEYS = 2000;
+ protected static final int WARMUP_LOOPS = 20000;
+ protected static final boolean USE_SLEEP = false; // throttle generation a bit
+
+ private List<Object> keys = new ArrayList<Object>(MAX_OVERALL_KEYS);
+ private Random r = new Random();
+
+ Log log = LogFactory.getLog(ProfileTest.class);
+
+ @Test(enabled = true)
+ public void testLocalModePess() throws Exception
+ {
+ Cache c = (Cache) cache;
+ c.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ c.getConfiguration().setConcurrencyLevel(2000);
+ c.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ runCompleteTest();
+ }
+
+ private void runCompleteTest() throws Exception
+ {
+ init();
+ startup();
+ warmup();
+ doTest();
+
+ // wait for user exit
+ System.in.read();
+ }
+
+ /**
+ * Thr following test phases can be profiled individually using triggers in JProfiler.
+ */
+
+ protected void init()
+ {
+ long startTime = System.currentTimeMillis();
+ log.warn("Starting init() phase");
+ keys.clear();
+ for (int i = 0; i < MAX_OVERALL_KEYS; i++)
+ {
+ Object key = createRandomKey(r);
+ while (keys.contains(key)) key = createRandomKey(r);
+ if (i % 10 == 0)
+ {
+ log.warn("Generated " + i + " keys");
+ }
+ keys.add(key);
+ }
+ System.gc();
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Finished init() phase. " + printDuration(duration));
+ }
+
+ private Object createRandomKey(Random r)
+ {
+ return Integer.toHexString(r.nextInt(Integer.MAX_VALUE));
+ }
+
+
+ protected void startup()
+ {
+ long startTime = System.currentTimeMillis();
+ log.warn("Starting cache");
+ ((Cache) cache).start();
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Started cache. " + printDuration(duration));
+ }
+
+ private void warmup() throws InterruptedException
+ {
+ long startTime = System.currentTimeMillis();
+ ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ log.warn("Starting warmup");
+ // creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
+ for (final Object key : keys)
+ {
+ exec.execute(new Runnable()
+ {
+ public void run()
+ {
+ // this will create the necessary nodes.
+ cache.put(key, Collections.emptyMap());
+ }
+ });
+ }
+
+ // loop through WARMUP_LOOPS gets and puts for JVM optimisation
+ for (int i = 0; i < WARMUP_LOOPS; i++)
+ {
+ exec.execute(new Runnable()
+ {
+ public void run()
+ {
+ Object key = keys.get(r.nextInt(MAX_OVERALL_KEYS));
+ cache.get(key);
+ cache.put(key, "Value");
+ cache.remove(key);
+ }
+ });
+ }
+
+ exec.shutdown();
+ exec.awaitTermination(360, TimeUnit.SECONDS);
+
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Finished warmup. " + printDuration(duration));
+ //cache.removeNode(Fqn.ROOT);
+ ((Cache) cache).stop();
+
+ startup();
+ }
+
+ private void doTest() throws Exception
+ {
+ ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ log.warn("Starting test");
+ int i;
+ long print = NUM_OPERATIONS / 10;
+
+ AtomicLong durationPuts = new AtomicLong();
+ AtomicLong durationGets = new AtomicLong();
+ AtomicLong durationRemoves = new AtomicLong();
+
+ long stElapsed = System.nanoTime();
+ for (i = 0; i < NUM_OPERATIONS; i++)
+ {
+ MyRunnable r = null;
+ switch (i % 3)
+ {
+ case 0:
+ r = new Putter(i, durationPuts);
+ break;
+ case 1:
+ r = new Getter(i, durationGets);
+ break;
+ case 2:
+ r = new Remover(i, durationRemoves);
+ break;
+ }
+ if (i % print == 0)
+ log.warn("processing iteration " + i);
+ exec.execute(r);
+// if (USE_SLEEP) TestingUtil.sleepRandom(MAX_RANDOM_SLEEP_MILLIS);
+ if (USE_SLEEP) TestingUtil.sleepThread(MAX_RANDOM_SLEEP_MILLIS);
+ }
+ log.warn("Finished generating runnables; awaiting executor completion");
+ // wait for executors to complete!
+ exec.shutdown();
+ while (!exec.awaitTermination(((long) i), TimeUnit.SECONDS))
+ {
+ Thread.sleep(1);
+ }
+
+ // wait up to 1 sec for each call?
+ long elapsedTimeNanos = System.nanoTime() - stElapsed;
+
+ log.warn("Finished test. " + printDuration((long) toMillis(elapsedTimeNanos)));
+ log.warn("Throughput: " + ((double) NUM_OPERATIONS * 1000 / toMillis(elapsedTimeNanos)) + " operations per second (roughly equal numbers of PUT, GET and REMOVE)");
+ log.warn("Average GET time: " + printAvg(durationGets.get()));
+ log.warn("Average PUT time: " + printAvg(durationPuts.get()));
+ log.warn("Average REMOVE time: " + printAvg(durationRemoves.get()));
+ }
+
+ private String printAvg(long totalNanos)
+ {
+ double nOps = (double) (NUM_OPERATIONS / 3);
+ double avg = ((double) totalNanos) / nOps;
+ double avgMicros = avg / 1000;
+ return avgMicros + " �s";
+ }
+
+ private double toMillis(long nanos)
+ {
+ return ((double) nanos / (double) 1000000);
+ }
+
+ enum Mode
+ {
+ PUT, GET, REMOVE
+ }
+
+ private abstract class MyRunnable implements Runnable
+ {
+ int id;
+ Mode mode;
+ AtomicLong duration;
+
+ public void run()
+ {
+ Object key = keys.get(r.nextInt(MAX_OVERALL_KEYS));
+ long d = 0, st = 0;
+ switch (mode)
+ {
+ case PUT:
+ Object value = getRandomString();
+ st = System.nanoTime();
+ cache.put(key, value);
+ d = System.nanoTime() - st;
+ break;
+ case GET:
+ st = System.nanoTime();
+ cache.get(key);
+ d = System.nanoTime() - st;
+ break;
+ case REMOVE:
+ st = System.nanoTime();
+ cache.remove(key);
+ d = System.nanoTime() - st;
+ break;
+ }
+ duration.getAndAdd(d);
+ }
+ }
+
+ private class Putter extends MyRunnable
+ {
+ private Putter(int id, AtomicLong duration)
+ {
+ this.id = id;
+ this.duration = duration;
+ mode = Mode.PUT;
+ }
+ }
+
+ private class Getter extends MyRunnable
+ {
+ private Getter(int id, AtomicLong duration)
+ {
+ this.id = id;
+ this.duration = duration;
+ mode = Mode.GET;
+ }
+ }
+
+ private class Remover extends MyRunnable
+ {
+ private Remover(int id, AtomicLong duration)
+ {
+ this.id = id;
+ this.duration = duration;
+ mode = Mode.REMOVE;
+ }
+ }
+
+ private String getRandomString()
+ {
+ StringBuilder sb = new StringBuilder();
+ int len = r.nextInt(10);
+
+ for (int i = 0; i < len; i++)
+ {
+ sb.append((char) (63 + r.nextInt(26)));
+ }
+ return sb.toString();
+ }
+
+ protected String printDuration(long duration)
+ {
+ if (duration > 2000)
+ {
+ double dSecs = ((double) duration / (double) 1000);
+ return "Duration: " + dSecs + " seconds";
+ }
+ else
+ {
+ return "Duration: " + duration + " millis";
+ }
+ }
+}
16 years, 2 months
JBoss Cache SVN: r6907 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 07:09:15 -0400 (Mon, 13 Oct 2008)
New Revision: 6907
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
Log:
snapshot of trunk
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
===================================================================
(Binary files differ)
16 years, 2 months
JBoss Cache SVN: r6906 - in benchmarks/benchmark-fwk/trunk: cache-products and 7 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 06:24:44 -0400 (Mon, 13 Oct 2008)
New Revision: 6906
Added:
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RC.xml
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RR.xml
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/config.sh
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/commons-codec.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jboss-common-core.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jboss-logging-spi.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jcip-annotations.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jgroups.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jta.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java
Modified:
benchmarks/benchmark-fwk/trunk/build.xml
Log:
Added support for starobrno
Modified: benchmarks/benchmark-fwk/trunk/build.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/build.xml 2008-10-13 09:35:27 UTC (rev 6905)
+++ benchmarks/benchmark-fwk/trunk/build.xml 2008-10-13 10:24:44 UTC (rev 6906)
@@ -232,12 +232,27 @@
</javac>
</target>
+ <target name="compile.module.starobrno" depends="fwk"
+ description="Compile module starobrno">
+ <mkdir dir="./classes/production/starobrno"/>
+ <javac destdir="./classes/production/starobrno" debug="${compiler.debug}"
+ nowarn="${compiler.generate.no.warnings}" fork="true">
+ <classpath>
+ <fileset dir="./cache-products/starobrno/lib" includes="*.jar"/>
+ <fileset dir="./lib/common" includes="*.jar"/>
+ <pathelement location="./lib/commons-logging.jar"/>
+ <pathelement location="${framework.output.dir}"/>
+ </classpath>
+ <src path="./cache-products/starobrno/src"/>
+ </javac>
+ </target>
+
<target name="clean" description="cleanup all">
<delete dir="./classes"/>
</target>
<target name="all"
- depends="clean, fwk, compile.module.jbosscache140, compile.module.jbosscache200, compile.module.pojocache220, compile.module.jbosscache210, compile.module.jbosscache220, compile.module.terracotta250, compile.module.ehcache159, compile.module.whirlycache101, compile.module.jbosscache300, compile.module.coherence331"
+ depends="clean, fwk, compile.module.jbosscache140, compile.module.jbosscache200, compile.module.pojocache220, compile.module.jbosscache210, compile.module.jbosscache220, compile.module.terracotta250, compile.module.ehcache159, compile.module.whirlycache101, compile.module.jbosscache300, compile.module.coherence331, compile.module.starobrno"
description="build all"/>
<target name="checkClusterAddresses" depends="fwk"
Copied: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RC.xml (from rev 6905, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/conf/mvcc-local-RC.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RC.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RC.xml 2008-10-13 10:24:44 UTC (rev 6906)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+ <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" nodeLockingScheme="mvcc"
+ concurrencyLevel="300"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <transport clusterName="JBossCache-Cluster"/>
+</jbosscache>
Copied: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RR.xml (from rev 6905, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/conf/mvcc-local-RR.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RR.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/starobrno/conf/mvcc-local-RR.xml 2008-10-13 10:24:44 UTC (rev 6906)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000" nodeLockingScheme="mvcc"
+ concurrencyLevel="300"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <transport clusterName="JBossCache-Cluster"/>
+</jbosscache>
Copied: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/config.sh (from rev 6905, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/starobrno/config.sh (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/starobrno/config.sh 2008-10-13 10:24:44 UTC (rev 6906)
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+#see "$CACHE_ROOT/cache-products/cache.sh" for details
+
+THIS_DIR="./cache-products/starobrno"
+
+#setting up classpath
+for JAR in $THIS_DIR/lib/*
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+CLASSPATH="$CLASSPATH:./classes/production/starobrno"
+CLASSPATH="$CLASSPATH:$THIS_DIR/conf"
+#--classpath was set
+
+#additional JVM options
+JVM_OPTIONS="$JVM_OPTIONS -Djava.net.preferIPv4Stack=true -Djbosscache.config.validate=false"
+JVM_OPTIONS="$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName=org.cachebench.cachewrappers.StarobrnoWrapper"
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/commons-codec.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/commons-codec.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jboss-common-core.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jboss-common-core.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jboss-logging-spi.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jboss-logging-spi.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jcip-annotations.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jcip-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jgroups.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jgroups.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jta.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/jta.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Copied: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java (from rev 6905, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java 2008-10-13 10:24:44 UTC (rev 6906)
@@ -0,0 +1,75 @@
+package org.cachebench.cachewrappers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.cachebench.CacheWrapper;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.starobrno.Cache;
+
+import java.util.List;
+import java.util.Map;
+
+public class StarobrnoWrapper implements CacheWrapper
+{
+ private Cache flatCache;
+ private Log log = LogFactory.getLog(StarobrnoWrapper.class);
+
+ public StarobrnoWrapper()
+ {
+ }
+
+ public void init(Map parameters) throws Exception
+ {
+ log.info("Creating cache with the following configuration: " + parameters);
+ flatCache = new DefaultCacheFactory().createCache((String) parameters.get("config"));
+ log.info("Running following JBossCacheVersion: " + org.jboss.cache.Version.version);
+ log.info("Running following JBossCacheCodeName: " + org.jboss.cache.Version.codename);
+ }
+
+ public void setUp() throws Exception
+ {
+ }
+
+ public void tearDown() throws Exception
+ {
+ flatCache.stop();
+ }
+
+ public void put(List<String> path, Object key, Object value) throws Exception
+ {
+ flatCache.put(key, value);
+ }
+
+ public Object get(List<String> path, Object key) throws Exception
+ {
+ return flatCache.get(key);
+ }
+
+ public void empty() throws Exception
+ {
+ flatCache.clear();
+ }
+
+ public int getNumMembers()
+ {
+ return -1; // todo
+ }
+
+ public String getInfo()
+ {
+ return "Cache size: " + flatCache.size();
+ }
+
+ public Object getReplicatedData(List<String> path, String key) throws Exception
+ {
+ return flatCache.get(key); // todo
+// if (!cache.getConfiguration().getCacheMode().isSynchronous())
+// {
+// log.info("Sleeping 5 seconds because the cache is replicated asynchronious!");
+// Thread.sleep(5000);
+// }
+// Option option = cache.getInvocationContext().getOptionOverrides();
+// option.setForceDataGravitation(true);
+// return get(path, key);
+ }
+}
\ No newline at end of file
16 years, 2 months
JBoss Cache SVN: r6905 - in core/trunk: src/main/java/org/jboss/cache/jmx and 52 other directories.
by jbosscache-commits@lists.jboss.org
Author: dpospisi(a)redhat.com
Date: 2008-10-13 05:35:27 -0400 (Mon, 13 Oct 2008)
New Revision: 6905
Added:
core/trunk/src/test/java/org/jboss/cache/util/UnitTestTestNGListener.java
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java
core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java
core/trunk/src/test/java/org/jboss/cache/FqnTest.java
core/trunk/src/test/java/org/jboss/cache/GetKeysTest.java
core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java
core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java
core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTestBase.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/WriteSkewTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticTestBase.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTxTest.java
core/trunk/src/test/java/org/jboss/cache/commands/RollbackOnNoOpTest.java
core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/ClearDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/MoveCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutKeyValueCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveKeyCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveNodeCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GetDataMapCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeysCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/write/InvalidateCommandTest.java
core/trunk/src/test/java/org/jboss/cache/config/ChannelInjectionTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThreadTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/EvictionQueueListTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/legacy/BackwardCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java
core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorChainTest.java
core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java
core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/interceptors/MarshalledValueInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/VersionInconsistencyTest.java
core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegistrationTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java
core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java
core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java
core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/LockMapTest.java
core/trunk/src/test/java/org/jboss/cache/lock/LockParentRootFlagTest.java
core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
core/trunk/src/test/java/org/jboss/cache/lock/LockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerTest.java
core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest.java
core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockWithUpgradeTest.java
core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java
core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/CustomCollectionTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/RedeploymentEmulationTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/RegionBasedMarshallingTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/RegionManagerTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ReplicateToInactiveRegionTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
core/trunk/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/mgmt/InvalidationTest.java
core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtCoreTest.java
core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
core/trunk/src/test/java/org/jboss/cache/mgmt/TxTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/AsyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/BadMuxConfigTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyAssignmentStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/ChannelInjectionPreferenceTest.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/MultiplexerTestHelper.java
core/trunk/src/test/java/org/jboss/cache/multiplexer/StateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/mvcc/MVCCFullStackTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotificationTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/BuddyGroupChangeNotificationTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/ConcurrentNotificationTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvalidatedTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionTransferTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/HasChildTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ParentVersionTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidationFailureTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/VersioningOnReadTest.java
core/trunk/src/test/java/org/jboss/cache/options/CacheModeLocalSimpleTest.java
core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java
core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java
core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java
core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java
core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java
core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/MemoryFootprintTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/DeadlockTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/SimultaneousRollbackAndPutTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/SuspendTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java
core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java
core/trunk/src/test/java/org/jboss/cache/util/DeltaMapTest.java
core/trunk/src/test/java/org/jboss/cache/util/MinMapUtilTest.java
core/trunk/src/test/java/org/jboss/cache/util/TestingUtil.java
core/trunk/src/test/resources/cache-jdbc.properties
core/trunk/src/test/resources/log4j.xml
Log:
Updated testsuite to support parallel test execution.
Fix in JmxRegistrationManager - did not unregister components properlly.
Fix non thread safe access in DummyTransactionManager.
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/pom.xml 2008-10-13 09:35:27 UTC (rev 6905)
@@ -66,7 +66,7 @@
<dependency>
<groupId>sleepycat</groupId>
<artifactId>je</artifactId>
- <version>1.7.0</version>
+ <version>3.2.43</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -113,10 +113,37 @@
<version>2.3</version>
<scope>test</scope>
</dependency>
+ <!-- 5.8 is needed for propper parallel test execution -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.8</version>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
</dependencies>
+
<build>
- <plugins>
+ <plugins>
+ <!-- ensure parallel test execution -->
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3-JBOSS</version>
+ <configuration>
+ <parallel>methods</parallel>
+ <threadCount>10</threadCount>
+ <forkMode>none</forkMode>
+ <trimStackTrace>false</trimStackTrace>
+ <properties>
+ <property>
+ <name>listener</name>
+ <value>org.jboss.cache.util.UnitTestTestNGListener</value>
+ </property>
+ </properties>
+ </configuration>
+ </plugin>
+ <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-1</version>
<executions>
@@ -171,6 +198,15 @@
</plugin>
</plugins>
</build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.4.3-JBOSS</version>
+ </plugin>
+ </plugins>
+ </reporting>
<!-- basic JBoss repository so that the common parent POM in jbosscache-support can be found -->
<repositories>
@@ -387,13 +423,21 @@
</profile>
<profile>
- <id>test-integration</id>
+ <id>profiling</id>
<properties>
- <defaultTestGroup>integration</defaultTestGroup>
+ <defaultTestGroup>profiling</defaultTestGroup>
</properties>
</profile>
<profile>
+ <id>test-integration</id>
+ <properties>
+ <defaultTestGroup>integration</defaultTestGroup>
+ </properties>
+ </profile>
+
+
+ <profile>
<id>JBossAS</id>
<activation>
<activeByDefault>false</activeByDefault>
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -156,7 +156,7 @@
List<ResourceDMBean> resourceDMBeans = getResourceDMBeans();
for (ResourceDMBean resource : resourceDMBeans)
{
- String resourceName = resource.getObject().getClass().getSimpleName();
+ String resourceName = resource.getObjectName();
ObjectName objectName = new ObjectName(getObjectName(resourceName));
if (mBeanServer.isRegistered(objectName))
{
@@ -193,8 +193,11 @@
return;
}
if (cacheSpi.getConfiguration().getCacheMode().equals(Configuration.CacheMode.LOCAL))
- {
- objectNameBase = LOCAL_CACHE_PREFIX + System.currentTimeMillis();
+ {
+ // CurrentTimeMillis is not good enaugh as an unique id generator. I am constantly
+ // getting conflicts in several parallel tests on my box. Maybe some more sofisticated
+ // unique id generator should be provided?
+ objectNameBase = LOCAL_CACHE_PREFIX + Thread.currentThread().getName() + "-" + System.currentTimeMillis();
}
else //the cache is clustered
{
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -48,6 +48,7 @@
private CacheSPI cache;
+ private JmxRegistrationManager jmxRegistrationManager;
@Inject
public void initialize(CacheSPI cache)
{
@@ -59,13 +60,13 @@
*/
@Start(priority = 14)
public void registerToPlatformMBeanServer()
- {
+ {
if (cache == null)
throw new IllegalStateException("The cache should had been injected before a call to this method");
Configuration config = cache.getConfiguration();
if (config.getExposeManagementStatistics())
{
- JmxRegistrationManager jmxRegistrationManager = new JmxRegistrationManager(cache);
+ jmxRegistrationManager = new JmxRegistrationManager(cache);
jmxRegistrationManager.registerAllMBeans();
log.info("JBossCache MBeans were successfully registered to the platform mbean server.");
}
@@ -83,7 +84,6 @@
Configuration config = cache.getConfiguration();
if (config.getExposeManagementStatistics())
{
- JmxRegistrationManager jmxRegistrationManager = new JmxRegistrationManager(cache);
jmxRegistrationManager.unregisterAllMBeans();
log.trace("JBossCache MBeans were successfully unregistered from the platform mbean server.");
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -47,8 +47,8 @@
private static final long serialVersionUID = 4396695354693176535L;
- public static DummyTransactionManager getInstance()
- {
+ public static synchronized DummyTransactionManager getInstance()
+ {
if (instance == null)
{
instance = new DummyTransactionManager();
@@ -75,12 +75,15 @@
return utx;
}
- public static void destroy()
+ public static synchronized void destroy()
{
if (instance == null)
return;
try
{
+ System.out.println("Destroy called on DummyTransactionManager. !!!!!!!!!!!!!!!!!!!!!!");
+ Thread.dumpStack();
+
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
Context ctx = new InitialContext(p);
Modified: core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -21,7 +21,7 @@
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class CacheFactoryTest
{
Configuration expected;
@@ -40,19 +40,21 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
}
+ cache = null;
+ expected = null;
}
public void testLoadOldConfig()
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache("configs/conf2x/buddy-replication-cache.xml");
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache("configs/conf2x/buddy-replication-cache.xml");
assert cache.getCacheStatus() == CacheStatus.STARTED : "Should have started";
}
public void testFromConfigFileStarted()
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(configFile);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(configFile);
// can't test for this anymore since the RuntimeConfig is attached to the running cache
//assertEquals(expected, cache.getConfiguration());
assert cache.getCacheStatus() == CacheStatus.STARTED : "Should have started";
@@ -61,7 +63,7 @@
public void testFromConfigFileUnstarted()
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(configFile, false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(configFile, false);
// can't test for this anymore since the RuntimeConfig is attached to the running cache
// assertEquals(expected, cache.getConfiguration());
@@ -72,7 +74,7 @@
public void testFromConfigObjStarted()
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(expected);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(expected);
assert cache.getCacheStatus() == CacheStatus.STARTED : "Should have started";
@@ -81,7 +83,7 @@
public void testFromConfigObjUnstarted()
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(expected, false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(expected, false);
assert cache.getCacheStatus() != CacheStatus.STARTED : "Should not have started";
@@ -100,7 +102,7 @@
public void testLifecycle() throws Exception
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(expected, false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(expected, false);
assert cache.getCacheStatus() != CacheStatus.STARTED : "Should not have started";
cache.start();
assert cache.getCacheStatus() == CacheStatus.STARTED : "Should have started";
@@ -111,7 +113,7 @@
public void testCreationFromStreamStarted() throws Exception
{
InputStream is = getClass().getClassLoader().getResourceAsStream(configFile);
- CacheFactory cf = new DefaultCacheFactory<Object, Object>();
+ CacheFactory cf = new UnitTestCacheFactory<Object, Object>();
cache = (CacheSPI) cf.createCache(is);
assert cache.getCacheStatus() == CacheStatus.STARTED : "Should have started";
doSimpleConfTests(cache.getConfiguration());
@@ -120,7 +122,7 @@
public void testCreationFromStream() throws Exception
{
InputStream is = getClass().getClassLoader().getResourceAsStream(configFile);
- CacheFactory cf = new DefaultCacheFactory<Object, Object>();
+ CacheFactory cf = new UnitTestCacheFactory<Object, Object>();
cache = (CacheSPI) cf.createCache(is, false);
assert cache.getCacheStatus() != CacheStatus.STARTED : "Should not have started";
doSimpleConfTests(cache.getConfiguration());
@@ -128,7 +130,7 @@
public void testComponentsInjected() throws Exception
{
- CacheFactory cf = new DefaultCacheFactory<Object, Object>();
+ CacheFactory cf = new UnitTestCacheFactory<Object, Object>();
Configuration c = new Configuration();
c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -18,10 +18,10 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CallbackTest
{
- CacheSPI<Object, Object> cache = null, cache2;
+ CacheSPI<Object, Object> cache = null;
final Fqn FQN_A = Fqn.fromString("/a");
final Fqn FQN_B = Fqn.fromString("/b");
static final String KEY = "key";
@@ -111,7 +111,7 @@
c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.setIsolationLevel(level);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- return (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c);
+ return (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c);
}
private TransactionManager startTransaction()
Modified: core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.testng.annotations.AfterMethod;
/**
* Tests functionality from DataContainer.
@@ -15,7 +16,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class DataContainerTest
{
private DataContainerImpl container;
@@ -32,6 +33,12 @@
container.setBuddyFqnTransformer(new BuddyFqnTransformer());
}
+ @AfterMethod
+ public void tearDown()
+ {
+ container = null;
+ nodes = null;
+ }
/**
* tests {@link DataContainerImpl#peek(Fqn, boolean, boolean)} method
*/
Modified: core/trunk/src/test/java/org/jboss/cache/FqnTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -27,7 +27,7 @@
* @author <a href="mailto:bela@jboss.org">Bela Ban</a> May 9, 2003
* @version $Revision$
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class FqnTest
{
private Cache<Object, Object> cache;
@@ -308,7 +308,7 @@
Configuration c = new Configuration();
c.setCacheMode("LOCAL");
- cache = new DefaultCacheFactory<Object, Object>().createCache(c);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(c);
cache.put(f, "key", "value");
Modified: core/trunk/src/test/java/org/jboss/cache/GetKeysTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/GetKeysTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/GetKeysTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,19 +12,32 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.Set;
+import org.testng.annotations.AfterMethod;
/**
* @author <a href="mailto:bela@jboss.org">Bela Ban</a>
* @version $Id$
*/
+
+@Test(groups = {"functional"}, sequential = true)
public class GetKeysTest
{
CacheSPI<Object, Object> cache;
+ @AfterMethod
+ public void tearDown()
+ {
+ if (cache != null) {
+ cache.stop();
+ cache.destroy();
+ cache = null;
+ }
+ }
+
@Test(groups = {"functional"})
public void testGetKeys() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache();
cache.put("/a/b/c", "name", "Bela Ban");
cache.put("/a/b/c", "age", 40);
cache.put("/a/b/c", "city", "Kreuzlingen");
@@ -36,13 +49,13 @@
ByteArrayOutputStream outstream = new ByteArrayOutputStream(20);
ObjectOutputStream out = new ObjectOutputStream(outstream);
- out.writeObject(keys);// must be serializable
+ out.writeObject(keys);// must be serializable
}
@Test(groups = {"functional"})
public void testGetChildren() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache();
cache.put("/a/b/c", null);
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
@@ -61,7 +74,7 @@
@Test(groups = {"functional"})
public void testGetKeysOnNode()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache();
cache.put("/a/b/c", "key", "value");
Node<Object, Object> node = cache.getRoot().getChild(Fqn.fromString("/a/b/c"));
Set<Object> keySet = node.getKeys();
Modified: core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,7 +16,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class TreeCacheFunctionalTest
{
CacheSPI<Object, Object> cache = null;
@@ -25,7 +25,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
Modified: core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,7 +12,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class TreeNodeTest
{
CacheSPI<Object, Object> cache;
@@ -20,7 +20,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache();
}
@AfterMethod(alwaysRun = true)
@@ -28,6 +28,7 @@
{
cache.stop();
cache.destroy();
+ cache = null;
}
public void testChildExist() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -35,18 +35,18 @@
*/
private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>() {
- private final AtomicInteger uniqueAddr = new AtomicInteger(10);
+ private final AtomicInteger uniqueAddr = new AtomicInteger(11);
@Override protected String initialValue() {
return "228.10.10." + String.valueOf(uniqueAddr.getAndIncrement());
}
};
-
+
/**
* Holds unique mcast_port for each thread used for JGroups channel construction.
*/
private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>() {
- private final AtomicInteger uniquePort = new AtomicInteger(45588);
+ private final AtomicInteger uniquePort = new AtomicInteger(45589);
@Override protected Integer initialValue() {
return uniquePort.getAndIncrement();
@@ -65,6 +65,13 @@
}
};
+ private static Vector<Cache> allCaches = new Vector<Cache>();
+
+ /**
+ * For each thread holds the name of the test class which executed createCache factory method.
+ */
+ private static final ThreadLocal<String> threadTestName = new ThreadLocal<String>();
+
// factory methods
public Cache<K, V> createCache() throws ConfigurationException {
@@ -111,6 +118,14 @@
public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException {
+ if (! Thread.currentThread().getName().contains("pool")) {
+ System.out.println("CreateCache called from wrong thread: " + Thread.currentThread().getName());
+ //Thread.dumpStack();
+ //System.exit(-1);
+ }
+
+ checkCaches();
+
switch (configuration.getCacheMode())
{
case LOCAL:
@@ -126,52 +141,118 @@
default:
log.info("Unknown cache mode!");
}
-
+
Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
Vector<Cache> caches = threadCaches.get();
caches.add(cache);
+ synchronized (allCaches) {
+ allCaches.add(cache);
+ }
return cache;
}
/**
* Destroys all caches created by this factory in the current thread.
+ *
+ * @return true if some cleanup was actually performed
*/
- public void cleanUp() {
- Vector<Cache> caches = threadCaches.get();
+ public boolean cleanUp() {
+ Vector<Cache> caches = new Vector<Cache>(threadCaches.get());
+ boolean ret = false;
+
for (Cache cache : caches) {
- TestingUtil.killCaches(cache);
+ TestingUtil.killCaches(cache);
+ ret = true;
}
- caches.setSize(0);
+ return ret;
}
+ public void removeCache(Cache c) {
+
+ if (! Thread.currentThread().getName().contains("pool")) {
+ System.out.println("RemoveCache called from wrong thread.");
+ //Thread.dumpStack();
+ //System.exit(-1);
+ }
+
+ Vector<Cache> caches = threadCaches.get();
+ synchronized (allCaches) {
+ if (caches.contains(c)) {
+ caches.remove(c);
+ allCaches.remove(c);
+ } else if (allCaches.contains(c)) {
+ System.out.println("[" + Thread.currentThread().getName() + "] WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Remove cache called from different thread.");
+ Thread.dumpStack();
+ }
+ }
+ }
+
/**
* Updates cluster configuration to ensure mutual thread isolation.
* @param configuration Configuration to update.
*/
- private void mangleConfiguration(Configuration configuration) {
- String clusterConfig = configuration.getClusterConfig();
+ public void mangleConfiguration(Configuration configuration) {
+ configuration.setClusterConfig(mangleClusterConfiguration(configuration.getClusterConfig()));
+ // Check if the cluster name contains thread id. If not, append.
+ // We can not just append the threadId, since some of the tests are crating instances
+ // using configurations derived from configurations returned by this factory.
+
+ String clusterName = configuration.getClusterName();
+
+ // append thread id
+ if (clusterName.indexOf(Thread.currentThread().getName()) == -1) {
+ clusterName = clusterName + "-" + Thread.currentThread().getName();
+// System.out.println(getThreadId() + " Setting cluster name " + newClusterName);
+ }
+
+ String testName = extractTestName();
+
+ // prepend test name
+ /*
+ if (clusterName.indexOf(testName) == -1) {
+ clusterName = testName + "-" + clusterName;
+ }
+ */
+
+ configuration.setClusterName(clusterName);
+
+ }
+
+ /**
+ * Updates cluster configuration to ensure mutual thread isolation.
+ * @param configuration Configuration to update.
+ */
+ public String mangleClusterConfiguration(String clusterConfig) {
if (clusterConfig == null) {
// No explicit cluster configuration found. we need to resolve the default config
// now in orded to be able to update it before the cache (and the channel) starts.
- // TODO: this does not seems to be the best solution :(
+ // TODO: this does not seem to be the best solution :(
clusterConfig = UnitTestCacheConfigurationFactory.getClusterConfigFromFile(
- configuration.getDefaultClusterConfig());
+ new Configuration().getDefaultClusterConfig());
}
+ if (Thread.currentThread().getName().equals("main")) {
+ Exception e = new Exception("Invoked from main thread.");
+ e.printStackTrace();
+ };
+
// replace mcast_addr
Pattern pattern = Pattern.compile("mcast_addr=[^;]*");
Matcher m = pattern.matcher(clusterConfig);
if (m.find()) {
String origAddr = m.group().substring(m.group().indexOf("=") + 1);
String newAddr = threadMcastIP.get();
- System.out.println("Replacing mcast_addr " + origAddr + " with " + newAddr);
+// System.out.println(getThreadId() + " Replacing mcast_addr " + origAddr + " with " + newAddr);
clusterConfig = m.replaceFirst("mcast_addr=" + newAddr);
+ } else {
+ Thread.dumpStack();
+ System.exit(1);
}
// replace mcast_port
@@ -180,12 +261,46 @@
if (m.find()) {
String origPort = m.group().substring(m.group().indexOf("=") + 1);
String newPort = threadMcastPort.get().toString();
- System.out.println("Replacing mcast_port " + origPort + " with " + newPort);
+ // System.out.println(getThreadId() + " Replacing mcast_port " + origPort + " with " + newPort);
clusterConfig = m.replaceFirst("mcast_port=" + newPort);
}
- configuration.setClusterConfig(clusterConfig);
+ return clusterConfig;
+ }
+
+ private String getThreadId() {
+ return "[" + Thread.currentThread().getName() + "]";
+ }
+
+ private void checkCaches() {
+ String lastTestName = threadTestName.get();
+ String currentTestName = extractTestName();
+ if ((lastTestName != null) && (! lastTestName.equals(currentTestName))) {
+
+ String threadId = "[" + Thread.currentThread().getName() + "] ";
+
+ // we are running new test class
+ // check if there is a cache(s) instance left & kill it if possitive
+
+ if (cleanUp()) {
+ System.out.print(threadId + "WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ");
+ System.out.print(threadId +" A test method in " + lastTestName + " did not clean all cache instances properly. ");
+ System.out.println(threadId +" Use UnitTestCacheFactory.cleanUp() or TestngUtil.killCaches(...) ");
+ }
+
+ }
+ threadTestName.set(currentTestName);
}
-
+
+ private String extractTestName() {
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ if (stack.length == 0) return null;
+ for (int i=stack.length-1; i>0; i--) {
+ StackTraceElement e = stack[i];
+ String className = e.getClassName();
+ if (className.indexOf("org.jboss.cache") != -1) return className; //+ "." + e.getMethodName();
+ }
+ return null;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,9 +3,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
@@ -27,6 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the {@link org.jboss.cache.Cache} public API at a high level
@@ -34,22 +33,22 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
*/
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class CacheAPITest
{
private CacheSPI<String, String> cache;
- final List<String> events = new ArrayList<String>();
+ private List<String> events;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
// start a single cache instance
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) cf.createCache("configs/local-tx.xml", false);
cache.getConfiguration().setEvictionConfig(null);
configure(cache.getConfiguration());
cache.start();
- events.clear();
+ events = new ArrayList<String>();
}
protected void configure(Configuration c)
@@ -62,6 +61,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
+ events = null;
}
protected NodeLockingScheme getNodeLockingScheme()
Modified: core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.api;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -15,8 +14,9 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class CacheSPITest
{
private CacheSPI<Object, Object> cache1;
@@ -34,8 +34,8 @@
conf1.setNodeLockingScheme(nodeLockingScheme);
conf2.setNodeLockingScheme(nodeLockingScheme);
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf1, false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf2, false);
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf1, false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf2, false);
}
@AfterMethod(alwaysRun = true)
@@ -46,6 +46,8 @@
try
{
cache1.stop();
+ cache1.destroy();
+ cache1 = null;
}
catch (Exception e)
{
@@ -57,6 +59,8 @@
try
{
cache2.stop();
+ cache2.destroy();
+ cache2 = null;
}
catch (Exception e)
{
@@ -91,10 +95,10 @@
{
Configuration conf1 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
Configuration conf2 = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+
+ //cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf1, false);
+ //cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf2, false);
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf1, false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf2, false);
-
cache1.start();
assertTrue("Cache1 is coordinator", cache1.getRPCManager().isCoordinator());
Modified: core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.api;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -13,6 +12,7 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests whether, in a single tx, deleting a parent node with an pre-existing
@@ -22,7 +22,7 @@
* @author Brian Stansberry
* @since 2.1.0
*/
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class DeletedChildResurrectionTest
{
private CacheSPI<Object, Object> cache;
@@ -40,7 +40,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setCacheLoaderConfig(null);
cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
@@ -54,6 +54,9 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache);
+ cache = null;
+ txManager = null;
+ root = null;
}
protected void configure(Configuration c)
Modified: core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheStatus;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
@@ -17,6 +16,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.AfterMethod;
/**
* Tests aspects of the {@link org.jboss.cache.Cache} public API when
@@ -25,7 +26,7 @@
* @author Brian Stansberry
*/
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class DestroyedCacheAPITest
{
private Cache<String, String> cache;
@@ -39,7 +40,7 @@
public void setUp() throws Exception
{
// start a single cache instance
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
cache = cf.createCache("configs/local-tx.xml", false);
cache.getConfiguration().setNodeLockingScheme(optimistic ? Configuration.NodeLockingScheme.OPTIMISTIC : Configuration.NodeLockingScheme.PESSIMISTIC);
cache.start();
@@ -51,6 +52,16 @@
cache.destroy();
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ if (cache != null) {
+ cache.destroy();
+ cache = null;
+ }
+ root = null;
+ }
+
/**
* Tests that the configuration contains the values expected, as well as immutability of certain elements
*/
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.api;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
@@ -24,6 +23,8 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests {@link org.jboss.cache.Node}-centric operations
@@ -34,12 +35,8 @@
@Test(groups = {"functional", "pessimistic"})
public class NodeAPITest
{
- private Node<Object, Object> rootNode;
+ protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new ThreadLocal<CacheSPI<Object, Object>>();
- protected CacheSPI<Object, Object> cache;
-
- private TransactionManager tm;
-
protected static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn
.fromString("/d");
protected Fqn A_B = Fqn.fromRelativeFqn(A, B);
@@ -49,12 +46,11 @@
public void setUp() throws Exception
{
// start a single cache instance
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache("configs/local-tx.xml", false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache("configs/local-tx.xml", false);
+ cacheTL.set(cache);
cache.getConfiguration().setNodeLockingScheme(getNodeLockingScheme());
configure(cache.getConfiguration());
cache.start();
- rootNode = cache.getRoot();
- tm = cache.getTransactionManager();
}
protected void configure(Configuration c)
@@ -65,6 +61,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
if (cache != null)
{
if (cache.getTransactionManager() != null)
@@ -77,13 +75,10 @@
{
// don't care
}
- }
- cache.stop();
+ }
+ TestingUtil.killCaches(cache);
+ cacheTL.set(null);
}
- if (rootNode != null)
- {
- rootNode = null;
- }
}
protected NodeLockingScheme getNodeLockingScheme()
@@ -93,6 +88,7 @@
protected void assertNodeLockingScheme()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
assert cache.getConfiguration().getNodeLockingScheme() == PESSIMISTIC;
boolean interceptorChainOK = false;
@@ -108,8 +104,9 @@
public void testAddingData()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
assertNodeLockingScheme();
-
+ Node<Object, Object> rootNode = cache.getRoot();
Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put("key", "value");
@@ -118,6 +115,9 @@
public void testAddingDataTx() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+ Node<Object, Object> rootNode = cache.getRoot();
tm.begin();
Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put("key", "value");
@@ -128,6 +128,10 @@
public void testOverwritingDataTx() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+ Node<Object, Object> rootNode = cache.getRoot();
+
Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put("key", "value");
assertEquals("value", nodeA.get("key"));
@@ -145,6 +149,9 @@
*/
public void testParentsAndChildren()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
Node<Object, Object> nodeA = rootNode.addChild(A);
Node<Object, Object> nodeB = nodeA.addChild(B);
Node<Object, Object> nodeC = nodeA.addChild(C);
@@ -187,6 +194,10 @@
public void testLocking() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+ Node<Object, Object> rootNode = cache.getRoot();
+
tm.begin();
Node<Object, Object> nodeA = rootNode.addChild(A);
Node<Object, Object> nodeB = nodeA.addChild(B);
@@ -208,6 +219,9 @@
public void testImmutabilityOfData()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
rootNode.put("key", "value");
Map<Object, Object> m = rootNode.getData();
try
@@ -233,6 +247,9 @@
public void testDefensiveCopyOfData()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
rootNode.put("key", "value");
Map<Object, Object> data = rootNode.getData();
Set<Object> keys = rootNode.getKeys();
@@ -257,6 +274,9 @@
public void testDefensiveCopyOfChildren()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
Fqn childFqn = Fqn.fromString("/child");
rootNode.addChild(childFqn).put("k", "v");
Set<Node<Object, Object>> children = rootNode.getChildren();
@@ -283,6 +303,9 @@
public void testImmutabilityOfChildren()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
rootNode.addChild(A);
try
@@ -298,12 +321,17 @@
protected void childrenUnderTxCheck() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
assertEquals(3, cache.getNumberOfNodes());
assertEquals(4, cache.getNumberOfLocksHeld());
}
public void testGetChildrenUnderTx() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+
tm.begin();
cache.put(A_B, "1", "1");
cache.put(A_C, "2", "2");
@@ -316,11 +344,16 @@
@SuppressWarnings("unchecked")
protected TransactionWorkspace<Object, Object> getTransactionWorkspace() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
return ((OptimisticTransactionContext) cache.getTransactionTable().get(cache.getTransactionTable().get(tm.getTransaction()))).getTransactionWorkSpace();
}
public void testGetChildAPI()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
// creates a Node<Object, Object> with fqn /a/b/c
Node childA = rootNode.addChild(A);
childA.addChild(B).addChild(C);
@@ -338,6 +371,9 @@
public void testClearingData()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
rootNode.put("k", "v");
rootNode.put("k2", "v2");
assertEquals(2, rootNode.getKeys().size());
@@ -348,6 +384,10 @@
public void testClearingDataTx() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+ Node<Object, Object> rootNode = cache.getRoot();
+
tm.begin();
rootNode.put("k", "v");
rootNode.put("k2", "v2");
@@ -361,6 +401,9 @@
public void testPutData()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
assertTrue(rootNode.getData().isEmpty());
Map<Object, Object> map = new HashMap<Object, Object>();
@@ -394,6 +437,10 @@
public void testGetChildrenNames() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+ Node<Object, Object> rootNode = cache.getRoot();
+
rootNode.addChild(A).put("k", "v");
rootNode.addChild(B).put("k", "v");
@@ -415,6 +462,9 @@
public void testDoubleRemovalOfData() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+
cache.put("/foo/1/2/3", "item", 1);
assert 1 == (Integer) cache.get("/foo/1/2/3", "item");
tm.begin();
@@ -433,6 +483,9 @@
public void testDoubleRemovalOfData2() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+
cache.put("/foo/1/2", "item", 1);
tm.begin();
assertEquals(cache.get("/foo/1", "item"), null);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotExistsException;
@@ -24,6 +23,7 @@
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Excercises and tests the new move() api
@@ -36,32 +36,36 @@
{
protected final Log log = LogFactory.getLog(getClass());
- protected Node<Object, Object> rootNode, nodeA, nodeB, nodeC, nodeD, nodeE;
- protected CacheSPI<Object, Object> cache;
- protected TransactionManager tm;
protected static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn.fromString("/d"), E = Fqn.fromString("/e");
- protected Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
+ protected static final Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
+ protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new ThreadLocal<CacheSPI<Object, Object>>();
+ protected ThreadLocal<TransactionManager> tmTL = new ThreadLocal<TransactionManager>();
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+
// start a single cache instance
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache("configs/local-tx.xml", false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache("configs/local-tx.xml", false);
cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache.getConfiguration().setFetchInMemoryState(false);
cache.getConfiguration().setEvictionConfig(null);
configure(cache.getConfiguration());
cache.start();
- rootNode = cache.getRoot();
- tm = cache.getTransactionManager();
+
+ cacheTL.set(cache);
+ tmTL.set(cache.getTransactionManager());
}
@AfterMethod(alwaysRun = true)
public void tearDown()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
TestingUtil.killCaches(cache);
+ cacheTL.set(null);
}
protected void configure(Configuration c)
@@ -71,11 +75,15 @@
public void testBasicMove()
{
- nodeA = rootNode.addChild(A);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
+ Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put(k, vA);
- nodeB = rootNode.addChild(B);
+ Node<Object, Object> nodeB = rootNode.addChild(B);
nodeB.put(k, vB);
- nodeC = nodeA.addChild(C);
+ Node<Object, Object> nodeC = nodeA.addChild(C);
nodeC.put(k, vC);
/*
/a/c
@@ -135,15 +143,19 @@
public void testMoveWithChildren()
{
- nodeA = rootNode.addChild(A);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
+ Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put(k, vA);
- nodeB = rootNode.addChild(B);
+ Node<Object, Object> nodeB = rootNode.addChild(B);
nodeB.put(k, vB);
- nodeC = nodeA.addChild(C);
+ Node<Object, Object> nodeC = nodeA.addChild(C);
nodeC.put(k, vC);
- nodeD = nodeC.addChild(D);
+ Node<Object, Object> nodeD = nodeC.addChild(D);
nodeD.put(k, vD);
- nodeE = nodeD.addChild(E);
+ Node<Object, Object> nodeE = nodeD.addChild(E);
nodeE.put(k, vE);
assertTrue(rootNode.hasChild(A));
@@ -203,9 +215,13 @@
public void testTxCommit() throws Exception
{
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
+
assertEquals(rootNode, nodeA.getParent());
assertEquals(nodeA, nodeB.getParent());
assertEquals(nodeA, rootNode.getChildren().iterator().next());
@@ -230,9 +246,13 @@
public void testTxRollback() throws Exception
{
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
+
assertEquals(rootNode, nodeA.getParent());
assertEquals(nodeA, nodeB.getParent());
assertEquals(nodeA, rootNode.getChildren().iterator().next());
@@ -288,6 +308,10 @@
protected void doCacheLoaderTest(boolean pasv, boolean useTx) throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
cache.destroy();
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv, "/", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, false, false, false));
cache.start();
@@ -303,15 +327,15 @@
assertEquals("value", m.get("key"));
}
- nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put(k, vA);
- nodeB = rootNode.addChild(B);
+ Node<Object, Object> nodeB = rootNode.addChild(B);
nodeB.put(k, vB);
- nodeC = nodeA.addChild(C);
+ Node<Object, Object> nodeC = nodeA.addChild(C);
nodeC.put(k, vC);
- nodeD = nodeC.addChild(D);
+ Node<Object, Object> nodeD = nodeC.addChild(D);
nodeD.put(k, vD);
- nodeE = nodeD.addChild(E);
+ Node<Object, Object> nodeE = nodeD.addChild(E);
nodeE.put(k, vE);
cache.evict(Fqn.ROOT, true);
@@ -365,11 +389,15 @@
public void testLocksDeepMove() throws Exception
{
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
- nodeD = nodeB.addChild(D);
- nodeC = rootNode.addChild(C);
- nodeE = nodeC.addChild(E);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
+ Node<Object, Object> nodeD = nodeB.addChild(D);
+ Node<Object, Object> nodeC = rootNode.addChild(C);
+ Node<Object, Object> nodeE = nodeC.addChild(E);
assertEquals(0, cache.getNumberOfLocksHeld());
tm.begin();
@@ -385,9 +413,13 @@
public void testLocks() throws Exception
{
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
- nodeC = rootNode.addChild(C);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = tmTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
+ Node<Object, Object> nodeC = rootNode.addChild(C);
assertEquals(0, cache.getNumberOfLocksHeld());
tm.begin();
@@ -401,21 +433,27 @@
protected void checkLocks()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
assertEquals("ROOT should have a RL, nodeC should have a RL, nodeA should have a RL, nodeB should have a WL", 4, cache.getNumberOfLocksHeld());
}
protected void checkLocksDeep()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
assertEquals("ROOT should have a RL, nodeC should have a RL, nodeA should have a RL, nodeB should have a WL, nodeD should have a WL", 6, cache.getNumberOfLocksHeld());
}
protected void assertNoLocks()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
assertEquals(0, cache.getNumberOfLocksHeld());
}
public void testConcurrency() throws InterruptedException
{
+ final CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
final int N = 3;// number of threads
final int loops = 1 << 6;// number of loops
// tests a tree structure as such:
@@ -529,6 +567,9 @@
public void testMoveInSamePlace()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Node<Object, Object> rootNode = cache.getRoot();
+
final Fqn FQN_X = Fqn.fromString("/x");
// set up the initial structure.
Node aNode = rootNode.addChild(A);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -23,47 +22,53 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
@Test(groups = {"functional", "jgroups", "pessimistic"})
public class NodeReplicatedMoveTest
{
- protected Node<Object, Object> rootNode, nodeA, nodeB, nodeC, nodeD, nodeE;
- protected CacheSPI<Object, Object> cache1;
- protected CacheSPI<Object, Object> cache2;
- protected TransactionManager tm;
+ private class NodeReplicatedMoveTestTL {
+ protected CacheSPI<Object, Object> cache1;
+ protected CacheSPI<Object, Object> cache2;
+ protected TransactionManager tm;
+ }
+ protected ThreadLocal<NodeReplicatedMoveTestTL> threadLocal = new ThreadLocal<NodeReplicatedMoveTestTL>();
+
protected static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn.fromString("/d"), E = Fqn.fromString("/e");
- protected Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
+ protected static final Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+ NodeReplicatedMoveTestTL tl = new NodeReplicatedMoveTestTL();
+ threadLocal.set(tl);
// start a single cache instance
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache1.getConfiguration().setSyncCommitPhase(true);
- cache1.getConfiguration().setSyncRollbackPhase(true);
- cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
- configure(cache1.getConfiguration());
- cache1.start();
- rootNode = cache1.getRoot();
- tm = cache1.getTransactionManager();
+ tl.cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ tl.cache1.getConfiguration().setSyncCommitPhase(true);
+ tl.cache1.getConfiguration().setSyncRollbackPhase(true);
+ tl.cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(tl.cache1.getConfiguration());
+ tl.cache1.start();
+ tl.tm = tl.cache1.getTransactionManager();
// start second instance
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache2.getConfiguration().setSyncCommitPhase(true);
- cache2.getConfiguration().setSyncRollbackPhase(true);
- cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
- configure(cache2.getConfiguration());
- cache2.start();
+ tl.cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ tl.cache2.getConfiguration().setSyncCommitPhase(true);
+ tl.cache2.getConfiguration().setSyncRollbackPhase(true);
+ tl.cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(tl.cache2.getConfiguration());
+ tl.cache2.start();
}
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- if (cache1 != null) cache1.stop();
- if (cache2 != null) cache2.stop();
- if (rootNode != null) rootNode = null;
+ NodeReplicatedMoveTestTL tl = threadLocal.get();
+ TestingUtil.killCaches(tl.cache1, tl.cache2);
+ threadLocal.set(null);
}
protected void configure(Configuration c)
@@ -73,8 +78,13 @@
public void testReplicatability()
{
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
+ NodeReplicatedMoveTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ Node<Object, Object> rootNode = tl.cache1.getRoot();
+
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
nodeA.put(k, vA);
nodeB.put(k, vB);
@@ -97,6 +107,10 @@
public void testInvalidations() throws Exception
{
+ NodeReplicatedMoveTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ Node<Object, Object> rootNode = tl.cache1.getRoot();
cache1.stop();
cache2.stop();
cache1.destroy();
@@ -111,8 +125,8 @@
cache1.start();
cache2.start();
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
nodeA.put(k, vA);
nodeB.put(k, vB);
@@ -157,9 +171,13 @@
public void testReplTxCommit() throws Exception
{
+ NodeReplicatedMoveTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ Node<Object, Object> rootNode = tl.cache1.getRoot();
Fqn A_B = Fqn.fromRelativeFqn(A, B);
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
nodeA.put(k, vA);
nodeB.put(k, vB);
@@ -171,13 +189,13 @@
assertEquals(vB, cache2.getRoot().getChild(A).getChild(B).get(k));
// now move...
- tm.begin();
+ tl.tm.begin();
cache1.move(nodeB.getFqn(), Fqn.ROOT);
assertEquals(vA, cache1.get(A, k));
assertNull(cache1.get(A_B, k));
assertEquals(vB, cache1.get(B, k));
- tm.commit();
+ tl.tm.commit();
assertEquals(vA, cache1.getRoot().getChild(A).get(k));
assertEquals(vB, cache1.getRoot().getChild(B).get(k));
@@ -188,8 +206,12 @@
public void testReplTxRollback() throws Exception
{
- nodeA = rootNode.addChild(A);
- nodeB = nodeA.addChild(B);
+ NodeReplicatedMoveTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ Node<Object, Object> rootNode = tl.cache1.getRoot();
+ Node<Object, Object> nodeA = rootNode.addChild(A);
+ Node<Object, Object> nodeB = nodeA.addChild(B);
nodeA.put(k, vA);
nodeB.put(k, vB);
@@ -200,13 +222,13 @@
assertEquals(vB, cache2.getRoot().getChild(A).getChild(B).get(k));
// now move...
- tm.begin();
+ tl.tm.begin();
cache1.move(nodeB.getFqn(), Fqn.ROOT);
assertEquals(vA, cache1.get(A, k));
assertEquals(vB, cache1.get(B, k));
- tm.rollback();
+ tl.tm.rollback();
assertEquals(vA, cache1.getRoot().getChild(A).get(k));
assertEquals(vB, cache1.getRoot().getChild(A).getChild(B).get(k));
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.api;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -11,11 +10,13 @@
import org.testng.annotations.Test;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests NodeSPI specific APIs.
*/
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class NodeSPITest
{
private CacheSPI<Object, Object> cache;
@@ -24,7 +25,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache.start();
root = cache.getRoot();
@@ -33,7 +34,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- if (cache != null) cache.stop();
+ if (cache != null) TestingUtil.killCaches(cache);
root = null;
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -16,6 +15,8 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tester class for Node.isResident functionality.
@@ -23,7 +24,7 @@
* @author <a href="mailto:mircea.markus@jboss.com">Mircea Markus</a>
* @since 2.1.0
*/
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class ResidentNodesTest
{
private CacheSPI<Object, Object> cache;
@@ -37,7 +38,7 @@
{
Configuration cacheConfig = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
cacheConfig.setCacheMode(Configuration.CacheMode.LOCAL);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cacheConfig, false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cacheConfig, false);
cache.getConfiguration().getEvictionConfig().setWakeupInterval(1000);
createNewRegion();
cache.start();
@@ -65,14 +66,11 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
- for (Cache c : caches)
- {
- if (c != null)
- {
- c.stop();
- }
- }
+ TestingUtil.killCaches(cache);
+ if (caches != null) TestingUtil.killCaches(caches);
+ cache = null;
+ caches = null;
+ evController = null;
}
/**
@@ -177,7 +175,7 @@
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
config.setCacheMode(Configuration.CacheMode.LOCAL);
config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config, true);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config, true);
cache.put(Fqn.fromString("/a/b"), "key", "value");
TransactionManager txManager = cache.getTransactionManager();
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
@@ -21,15 +20,16 @@
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.Test;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "jgroups", "pessimistic"})
+@Test(groups = {"functional", "jgroups", "pessimistic"}, sequential = true)
public class SyncReplTest
{
private CacheSPI<Object, Object> cache1, cache2;
@@ -39,8 +39,8 @@
public void setUp()
{
System.out.println("*** In setUp()");
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
@@ -59,6 +59,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
protected void configure(Configuration c)
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
@@ -33,11 +32,12 @@
import javax.transaction.TransactionManager;
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "jgroups", "transaction", "pessimistic"})
+@Test(groups = {"functional", "jgroups", "transaction", "pessimistic"}, sequential = true)
public class SyncReplTxTest
{
private List<CacheSPI<Object, Object>> caches;
@@ -48,7 +48,7 @@
{
System.out.println("*** In setUp()");
caches = new ArrayList<CacheSPI<Object, Object>>();
- CacheSPI<Object, Object> cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ CacheSPI<Object, Object> cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache1.getConfiguration().setSyncCommitPhase(true);
@@ -59,14 +59,14 @@
cache1.start();
- CacheSPI<Object, Object> cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
+ CacheSPI<Object, Object> cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
cache2.start();
caches.add(cache1);
caches.add(cache2);
- TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), 5000);
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), 10000);
System.out.println("*** Finished setUp()");
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -11,6 +10,7 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
@Test(groups = {"functional", "transaction"})
public class BatchWithTM extends AbstractBatchTest
@@ -38,6 +38,7 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
@@ -79,6 +80,7 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
@@ -104,6 +106,7 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
@@ -114,7 +117,7 @@
private Cache<String, String> createCache()
{
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL); // this should pick up any configured TM for the test
c.setNodeLockingScheme(NodeLockingScheme.MVCC);
c.setInvocationBatchingEnabled(true);
Modified: core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.ConfigurationException;
@@ -51,6 +51,7 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
@@ -88,6 +89,7 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
@@ -108,6 +110,7 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
@@ -132,12 +135,13 @@
finally
{
TestingUtil.killCaches(cache);
+ cache = null;
}
}
private Cache<String, String> createCache(boolean enableBatch)
{
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
Configuration c = new Configuration();
c.setNodeLockingScheme(NodeLockingScheme.MVCC);
c.setInvocationBatchingEnabled(enableBatch);
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.api.mvcc;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -19,6 +18,7 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.Collections;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
@@ -27,59 +27,72 @@
@Test(groups = {"functional", "mvcc"})
public abstract class LockTestBase
{
- protected Cache<String, String> cache;
- protected TransactionManager tm;
protected Fqn A = Fqn.fromString("/a");
protected Fqn AB = Fqn.fromString("/a/b");
protected Fqn ABC = Fqn.fromString("/a/b/c");
protected Fqn ABCD = Fqn.fromString("/a/b/c/d");
- protected LockManager lockManager;
- protected InvocationContextContainer icc;
protected boolean repeatableRead = true;
protected boolean lockParentForChildInsertRemove = false;
+ protected class LockTestBaseTL {
+ public Cache<String, String> cache;
+ public TransactionManager tm;
+ public LockManager lockManager;
+ public InvocationContextContainer icc;
+ }
+
+ protected ThreadLocal<LockTestBaseTL> threadLocal = new ThreadLocal<LockTestBaseTL>();
@BeforeMethod
public void setUp()
{
- cache = new DefaultCacheFactory<String, String>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL), false);
- cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
- cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
- cache.getConfiguration().setLockParentForChildInsertRemove(lockParentForChildInsertRemove);
+ LockTestBaseTL tl = new LockTestBaseTL();
+
+ tl.cache = new UnitTestCacheFactory<String, String>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL), false);
+ tl.cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
+ tl.cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ tl.cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
+ tl.cache.getConfiguration().setLockParentForChildInsertRemove(lockParentForChildInsertRemove);
// reduce lock acquisition timeout so this doesn't take forever to run
- cache.getConfiguration().setLockAcquisitionTimeout(200); // 200 ms
- cache.start();
- lockManager = TestingUtil.extractComponentRegistry(cache).getComponent(LockManager.class);
- icc = TestingUtil.extractComponentRegistry(cache).getComponent(InvocationContextContainer.class);
- tm = TestingUtil.extractComponentRegistry(cache).getComponent(TransactionManager.class);
+ tl.cache.getConfiguration().setLockAcquisitionTimeout(200); // 200 ms
+ tl.cache.start();
+ tl.lockManager = TestingUtil.extractComponentRegistry(tl.cache).getComponent(LockManager.class);
+ tl.icc = TestingUtil.extractComponentRegistry(tl.cache).getComponent(InvocationContextContainer.class);
+ tl.tm = TestingUtil.extractComponentRegistry(tl.cache).getComponent(TransactionManager.class);
+ threadLocal.set(tl);
}
@AfterMethod
public void tearDown()
{
- TestingUtil.killCaches(cache);
+ LockTestBaseTL tl = threadLocal.get();
+ TestingUtil.killCaches(tl.cache);
+ threadLocal.set(null);
}
protected void assertLocked(Fqn fqn)
{
- LockAssert.assertLocked(fqn, lockManager, icc);
+ LockTestBaseTL tl = threadLocal.get();
+ LockAssert.assertLocked(fqn, tl.lockManager, tl.icc);
}
protected void assertNotLocked(Fqn fqn)
{
- LockAssert.assertNotLocked(fqn, lockManager, icc);
+ LockTestBaseTL tl = threadLocal.get();
+ LockAssert.assertNotLocked(fqn, tl.lockManager, tl.icc);
}
protected void assertNoLocks()
{
- LockAssert.assertNoLocks(lockManager, icc);
+ LockTestBaseTL tl = threadLocal.get();
+ LockAssert.assertNoLocks(tl.lockManager, tl.icc);
}
public void testLocksOnPutKeyVal() throws Exception
{
- tm.begin();
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v");
if (lockParentForChildInsertRemove)
assertLocked(Fqn.ROOT);
else
@@ -87,22 +100,22 @@
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- assert cache.get(AB, "k").equals("v");
+ tl.tm.begin();
+ assert tl.cache.get(AB, "k").equals("v");
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
assertNotLocked(AB);
assertNotLocked(ABC);
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- cache.put(ABC, "k", "v");
+ tl.tm.begin();
+ tl.cache.put(ABC, "k", "v");
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
if (lockParentForChildInsertRemove)
@@ -110,15 +123,16 @@
else
assertNotLocked(AB);
assertLocked(ABC);
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
}
public void testLocksOnPutData() throws Exception
{
- tm.begin();
- cache.put(AB, Collections.singletonMap("k", "v"));
+ LockTestBaseTL tl = threadLocal.get();
+ tl.tm.begin();
+ tl.cache.put(AB, Collections.singletonMap("k", "v"));
if (lockParentForChildInsertRemove)
assertLocked(Fqn.ROOT);
else
@@ -126,23 +140,23 @@
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
- assert "v".equals(cache.get(AB, "k"));
- tm.commit();
- assert "v".equals(cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ tl.tm.commit();
+ assert "v".equals(tl.cache.get(AB, "k"));
assertNoLocks();
- tm.begin();
- assert "v".equals(cache.get(AB, "k"));
+ tl.tm.begin();
+ assert "v".equals(tl.cache.get(AB, "k"));
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
assertNotLocked(AB);
assertNotLocked(ABC);
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- cache.put(ABC, Collections.singletonMap("k", "v"));
+ tl.tm.begin();
+ tl.cache.put(ABC, Collections.singletonMap("k", "v"));
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
if (lockParentForChildInsertRemove)
@@ -150,64 +164,67 @@
else
assertNotLocked(AB);
assertLocked(ABC);
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
}
public void testLocksOnRemoveNode() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
// init some data on a node
- cache.put(AB, Collections.singletonMap("k", "v"));
+ tl.cache.put(AB, Collections.singletonMap("k", "v"));
- assert "v".equals(cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
- tm.begin();
- cache.removeNode(AB);
+ tl.tm.begin();
+ tl.cache.removeNode(AB);
assertLocked(AB);
if (lockParentForChildInsertRemove)
assertLocked(A);
else
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.getNode(AB) == null : "Should not exist";
+ tl.tm.commit();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
assertNoLocks();
}
public void testLocksOnEvictNode() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
// init some data on a node
- cache.put(AB, Collections.singletonMap("k", "v"));
+ tl.cache.put(AB, Collections.singletonMap("k", "v"));
- assert "v".equals(cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
- tm.begin();
- cache.evict(AB);
+ tl.tm.begin();
+ tl.cache.evict(AB);
assertLocked(AB);
if (lockParentForChildInsertRemove)
assertLocked(A);
else
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.getNode(AB) == null : "Should not exist";
+ tl.tm.commit();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
assertNoLocks();
}
public void testLocksOnEvictRecursiveNode() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
// init some data on a node
- cache.put(AB, Collections.singletonMap("k", "v"));
- cache.put(ABC, Collections.singletonMap("k", "v"));
- cache.put(ABCD, Collections.singletonMap("k", "v"));
+ tl.cache.put(AB, Collections.singletonMap("k", "v"));
+ tl.cache.put(ABC, Collections.singletonMap("k", "v"));
+ tl.cache.put(ABCD, Collections.singletonMap("k", "v"));
- assert "v".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
- assert "v".equals(cache.get(ABCD, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(ABCD, "k"));
- tm.begin();
- cache.evict(AB, true);
+ tl.tm.begin();
+ tl.cache.evict(AB, true);
assertLocked(AB);
assertLocked(ABC);
assertLocked(ABCD);
@@ -216,464 +233,481 @@
else
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.getNode(AB) == null : "Should not exist";
+ tl.tm.commit();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
assertNoLocks();
}
public void testLocksOnRemoveNonexistentNode() throws Exception
{
- assert cache.getNode(AB) == null : "Should not exist";
+ LockTestBaseTL tl = threadLocal.get();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
- tm.begin();
- cache.removeNode(AB);
+ tl.tm.begin();
+ tl.cache.removeNode(AB);
assertLocked(AB);
if (lockParentForChildInsertRemove)
assertLocked(A);
else
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.getNode(AB) == null : "Should not exist";
+ tl.tm.commit();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
assertNoLocks();
}
public void testLocksOnEvictNonexistentNode() throws Exception
{
- assert cache.getNode(AB) == null : "Should not exist";
+ LockTestBaseTL tl = threadLocal.get();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
- tm.begin();
- cache.evict(AB);
+ tl.tm.begin();
+ tl.cache.evict(AB);
assertLocked(AB);
if (lockParentForChildInsertRemove)
assertLocked(A);
else
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.getNode(AB) == null : "Should not exist";
+ tl.tm.commit();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
assertNoLocks();
}
public void testLocksOnRemoveData() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
// init some data on a node
- cache.put(AB, "k", "v");
- cache.put(AB, "k2", "v2");
+ tl.cache.put(AB, "k", "v");
+ tl.cache.put(AB, "k2", "v2");
- assert "v".equals(cache.get(AB, "k"));
- assert "v2".equals(cache.get(AB, "k2"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ assert "v2".equals(tl.cache.get(AB, "k2"));
// remove
- tm.begin();
- Object x = cache.remove(AB, "k");
+ tl.tm.begin();
+ Object x = tl.cache.remove(AB, "k");
assert x.equals("v");
assertLocked(AB);
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.get(AB, "k") == null : "Should not exist";
- assert "v2".equals(cache.get(AB, "k2"));
+ tl.tm.commit();
+ assert tl.cache.get(AB, "k") == null : "Should not exist";
+ assert "v2".equals(tl.cache.get(AB, "k2"));
assertNoLocks();
// clearData
- tm.begin();
- cache.clearData(AB);
+ tl.tm.begin();
+ tl.cache.clearData(AB);
assertLocked(AB);
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
+ tl.tm.commit();
- assert cache.get(AB, "k") == null : "Should not exist";
- assert cache.get(AB, "k2") == null : "Should not exist";
+ assert tl.cache.get(AB, "k") == null : "Should not exist";
+ assert tl.cache.get(AB, "k2") == null : "Should not exist";
assertNoLocks();
// nonexistent key
- assert cache.get(AB, "k3") == null : "Should not exist";
- tm.begin();
- cache.remove(AB, "k3");
+ assert tl.cache.get(AB, "k3") == null : "Should not exist";
+ tl.tm.begin();
+ tl.cache.remove(AB, "k3");
assertLocked(AB);
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
}
public void testLocksOnRemoveDataNonExistentNode() throws Exception
{
- assert cache.getNode(AB) == null : "Should not exist";
+ LockTestBaseTL tl = threadLocal.get();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
- tm.begin();
- cache.remove(AB, "k");
+ tl.tm.begin();
+ tl.cache.remove(AB, "k");
assertNotLocked(AB);
assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
- tm.commit();
- assert cache.getNode(AB) == null : "Should not exist";
+ tl.tm.commit();
+ assert tl.cache.getNode(AB) == null : "Should not exist";
}
public void testReadMethods() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
- tm.begin();
- assert "v".equals(cache.get(AB, "k"));
+ tl.tm.begin();
+ assert "v".equals(tl.cache.get(AB, "k"));
assertNoLocks();
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- assert cache.getData(AB).containsKey("k");
+ tl.tm.begin();
+ assert tl.cache.getData(AB).containsKey("k");
assertNoLocks();
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- assert cache.getKeys(AB).contains("k");
+ tl.tm.begin();
+ assert tl.cache.getKeys(AB).contains("k");
assertNoLocks();
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- assert cache.getNode(AB) != null;
+ tl.tm.begin();
+ assert tl.cache.getNode(AB) != null;
assertNoLocks();
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
- tm.begin();
- assert cache.getNode(A) != null;
- assert !(cache.getNode(A).getChildrenNames().isEmpty());
- assert cache.getNode(A).getChildrenNames().contains(AB.getLastElement());
+ tl.tm.begin();
+ assert tl.cache.getNode(A) != null;
+ assert !(tl.cache.getNode(A).getChildrenNames().isEmpty());
+ assert tl.cache.getNode(A).getChildrenNames().contains(AB.getLastElement());
assertNoLocks();
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
}
public void testWriteDoesntBlockRead() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
// start a write.
- tm.begin();
- cache.put(AB, "k2", "v2");
+ tl.tm.begin();
+ tl.cache.put(AB, "k2", "v2");
assertLocked(AB);
- Transaction write = tm.suspend();
+ Transaction write = tl.tm.suspend();
// now start a read and confirm that the write doesn't block it.
- tm.begin();
- assert "v".equals(cache.get(AB, "k"));
- assert null == cache.get(AB, "k2") : "Should not see uncommitted changes";
- Transaction read = tm.suspend();
+ tl.tm.begin();
+ assert "v".equals(tl.cache.get(AB, "k"));
+ assert null == tl.cache.get(AB, "k2") : "Should not see uncommitted changes";
+ Transaction read = tl.tm.suspend();
// commit the write
- tm.resume(write);
- tm.commit();
+ tl.tm.resume(write);
+ tl.tm.commit();
assertNoLocks();
- tm.resume(read);
+ tl.tm.resume(read);
if (repeatableRead)
- assert null == cache.get(AB, "k2") : "Should have repeatable read";
+ assert null == tl.cache.get(AB, "k2") : "Should have repeatable read";
else
- assert "v2".equals(cache.get(AB, "k2")) : "Read committed should see committed changes";
- tm.commit();
+ assert "v2".equals(tl.cache.get(AB, "k2")) : "Read committed should see committed changes";
+ tl.tm.commit();
assertNoLocks();
}
public void testWriteDoesntBlockReadNonexistent() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
// start a write.
- tm.begin();
- cache.put(AB, "k", "v");
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v");
assertLocked(AB);
- Transaction write = tm.suspend();
+ Transaction write = tl.tm.suspend();
// now start a read and confirm that the write doesn't block it.
- tm.begin();
- assert null == cache.get(AB, "k") : "Should not see uncommitted changes";
- assert null == cache.getNode(AB);
- Transaction read = tm.suspend();
+ tl.tm.begin();
+ assert null == tl.cache.get(AB, "k") : "Should not see uncommitted changes";
+ assert null == tl.cache.getNode(AB);
+ Transaction read = tl.tm.suspend();
// commit the write
- tm.resume(write);
- tm.commit();
+ tl.tm.resume(write);
+ tl.tm.commit();
assertNoLocks();
- tm.resume(read);
+ tl.tm.resume(read);
if (repeatableRead)
{
- assert null == cache.get(AB, "k") : "Should have repeatable read";
- assert null == cache.getNode(AB);
+ assert null == tl.cache.get(AB, "k") : "Should have repeatable read";
+ assert null == tl.cache.getNode(AB);
}
else
{
- assert "v".equals(cache.get(AB, "k")) : "Read committed should see committed changes";
- assert null != cache.getNode(AB);
+ assert "v".equals(tl.cache.get(AB, "k")) : "Read committed should see committed changes";
+ assert null != tl.cache.getNode(AB);
}
- tm.commit();
+ tl.tm.commit();
assertNoLocks();
}
public void testConcurrentWriters() throws Exception
{
- tm.begin();
- cache.put(AB, "k", "v");
- Transaction t1 = tm.suspend();
+ LockTestBaseTL tl = threadLocal.get();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v");
+ Transaction t1 = tl.tm.suspend();
- tm.begin();
+ tl.tm.begin();
try
{
- cache.put(AB, "k", "v");
+ tl.cache.put(AB, "k", "v");
assert false : "Should fail lock acquisition";
}
catch (TimeoutException expected)
{
// expected.printStackTrace(); // for debugging
}
- tm.commit();
- tm.resume(t1);
- tm.commit();
+ tl.tm.commit();
+ tl.tm.resume(t1);
+ tl.tm.commit();
assertNoLocks();
}
public void testRollbacks() throws Exception
{
- cache.put(AB, "k", "v");
- tm.begin();
- assert "v".equals(cache.get(AB, "k"));
- Transaction reader = tm.suspend();
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
+ tl.tm.begin();
+ assert "v".equals(tl.cache.get(AB, "k"));
+ Transaction reader = tl.tm.suspend();
- tm.begin();
- cache.put(AB, "k", "v2");
- tm.rollback();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v2");
+ tl.tm.rollback();
- tm.resume(reader);
- assert "v".equals(cache.get(AB, "k")) : "Expecting 'v' but was " + cache.get(AB, "k");
- tm.commit();
+ tl.tm.resume(reader);
+ assert "v".equals(tl.cache.get(AB, "k")) : "Expecting 'v' but was " + tl.cache.get(AB, "k");
+ tl.tm.commit();
// even after commit
- assert "v".equals(cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
assertNoLocks();
}
public void testRollbacksOnNullNode() throws Exception
{
- tm.begin();
- assert null == cache.get(AB, "k");
- assert null == cache.getNode(AB);
- Transaction reader = tm.suspend();
+ LockTestBaseTL tl = threadLocal.get();
+ tl.tm.begin();
+ assert null == tl.cache.get(AB, "k");
+ assert null == tl.cache.getNode(AB);
+ Transaction reader = tl.tm.suspend();
- tm.begin();
- cache.put(AB, "k", "v");
- assert null != cache.getNode(AB);
- assert "v".equals(cache.get(AB, "k"));
- tm.rollback();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v");
+ assert null != tl.cache.getNode(AB);
+ assert "v".equals(tl.cache.get(AB, "k"));
+ tl.tm.rollback();
- tm.resume(reader);
- assert null == cache.get(AB, "k") : "Expecting null but was " + cache.get(AB, "k");
- assert null == cache.getNode(AB);
- tm.commit();
+ tl.tm.resume(reader);
+ assert null == tl.cache.get(AB, "k") : "Expecting null but was " + tl.cache.get(AB, "k");
+ assert null == tl.cache.getNode(AB);
+ tl.tm.commit();
// even after commit
- assert null == cache.get(AB, "k");
- assert null == cache.getNode(AB);
+ assert null == tl.cache.get(AB, "k");
+ assert null == tl.cache.getNode(AB);
assertNoLocks();
}
public void testPhantomChildren() throws Exception
{
- cache.put(AB, "k", "v");
- assert cache.getNode(AB).getChildren().size() == 0;
- assert cache.getNode(A).getChildren().size() == 1;
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
+ assert tl.cache.getNode(AB).getChildren().size() == 0;
+ assert tl.cache.getNode(A).getChildren().size() == 1;
- tm.begin();
- cache.put(ABC, "k", "v");
- assert cache.getRoot().hasChild(ABC);
- assert cache.getNode(ABC) != null;
- assert cache.getNode(AB).getChild(ABC.getLastElement()) != null;
- assert cache.getNode(AB).getChildren().size() == 1;
- Transaction t = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(ABC, "k", "v");
+ assert tl.cache.getRoot().hasChild(ABC);
+ assert tl.cache.getNode(ABC) != null;
+ assert tl.cache.getNode(AB).getChild(ABC.getLastElement()) != null;
+ assert tl.cache.getNode(AB).getChildren().size() == 1;
+ Transaction t = tl.tm.suspend();
- assert cache.getNode(ABC) == null;
- assert cache.getNode(AB).getChild(ABC.getLastElement()) == null;
- assert cache.getNode(AB).getChildren().size() == 0;
+ assert tl.cache.getNode(ABC) == null;
+ assert tl.cache.getNode(AB).getChild(ABC.getLastElement()) == null;
+ assert tl.cache.getNode(AB).getChildren().size() == 0;
- tm.resume(t);
- assert cache.getRoot().hasChild(ABC);
- assert cache.getNode(ABC) != null;
- tm.commit();
+ tl.tm.resume(t);
+ assert tl.cache.getRoot().hasChild(ABC);
+ assert tl.cache.getNode(ABC) != null;
+ tl.tm.commit();
- assert cache.getNode(ABC) != null;
- assert cache.getNode(AB).getChild(ABC.getLastElement()) != null;
- assert cache.getNode(AB).getChildren().size() == 1;
+ assert tl.cache.getNode(ABC) != null;
+ assert tl.cache.getNode(AB).getChild(ABC.getLastElement()) != null;
+ assert tl.cache.getNode(AB).getChildren().size() == 1;
}
public void testChildCount() throws Exception
{
- cache.put(AB, "k", "v");
- assert cache.getNode(AB).getChildren().size() == 0;
- assert cache.getNode(A).getChildren().size() == 1;
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
+ assert tl.cache.getNode(AB).getChildren().size() == 0;
+ assert tl.cache.getNode(A).getChildren().size() == 1;
- tm.begin();
- assert cache.getNode(AB).getChildren().size() == 0;
- assert cache.getNode(A).getChildren().size() == 1;
- cache.removeNode(AB);
- assert cache.getNode(A).getChildren().size() == 0;
- assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
- assert cache.getNode(AB) == null;
- Transaction t = tm.suspend();
+ tl.tm.begin();
+ assert tl.cache.getNode(AB).getChildren().size() == 0;
+ assert tl.cache.getNode(A).getChildren().size() == 1;
+ tl.cache.removeNode(AB);
+ assert tl.cache.getNode(A).getChildren().size() == 0;
+ assert tl.cache.getNode(A).hasChild(AB.getLastElement()) == false;
+ assert tl.cache.getNode(AB) == null;
+ Transaction t = tl.tm.suspend();
- assert cache.getNode(AB) != null;
- assert cache.getNode(A).getChild(AB.getLastElement()) != null;
- assert cache.getNode(A).getChildren().size() == 1;
+ assert tl.cache.getNode(AB) != null;
+ assert tl.cache.getNode(A).getChild(AB.getLastElement()) != null;
+ assert tl.cache.getNode(A).getChildren().size() == 1;
- tm.resume(t);
- assert cache.getNode(A).getChildren().size() == 0;
- assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
- assert cache.getNode(AB) == null;
- tm.commit();
+ tl.tm.resume(t);
+ assert tl.cache.getNode(A).getChildren().size() == 0;
+ assert tl.cache.getNode(A).hasChild(AB.getLastElement()) == false;
+ assert tl.cache.getNode(AB) == null;
+ tl.tm.commit();
- assert cache.getNode(A).getChildren().size() == 0;
- assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
- assert cache.getNode(AB) == null;
+ assert tl.cache.getNode(A).getChildren().size() == 0;
+ assert tl.cache.getNode(A).hasChild(AB.getLastElement()) == false;
+ assert tl.cache.getNode(AB) == null;
}
public void testOverwritingOnInsert() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
- tm.begin();
- cache.put(ABC, "k", "v");
- assert "v".equals(cache.get(ABC, "k"));
- assert "v".equals(cache.get(AB, "k"));
- Transaction t1 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(ABC, "k", "v");
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ Transaction t1 = tl.tm.suspend();
- tm.begin();
- cache.put(AB, "k", "v2");
- assert "v2".equals(cache.get(AB, "k"));
- assert null == cache.get(ABC, "k");
- Transaction t2 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v2");
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert null == tl.cache.get(ABC, "k");
+ Transaction t2 = tl.tm.suspend();
- tm.resume(t1);
+ tl.tm.resume(t1);
t1.commit();
- assert "v".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
- tm.resume(t2);
+ tl.tm.resume(t2);
t2.commit();
- assert "v2".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
}
public void testOverwritingOnInsert2() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
- tm.begin();
- cache.put(AB, "k", "v2");
- assert "v2".equals(cache.get(AB, "k"));
- assert null == cache.get(ABC, "k");
- Transaction t1 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v2");
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert null == tl.cache.get(ABC, "k");
+ Transaction t1 = tl.tm.suspend();
- tm.begin();
- cache.put(ABC, "k", "v");
- assert "v".equals(cache.get(ABC, "k"));
- assert "v".equals(cache.get(AB, "k"));
- Transaction t2 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(ABC, "k", "v");
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ Transaction t2 = tl.tm.suspend();
- tm.resume(t1);
+ tl.tm.resume(t1);
t1.commit();
- assert "v2".equals(cache.get(AB, "k"));
- assert null == cache.get(ABC, "k");
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert null == tl.cache.get(ABC, "k");
- tm.resume(t2);
+ tl.tm.resume(t2);
t2.commit();
- assert "v2".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
}
public void testOverwritingOnInsert3() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
- tm.begin();
- cache.put(AB, "k", "v2");
- assert "v2".equals(cache.get(AB, "k"));
- assert null == cache.get(ABC, "k");
- Transaction t1 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(AB, "k", "v2");
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert null == tl.cache.get(ABC, "k");
+ Transaction t1 = tl.tm.suspend();
- tm.begin();
- cache.put(ABC, "k", "v");
- assert "v".equals(cache.get(ABC, "k"));
- assert "v".equals(cache.get(AB, "k"));
- tm.commit();
+ tl.tm.begin();
+ tl.cache.put(ABC, "k", "v");
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ tl.tm.commit();
- assert "v".equals(cache.get(ABC, "k"));
- assert "v".equals(cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
- tm.resume(t1);
+ tl.tm.resume(t1);
t1.commit();
- assert "v2".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
+ assert "v2".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
}
public void testConcurrentInsertRemove1() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
- tm.begin();
- cache.put(ABC, "k", "v");
- assert "v".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
- Transaction t1 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.put(ABC, "k", "v");
+ assert "v".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ Transaction t1 = tl.tm.suspend();
- tm.begin();
- cache.removeNode(AB);
- assert null == cache.get(ABC, "k");
- assert null == cache.get(AB, "k");
- tm.commit();
+ tl.tm.begin();
+ tl.cache.removeNode(AB);
+ assert null == tl.cache.get(ABC, "k");
+ assert null == tl.cache.get(AB, "k");
+ tl.tm.commit();
- assert null == cache.get(ABC, "k");
- assert null == cache.get(AB, "k");
+ assert null == tl.cache.get(ABC, "k");
+ assert null == tl.cache.get(AB, "k");
- tm.resume(t1);
+ tl.tm.resume(t1);
t1.commit();
- assert null == cache.get(ABC, "k");
- assert null == cache.get(AB, "k");
+ assert null == tl.cache.get(ABC, "k");
+ assert null == tl.cache.get(AB, "k");
}
public void testConcurrentInsertRemove2() throws Exception
{
- cache.put(AB, "k", "v");
+ LockTestBaseTL tl = threadLocal.get();
+ tl.cache.put(AB, "k", "v");
- tm.begin();
- cache.removeNode(AB);
- assert null == cache.get(ABC, "k");
- assert null == cache.get(AB, "k");
- Transaction t1 = tm.suspend();
+ tl.tm.begin();
+ tl.cache.removeNode(AB);
+ assert null == tl.cache.get(ABC, "k");
+ assert null == tl.cache.get(AB, "k");
+ Transaction t1 = tl.tm.suspend();
- tm.begin();
- assert "v".equals(cache.get(AB, "k"));
- cache.put(ABC, "k", "v");
- assert "v".equals(cache.get(ABC, "k"));
- tm.commit();
+ tl.tm.begin();
+ assert "v".equals(tl.cache.get(AB, "k"));
+ tl.cache.put(ABC, "k", "v");
+ assert "v".equals(tl.cache.get(ABC, "k"));
+ tl.tm.commit();
- assert "v".equals(cache.get(AB, "k"));
- assert "v".equals(cache.get(ABC, "k"));
+ assert "v".equals(tl.cache.get(AB, "k"));
+ assert "v".equals(tl.cache.get(ABC, "k"));
- tm.resume(t1);
+ tl.tm.resume(t1);
t1.commit();
- assert null == cache.get(ABC, "k");
- assert null == cache.get(AB, "k");
+ assert null == tl.cache.get(ABC, "k");
+ assert null == tl.cache.get(AB, "k");
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.mvcc;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.api.NodeMoveAPITest;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -12,13 +13,13 @@
@Test(groups = {"functional", "mvcc"})
public abstract class NodeMoveMvccTestBase extends NodeMoveAPITest
{
- Fqn A_B = Fqn.fromRelativeFqn(A, B);
- Fqn A_B_C = Fqn.fromRelativeFqn(A_B, C);
- Fqn A_B_C_E = Fqn.fromRelativeFqn(A_B_C, E);
- Fqn A_B_D = Fqn.fromRelativeFqn(A_B, D);
- Fqn C_E = Fqn.fromRelativeFqn(C, E);
- Fqn D_B = Fqn.fromRelativeFqn(D, B);
- Fqn D_B_C = Fqn.fromRelativeFqn(D_B, C);
+ static final Fqn A_B = Fqn.fromRelativeFqn(A, B);
+ static final Fqn A_B_C = Fqn.fromRelativeFqn(A_B, C);
+ static final Fqn A_B_C_E = Fqn.fromRelativeFqn(A_B_C, E);
+ static final Fqn A_B_D = Fqn.fromRelativeFqn(A_B, D);
+ static final Fqn C_E = Fqn.fromRelativeFqn(C, E);
+ static final Fqn D_B = Fqn.fromRelativeFqn(D, B);
+ static final Fqn D_B_C = Fqn.fromRelativeFqn(D_B, C);
public NodeMoveMvccTestBase()
@@ -29,6 +30,7 @@
@Override
protected void checkLocks()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockManager lm = cr.getComponent(LockManager.class);
InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
@@ -43,6 +45,7 @@
@Override
protected void checkLocksDeep()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockManager lm = cr.getComponent(LockManager.class);
InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
@@ -62,6 +65,7 @@
@Override
protected void assertNoLocks()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockManager lm = cr.getComponent(LockManager.class);
InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
@@ -70,6 +74,7 @@
public void testNonexistentSource()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put(A_B_C, "k", "v");
assert "v".equals(cache.get(A_B_C, "k"));
assert 1 == cache.getNode(A_B).getChildren().size();
@@ -86,6 +91,7 @@
public void testNonexistentTarget()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put(A_B_C, "k", "v");
assert "v".equals(cache.get(A_B_C, "k"));
assert 1 == cache.getNode(A_B).getChildren().size();
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.mvcc.read_committed;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.ComponentRegistry;
@@ -17,6 +18,7 @@
@Override
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
super.configureCache();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
@@ -25,6 +27,7 @@
@AfterMethod
public void postTest()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,8 @@
package org.jboss.cache.api.mvcc.read_committed;
+import javax.transaction.TransactionManager;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Node;
import org.jboss.cache.api.NodeAPITest;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -29,6 +32,9 @@
protected void assertNodeLockingScheme()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ TransactionManager tm = cache.getTransactionManager();
+
assert cache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.MVCC;
boolean interceptorChainOK = false;
@@ -52,6 +58,8 @@
@Override
protected void childrenUnderTxCheck() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
assert cache.getNode(A_B) != null;
assert cache.getNode(A_C) != null;
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,7 @@
package org.jboss.cache.api.mvcc.read_committed;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -19,9 +21,13 @@
@Override
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "debug=true", false, true, false);
+
+ String binName = "bin-" + Thread.currentThread().getName();
+
+ CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "debug=true,bin=" + binName, false, true, false);
clc.setPassivation(true);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
@@ -29,6 +35,7 @@
@AfterMethod
public void postTest()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.mvcc.repeatable_read;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.ComponentRegistry;
@@ -17,6 +18,7 @@
@Override
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
super.configureCache();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
@@ -25,6 +27,7 @@
@AfterMethod
public void postTest()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.mvcc.repeatable_read;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.api.NodeAPITest;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -30,6 +31,8 @@
protected void assertNodeLockingScheme()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
assert cache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.MVCC;
boolean interceptorChainOK = false;
@@ -53,6 +56,8 @@
@Override
protected void childrenUnderTxCheck() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
assert cache.getNode(A_B) != null;
assert cache.getNode(A_C) != null;
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.mvcc.repeatable_read;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -19,6 +20,7 @@
@Override
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "", false, true, false);
@@ -29,6 +31,7 @@
@AfterMethod
public void postTest()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,6 +4,8 @@
import org.testng.annotations.Test;
import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import org.jboss.cache.Cache;
@Test(groups = {"functional", "mvcc"})
public class RepeatableReadLockTest extends LockTestBase
@@ -15,6 +17,10 @@
public void testRepeatableReadWithRemove() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
+ Cache<String, String> cache = tl.cache;
+ TransactionManager tm = tl.tm;
+
cache.put(AB, "k", "v");
tm.begin();
@@ -39,6 +45,10 @@
public void testRepeatableReadWithEvict() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
+ Cache<String, String> cache = tl.cache;
+ TransactionManager tm = tl.tm;
+
cache.put(AB, "k", "v");
tm.begin();
@@ -63,6 +73,10 @@
public void testRepeatableReadWithNull() throws Exception
{
+ LockTestBaseTL tl = threadLocal.get();
+ Cache<String, String> cache = tl.cache;
+ TransactionManager tm = tl.tm;
+
assert cache.getNode(AB) == null;
tm.begin();
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/WriteSkewTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/WriteSkewTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/WriteSkewTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.api.mvcc.repeatable_read;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.api.mvcc.LockAssert;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -22,8 +21,9 @@
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
-@Test(groups = {"functional", "mvcc"})
+@Test(groups = {"functional", "mvcc"}, sequential = true)
public class WriteSkewTest
{
protected Cache<String, String> cache;
@@ -39,7 +39,7 @@
@BeforeMethod
public void setUp()
{
- cache = new DefaultCacheFactory<String, String>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL), false);
+ cache = new UnitTestCacheFactory<String, String>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL), false);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
@@ -51,6 +51,10 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
+ icc = null;
+ lockManager = null;
+ tm = null;
}
private void postStart()
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,8 +1,10 @@
package org.jboss.cache.api.nodevalidity;
+import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.testng.annotations.Test;
@@ -20,6 +22,9 @@
public void testTombstoneRevival()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
modifier.put(parent, K, V);
modifier.removeNode(parent);
@@ -43,11 +48,16 @@
public void testTombstoneVersioningFailure() throws Exception
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
CacheSPI modifierImpl = (CacheSPI) modifier;
CacheSPI observerImpl = (CacheSPI) observer;
modifier.put(parent, K, V);
+ DummyInMemoryCacheLoader loader = loaderTL.get();
+
// test that this exists in the (shared) loader
assert loader.get(parent) != null;
assert loader.get(parent).size() > 0;
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,9 +1,10 @@
package org.jboss.cache.api.nodevalidity;
+import java.util.Properties;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -19,7 +20,7 @@
@Test(groups = {"functional", "pessimistic"})
public class InvalidatedPessNodeValidityTest extends NodeValidityTestBase
{
- protected DummyInMemoryCacheLoader loader;
+ protected ThreadLocal<DummyInMemoryCacheLoader> loaderTL = new ThreadLocal<DummyInMemoryCacheLoader>();
public InvalidatedPessNodeValidityTest()
{
@@ -40,21 +41,27 @@
@AfterMethod
public void emptyCacheLoader()
{
- if (loader != null) loader.wipe();
+ DummySharedInMemoryCacheLoader loader = (DummySharedInMemoryCacheLoader) loaderTL.get();
+ if (loader != null) loader.wipeBin();
+ loaderTL.set(null);
}
protected Cache<String, String> newCache()
{
- CacheFactory<String, String> f = new DefaultCacheFactory<String, String>();
- Cache<String, String> cache = f.createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ CacheFactory<String, String> f = new UnitTestCacheFactory<String, String>();
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ Cache<String, String> cache = f.createCache(c, false);
nodeLockingSchemeSpecificSetup(cache.getConfiguration());
// need a cache loader as a shared data source between the 2 instances
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
iclc.setClassName(DummySharedInMemoryCacheLoader.class.getName());
- CacheLoaderConfig clc = new CacheLoaderConfig();
- clc.addIndividualCacheLoaderConfig(iclc);
+ Properties props = new Properties();
+ props.setProperty("bin", "bin-" + Thread.currentThread().getName());
+ iclc.setProperties(props);
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ clc.addIndividualCacheLoaderConfig(iclc);
cache.getConfiguration().setCacheLoaderConfig(clc);
// disable state transfer!!
cache.getConfiguration().setFetchInMemoryState(false);
@@ -63,7 +70,8 @@
CacheSPI spi = (CacheSPI) cache;
- loader = (DummyInMemoryCacheLoader) spi.getCacheLoaderManager().getCacheLoader();
+ DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader) spi.getCacheLoaderManager().getCacheLoader();
+ loaderTL.set(loader);
return cache;
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
@@ -15,7 +15,7 @@
@Test(groups = {"functional", "pessimistic"})
public class LocalPessNodeValidityTest extends NodeValidityTestBase
{
- private Cache<String, String> cache;
+ private ThreadLocal<Cache<String, String>> cacheTL = new ThreadLocal<Cache<String, String>>();
public LocalPessNodeValidityTest()
{
@@ -26,9 +26,10 @@
@AfterMethod
public void tearDown()
{
+ Cache<String, String> cache = cacheTL.get();
super.tearDown();
TestingUtil.killCaches(cache);
- cache = null;
+ cacheTL.set(null);
}
protected Cache<String, String> createObserver()
@@ -38,12 +39,15 @@
protected Cache<String, String> createModifier()
{
+ Cache<String, String> cache = cacheTL.get();
+
if (cache == null)
{
- CacheFactory<String, String> f = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> f = new UnitTestCacheFactory<String, String>();
cache = f.createCache(false);
nodeLockingSchemeSpecificSetup(cache.getConfiguration());
cache.start();
+ cacheTL.set(cache);
return cache;
}
return cache;
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -34,11 +34,12 @@
// needed to test tombstones
protected boolean invalidation = false;
- protected Cache<String, String> observer;
- protected Cache<String, String> modifier;
- protected Fqn parent = Fqn.fromString("/parent");
- protected Fqn child = Fqn.fromString("/parent/child");
- protected String K = "k", V = "v";
+ protected ThreadLocal<Cache<String, String>> observerTL = new ThreadLocal<Cache<String, String>>();
+ protected ThreadLocal<Cache<String, String>> modifierTL = new ThreadLocal<Cache<String, String>>();
+
+ protected static final Fqn parent = Fqn.fromString("/parent");
+ protected static final Fqn child = Fqn.fromString("/parent/child");
+ protected static final String K = "k", V = "v";
protected abstract Cache<String, String> createObserver();
@@ -63,21 +64,27 @@
@BeforeMethod
public void setUp()
{
- observer = createObserver();
- modifier = createModifier();
+ Cache<String, String> observer = createObserver();
+ Cache<String, String> modifier = createModifier();
+ observerTL.set(observer);
+ modifierTL.set(modifier);
if (clustered) TestingUtil.blockUntilViewsReceived(60000, observer, modifier);
}
@AfterMethod
public void tearDown()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
TestingUtil.killCaches(observer, modifier);
- observer = null;
- modifier = null;
+ observerTL.set(null);
+ modifierTL.set(null);
}
public void testRemoval()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
// observer.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
observer.put(parent, K, V);
@@ -93,6 +100,8 @@
public void testRemovalWithChildren()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
// observer.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
observer.put(child, K, V);
@@ -111,6 +120,9 @@
public void testMove()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
Fqn newParent = Fqn.fromString("/newParent/parent");
//observer.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
@@ -135,6 +147,9 @@
public void testMoveWithChildren()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
Fqn newParent = Fqn.fromString("/newParent/parent");
Fqn newChild = Fqn.fromString("/newParent/parent/child");
@@ -166,6 +181,9 @@
public void testEvict()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
// eviction should affect validity
observer.put(parent, K, V);
Node<String, String> obsNode = observer.getRoot().getChild(parent);
@@ -181,6 +199,9 @@
public void testOperationsOnInvalidNode()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
observer.put(parent, K, V);
Node<String, String> obsNode = observer.getRoot().getChild(parent);
@@ -296,6 +317,9 @@
public void testExistenceOfTombstones()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
CacheSPI modifierImpl = (CacheSPI) modifier;
CacheSPI observerImpl = (CacheSPI) observer;
@@ -328,6 +352,9 @@
public void testExistenceOfTombstonesWithChildren()
{
+ Cache<String, String> observer = observerTL.get();
+ Cache<String, String> modifier = modifierTL.get();
+
CacheSPI modifierImpl = (CacheSPI) modifier;
CacheSPI observerImpl = (CacheSPI) observer;
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.testng.annotations.Test;
@@ -25,9 +25,11 @@
protected Cache<String, String> newCache()
{
- CacheFactory<String, String> f = new DefaultCacheFactory<String, String>();
- Cache<String, String> cache = f.createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ CacheFactory<String, String> f = new UnitTestCacheFactory<String, String>();
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+
+ Cache<String, String> cache = f.createCache(c, false);
nodeLockingSchemeSpecificSetup(cache.getConfiguration());
cache.start();
return cache;
Modified: core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,6 +11,7 @@
import java.util.List;
import java.util.Set;
+import org.jboss.cache.CacheSPI;
/**
* An optimistic version of {@link org.jboss.cache.api.NodeAPITest}
@@ -25,6 +26,8 @@
protected void assertNodeLockingScheme()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
assert cache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
boolean interceptorChainOK = false;
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -36,37 +36,38 @@
*/
public void testNoOpWhenLockedAnd0msTimeout() throws Exception
{
+ PutForExternalReadTestBaseTL threadCfg = threadLocal.get();
// create the parent node first ...
- cache1.put(parentFqn, key, value);
+ threadCfg.cache1.put(parentFqn, key, value);
- tm1.begin();
- cache1.put(parentFqn, key, value2);
+ threadCfg.tm1.begin();
+ threadCfg.cache1.put(parentFqn, key, value2);
- Transaction t = tm1.suspend();
+ Transaction t = threadCfg.tm1.suspend();
- assertLocked(parentFqn, cache1, true);
+ assertLocked(parentFqn, threadCfg.cache1, true);
// parentFqn should be write-locked.
long startTime = System.currentTimeMillis();
- cache1.putForExternalRead(fqn, key, value);
+ threadCfg.cache1.putForExternalRead(fqn, key, value);
long waited = System.currentTimeMillis() - startTime;
// crappy way to test that pFER does not block, but it is effective.
- assertTrue("Should not wait " + waited + " millis for lock timeout, should attempt to acquire lock with 0ms!", waited < cache1.getConfiguration().getLockAcquisitionTimeout());
+ assertTrue("Should not wait " + waited + " millis for lock timeout, should attempt to acquire lock with 0ms!", waited < threadCfg.cache1.getConfiguration().getLockAcquisitionTimeout());
// should not block.
- tm1.resume(t);
- tm1.commit();
+ threadCfg.tm1.resume(t);
+ threadCfg.tm1.commit();
asyncWait();
- assertEquals("Parent node write should have succeeded", value2, cache1.get(parentFqn, key));
+ assertEquals("Parent node write should have succeeded", value2, threadCfg.cache1.get(parentFqn, key));
if (isUsingInvalidation())
- assertNull("Parent node write should have invalidated", cache2.get(parentFqn, key));
+ assertNull("Parent node write should have invalidated", threadCfg.cache2.get(parentFqn, key));
else
- assertEquals("Parent node write should have replicated", value2, cache2.get(parentFqn, key));
+ assertEquals("Parent node write should have replicated", value2, threadCfg.cache2.get(parentFqn, key));
- assertNull("PFER should have been a no-op", cache1.get(fqn, key));
- assertNull("PFER should have been a no-op", cache2.get(fqn, key));
+ assertNull("PFER should have been a no-op", threadCfg.cache1.get(fqn, key));
+ assertNull("PFER should have been a no-op", threadCfg.cache2.get(fqn, key));
}
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -5,7 +5,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.ReplicableCommand;
@@ -29,86 +28,98 @@
import javax.transaction.TransactionManager;
import java.util.List;
import java.util.Vector;
+import org.jboss.cache.UnitTestCacheFactory;
@Test(groups = {"functional", "jgroups", "transaction"})
public abstract class PutForExternalReadTestBase
{
// TODO: Refactor this test so it isn't bound to using Thread.sleep() calls.
- protected CacheSPI<String, String> cache1, cache2;
+ protected Configuration.CacheMode cacheMode;
+ protected NodeLockingScheme nodeLockingScheme;
+ protected final Fqn fqn = Fqn.fromString("/one/two");
+ protected final Fqn parentFqn = fqn.getParent();
+ protected final String key = "k", value = "v", value2 = "v2";
+
+ protected class PutForExternalReadTestBaseTL {
+ protected CacheSPI<String, String> cache1, cache2;
- ReplicationListener replListener1;
- ReplicationListener replListener2;
+ ReplicationListener replListener1;
+ ReplicationListener replListener2;
+ protected TransactionManager tm1, tm2;
- protected TransactionManager tm1, tm2;
+ protected boolean useTx;
+ }
+
+
+ ThreadLocal<PutForExternalReadTestBaseTL> threadLocal = new ThreadLocal<PutForExternalReadTestBaseTL>();
- protected Fqn fqn = Fqn.fromString("/one/two");
- protected Fqn parentFqn = fqn.getParent();
-
- protected String key = "k", value = "v", value2 = "v2";
-
- protected boolean useTx;
- protected Configuration.CacheMode cacheMode;
- protected NodeLockingScheme nodeLockingScheme;
-
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ PutForExternalReadTestBaseTL tl = new PutForExternalReadTestBaseTL();
+ threadLocal.set(tl);
+
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
- cache1 = (CacheSPI<String, String>) cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
- cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ tl.cache1 = (CacheSPI<String, String>) cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
+ tl.cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ tl.cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
- cache1.start();
- tm1 = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
+ tl.cache1.start();
+ tl.tm1 = tl.cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
- cache2 = (CacheSPI<String, String>) cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
- cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ tl.cache2 = (CacheSPI<String, String>) cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
+ tl.cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ tl.cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
- cache2.start();
- tm2 = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
+ tl.cache2.start();
+ tl.tm2 = tl.cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
- TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
+ TestingUtil.blockUntilViewsReceived(10000, tl.cache1, tl.cache2);
}
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- TestingUtil.killCaches(cache1, cache2);
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
+ if (tl != null) {
+ TestingUtil.killCaches(tl.cache1, tl.cache2);
+ threadLocal.set(null);
+ }
}
public void testNoOpWhenNodePresent()
{
- cache1.putForExternalRead(fqn, key, value);
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
+ tl.cache1.putForExternalRead(fqn, key, value);
asyncWait();
- assertEquals("PFER should have succeeded", value, cache1.get(fqn, key));
+ assertEquals("PFER should have succeeded", value, tl.cache1.get(fqn, key));
if (isUsingInvalidation())
- assertNull("PFER should not have effected cache2", cache2.get(fqn, key));
+ assertNull("PFER should not have effected cache2", tl.cache2.get(fqn, key));
else
- assertEquals("PFER should have replicated", value, cache2.get(fqn, key));
+ assertEquals("PFER should have replicated", value, tl.cache2.get(fqn, key));
// reset
- cache1.removeNode(fqn);
+ tl.cache1.removeNode(fqn);
asyncWait();
- assertFalse("Should have reset", cache1.getRoot().hasChild(fqn));
- assertFalse("Should have reset", cache2.getRoot().hasChild(fqn));
+ assertFalse("Should have reset", tl.cache1.getRoot().hasChild(fqn));
+ assertFalse("Should have reset", tl.cache2.getRoot().hasChild(fqn));
- cache1.put(fqn, key, value);
+ tl.cache1.put(fqn, key, value);
asyncWait();
// now this pfer should be a no-op
- cache1.putForExternalRead(fqn, key, value2);
+ tl.cache1.putForExternalRead(fqn, key, value2);
- assertEquals("PFER should have been a no-op", value, cache1.get(fqn, key));
+ assertEquals("PFER should have been a no-op", value, tl.cache1.get(fqn, key));
if (isUsingInvalidation())
- assertNull("PFER should have been a no-op", cache2.get(fqn, key));
+ assertNull("PFER should have been a no-op", tl.cache2.get(fqn, key));
else
- assertEquals("PFER should have been a no-op", value, cache2.get(fqn, key));
+ assertEquals("PFER should have been a no-op", value, tl.cache2.get(fqn, key));
}
private Vector<Address> anyAddresses()
@@ -119,12 +130,13 @@
public void testAsyncForce() throws Exception
{
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
RPCManager rpcManager = EasyMock.createNiceMock(RPCManager.class);
- RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
+ RPCManager originalRpcManager = tl.cache1.getConfiguration().getRuntimeConfig().getRPCManager();
List<Address> memberList = originalRpcManager.getMembers();
expect(rpcManager.getMembers()).andReturn(memberList).anyTimes();
// inject a mock RPC manager so that we can test whether calls made are sync or async.
- ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache1);
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(tl.cache1);
cr.registerComponent(rpcManager, RPCManager.class);
cr.rewire();
@@ -139,49 +151,51 @@
replay(rpcManager);
// now try a simple replication. Since the RPCManager is a mock object it will not actually replicate anything.
- cache1.putForExternalRead(fqn, key, value);
+ tl.cache1.putForExternalRead(fqn, key, value);
verify(rpcManager);
// cleanup
- TestingUtil.extractComponentRegistry(cache1).registerComponent(originalRpcManager, RPCManager.class);
- cache1.removeNode(fqn);
+ TestingUtil.extractComponentRegistry(tl.cache1).registerComponent(originalRpcManager, RPCManager.class);
+ tl.cache1.removeNode(fqn);
}
public void testTxSuspension() throws Exception
{
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
// create parent node first
- cache1.put(parentFqn, key, value);
+ tl.cache1.put(parentFqn, key, value);
// start a tx and do some stuff.
- tm1.begin();
- cache1.get(parentFqn, key);
- cache1.putForExternalRead(fqn, key, value); // should have happened in a separate tx and have committed already.
- Transaction t = tm1.suspend();
+ tl.tm1.begin();
+ tl.cache1.get(parentFqn, key);
+ tl.cache1.putForExternalRead(fqn, key, value); // should have happened in a separate tx and have committed already.
+ Transaction t = tl.tm1.suspend();
asyncWait();
- assertLocked(parentFqn, cache1, false);
+ assertLocked(parentFqn, tl.cache1, false);
- assertEquals("PFER should have completed", value, cache1.get(fqn, key));
+ assertEquals("PFER should have completed", value, tl.cache1.get(fqn, key));
if (isUsingInvalidation())
- assertNull("PFER should not have effected cache2", cache2.get(fqn, key));
+ assertNull("PFER should not have effected cache2", tl.cache2.get(fqn, key));
else
- assertEquals("PFER should have completed", value, cache2.get(fqn, key));
+ assertEquals("PFER should have completed", value, tl.cache2.get(fqn, key));
- tm1.resume(t);
- tm1.commit();
+ tl.tm1.resume(t);
+ tl.tm1.commit();
- assertEquals("parent fqn tx should have completed", value, cache1.get(parentFqn, key));
+ assertEquals("parent fqn tx should have completed", value, tl.cache1.get(parentFqn, key));
if (isUsingInvalidation())
- assertNull("parent fqn tx should have invalidated cache2", cache2.get(parentFqn, key));
+ assertNull("parent fqn tx should have invalidated cache2", tl.cache2.get(parentFqn, key));
else
- assertEquals("parent fqn tx should have completed", value, cache2.get(parentFqn, key));
+ assertEquals("parent fqn tx should have completed", value, tl.cache2.get(parentFqn, key));
}
public void testExceptionSuppression() throws Exception
{
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
RPCManager barfingRpcManager = EasyMock.createNiceMock(RPCManager.class);
- RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
+ RPCManager originalRpcManager = tl.cache1.getConfiguration().getRuntimeConfig().getRPCManager();
try
{
List<Address> memberList = originalRpcManager.getMembers();
@@ -190,13 +204,13 @@
expect(barfingRpcManager.callRemoteMethods(anyAddresses(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andThrow(new RuntimeException("Barf!")).anyTimes();
replay(barfingRpcManager);
- TestingUtil.extractComponentRegistry(cache1).registerComponent(barfingRpcManager, RPCManager.class);
- cache1.getConfiguration().getRuntimeConfig().setRPCManager(barfingRpcManager);
- TestingUtil.extractComponentRegistry(cache1).rewire();
+ TestingUtil.extractComponentRegistry(tl.cache1).registerComponent(barfingRpcManager, RPCManager.class);
+ tl.cache1.getConfiguration().getRuntimeConfig().setRPCManager(barfingRpcManager);
+ TestingUtil.extractComponentRegistry(tl.cache1).rewire();
try
{
- cache1.put(fqn, key, value);
+ tl.cache1.put(fqn, key, value);
if (!isOptimistic()) fail("Should have barfed");
}
catch (RuntimeException re)
@@ -206,14 +220,14 @@
if (isOptimistic() && !isUsingInvalidation())
{
// proves that the put did, in fact, barf. Doesn't work for invalidations since the inability to invalidate will not cause a rollback.
- assertNull(cache1.get(fqn, key));
+ assertNull(tl.cache1.get(fqn, key));
}
else
{
// clean up any indeterminate state left over
try
{
- cache1.removeNode(fqn);
+ tl.cache1.removeNode(fqn);
// as above, the inability to invalidate will not cause an exception
if (!isUsingInvalidation()) fail("Should have barfed");
}
@@ -222,35 +236,36 @@
}
}
- assertNull("Should have cleaned up", cache1.get(fqn, key));
+ assertNull("Should have cleaned up", tl.cache1.get(fqn, key));
// should not barf
- cache1.putForExternalRead(fqn, key, value);
+ tl.cache1.putForExternalRead(fqn, key, value);
}
finally
{
- TestingUtil.extractComponentRegistry(cache1).registerComponent(originalRpcManager, RPCManager.class);
+ TestingUtil.extractComponentRegistry(tl.cache1).registerComponent(originalRpcManager, RPCManager.class);
}
}
public void testBasicPropagation() throws Exception
{
- assert !cache1.exists(fqn);
- assert !cache2.exists(fqn);
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
+ assert !tl.cache1.exists(fqn);
+ assert !tl.cache2.exists(fqn);
- cache1.putForExternalRead(fqn, key, value);
+ tl.cache1.putForExternalRead(fqn, key, value);
asyncWait();
- assertEquals("PFER updated cache1", value, cache1.get(fqn, key));
+ assertEquals("PFER updated cache1", value, tl.cache1.get(fqn, key));
Object expected = isUsingInvalidation() ? null : value;
- assertEquals("PFER propagated to cache2 as expected", expected, cache2.get(fqn, key));
+ assertEquals("PFER propagated to cache2 as expected", expected, tl.cache2.get(fqn, key));
// replication to cache 1 should NOT happen.
- cache2.putForExternalRead(fqn, key, value);
+ tl.cache2.putForExternalRead(fqn, key, value);
- assertEquals("PFER updated cache2", value, cache2.get(fqn, key));
- assertEquals("Cache1 should be unaffected", value, cache1.get(fqn, key));
+ assertEquals("PFER updated cache2", value, tl.cache2.get(fqn, key));
+ assertEquals("Cache1 should be unaffected", value, tl.cache1.get(fqn, key));
}
/**
@@ -280,55 +295,56 @@
*/
public void testMemLeakOnSuspendedTransactions() throws Exception
{
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
Fqn fqn2 = Fqn.fromString("/fqn/two");
- tm1.begin();
- cache1.putForExternalRead(fqn, key, value);
- tm1.commit();
+ tl.tm1.begin();
+ tl.cache1.putForExternalRead(fqn, key, value);
+ tl.tm1.commit();
TestingUtil.sleepThread(500);
- assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
- assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
- assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
- assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+ assert tl.cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tl.cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tl.cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tl.cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
- tm1.begin();
- cache1.putForExternalRead(fqn, key, value);
- cache1.put(fqn2, key, value);
- tm1.commit();
+ tl.tm1.begin();
+ tl.cache1.putForExternalRead(fqn, key, value);
+ tl.cache1.put(fqn2, key, value);
+ tl.tm1.commit();
asyncWait();
- assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
- assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
- assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
- assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+ assert tl.cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tl.cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tl.cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tl.cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
- tm1.begin();
- cache1.put(fqn2, key, value);
- cache1.putForExternalRead(fqn, key, value);
- tm1.commit();
+ tl.tm1.begin();
+ tl.cache1.put(fqn2, key, value);
+ tl.cache1.putForExternalRead(fqn, key, value);
+ tl.tm1.commit();
asyncWait();
- assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
- assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
- assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
- assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+ assert tl.cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tl.cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tl.cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tl.cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
- tm1.begin();
- cache1.put(fqn2, key, value);
- cache1.putForExternalRead(fqn, key, value);
- cache1.put(fqn2, key, value);
- tm1.commit();
+ tl.tm1.begin();
+ tl.cache1.put(fqn2, key, value);
+ tl.cache1.putForExternalRead(fqn, key, value);
+ tl.cache1.put(fqn2, key, value);
+ tl.tm1.commit();
asyncWait();
- assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
- assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
- assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
- assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
+ assert tl.cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
+ assert tl.cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
+ assert tl.cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2 should have no stale global TXs";
+ assert tl.cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
}
/**
@@ -339,29 +355,30 @@
*/
private void cacheModeLocalTest(boolean transactional) throws Exception
{
+ PutForExternalReadTestBaseTL tl = threadLocal.get();
RPCManager rpcManager = EasyMock.createMock(RPCManager.class);
- RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
+ RPCManager originalRpcManager = tl.cache1.getConfiguration().getRuntimeConfig().getRPCManager();
// inject a mock RPC manager so that we can test whether calls made are sync or async.
- cache1.getConfiguration().getRuntimeConfig().setRPCManager(rpcManager);
+ tl.cache1.getConfiguration().getRuntimeConfig().setRPCManager(rpcManager);
// specify that we expect nothing will be called on the mock Rpc Manager.
replay(rpcManager);
// now try a simple replication. Since the RPCManager is a mock object it will not actually replicate anything.
if (transactional)
- tm1.begin();
+ tl.tm1.begin();
- cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache1.putForExternalRead(fqn, key, value);
+ tl.cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ tl.cache1.putForExternalRead(fqn, key, value);
if (transactional)
- tm1.commit();
+ tl.tm1.commit();
verify(rpcManager);
// cleanup
- cache1.getConfiguration().getRuntimeConfig().setRPCManager(originalRpcManager);
- cache1.removeNode(fqn);
+ tl.cache1.getConfiguration().getRuntimeConfig().setRPCManager(originalRpcManager);
+ tl.cache1.removeNode(fqn);
}
protected abstract void assertLocked(Fqn fqn, CacheSPI cache, boolean writeLocked);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,6 +16,7 @@
import org.testng.annotations.Test;
import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -58,7 +59,7 @@
cache2.create();
cache2.addCacheListener(new BuddyJoinedListener(latch));
cache2.start();
- caches.add(cache2);
+ cachesTL.get().add(cache2);
}
private void replaceLatch(Cache<?, ?> cache, CountDownLatch newLatch)
@@ -79,7 +80,8 @@
public void testNonRegionBasedStateTransfer() throws Exception
{
- caches = new ArrayList<CacheSPI<Object, Object>>();
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ cachesTL.set(caches);
caches.add(createCache(1, "TEST", false, true));
Fqn main = Fqn.fromString("/a/b/c");
@@ -115,7 +117,8 @@
public void testRegionBasedStateTransfer() throws Exception
{
- caches = new ArrayList<CacheSPI<Object, Object>>();
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ cachesTL.set(caches);
CountDownLatch latch = new CountDownLatch(4);
@@ -190,7 +193,8 @@
public void testPersistentStateTransfer() throws Exception
{
- caches = new ArrayList<CacheSPI<Object, Object>>();
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ cachesTL.set(caches);
CountDownLatch latch = new CountDownLatch(2);
caches.add(createCacheWithCacheLoader(false, false, false, true, false));
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.BuddyReplicationConfig;
@@ -24,6 +23,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests handling of the buddy backup region during region
@@ -38,8 +38,8 @@
public static final Fqn A_B = Fqn.fromString("/a/b");
public static final String JOE = "JOE";
- protected Map<String, Cache> caches;
- private ClassLoader orig_TCL;
+ protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
+ private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();
public void testBuddyBackupActivation() throws Exception
{
@@ -127,6 +127,9 @@
boolean startCache)
throws Exception
{
+
+ Map<String, Cache> caches = cachesTL.get();
+
if (caches.get(cacheID) != null)
{
throw new IllegalStateException(cacheID + " already created");
@@ -135,9 +138,9 @@
CacheMode mode = sync ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(mode);
- CacheSPI<?, ?> cache = (CacheSPI<?, ?>) new DefaultCacheFactory<Object, Object>().createCache(c, false);
+ CacheSPI<?, ?> cache = (CacheSPI<?, ?>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
- cache.getConfiguration().setClusterName("TestCluster");
+ //cache.getConfiguration().setClusterName("TestCluster");
if (useMarshalling)
{
cache.getConfiguration().setUseRegionBasedMarshalling(true);
@@ -160,10 +163,11 @@
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- caches = new HashMap<String, Cache>();
+ Map<String, Cache> caches = new HashMap<String, Cache>();
+ cachesTL.set(caches);
// Save the TCL in case a test changes it
- orig_TCL = Thread.currentThread().getContextClassLoader();
+ orig_TCL_TL.set(Thread.currentThread().getContextClassLoader());
}
@AfterMethod(alwaysRun = true)
@@ -172,12 +176,14 @@
super.tearDown();
// Restore the TCL in case a test changed it
- Thread.currentThread().setContextClassLoader(orig_TCL);
+ Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
+ Map<String, Cache> caches = new HashMap<String, Cache>();
for (String cacheID : caches.keySet())
{
stopCache(caches.get(cacheID));
}
+ cachesTL.set(null);
}
protected void stopCache(Cache cache)
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -6,9 +6,11 @@
*/
package org.jboss.cache.buddyreplication;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.CachePrinter;
@@ -28,7 +30,8 @@
public void testSingleBuddy() throws Exception
{
log.debug("Running testSingleBuddy");
- caches = createCaches(3, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false);
+ cachesTL.set(caches);
System.out.println("*** Testing cache 0:");
assertIsBuddy(caches.get(0), caches.get(1), true);
@@ -45,7 +48,8 @@
public void test2Buddies() throws Exception
{
log.debug("Running test2Buddies");
- caches = createCaches(2, 3, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(2, 3, false);
+ cachesTL.set(caches);
TestingUtil.blockUntilViewsReceived(5000, caches.toArray(new Cache[0]));
// TestingUtil.sleepThread(2000);
@@ -64,7 +68,8 @@
public void testRemovalFromClusterSingleBuddy() throws Exception
{
log.debug("Running testRemovalFromClusterSingleBuddy");
- caches = createCaches(3, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false);
+ cachesTL.set(caches);
System.out.println("*** Testing cache 0");
assertIsBuddy(caches.get(0), caches.get(1), true);
@@ -91,7 +96,8 @@
public void testRemovalFromCluster2Buddies() throws Exception
{
log.debug("Running testRemovalFromCluster2Buddies");
- caches = createCaches(2, 4, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(2, 4, false);
+ cachesTL.set(caches);
assertNoLocks(caches);
System.out.println("*** Testing cache 0");
@@ -129,7 +135,8 @@
public void testAddingNewCaches() throws Exception
{
log.debug("Running testAddingNewCaches");
- caches = createCaches(2, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(2, false);
+ cachesTL.set(caches);
// get some data in there.
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -59,7 +59,8 @@
public void test2CachesWithPoolNames() throws Exception
{
log.error("Running test2CachesWithPoolNames");
- caches = createCaches(2, true);
+ List<CacheSPI<Object, Object>> caches = createCaches(2, true);
+ cachesTL.set(caches);
log.error("Created 2 caches");
BuddyManager m = caches.get(0).getBuddyManager();
@@ -73,7 +74,8 @@
{
log.debug("Running test3CachesWithPoolNames");
long st = System.currentTimeMillis();
- caches = createCaches(3, true);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, true);
+ cachesTL.set(caches);
System.out.println("Setup: " + (System.currentTimeMillis() - st));
st = System.currentTimeMillis();
@@ -89,7 +91,8 @@
public void testBuddyPoolSync() throws Exception
{
log.debug("Running testBuddyPoolSync");
- caches = createCaches(3, true);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, true);
+ cachesTL.set(caches);
Map map = caches.get(0).getBuddyManager().buddyPool;
@@ -105,7 +108,8 @@
public void testChangingBuddyPoolMembership() throws Exception
{
log.debug("Running testChangingBuddyPoolMembership");
- caches = createCaches(3, true);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, true);
+ cachesTL.set(caches);
Map map = caches.get(0).getBuddyManager().buddyPool;
@@ -136,7 +140,8 @@
{
log.debug("Running testConcurrency");
int numCaches = 4;
- caches = new ArrayList<CacheSPI<Object, Object>>(4);
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(4);
+ cachesTL.set(caches);
CountDownLatch latch = new CountDownLatch(1);
CacheStarter[] starters = new CacheStarter[numCaches];
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,8 +7,8 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.parsing.XmlConfigHelper;
@@ -16,6 +16,7 @@
import org.jboss.cache.config.parsing.element.BuddyElementParser;
import org.jboss.cache.interceptors.LegacyDataGravitatorInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -26,7 +27,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "jgroups"})
+@Test(groups = {"functional", "jgroups"}, sequential = true)
public class BuddyReplicationConfigTest
{
private CacheSPI<Object, Object> cache;
@@ -34,13 +35,13 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
public void testNullConfig() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(null);
assertNull(cache.getBuddyManager());
}
@@ -49,7 +50,7 @@
{
String xmlConfig = "<buddy enabled=\"false\"/>";
BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(config);
assertNull(cache.getBuddyManager());
}
@@ -58,9 +59,10 @@
{
String xmlConfig = "<buddy enabled=\"true\"/>";
BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache.getConfiguration().setBuddyReplicationConfig(config);
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setBuddyReplicationConfig(config);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache.create();
cache.start();
assertNotNull(cache.getBuddyManager());
@@ -84,7 +86,7 @@
public void testXmlConfig() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(new XmlConfigurationParser().parseFile("configs/buddy-replication-cache.xml"), false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(new XmlConfigurationParser().parseFile("configs/buddy-replication-cache.xml"), false);
cache.create();
cache.start();
BuddyManager bm = cache.getBuddyManager();
@@ -114,7 +116,7 @@
{
String xmlConfig = "<buddy enabled=\"true\"/>";
BuddyReplicationConfig config = getBuddyReplicationConfig(xmlConfig);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(config);
cache.create();
cache.start();
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -49,7 +49,8 @@
public void testSimplePut() throws Exception
{
log.debug("Running testSimplePut");
- caches = createCaches(3, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false);
+ cachesTL.set(caches);
String fqn = "/test";
String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
@@ -80,8 +81,9 @@
public void testPutAndRemove() throws Exception
{
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false);
+ cachesTL.set(caches);
log.debug("Running testPutAndRemove");
- caches = createCaches(3, false);
String fqn = "/test";
String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
@@ -125,7 +127,8 @@
public void testPutAndRemove2() throws Exception
{
log.debug("Running testPutAndRemove2");
- caches = createCaches(2, 4, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(2, 4, false);
+ cachesTL.set(caches);
String fqn = "/test";
String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
@@ -171,7 +174,8 @@
public void testBuddyJoin() throws Exception
{
log.debug("Running testBuddyJoin");
- caches = createCaches(2, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(2, false);
+ cachesTL.set(caches);
CacheSPI<Object, Object> cache2 = null;
try
@@ -246,9 +250,8 @@
public void testCompleteStateSurvival() throws Exception
{
log.debug("Running testCompleteStateSurvival");
- caches = null;
-
- caches = createCaches(3, false, true);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false, true);
+ cachesTL.set(caches);
CacheBlockListener blockListener = new CacheBlockListener();
caches.get(0).addCacheListener(blockListener);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -6,6 +6,7 @@
*/
package org.jboss.cache.buddyreplication;
+import java.util.List;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
@@ -39,7 +40,8 @@
private void testDataGravitation(boolean killOwner) throws Exception
{
- caches = createCaches(3, false, true, optimisticLocks);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false, true, optimisticLocks);
+ cachesTL.set(caches);
Fqn fqn = Fqn.fromString("/test");
Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
@@ -147,7 +149,8 @@
public void testDataReplicationSuppression() throws Exception
{
- caches = createCaches(3, false, false, optimisticLocks);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false, false, optimisticLocks);
+ cachesTL.set(caches);
Fqn fqn = Fqn.fromString("/test");
Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
@@ -183,7 +186,8 @@
public void testSubtreeRetrieval() throws Exception
{
- caches = createCaches(3, false, true, optimisticLocks);
+ List<CacheSPI<Object, Object>> caches = createCaches(3, false, true, optimisticLocks);
+ cachesTL.set(caches);
Fqn fqn = Fqn.fromString("/test");
Fqn fqn2 = Fqn.fromString("/test/subtree");
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,14 +4,14 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheStatus;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.TestingUtil;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -25,7 +25,7 @@
*
* @author Fredrik Johansson, Cubeia Ltd
*/
-@Test
+@Test(sequential = true)
public class BuddyReplicationRejoinTest extends BuddyReplicationTestsBase
{
private static Log log = LogFactory.getLog(BuddyReplicationRejoinTest.class);
@@ -38,7 +38,7 @@
private Cache<String, Integer> cache1;
private Cache<String, Integer> cache2;
- @BeforeTest
+ @BeforeMethod
public void setUp() throws Exception
{
BuddyReplicationConfig brc = new BuddyReplicationConfig();
@@ -54,14 +54,16 @@
// Cache1 will be used only for recovery.
// Cache2 will perform some updates on the objects and then fail.
- cache1 = new DefaultCacheFactory<String, Integer>().createCache(c, false);
- cache2 = new DefaultCacheFactory<String, Integer>().createCache(c.clone(), false);
+ cache1 = new UnitTestCacheFactory<String, Integer>().createCache(c, false);
+ cache2 = new UnitTestCacheFactory<String, Integer>().createCache(c.clone(), false);
}
- @AfterTest
+ @AfterMethod
public void tearDown()
{
TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
/**
@@ -141,7 +143,7 @@
checkRecoveredData(cache1, 1);
printCacheDetails("DATA GRAVITATED BACK TO CACHE1");
- cache2 = new DefaultCacheFactory<String, Integer>().createCache(cfg);
+ cache2 = new UnitTestCacheFactory<String, Integer>().createCache(cfg);
printCacheDetails("BUDDY BACK");
runBuddyUpdatesAndFail();
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -29,6 +28,7 @@
import javax.transaction.TransactionManager;
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Base class for BR tests
@@ -38,7 +38,7 @@
@Test(groups = {"functional", "jgroups"})
public abstract class BuddyReplicationTestsBase
{
- protected List<CacheSPI<Object, Object>> caches;
+ protected ThreadLocal<List<CacheSPI<Object, Object>>> cachesTL = new ThreadLocal<List<CacheSPI<Object, Object>>>();
protected BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
@AfterMethod(alwaysRun = true)
@@ -46,6 +46,7 @@
{
System.out.println("***** TEARING DOWN *****");
System.setProperty("org.jboss.cache.shutdown.force", "true");
+ List<CacheSPI<Object, Object>> caches = cachesTL.get();
if (caches != null)
{
// an optimisation to aid the progress of unit tests, especially in the case of TCP connections. Note that this
@@ -93,8 +94,11 @@
}
}
}
- caches = null;
+ cachesTL.set(null);
System.gc();
+
+ new UnitTestCacheFactory().cleanUp();
+
}
protected final static int VIEW_BLOCK_TIMEOUT = 5000;
@@ -126,9 +130,11 @@
protected CacheSPI<Object, Object> createCache(boolean optimisticLocks, int numBuddies, String buddyPoolName, boolean useDataGravitation, boolean removeOnFind, boolean start) throws Exception
{
- CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, false, false, true), false);
- c.getConfiguration().setClusterName("BuddyReplicationTest");
+ CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, false, false, true), false);
+ String threadId = Thread.currentThread().getName();
+ //c.getConfiguration().setClusterName("BuddyReplicationTest-" + threadId);
+
BuddyReplicationConfig brc = new BuddyReplicationConfig();
if (buddyPoolName != null) brc.setBuddyPoolName(buddyPoolName);
brc.setEnabled(true);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -25,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests use of the data gravitator alongside other cache loaders as well as data gravitator options such as removeOnFind.
@@ -67,7 +67,8 @@
throws Exception
{
// create 3 caches
- caches = createCachesWithCacheLoader(3, autoGravitate, true, passivation);
+ List<CacheSPI<Object, Object>> caches = createCachesWithCacheLoader(3, autoGravitate, true, passivation);
+ cachesTL.set(caches);
CacheLoader[] loaders = getLoaders(caches);
@@ -171,7 +172,8 @@
throws Exception
{
// create 3 caches
- caches = createCachesWithCacheLoader(3, autoGravitate, false, passivation);
+ List<CacheSPI<Object, Object>> caches = createCachesWithCacheLoader(3, autoGravitate, false, passivation);
+ cachesTL.set(caches);
CacheLoader[] loaders = getLoaders(caches);
Fqn b1 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
Fqn b2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
@@ -245,11 +247,11 @@
Configuration cfg1 = cache1.getConfiguration();
configureEviction(cfg1);
Configuration cfg0 = cfg1.clone();
- CacheSPI<Object, Object> cache0 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cfg0, false);
+ CacheSPI<Object, Object> cache0 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cfg0, false);
// Store them for the teardown method
- if (caches == null)
- caches = new ArrayList<CacheSPI<Object, Object>>();
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ cachesTL.set(caches);
caches.add(cache0);
caches.add(cache1);
@@ -295,13 +297,13 @@
Configuration cfg0 = cache0.getConfiguration();
configureEviction(cfg0);
Configuration cfg1 = cfg0.clone();
- CacheSPI<Object, Object> cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cfg1, false);
+ CacheSPI<Object, Object> cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cfg1, false);
Configuration cfg2 = cfg0.clone();
- CacheSPI<Object, Object> cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cfg2, false);
+ CacheSPI<Object, Object> cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cfg2, false);
// Store them for the teardown method
- if (caches == null)
- caches = new ArrayList<CacheSPI<Object, Object>>();
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ cachesTL.set(caches);
caches.add(cache0);
caches.add(cache1);
caches.add(cache2);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -6,6 +6,7 @@
*/
package org.jboss.cache.buddyreplication;
+import java.util.List;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
import static org.jboss.cache.util.TestingUtil.dumpCacheContents;
@@ -13,6 +14,7 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.CacheSPI;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
@@ -27,7 +29,9 @@
public void testTransactionsCommit() throws Exception
{
- caches = createCaches(3, false, true, false);
+ List<CacheSPI<Object, Object>> caches = caches = createCaches(3, false, true, false);
+ cachesTL.set(caches);
+
caches.get(0).put(fqn, key, value);
Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
@@ -93,7 +97,8 @@
public void testTransactionsRollback() throws Exception
{
- caches = createCaches(3, false, true, false);
+ List<CacheSPI<Object, Object>> caches = caches = createCaches(3, false, true, false);
+ cachesTL.set(caches);
caches.get(0).put(fqn, key, value);
Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.buddyreplication;
+import java.util.List;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
@@ -17,7 +18,8 @@
{
public void testCachesWithoutStateTransfer() throws Exception
{
- caches = createCaches(1, 3, false, false, false, false);
+ List<CacheSPI<Object, Object>> caches = createCaches(1, 3, false, false, false, false);
+ cachesTL.set(caches);
int cacheNumber = 0;
for (CacheSPI c : caches)
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.notifications.annotation.BuddyGroupChanged;
@@ -9,19 +8,20 @@
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.TestingUtil;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
/**
* To test http://jira.jboss.org/jira/browse/JBCACHE-1349
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class EmptyRegionTest extends BuddyReplicationTestsBase
{
CacheSPI c1, c2;
@@ -30,13 +30,13 @@
Region region, region2;
CountDownLatch buddyJoinLatch = new CountDownLatch(1);
- @BeforeTest
+ @BeforeMethod
public void setUp() throws Exception
{
c1 = createCache(1, null, false, false, false);
c1.getConfiguration().setUseRegionBasedMarshalling(true);
c1.getConfiguration().setFetchInMemoryState(true);
- c2 = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(c1.getConfiguration().clone(), false);
+ c2 = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c1.getConfiguration().clone(), false);
c1.start();
region = c1.getRegion(regionFqn, true);
region2 = c1.getRegion(region2Fqn, true);
@@ -48,10 +48,12 @@
c2.addCacheListener(new BuddyJoinListener());
}
- @AfterTest
+ @AfterMethod
public void tearDown()
{
TestingUtil.killCaches(c1, c2);
+ c1 = null;
+ c2 = null;
}
public void testEmptyRegion() throws InterruptedException
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,45 +1,49 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.eviction.NullEvictionAlgorithmConfig;
import org.jboss.cache.util.TestingUtil;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
/**
* Tests the eviction of buddy backup regions
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.2.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class EvictionOfBuddyBackupsTest extends BuddyReplicationTestsBase
{
private CacheSPI cache1, cache2;
private Fqn fqn = Fqn.fromString("/a/b/c");
- @BeforeTest
+ @BeforeMethod
public void setUp() throws Exception
{
cache1 = createCache(1, null, true, false);
cache1.getConfiguration().setEvictionConfig(getEvictionConfig());
cache1.start();
- cache2 = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone());
+ cache2 = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone());
TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
}
- @AfterTest
- public void tearDown()
+ @AfterMethod
+ @Override
+ public void tearDown() throws Exception
{
+ super.tearDown();
TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
private EvictionConfig getEvictionConfig()
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.buddyreplication;
+import java.util.List;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.CachePrinter;
@@ -10,7 +11,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class GravitationCleanupTest extends BuddyReplicationTestsBase
{
Fqn fqn = Fqn.fromString("/a/b/c");
@@ -39,7 +40,8 @@
private void testDataOwner(boolean optimistic) throws Exception
{
- caches = createCaches(1, 2, false, true, optimistic);
+ List<CacheSPI<Object, Object>> caches = createCaches(1, 2, false, true, optimistic);
+ cachesTL.set(caches);
// add some stuff on the primary
CacheSPI dataOwner = caches.get(0);
@@ -79,7 +81,8 @@
private void testBuddy(boolean optimistic) throws Exception
{
- caches = createCaches(1, 3, false, true, optimistic);
+ List<CacheSPI<Object, Object>> caches = createCaches(1, 3, false, true, optimistic);
+ cachesTL.set(caches);
// add some stuff on the primary
CacheSPI dataOwner = caches.get(0);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -28,7 +28,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class NextMemberBuddyLocatorTest
{
private IpAddress dataOwner;
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -5,6 +5,7 @@
import org.testng.annotations.Test;
import java.util.ArrayList;
+import java.util.List;
/**
* Test added to replicate a found issue. When fixing it consider moving test to some other class.
@@ -19,7 +20,8 @@
{
CacheSPI cache1 = createCache(false, 1, "myBuddyPoolReplicationGroup", false, true, true);
CacheSPI cache2 = createCache(false, 1, "myBuddyPoolReplicationGroup", false, true, true);
- caches = new ArrayList<CacheSPI<Object, Object>>(2);
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(2);
+ cachesTL.set(caches);
caches.add(cache1);
caches.add(cache2);
int opCount = 10;
Modified: core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,6 @@
import org.easymock.EasyMock;
import static org.easymock.EasyMock.*;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.config.Configuration;
@@ -19,8 +18,9 @@
import java.util.Collections;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class ReplicationQueueTest
{
private static final int COUNT = 10;
@@ -32,16 +32,17 @@
@BeforeMethod
public void setUp() throws CloneNotSupportedException
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
- cache.getConfiguration().setUseReplQueue(true);
- cache.getConfiguration().setReplQueueMaxElements(COUNT);
- cache.getConfiguration().setReplQueueInterval(-1);
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
+ c.setUseReplQueue(true);
+ c.setReplQueueMaxElements(COUNT);
+ c.setReplQueueInterval(-1);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache.start();
registry = TestingUtil.extractComponentRegistry(cache);
replQ = registry.getComponent(ReplicationQueue.class);
originalRpcManager = cache.getConfiguration().getRuntimeConfig().getRPCManager();
- cache2 = new DefaultCacheFactory<Object, Object>().createCache(cache.getConfiguration().clone());
+ cache2 = new UnitTestCacheFactory<Object, Object>().createCache(cache.getConfiguration().clone());
TestingUtil.blockUntilViewsReceived(60000, cache, cache2);
}
@@ -52,6 +53,8 @@
// reset the original RPCManager
injectRpcManager(originalRpcManager);
TestingUtil.killCaches(cache, cache2);
+ cache = null;
+ cache2 = null;
}
private void injectRpcManager(RPCManager manager)
Modified: core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.cluster;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
@@ -11,8 +10,9 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class ReplicationQueueTxTest
{
Cache cache, cache2;
@@ -21,12 +21,13 @@
@BeforeMethod
public void setUp() throws CloneNotSupportedException
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_ASYNC), false);
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_ASYNC);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache.getConfiguration().setUseReplQueue(true);
cache.getConfiguration().setReplQueueInterval(100);
cache.getConfiguration().setReplQueueMaxElements(10);
cache.start();
- cache2 = new DefaultCacheFactory<Object, Object>().createCache(cache.getConfiguration().clone());
+ cache2 = new UnitTestCacheFactory<Object, Object>().createCache(cache.getConfiguration().clone());
TestingUtil.blockUntilViewsReceived(60000, cache, cache2);
txManager = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -36,6 +37,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache, cache2);
+ cache = null;
+ cache2 = null;
}
public void testTransactionalReplication() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/commands/RollbackOnNoOpTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/RollbackOnNoOpTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/RollbackOnNoOpTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.commands;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
@@ -10,12 +9,13 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class RollbackOnNoOpTest
{
private CacheSPI<Object, Object> cache;
@@ -25,7 +25,7 @@
public void setUp()
{
Configuration cacheConfig = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, false);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cacheConfig, false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cacheConfig, false);
cache.start();
txMgr = cache.getTransactionManager();
}
@@ -34,6 +34,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
+ txMgr = null;
}
public void testRollbackOnRemoveNodeDoesNotFail() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollbackTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.commands;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
@@ -13,6 +12,7 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Test to check that structural nodes are being removed on rollback: http://jira.jboss.com/jira/browse/JBCACHE-1365.
@@ -20,7 +20,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class StructuralNodesOnRollbackTest
{
private CacheSPI<Object, Object> cache;
@@ -30,7 +30,7 @@
public void setUp()
{
Configuration cacheConfig = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, false);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cacheConfig);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cacheConfig);
txMgr = cache.getTransactionManager();
}
@@ -38,6 +38,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
+ txMgr = null;
}
public void testNoTx() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -27,7 +27,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class GravitateDataCommandTest
{
LegacyGravitateDataCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/ClearDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/ClearDataCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/ClearDataCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,7 +14,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class ClearDataCommandTest extends AbstractVersionedDataCommandTest
{
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -13,7 +13,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class CreateNodeCommandTest extends AbstractDataCommandTest
{
CreateNodeCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/MoveCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/MoveCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/MoveCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -18,7 +18,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class MoveCommandTest extends AbstractDataCommandTest
{
MoveCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -23,7 +23,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class PutDataMapCommandTest extends TestContextBase
{
Fqn testFqn = Fqn.fromString("/testfqn");
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutKeyValueCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutKeyValueCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutKeyValueCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,7 +16,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class PutKeyValueCommandTest extends AbstractVersionedDataCommandTest
{
PessPutForExternalReadCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveKeyCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveKeyCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveKeyCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -15,7 +15,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class RemoveKeyCommandTest extends AbstractVersionedDataCommandTest
{
PessRemoveKeyCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveNodeCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveNodeCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/RemoveNodeCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,7 +12,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class RemoveNodeCommandTest extends AbstractVersionedDataCommandTest
{
PessRemoveNodeCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -23,7 +23,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class VersionedInvalidateCommandTest extends AbstractDataCommandTest
{
DataVersion dataVersion;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -15,7 +15,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class GetChildrenNamesCommandTest extends AbstractDataCommandTest
{
private GetChildrenNamesCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetDataMapCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GetDataMapCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetDataMapCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -13,7 +13,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class GetDataMapCommandTest extends AbstractDataCommandTest
{
GetDataMapCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -18,7 +18,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class GetKeyValueCommandTest extends TestContextBase
{
private IMocksControl control;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeysCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeysCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeysCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -13,7 +13,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class GetKeysCommandTest extends AbstractDataCommandTest
{
Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -20,7 +20,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class EvictCommandTest extends AbstractDataCommandTest
{
EvictCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/InvalidateCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/InvalidateCommandTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/InvalidateCommandTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -19,7 +19,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class InvalidateCommandTest extends AbstractDataCommandTest
{
InvalidateCommand command;
Modified: core/trunk/src/test/java/org/jboss/cache/config/ChannelInjectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ChannelInjectionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/config/ChannelInjectionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
import org.jgroups.JChannel;
@@ -12,6 +11,7 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests that JBC prefers an injected Channel to creating one via
@@ -20,7 +20,7 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ChannelInjectionTest
{
private Set<Cache<String, String>> caches = new HashSet<Cache<String, String>>();
@@ -32,13 +32,14 @@
{
try
{
- cache.stop();
+ TestingUtil.killCaches(cache);
}
catch (Exception e)
{
e.printStackTrace(System.out);
}
}
+ caches = null;
}
public void testChannelInjectionPreference() throws Exception
@@ -66,7 +67,7 @@
{
Configuration config = new Configuration();
config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
Cache<String, String> cache = instance.createCache(config, false);
caches.add(cache);
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementParserTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,7 +12,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 3.0
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class BuddyElementParserTest
{
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -26,13 +26,13 @@
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FilenameFilter;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* The purpose of this test is to make sure that the config files we ship are correct both according to xml schema and
@@ -88,12 +88,12 @@
public void testConfigWarnings()
{
- DefaultCacheFactory dcf = new DefaultCacheFactory();
+ UnitTestCacheFactory ucf = new UnitTestCacheFactory();
for (String aConfFile : getConfigFileNames())
{
System.out.println("Processing file: " + aConfFile);
assert !appender.isFoundUnknownWarning();
- Cache cache = dcf.createCache(CONFIG_ROOT + "/" + aConfFile);
+ Cache cache = ucf.createCache(CONFIG_ROOT + "/" + aConfFile);
cache.stop();
assert !appender.isFoundUnknownWarning();
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -26,6 +25,7 @@
import java.io.IOException;
import java.util.Properties;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests cache behavior in the presence of concurrent passivation.
@@ -33,7 +33,7 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ConcurrentEvictionTest
{
private Cache<Integer, String> cache;
@@ -56,7 +56,7 @@
void initCaches() throws Exception
{
TestingUtil.recursiveFileRemove(tmpDir + cacheLoaderDir);
- CacheFactory<Integer, String> factory = new DefaultCacheFactory<Integer, String>();
+ CacheFactory<Integer, String> factory = new UnitTestCacheFactory<Integer, String>();
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
conf.setEvictionConfig(buildEvictionConfig());
conf.setCacheLoaderConfig(buildCacheLoaderConfig());
@@ -98,6 +98,7 @@
{
TestingUtil.recursiveFileRemove(tmpDir + cacheLoaderDir);
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testConcurrentEviction() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThreadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThreadTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThreadTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,8 +1,8 @@
package org.jboss.cache.eviction;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.ComponentRegistry;
@@ -20,7 +20,7 @@
{
Configuration cfg = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL, true);
cfg.getEvictionConfig().setWakeupInterval(0);
- c = new DefaultCacheFactory<String, String>().createCache(cfg);
+ c = new UnitTestCacheFactory<String, String>().createCache(cfg);
ComponentRegistry cr = TestingUtil.extractComponentRegistry(c);
RegionManager rm = cr.getComponent(RegionManager.class);
EvictionTimerTask ett = rm.getEvictionTimerTask();
@@ -39,7 +39,7 @@
{
Configuration cfg = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL, true);
cfg.getEvictionConfig().setWakeupInterval(10);
- c = new DefaultCacheFactory<String, String>().createCache(cfg);
+ c = new UnitTestCacheFactory<String, String>().createCache(cfg);
ComponentRegistry cr = TestingUtil.extractComponentRegistry(c);
RegionManager rm = cr.getComponent(RegionManager.class);
EvictionTimerTask ett = rm.getEvictionTimerTask();
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,7 +12,7 @@
* @author Daniel Huang
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ElementSizeAlgorithmTest extends EvictionTestsBase
{
RegionManager regionManager;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -27,12 +26,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author Daniel Huang
* @version $Revison: $
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ElementSizePolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache;
@@ -64,7 +64,7 @@
evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/org/jboss/test/data"), new ElementSizeAlgorithmConfig(-1, 5)));
evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromString("/test/"), new ElementSizeAlgorithmConfig(5000, 1)));
conf.setEvictionConfig(evConfig);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf, false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf, false);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.start();
@@ -73,7 +73,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testEviction() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,13 +12,14 @@
import java.util.List;
import java.util.Set;
+import org.testng.annotations.AfterMethod;
/**
* @author Daniel Huang
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ElementSizeQueueTest
{
private ElementSizeQueue queue;
@@ -28,6 +29,11 @@
{
queue = new ElementSizeQueue();
}
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() {
+ queue = null;
+ }
public void testQueue() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,10 +7,10 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.util.TestingUtil;
@@ -196,7 +196,7 @@
try
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache();
regionManager = cache.getRegionManager();
assertEquals(0, regionManager.getAllRegions(Region.Type.ANY).size());
}
@@ -208,7 +208,7 @@
private CacheSPI<Object, Object> setupCache(String configurationName)
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(configurationName, false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(configurationName, false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.start();
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionQueueListTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionQueueListTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionQueueListTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,6 +14,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -21,7 +22,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class EvictionQueueListTest
{
EvictionQueueList list;
@@ -32,6 +33,12 @@
list = new EvictionQueueList();
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ list = null;
+ }
+
public void testAddToBottom() throws Exception
{
for (int i = 0; i < 100; i++)
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
@@ -23,6 +22,7 @@
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Unit tests for {@link org.jboss.cache.eviction.ExpirationAlgorithm}.
@@ -30,7 +30,7 @@
* @author Elias Ross
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ExpirationPolicyTest extends EvictionTestsBase
{
private static final Log log = LogFactory.getLog(ExpirationPolicyTest.class);
@@ -54,7 +54,7 @@
EvictionConfig econf = new EvictionConfig(eRC);
econf.setWakeupInterval(100);
conf.setEvictionConfig(econf);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf, false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf, false);
cache.start();
future = System.currentTimeMillis() + 500;
@@ -64,7 +64,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testUpdateToFuture() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -22,7 +22,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class FIFOAlgorithmTest extends EvictionTestsBase
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -26,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Unit tests for FIFOPolicy.
@@ -33,7 +33,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class FIFOPolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache;
@@ -66,13 +66,14 @@
config.setEvictionConfig(evConfig);
config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config, true);// read in generic local xml
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config, true);// read in generic local xml
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testEviction()
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOQueueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -13,6 +13,7 @@
import static org.testng.AssertJUnit.assertTrue;
import org.jboss.cache.config.EvictionConfig;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -22,7 +23,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class FIFOQueueTest
{
private static final int CAPACITY = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
@@ -35,6 +36,12 @@
queue = new FIFOQueue();
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ queue = null;
+ }
+
public void testQueue() throws Exception
{
for (int i = 0; i < 50000; i++)
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,6 +11,7 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.config.EvictionRegionConfig;
+import org.testng.annotations.AfterMethod;
import static org.jboss.cache.eviction.EvictionEvent.Type.*;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
@@ -22,7 +23,7 @@
* @author Daniel Huang - dhuang(a)jboss.org - 10/2005
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LFUAlgorithmTest extends EvictionTestsBase
{
RegionManager regionManager;
@@ -37,6 +38,14 @@
algo = (LFUAlgorithm) createAndAssignToRegion("/a/b", regionManager, config);
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ regionManager = null;
+ config = null;
+ algo = null;
+ }
+
public void testMaxNode1()
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -24,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Unit tests for LFU Policy.
@@ -31,7 +31,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LFUPolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache;
@@ -65,13 +65,14 @@
config.setEvictionConfig(evConfig);
config.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config, true);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config, true);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
/* THIS TEST NEEDS REWRITING
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,6 +12,7 @@
import java.util.List;
import java.util.Set;
+import org.testng.annotations.AfterMethod;
/**
* Unit tests for LFUQueue.
@@ -19,7 +20,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LFUQueueTest
{
private LFUQueue queue;
@@ -30,6 +31,12 @@
queue = new LFUQueue();
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ queue = null;
+ }
+
public void testQueue() throws Exception
{
NodeEntry ne;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,6 +7,7 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.BeforeMethod;
@@ -18,7 +19,7 @@
* @author Ben Wang, Feb 11, 2004
* @author Daniel Huang (dhuang(a)jboss.org)
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class LRUAlgorithmTest extends EvictionTestsBase
{
@@ -36,6 +37,14 @@
algorithm = (LRUAlgorithm) createAndAssignToRegion("/a/b", regionManager, config);
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ regionManager = null;
+ config = null;
+ algorithm = null;
+ }
+
/**
* maxNodes = 1. Eception is evictFromCacheNode. Should be commented for now.
*/
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
@@ -22,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Unit tests for LRU Policy.
@@ -30,7 +30,7 @@
* @author Daniel Huang - dhuang(a)jboss.org
* @version $Revision$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class LRUPolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache;
@@ -58,7 +58,7 @@
evConfig.setEvictionRegionConfigs(regionConfigs);
conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
conf.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(conf);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf);
wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
System.out.println("-- wakeupInterval is " + wakeupIntervalMillis);
@@ -74,7 +74,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testInUseEviction() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUQueueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUQueueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -15,6 +15,7 @@
import java.util.Iterator;
import org.jboss.cache.Fqn;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -23,7 +24,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LRUQueueTest
{
private LRUQueue queue;
@@ -34,6 +35,12 @@
queue = new LRUQueue();
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ queue = null;
+ }
+
public void testQueue() throws Exception
{
for (int i = 0; i < 500; i++)
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,6 +10,7 @@
import org.jboss.cache.RegionImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.testng.annotations.AfterMethod;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -20,7 +21,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class MRUAlgorithmTest extends EvictionTestsBase
{
MRUAlgorithm algorithm;
@@ -35,6 +36,13 @@
algorithm = (MRUAlgorithm) createAndAssignToRegion("/a/b", regionManager, config);
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ regionManager = null;
+ algorithm = null;
+ }
+
public void testMaxNodes() throws Exception
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,6 +9,7 @@
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.element.EvictionElementParser;
+import org.testng.annotations.AfterMethod;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.BeforeMethod;
@@ -21,7 +22,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = "unit", sequential = false)
+@Test(groups = "unit", sequential = true)
public class MRUConfigurationTest
{
MRUAlgorithmConfig config = null;
@@ -32,6 +33,12 @@
config = new MRUAlgorithmConfig();
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ config = null;
+ }
+
public void testXMLParsing() throws Exception
{
String xml =
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,8 +7,8 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
@@ -27,7 +27,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class MRUPolicyTest
{
CacheSPI<Object, Object> cache;
@@ -54,7 +54,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
private void initCaches()
@@ -70,7 +71,7 @@
config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config);
}
public void testEviction() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUQueueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUQueueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -22,7 +22,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class MRUQueueTest
{
private MRUQueue queue;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -20,8 +19,10 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class NullEvictionPolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache;
@@ -35,11 +36,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- if (cache != null)
- {
- cache.stop();
- cache.destroy();
- }
+ TestingUtil.killCaches(cache);
+ cache = null;
}
@@ -58,7 +56,7 @@
config.setEvictionConfig(evConfig);
config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config);
String dfltRootStr = "/a/";
String testRootStr = "/test/";
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -19,6 +18,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the eviction and the possible lack of locking nodes.
@@ -28,7 +28,7 @@
*
* @author fhenning
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class OptimisticEvictionTest extends EvictionTestsBase
{
private CacheSPI<Object, Object> cache;
@@ -39,7 +39,7 @@
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
config.setEvictionConfig(buildEvictionConfig());
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(config);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(config);
}
private EvictionConfig buildEvictionConfig() throws Exception
@@ -54,6 +54,7 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testEvictionOccurence() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -25,7 +25,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
import org.jboss.cache.config.Configuration;
@@ -40,6 +39,8 @@
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit tests for programmatic configuration of LRU policy
@@ -47,7 +48,7 @@
* @author Ben Wang, Oct, 2006
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ProgrammaticLRUPolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache;
@@ -69,7 +70,7 @@
private void initCaches()
{
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- CacheFactory<Object, Object> instance = new DefaultCacheFactory<Object, Object>();
+ CacheFactory<Object, Object> instance = new UnitTestCacheFactory<Object, Object>();
cache = (CacheSPI<Object, Object>) instance.createCache(conf, false);
EvictionConfig erc = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 200);
conf.setEvictionConfig(erc);
@@ -83,7 +84,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
private void addStringBasedRegion() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,12 +14,13 @@
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
+import org.testng.annotations.AfterMethod;
/**
* @author Ben Wang, Feb 11, 2004
* @author Daniel Huang (dhuang(a)jboss.org)
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class RegionTest
{
RegionManager regionManager;
@@ -35,6 +36,13 @@
r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), new LRUAlgorithmConfig()));
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ algorithm = null;
+ regionManager = null;
+ }
+
public void testAddedQueue() throws InterruptedException
{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.eviction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -18,11 +17,12 @@
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author Ben Wang, Feb 11, 2004
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ReplicatedLRUPolicyTest extends EvictionTestsBase
{
CacheSPI<Object, Object> cache1, cache2, cache3;
@@ -32,7 +32,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true), false);
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true), false);
cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache1.getConfiguration().setUseRegionBasedMarshalling(true);
cache1.getConfiguration().getEvictionConfig().setWakeupInterval(wakeupIntervalMillis);
@@ -41,7 +41,7 @@
cache1.getNotifier().addCacheListener(listener);
listener.resetCounter();
- cache3 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
+ cache3 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
cache3.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache3.getConfiguration().setUseRegionBasedMarshalling(true);
cache3.getConfiguration().getEvictionConfig().setWakeupInterval(wakeupIntervalMillis);
@@ -52,6 +52,9 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache1, cache2, cache3);
+ cache1 = null;
+ cache2 = null;
+ cache3 = null;
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/legacy/BackwardCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/legacy/BackwardCompatibilityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/legacy/BackwardCompatibilityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.eviction.legacy;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -25,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
@Test(groups = "functional", sequential = false)
public class BackwardCompatibilityTest
@@ -211,7 +211,7 @@
Cache cache = null;
try
{
- cache = new DefaultCacheFactory().createCache(c);
+ cache = new UnitTestCacheFactory().createCache(c);
EvictionRegionConfig erc = cache.getRegion(Fqn.ROOT, false).getEvictionRegionConfig();
assert erc.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.eviction.minttl;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
@@ -14,6 +13,8 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* This test exercises the minimum time to live for any element in the cache
@@ -21,7 +22,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public abstract class MinTTLTestBase extends EvictionTestsBase
{
// this should ideally be in an eviction test base class so all eviction policies can be tested
@@ -52,14 +53,15 @@
ec.setWakeupInterval(200);
ec.addEvictionRegionConfig(regionCfg);
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setEvictionConfig(ec);
}
@AfterMethod
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testNoMinimumTTL() throws InterruptedException
Modified: core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.factories;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.testng.annotations.Test;
@@ -14,7 +14,7 @@
{
public void testConstruction()
{
- Cache c = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC));
+ Cache c = new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC));
c.put("/a", "b", "c");
c.stop();
c.destroy();
Modified: core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorChainTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorChainTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorChainTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.factories;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import static org.testng.AssertJUnit.assertEquals;
@@ -11,11 +10,13 @@
import org.testng.annotations.Test;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class CustomInterceptorChainTest extends InterceptorChainTestBase
{
private CacheSPI<Object, Object> cache;
@@ -24,7 +25,7 @@
public void setUp() throws Exception
{
Configuration c = new Configuration();
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c);
cache.create();
}
@@ -33,7 +34,7 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -23,7 +23,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.CustomInterceptorConfig;
import org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor;
@@ -34,6 +33,8 @@
import java.util.Collections;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests how custom interceptor construction is handled.
@@ -41,7 +42,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 3.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CustomInterceptorConstructionTest
{
CacheSPI cache;
@@ -52,7 +53,7 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
}
cache = null;
}
@@ -156,12 +157,12 @@
Configuration config = new Configuration();
config.setCacheMode(Configuration.CacheMode.LOCAL);
config.setNodeLockingScheme(Configuration.NodeLockingScheme.MVCC);
- CacheFactory cacheFactory2 = new DefaultCacheFactory<Object, Object>();
+ CacheFactory cacheFactory2 = new UnitTestCacheFactory<Object, Object>();
CacheSPI tmpCacheSPI = (CacheSPI) cacheFactory2.createCache(config);
defaultInterceptroCount = tmpCacheSPI.getInterceptorChain().size();
tmpCacheSPI.stop();
- CacheFactory cacheFactory = new DefaultCacheFactory<Object, Object>();
+ CacheFactory cacheFactory = new UnitTestCacheFactory<Object, Object>();
config.setCustomInterceptors(interceptorConfig);
cache = (CacheSPI) cacheFactory.createCache(config, true);
}
Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
@@ -25,7 +25,7 @@
import java.util.Iterator;
import java.util.List;
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class InterceptorChainFactoryTest extends InterceptorChainTestBase
{
CacheSPI cache = null;
@@ -37,17 +37,14 @@
configuration.setCacheMode(LOCAL);
configuration.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
configuration.setUseLazyDeserialization(false);
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(configuration, false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(configuration,false);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- if (cache != null)
- {
- cache.stop();
- cache.destroy();
- }
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testBareConfig() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.factories;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -24,7 +24,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class LateConfigurationTest
{
CacheSPI c;
@@ -32,13 +32,14 @@
@BeforeMethod
public void setUp()
{
- c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
}
@AfterMethod
public void tearDown()
{
TestingUtil.killCaches(c);
+ c = null;
}
public void testTransactionManager()
Modified: core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.ReplicationException;
import org.jboss.cache.SuspectException;
@@ -25,6 +24,7 @@
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests restart (stop-destroy-create-start) of ComponentRegistry
@@ -32,7 +32,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class LifeCycleTest
{
private CacheSPI<Object, Object>[] c;
@@ -425,9 +425,10 @@
private CacheSPI<Object, Object> createCache(Configuration.CacheMode cache_mode)
{
- CacheSPI<Object, Object> retval = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- retval.getConfiguration().setCacheMode(cache_mode);
- retval.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ Configuration c = new Configuration();
+ c.setCacheMode(cache_mode);
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ CacheSPI<Object, Object> retval = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
return retval;
}
Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -21,6 +21,7 @@
import java.io.InputStream;
import java.net.URL;
+import org.jgroups.conf.ConfiguratorFactory;
/**
* Cache configuration factory used by unit tests.
@@ -120,7 +121,7 @@
tmp = tmp.replace("${jgroups.udp.mcast_addr:228.10.10.10}", "228.10.10.10");
tmp = tmp.replace("${jgroups.udp.mcast_port:45588}", "45588");
tmp = tmp.replace("${jgroups.udp.ip_ttl:2}", "2");
- System.out.println("config string: " + tmp);
+// System.out.println("config string: " + tmp);
return tmp;
}
catch (Exception e)
@@ -130,6 +131,34 @@
}
/**
+ * Helper method that takes a <b>JGroups</b> configuration file and creates an old-style JGroups config {@link String} that can be used
+ * in {@link org.jboss.cache.config.Configuration#setClusterConfig(String)}. Note that expressions
+ * in the file - such as <tt>${jgroups.udp.mcast_port:45588}</tt> are expanded out accordingly.
+ *
+ * @param properties config properties
+ * @return a String
+ */
+ public static String getClusterConfigFromProperties(String properties)
+ {
+ try
+ {
+ XmlConfigurator conf = XmlConfigurator.getInstance(ConfiguratorFactory.getConfigStream(properties));
+ String tmp = conf.getProtocolStackString();
+ // parse this string for ${} substitutions
+ // Highly crappy approach!!
+ tmp = tmp.replace("${jgroups.udp.mcast_addr:228.10.10.10}", "228.10.10.10");
+ tmp = tmp.replace("${jgroups.udp.mcast_port:45588}", "45588");
+ tmp = tmp.replace("${jgroups.udp.ip_ttl:2}", "2");
+ System.out.println("config string: " + tmp);
+ return tmp;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Problems with properties " + properties, e);
+ }
+ }
+
+ /**
* Takes a JGroups configuration "old-style" String and injects the "DELAY" protcol.
*
* @param jgroupsConfigString JGroups config string
Modified: core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import static org.jboss.cache.integration.hibernate.HibernateIntegrationTestUtil.*;
@@ -18,6 +17,8 @@
import javax.transaction.TransactionManager;
import java.util.HashSet;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests that mimic the Hibernate Second Level Cache UpdateTimestamps
@@ -29,7 +30,7 @@
*
* @author Brian Stansberry
*/
-@Test(groups = "integration")
+@Test(groups = "integration", sequential = true)
public class UpdateTimestampsCachingTest
{
private static final Log log = LogFactory.getLog(UpdateTimestampsCachingTest.class);
@@ -48,12 +49,13 @@
public void tearDown()
{
for (Cache<String, Object> cache : caches)
- cache.stop();
+ TestingUtil.killCaches(cache);
+ caches = null;
}
private Cache<String, Object> createCache(boolean optimistic)
{
- CacheFactory<String, Object> cf = new DefaultCacheFactory<String, Object>();
+ CacheFactory<String, Object> cf = new UnitTestCacheFactory<String, Object>();
Cache<String, Object> cache = cf.createCache("configs/local-tx.xml", false);
cache.getConfiguration().setNodeLockingScheme(optimistic ? Configuration.NodeLockingScheme.OPTIMISTIC : Configuration.NodeLockingScheme.PESSIMISTIC);
cache.start();
Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,12 +2,10 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.util.TestingUtil;
-import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@@ -15,6 +13,8 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.AfterMethod;
/**
* This is to test that "old-style" interceptors from 2.0.x and 2.1.x will work with the new interceptor structure.
@@ -22,7 +22,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.2.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class LegacyInterceptorTest
{
Cache cache;
@@ -30,27 +30,24 @@
TestInterceptor testInterceptor;
Executor testRunner;
- @BeforeTest
- public void setUp()
+ @BeforeMethod
+ public void createLatches()
{
- cache = new DefaultCacheFactory<Object, Object>().createCache();
+ cache = new UnitTestCacheFactory<Object, Object>().createCache();
testInterceptor = new TestInterceptor();
((CacheSPI) cache).addInterceptor(testInterceptor, TxInterceptor.class);
testRunner = Executors.newSingleThreadExecutor();
- }
- @BeforeMethod
- public void createLatches()
- {
interceptorResumeLatch = new CountDownLatch(1);
interceptorInvokedLatch = new CountDownLatch(1);
}
- @AfterTest
+ @AfterMethod
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testPut() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/MarshalledValueInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/MarshalledValueInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/MarshalledValueInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.MarshalledValueHelper;
import org.jboss.cache.util.CachePrinter;
@@ -13,12 +12,13 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class MarshalledValueInterceptorTest
{
CacheSPI c;
@@ -27,17 +27,18 @@
public void tearDown()
{
TestingUtil.killCaches(c);
+ c = null;
}
public void testDefaultInterceptorStack()
{
- c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache();
+ c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
assert TestingUtil.findInterceptor(c, MarshalledValueInterceptor.class) == null;
TestingUtil.killCaches(c);
- c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
c.getConfiguration().setUseLazyDeserialization(true);
c.start();
@@ -48,7 +49,7 @@
{
Configuration cfg = new Configuration();
cfg.setUseLazyDeserialization(true);
- c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(cfg);
+ c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(cfg);
System.out.println(CachePrinter.printCacheInterceptors(c));
assert TestingUtil.findInterceptor(c, MarshalledValueInterceptor.class) != null;
@@ -58,7 +59,7 @@
{
Configuration cfg = new Configuration();
cfg.setUseLazyDeserialization(false);
- c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(cfg);
+ c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(cfg);
System.out.println(CachePrinter.printCacheInterceptors(c));
assert TestingUtil.findInterceptor(c, MarshalledValueInterceptor.class) == null;
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -30,13 +29,14 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the async interceptor
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "jgroups"})
+@Test(groups = {"functional", "jgroups"}, sequential = true)
public class InvalidationInterceptorTest
{
private static Log log = LogFactory.getLog(InvalidationInterceptorTest.class);
@@ -868,12 +868,14 @@
protected CacheSPI<Object, Object> createUnstartedCache(boolean optimistic) throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setClusterName("MyCluster");
- cache.getConfiguration().setStateRetrievalTimeout(3000);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- if (optimistic) cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ Configuration c = new Configuration();
+ //c.setClusterName("MyCluster");
+ c.setStateRetrievalTimeout(3000);
+ c.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ if (optimistic) c.setNodeLockingScheme("OPTIMISTIC");
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
toClean.add(cache);
return cache;
}
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
@@ -17,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Make sure tombstones are evicted
@@ -24,7 +24,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class TombstoneEvictionTest
{
private CacheSPI c1, c2;
@@ -36,8 +36,9 @@
public void setUp() throws Exception
{
log.trace("**** setup called");
- c1 = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ Configuration c = new Configuration();
+
// the FIFO policy cfg
FIFOAlgorithmConfig cfg = new FIFOAlgorithmConfig();
cfg.setMaxNodes(1);
@@ -58,12 +59,13 @@
ec.setWakeupInterval(2000);
ec.setEvictionRegionConfigs(evictionRegionConfigs);
- c1.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- c1.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- c1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- c1.getConfiguration().setEvictionConfig(ec);
+ c.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c.setEvictionConfig(ec);
- c2 = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(c1.getConfiguration().clone(), false);
+ c1 = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+ c2 = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c.clone(), false);
c1.start();
c2.start();
@@ -75,6 +77,8 @@
public void tearDown()
{
TestingUtil.killCaches(c1, c2);
+ c1 = null;
+ c2 = null;
}
private static final Log log = LogFactory.getLog(TombstoneEvictionTest.class);
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/VersionInconsistencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/VersionInconsistencyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/VersionInconsistencyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -15,6 +14,7 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* This test simulates the problem described in JBCACHE-1155
@@ -22,7 +22,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class VersionInconsistencyTest
{
private Cache cache1, cache2;
@@ -32,18 +32,22 @@
@BeforeMethod
public void setUp()
{
- cache1 = new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- cache2.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ Configuration c1 = new Configuration();
+ Configuration c2 = new Configuration();
+
+ c1.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ c2.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- cache1.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- cache2.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ c1.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ c2.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c1.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c2.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c1, false);
+ cache2 = new UnitTestCacheFactory<Object, Object>().createCache(c2, false);
+
cache1.start();
cache2.start();
@@ -56,8 +60,9 @@
@AfterMethod
public void tearDown()
{
- cache1.stop();
- cache2.stop();
+ TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
public void dataInconsistency() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.testng.annotations.AfterMethod;
/**
* Tests functionality defined by InterceptorChain.
@@ -19,7 +20,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = {"unit"})
+@Test(groups = {"unit"}, sequential = true)
public class InterceptorChainTest
{
private CommandInterceptor icInterceptor;
@@ -40,6 +41,17 @@
chain = new InterceptorChain(icInterceptor);
}
+ @AfterMethod
+ public void tearDown()
+ {
+ icInterceptor = null;
+ invalidationInterceptor = null;
+ txInterceptor = null;
+ pessimisticInterceptor = null;
+ callInterceptor = null;
+ chain = null;
+ }
+
public void testGetIntercpetorsAsList() throws Throwable
{
invalidationInterceptor.setNext(txInterceptor);
Modified: core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.invocationcontext;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.transaction.TransactionContext;
@@ -14,13 +14,15 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* A test to ensure the transactional context is properly set up in the IC
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class TransactionTest
{
private CacheSPI<Object, Object> cache;
@@ -29,18 +31,15 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache("configs/local-tx.xml");
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache("configs/local-tx.xml");
tm = cache.getTransactionManager();
}
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- if (cache != null)
- {
- cache.stop();
- cache = null;
- }
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTxExistenceAfterWrite() throws Exception
@@ -153,7 +152,7 @@
cache = null;
}
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache("configs/replSync.xml", false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache("configs/replSync.xml", false);
cache.getConfiguration().setCacheMode(CacheMode.REPL_ASYNC);
cache.start();
tm = cache.getTransactionManager();
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -21,6 +21,7 @@
*/
package org.jboss.cache.jmx;
+import com.mchange.v2.c3p0.util.TestUtils;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
@@ -34,6 +35,9 @@
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tester class for {@link JmxRegistrationManager}.
@@ -41,10 +45,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 3.0
*/
-@Test (groups = "functional")
+@Test (groups = "functional", sequential = true)
public class JmxRegistrationManagerTest
{
- private DefaultCacheFactory cacheFactory = new DefaultCacheFactory();
+ private UnitTestCacheFactory cacheFactory = new UnitTestCacheFactory();
private MBeanServer mBeanServer;
@BeforeMethod
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,6 +24,7 @@
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the JMX wrapper class around the cache.
@@ -31,7 +32,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @author Brian Stansberry
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheJmxWrapperTest extends CacheJmxWrapperTestBase
{
public void testCacheMBeanBinding() throws Exception
@@ -85,7 +86,7 @@
// Go back to the default
wrapper.setCacheObjectName(null);
- assertEquals("Got default ObjectName", JmxRegistrationManager.REPLICATED_CACHE_PREFIX + CLUSTER_NAME, wrapper.getCacheObjectName());
+ assertEquals("Got default ObjectName", JmxRegistrationManager.REPLICATED_CACHE_PREFIX + clusterName, wrapper.getCacheObjectName());
registerWrapper(wrapper);
assertEquals("Returns standard name", mBeanName, new ObjectName(wrapper.getCacheObjectName()));
@@ -246,6 +247,9 @@
{
Configuration c = createConfiguration();
c.setCacheMode(CacheMode.REPL_ASYNC);
+ // This cache instance does not go through UnitTestCacheFactory so we need to modify
+ // it's config explicitelly.
+ new UnitTestCacheFactory<String, String>().mangleConfiguration(c);
CacheJmxWrapperMBean<String, String> wrapper = registerWrapper(c);
wrapper.start();
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.jboss.cache.jmx.JmxRegistrationManager;
import org.jboss.cache.jmx.CacheJmxWrapper;
@@ -18,6 +17,7 @@
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the JMX wrapper class around the cache.
@@ -28,8 +28,9 @@
@Test(groups = "functional")
public abstract class CacheJmxWrapperTestBase
{
- public static final String CLUSTER_NAME = "CacheMBeanTest";
+ public static final String CLUSTER_NAME_BASE = "CacheMBeanTest";
+ protected String clusterName;
protected Cache<String, String> cache;
protected CacheJmxWrapperMBean<String, String> jmxWrapper;
protected MBeanServer mBeanServer;
@@ -39,9 +40,10 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+ clusterName = CLUSTER_NAME_BASE + "-" + Thread.currentThread().getName();
mBeanServer = MBeanServerFactory.createMBeanServer("CacheMBeanTest");
- mBeanNameStr = JmxRegistrationManager.REPLICATED_CACHE_PREFIX + CLUSTER_NAME;
+ mBeanNameStr = JmxRegistrationManager.REPLICATED_CACHE_PREFIX + clusterName;
mBeanName = new ObjectName(mBeanNameStr);
}
@@ -109,7 +111,7 @@
protected Cache<String, String> createCache(Configuration config)
{
- CacheFactory<String, String> factory = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> factory = new UnitTestCacheFactory<String, String>();
cache = factory.createCache(config, false);
return cache;
}
@@ -117,7 +119,7 @@
protected Configuration createConfiguration()
{
Configuration c = new Configuration();
- c.setClusterName(CLUSTER_NAME);
+ c.setClusterName(clusterName);
c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.setExposeManagementStatistics(true);
c.setCacheMode(Configuration.CacheMode.LOCAL);
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegistrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegistrationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegistrationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -34,7 +34,7 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class InterceptorRegistrationTest extends CacheJmxWrapperTestBase
{
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -65,7 +65,7 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class LegacyConfigurationTest extends CacheJmxWrapperTestBase
{
@SuppressWarnings({"deprecation", "unchecked"})
@@ -234,7 +234,7 @@
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
- wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK);
+ wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK + Thread.currentThread().getName());
JChannelFactory factory = new JChannelFactory();
factory.setDomain("jbc.mux.test");
@@ -250,6 +250,10 @@
RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
assertNotNull("Channel created", rc.getChannel());
+
+ //wrapper.stop();
+ //wrapper.destroy();
+
}
protected static Element getBuddyReplicationConfig() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.jmx.JmxRegistrationManager;
@@ -24,6 +23,8 @@
import javax.management.ObjectName;
import java.util.EnumSet;
import java.util.HashMap;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Functional tests for CacheJmxWrapper broadcast of cache event notifications
@@ -31,7 +32,7 @@
* @author Jerry Gauthier
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class NotificationTest
{
protected static final String CLUSTER_NAME = "NotificationTestCluster";
@@ -109,7 +110,7 @@
{
// stop the cache before the listener is unregistered
//cache1.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
@@ -279,7 +280,7 @@
private CacheSPI<Object, Object> createCache(String clusterName) throws Exception
{
Configuration config = createConfiguration(clusterName);
- CacheFactory<Object, Object> factory = new DefaultCacheFactory<Object, Object>();
+ CacheFactory<Object, Object> factory = new UnitTestCacheFactory<Object, Object>();
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) factory.createCache(config, false);
cache.create();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -20,6 +19,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Properties;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the compatibility between <tt>JDBCCacheLoader</tt> and <tt>JDBCCacheLoaderOld</tt>. More exactly,
@@ -29,7 +29,7 @@
* @author Mircea.Markus(a)iquestint.com
* @version 1.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
@SuppressWarnings("deprecation")
public class AdjListJDBCCacheLoaderCompatibilityTest
{
@@ -51,8 +51,8 @@
{
newImpl = getNewCacheLoader();
oldImpl = getOldLoader();
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache();
- cache2 = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
+ cache2 = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
newImpl.setCache(cache);//this is needed for marshaller
oldImpl.setCache(cache2);
oldImpl.start();
@@ -67,6 +67,8 @@
newImpl.stop();
TestingUtil.killCaches(cache, cache2);
+ cache = null;
+ cache2 = null;
}
public void testCommonOperations() throws Exception
@@ -223,12 +225,16 @@
{
Properties prop = getProperties();
+ String tablePrefix = prop.getProperty("cache.jdbc.table.name", "jbosscache");
+ prop.setProperty("cache.jdbc.table.name", tablePrefix + TestingUtil.getThreadId());
+
String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
"cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
"cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
"cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n";
+ "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
+ "cache.jdbc.table.name=" + prop.getProperty("cache.jdbc.table.name");
CacheLoaderConfig.IndividualCacheLoaderConfig base = getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props).getFirstCacheLoaderConfig();
@@ -243,12 +249,16 @@
{
Properties prop = getProperties();
+ String tablePrefix = prop.getProperty("cache.jdbc.table.name", "jbosscache");
+ prop.setProperty("cache.jdbc.table.name", tablePrefix + TestingUtil.getThreadId());
+
String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
"cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
"cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
"cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat");// + "\n" +
+ "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
+ "cache.jdbc.table.name=" + prop.getProperty("cache.jdbc.table.name");
// "cache.jdbc.connection.factory=org.jboss.cache.manualtests.cacheloader.OneConnectionFactory";
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.config.Configuration;
@@ -18,8 +17,10 @@
import java.io.ByteArrayOutputStream;
import java.util.Collections;
import java.util.HashMap;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class AsyncFileCacheLoaderTest extends AbstractCacheLoaderTestBase
{
private CacheSPI<Object, Object> cache;
@@ -31,7 +32,7 @@
protected void configureCache(String props) throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
// cache.setCacheLoaderConfiguration(buildSingleCacheLoaderConfig("", "org.jboss.cache.loader.jdbm.JdbmCacheLoader",
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", props, true, false, true));
@@ -44,7 +45,8 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
@@ -18,15 +19,20 @@
@Override
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
- String tmpCLLoc = tmpDir + "/JBossCache-FileCacheLoaderTest";
+ String threadId = Thread.currentThread().getName();
+ String tmpCLLoc = tmpDir + "/JBossCache-BdbjeCacheLoaderTest-" + threadId;
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
+
public void testTransaction() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
// to help recreate the issue in
// http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048003#4048003
@@ -45,4 +51,5 @@
cache.getTransactionManager().commit();
}
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -5,7 +5,6 @@
import com.sleepycat.je.DeadlockException;
import com.sleepycat.je.Environment;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.bdbje.BdbjeCacheLoaderConfig;
@@ -27,6 +26,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests BdbjeCacheLoader directly via the CacheLoader interface.
@@ -37,7 +38,7 @@
*
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class BdbjeTest
{
@@ -104,7 +105,7 @@
{
try
{
- cache.stop();
+ TestingUtil.killCaches(cache);
}
catch (Exception ignored)
{
@@ -129,7 +130,7 @@
* name and TransactionManagerLookupClass (transactional) propertes only.
* the CacheSPI object is not used otherwise during testing.
*/
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setClusterName("myCluster");
if (transactional)
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -17,13 +17,14 @@
import org.testng.annotations.Test;
import com.mchange.v2.c3p0.PooledDataSource;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test for C3p0ConnectionFactory
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class C3p0ConnectionFactoryTest
{
private C3p0ConnectionFactory cf;
@@ -34,6 +35,12 @@
{
Properties prop = load("cache-jdbc.properties");
+ String tablePrefix = prop.getProperty("cache.jdbc.table.name", "jbosscache");
+ prop.setProperty("cache.jdbc.table.name", tablePrefix + TestingUtil.getThreadId());
+
+ String pkPrefix = prop.getProperty("cache.jdbc.table.primarykey", "jbosscache_pk");
+ prop.setProperty("cache.jdbc.table.primarykey", pkPrefix + TestingUtil.getThreadId());
+
config = new AdjListJDBCCacheLoaderConfig();
config.setProperties(prop);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,6 +7,8 @@
package org.jboss.cache.loader;
import java.util.Properties;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test that runs the the tests defined JDBCCacheLoaderTest using a standalone
@@ -28,8 +30,11 @@
"cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
"cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
- "cache.jdbc.connection.factory=" + CF_CLASS;
+ "cache.jdbc.connection.factory=" + CF_CLASS + "\n" +
+ "cache.jdbc.table.name=jbosscache" + TestingUtil.getThreadId() + "\n" +
+ "cache.jdbc.table.primarykey=jbosscache_pk" + TestingUtil.getThreadId();
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheLoaderManagerTest extends AbstractCacheLoaderTestBase
{
private LoadersElementParser loadersElementParser = new LoadersElementParser();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCounterTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,7 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
@@ -20,7 +20,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheLoaderMethodCallCounterTest extends AbstractCacheLoaderTestBase
{
private CacheSPI cache;
@@ -30,7 +30,7 @@
public void setUp() throws Exception
{
if (cache != null) tearDown();
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyCountingCacheLoader.class.getName(), "", false, false, false));
cache.start();
@@ -41,6 +41,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,12 +8,14 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -21,7 +23,7 @@
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class CacheLoaderPurgingTest extends AbstractCacheLoaderTestBase
{
private CacheSPI<Object, Object> cache;
@@ -34,14 +36,14 @@
if (cache != null)
{
cache.removeNode(Fqn.ROOT);
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
public void testSingleLoaderNoPurge() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
Configuration c = cache.getConfiguration();
c.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
@@ -65,7 +67,7 @@
public void testSingleLoaderPurge() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
Configuration c = cache.getConfiguration();
c.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false, true));
cache.start();
@@ -91,7 +93,7 @@
public void testTwoLoadersPurge() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
String xml =
" <loaders passivation=\"false\">\n" +
" <loader class=\"org.jboss.cache.loader.DummySharedInMemoryCacheLoader\" fetchPersistentState=\"true\"\n" +
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Node;
@@ -35,6 +34,8 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.Test;
/**
* Commons tests for all CacheLoaders
@@ -42,12 +43,14 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
private static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
- protected CacheSPI<Object, Object> cache;
- CacheLoader loader = null;
+
+ protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new ThreadLocal<CacheSPI<Object, Object>>();
+ ThreadLocal<CacheLoader> loaderTL = new ThreadLocal<CacheLoader>();
+
static final Fqn FQN = Fqn.fromString("/key");
private static final Fqn SUBTREE_FQN = Fqn.fromRelativeElements(FQN, "subtree");
@@ -56,19 +59,23 @@
private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, FQN);
private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, SUBTREE_FQN);
-
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
try
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> cache =
+ (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
+ cacheTL.set(cache);
+
Configuration c = cache.getConfiguration();
c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
configureCache();
cache.start();
- loader = cache.getCacheLoaderManager().getCacheLoader();
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ loaderTL.set(loader);
postConfigure();
}
catch (Exception e)
@@ -89,8 +96,12 @@
public void tearDown() throws Exception
{
cleanup();
- if (loader != null) loader.remove(Fqn.ROOT);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+ //if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
+ cacheTL.set(null);
+ loaderTL.set(null);
}
protected void cleanup()
@@ -111,6 +122,7 @@
*/
protected boolean exists(String fqn, String key)
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
if (key == null) return n != null;
return n != null && n.getKeysDirect().contains(key);
@@ -118,6 +130,7 @@
public void testPrint() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
cache.put(NODE, KEY, 10);
@@ -129,6 +142,7 @@
public void testPut() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -149,6 +163,8 @@
public void testPut2() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
final String NODE = "/a/b/c";
assertNull(loader.get(Fqn.fromString(NODE)));
final String KEY = "key";
@@ -177,6 +193,8 @@
{
final Fqn NODE = Fqn.fromString("/a/b/c");
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
cache.removeNode(NODE);
addDelay();
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -205,6 +223,7 @@
public void testShallowMove() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Fqn a = Fqn.fromString("/a");
Fqn b = Fqn.fromString("/b");
Fqn a_b = Fqn.fromString("/a/b");
@@ -234,6 +253,8 @@
public void testDeepMove() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn a = Fqn.fromString("/a");
Fqn b = Fqn.fromString("/b");
Fqn a_b = Fqn.fromString("/a/b");
@@ -272,6 +293,9 @@
*/
public void testPutRemoveCombos() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
final String NODE = "/a/b/c";
cache.removeNode(NODE);
Fqn fqn = Fqn.fromString(NODE);
@@ -292,6 +316,8 @@
public void testGet() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/a/b/c";
Object retval;
cache.removeNode(NODE);
@@ -311,6 +337,8 @@
public void testGetNode() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/a/b/c";
Node<Object, Object> retval;
cache.removeNode(NODE);
@@ -329,6 +357,8 @@
public void testSerialization() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
SamplePojo pojo = new SamplePojo(39, "Bela");
pojo.getHobbies().add("Running");
pojo.getHobbies().add("Beerathlon");
@@ -350,6 +380,7 @@
*/
public void testPopulate()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -387,6 +418,7 @@
public void testPreloading() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.removeNode(Fqn.ROOT);
cache.put("1/2/3/4/5/d", "key", "val");
cache.evict(Fqn.fromString("1/2/3/4/5/d"));
@@ -402,6 +434,7 @@
@SuppressWarnings("unchecked")
public void testCacheLoading2() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Set keys = null;
cache.put("/a/b/c", "key", "val");
keys = cache.getNode("/a/b/c").getKeys();
@@ -412,6 +445,7 @@
public void testExists()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put("/eins/zwei/drei", "key1", "val1");
assertTrue(cache.exists("/eins/zwei/drei"));
assert (exists("/eins/zwei/drei", "key1"));
@@ -422,6 +456,7 @@
public void testGetChildren()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1/2/3/4/5/d/one", null);
@@ -443,6 +478,7 @@
public void testGetChildrenWithEviction() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
cache.put("/a/b/c/3", null);
@@ -464,6 +500,7 @@
public void testGetChildren2()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -482,6 +519,7 @@
public void testGetChildren3()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -500,6 +538,7 @@
public void testGetChildren4()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
if (!cache.exists("/a/b/c"))
@@ -518,6 +557,7 @@
public void testGetChildren5()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/a/1", null);
@@ -540,6 +580,7 @@
public void testGetChildren6()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/a/1", null);
@@ -565,6 +606,7 @@
public void testGetChildren7()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/a/1", null);
@@ -592,6 +634,7 @@
public void testGetChildren8()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -611,6 +654,7 @@
public void testGetChildren9()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/a/1", null);
@@ -651,6 +695,7 @@
public void testGetChildren10()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/a/1", null);
@@ -683,6 +728,7 @@
public void testGetChildren11()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Set children;
try
{
@@ -725,6 +771,7 @@
public void testGetChildren12()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Set children;
cache.put("/a/b", "key", "val");
cache.put("/a/b/1", "key", "val");
@@ -756,6 +803,8 @@
public void testLoaderGetChildrenNames() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn f = Fqn.fromString("/a");
cache.put(f, "k", "v");
assertEquals("v", loader.get(f).get("k"));
@@ -764,6 +813,7 @@
public void testGetKeys() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Fqn f = Fqn.fromString("/a");
cache.put(f, "one", "one");
cache.put(f, "two", "two");
@@ -776,6 +826,8 @@
public void testGetData() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn f = Fqn.fromString("/a");
assert !cache.exists(f);
assert !loader.exists(f);
@@ -792,6 +844,7 @@
public void testRemoveData()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -808,6 +861,7 @@
public void testRemoveData2()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -826,6 +880,7 @@
public void testRemoveData3()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -841,6 +896,8 @@
public void testRemoveData4() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -861,6 +918,8 @@
public void testReplaceAll() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -886,6 +945,7 @@
public void testRemoveKey()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
assertEquals(1, cache.getNode(key).getKeys().size());
@@ -901,6 +961,7 @@
public void testRemoveKey2() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -917,6 +978,7 @@
public void testRemoveKey3() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -938,6 +1000,7 @@
public void testRemove()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -953,6 +1016,7 @@
public void testRemoveRoot()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
assertEquals(0, cache.getRoot().getKeys().size());
cache.put("/1/2/3/4/5", null);
cache.put("uno/due/tre", null);
@@ -965,6 +1029,8 @@
public void testLoaderRemoveRoot() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn f = Fqn.fromString("/a");
loader.put(f, "k", "v");
assertTrue(loader.get(f).containsKey("k"));
@@ -978,6 +1044,7 @@
public void testEvictionWithCacheLoader()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put("/first/second", "key1", "val1");// stored in cache loader
cache.put("/first/second/third", "key2", "val2");// stored in cache loader
cache.evict(Fqn.fromString("/first/second"));// doesn't remove node, just data !
@@ -995,6 +1062,7 @@
public void testEvictionWithCacheLoader2()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put("/first/second/third", "key1", "val1");// stored in cache loader
cache.evict(Fqn.fromString("/first/second/third"));// removes node, because there are no children
addDelay();
@@ -1011,6 +1079,7 @@
public void testEvictionWithGetChildrenNames() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -1040,6 +1109,8 @@
TransactionManager mgr = getTransactionManager();
mgr.begin();
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
cache.put("/one/two/three", "key1", "val1");
cache.put("/one/two/three/four", "key2", "val2");
mgr.commit();
@@ -1056,6 +1127,8 @@
{
TransactionManager mgr = getTransactionManager();
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
cache.removeNode("/one");
addDelay();
mgr.begin();
@@ -1106,6 +1179,8 @@
private void doTestBasicOperations() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
/* One FQN only. */
doPutTests(Fqn.fromString("/key"));
doRemoveTests(Fqn.fromString("/key"));
@@ -1136,6 +1211,7 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
assertTrue(!loader.exists(fqn));
/* put(Fqn,Object,Object) and get(Fqn,Object) */
@@ -1182,6 +1258,7 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
/* remove(Fqn,Object) */
Object oldVal;
oldVal = loader.remove(fqn, "one");
@@ -1216,6 +1293,8 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
/* Create top level node implicitly. */
assertTrue(!loader.exists(Fqn.fromString("/key0")));
loader.put(Fqn.fromString("/key0/level1/level2"), null);
@@ -1379,6 +1458,8 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
@@ -1448,6 +1529,8 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
Set set = loader.getChildrenNames(fqn);
if (names != null)
{
@@ -1493,6 +1576,8 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
/* PUT_KEY_VALUE, PUT_DATA */
List<Modification> list = createUpdates();
loader.put(list);
@@ -1539,6 +1624,9 @@
public void testOnePhaseTransaction()
throws Exception
{
+
+ CacheLoader loader = loaderTL.get();
+
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
checkModifications(mods);
@@ -1551,6 +1639,8 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
// Object txnKey = new Object();
TransactionManager mgr = getTransactionManager();
mgr.begin();
@@ -1569,6 +1659,7 @@
*/
public void testTransactionRollback() throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.remove(Fqn.fromString("/"));
int num;
try
@@ -1599,6 +1690,7 @@
*/
public void testIntegratedTransactionRollback() throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.remove(Fqn.fromString("/"));
int num = 0;
try
@@ -1666,6 +1758,7 @@
*/
private void checkModifications(List<Modification> list) throws Exception
{
+ CacheLoader loader = loaderTL.get();
for (Modification mod : list)
{
@@ -1707,6 +1800,8 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
loader.put(FQN, null, "x");
addDelay();
assertEquals("x", loader.get(FQN).get(null));
@@ -1765,6 +1860,7 @@
throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.put(FQN, "one", "two");
addDelay();
assertEquals("two", loader.get(FQN).get("one"));
@@ -1777,6 +1873,8 @@
throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
// Empty state
loader.remove(Fqn.fromString("/"));
@@ -1882,6 +1980,8 @@
public void testRemoveInTransactionCommit() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a/b");
loader.remove(fqn);
String key = "key";
@@ -1907,6 +2007,8 @@
public void testRemoveInTransactionRollback() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a/b");
loader.remove(fqn);
String key = "key";
@@ -1934,6 +2036,7 @@
*/
public void testRemoveAndGetInTransaction() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
Fqn fqn = Fqn.fromString("/a/b");
String key = "key";
String value = "value";
@@ -1956,6 +2059,8 @@
public void testPutAllAfterEvict() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -1981,6 +2086,8 @@
public void testPutAllAfterEvictWithChild() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -2012,6 +2119,8 @@
public void testPartialLoadAndStore()
throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
/* Empty state. */
loader.remove(Fqn.fromString("/"));
@@ -2067,6 +2176,8 @@
public void testBuddyBackupStore() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
/* Empty state. */
loader.remove(Fqn.ROOT);
@@ -2114,6 +2225,8 @@
public void testIgnoreModifications() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a");
cache.put(fqn, "k", "v");
assert "v".equals(cache.get(fqn, "k"));
@@ -2162,6 +2275,7 @@
protected void threadSafetyTest(final boolean singleFqn) throws Exception
{
+ final CacheLoader loader = loaderTL.get();
final CountDownLatch latch = new CountDownLatch(1);
final Fqn fqn = Fqn.fromString("/a/b/c");
final List<Fqn> fqns = new ArrayList<Fqn>(30);
@@ -2320,6 +2434,7 @@
protected TransactionManager getTransactionManager()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
return cache.getConfiguration().getRuntimeConfig().getTransactionManager();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -24,13 +23,14 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests using cache loaders with replicating data
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheLoaderWithReplicationTest extends AbstractCacheLoaderTestBase
{
private Cache<Object, Object> cache1, cache2;
@@ -43,11 +43,11 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache1 = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache1 = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, true, false));
cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache2 = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache2 = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, true, false));
cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
@@ -80,8 +80,7 @@
{
}
- cache1.stop();
- cache1.destroy();
+ TestingUtil.killCaches(cache1);
}
finally
{
@@ -112,8 +111,7 @@
{
}
- cache2.stop();
- cache2.destroy();
+ TestingUtil.killCaches(cache2);
}
finally
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -6,6 +6,7 @@
*/
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
@@ -21,8 +22,8 @@
@Test(groups = {"functional"})
public class ChainingCacheLoaderBasicTest extends CacheLoaderTestsBase
{
- private String loc1 = "JBossCache-ChainingCacheLoaderBasicTest-1";
- private String loc2 = "JBossCache-ChainingCacheLoaderBasicTest-2";
+ private static final String loc1 = "JBossCache-ChainingCacheLoaderBasicTest-1";
+ private static final String loc2 = "JBossCache-ChainingCacheLoaderBasicTest-2";
public ChainingCacheLoaderBasicTest()
{
@@ -35,6 +36,7 @@
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2));
TestingUtil.recursiveFileRemove(loc1);
TestingUtil.recursiveFileRemove(loc2);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -18,13 +17,15 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests ignoreModifications and tests contents of individual loaders
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ChainingCacheLoaderFullTest
{
private CacheSPI<Object, Object> cache;
@@ -37,7 +38,7 @@
protected void startCache(boolean ignoreMods1, boolean ignoreMods2) throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(ignoreMods1, ignoreMods2));
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
@@ -58,7 +59,7 @@
protected void cleanup() throws Exception
{
cache.removeNode(Fqn.ROOT);
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
@@ -28,13 +27,14 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests ClusteredCacheLoader
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ClusteredCacheLoaderTest extends AbstractCacheLoaderTestBase
{
private static Log log = LogFactory.getLog(ClusteredCacheLoaderTest.class);
@@ -50,22 +50,27 @@
public void setUp() throws Exception
{
if (cache1 != null || cache2 != null) tearDown();
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setClusterName("CCL-Test");
- cache1.getConfiguration().setStateRetrievalTimeout(2000);
- cache2.getConfiguration().setClusterName("CCL-Test");
- cache2.getConfiguration().setStateRetrievalTimeout(2000);
- cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ Configuration c1 = new Configuration();
+ Configuration c2 = new Configuration();
+ //c1.setClusterName("CCL-Test-" + Thread.currentThread().getName());
+ c1.setStateRetrievalTimeout(2000);
+ //c2.setClusterName("CCL-Test-" + Thread.currentThread().getName());
+ c2.setStateRetrievalTimeout(2000);
+ c1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false, false, false));
- cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false, false, false));
+ c1.setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false, false, false));
+ c2.setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false, false, false));
- cache1.getConfiguration().setUseRegionBasedMarshalling(useRegionBasedMarshalling);
- cache2.getConfiguration().setUseRegionBasedMarshalling(useRegionBasedMarshalling);
+ c1.setUseRegionBasedMarshalling(useRegionBasedMarshalling);
+ c2.setUseRegionBasedMarshalling(useRegionBasedMarshalling);
+
+
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c1, false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c2, false);
+
if (useRegionBasedMarshalling)
{
cache1.getRegionManager().getRegion(fqn, Region.Type.MARSHALLING, true).registerContextClassLoader(this.getClass().getClassLoader());
@@ -88,14 +93,14 @@
System.out.println("***** TEARING DOWN ***** ");
if (cache1 != null)
{
- cache1.stop();
+ TestingUtil.killCaches(cache1);
cache1 = null;
loader1 = null;
}
if (cache2 != null)
{
- cache2.stop();
+ TestingUtil.killCaches(cache2);
cache2 = null;
loader2 = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ConcurrentPutRemoveEvictTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.loader;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -37,7 +37,7 @@
CacheLoaderConfig cacheLoaderConfig = getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false);
Configuration cfg = new Configuration();
cfg.setCacheLoaderConfig(cacheLoaderConfig);
- cache = new DefaultCacheFactory<String, String>().createCache(cfg);
+ cache = new UnitTestCacheFactory<String, String>().createCache(cfg);
cache.put(fqn, key, "value");
}
@@ -45,6 +45,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void doTest() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.transaction.DummyTransactionManager;
import static org.testng.AssertJUnit.assertNotNull;
@@ -25,11 +24,13 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class DataSourceIntegrationTest extends AbstractCacheLoaderTestBase
{
- private String old_factory = null;
+ //private String old_factory = null;
private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/MockDS";
private CacheSPI cache;
@@ -37,7 +38,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
DummyTransactionManager.getInstance();
}
@@ -67,7 +68,7 @@
{
// expected
}
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode("local");
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(JNDI_NAME));
@@ -86,6 +87,7 @@
{
Context ctx = new InitialContext();
ctx.unbind(JNDI_NAME);
+ /*
if (old_factory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
@@ -94,12 +96,13 @@
{
System.getProperties().remove(Context.INITIAL_CONTEXT_FACTORY);
}
+ */
if (cache != null)
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@@ -15,6 +16,7 @@
{
// use the shared variation of the DIMCL so that state is persisted in a static variable in memory rather than an
// instance one.
+ CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "debug=true", false, true, false);
cache.getConfiguration().setCacheLoaderConfig(clc);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
import org.testng.annotations.Test;
@@ -12,9 +13,23 @@
{
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
// use the shared variation of the DIMCL so that state is persisted in a static variable in memory rather than an
- // instance one.
- CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "", false, true, false);
+ // instance one.
+ String bin = "DummyInMemoryCacheLoader-" + Thread.currentThread().getName();
+ CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "bin=" + bin, false, true, false);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
+
+ @Override
+ protected void cleanup()
+ {
+ DummySharedInMemoryCacheLoader loader = (DummySharedInMemoryCacheLoader) loaderTL.get();
+ if (loader != null) {
+ loader.wipeBin();
+ loaderTL.set(null);
+ }
+ }
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DummySharedInMemoryCacheLoader.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -46,4 +46,8 @@
{
BINS.clear();
}
+
+ public void wipeBin() {
+ BINS.remove(bin);
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
@@ -10,8 +11,10 @@
{
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
- String tmpCLLoc = tmpDir + "/JBossCache-FileCacheLoaderTest";
+ String threadId = Thread.currentThread().getName();
+ String tmpCLLoc = tmpDir + "/JBossCache-FileCacheLoaderTest-" + threadId;
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -19,6 +18,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Test case that proves that the CacheImpl is serialized inside the CacheLoaderInterceptor
@@ -40,7 +40,7 @@
public void testBlockingProblem() throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
//setCacheLoader(new TestSlowCacheLoader());
CacheLoaderConfig clc = new CacheLoaderConfig();
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,13 +14,14 @@
import org.testng.annotations.Test;
import java.util.Properties;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test for JDBCCacheLoaderConfigTest
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = {"unit"})
+@Test(groups = {"unit"}, sequential = true)
public class JDBCCacheLoaderConfigTest
{
private AdjListJDBCCacheLoaderConfig cacheLoaderConfig;
@@ -52,10 +53,10 @@
public void testSetGetBatchInfo()
{
Properties props = new Properties();
- props.put("ache.jdbc.table.name","jbosscache");
+ props.put("ache.jdbc.table.name","jbosscache" + TestingUtil.getThreadId());
props.put("cache.jdbc.table.create", "true");
props.put("cache.jdbc.table.drop","true");
- props.put("cache.jdbc.table.primarykey","jbosscache_pk");
+ props.put("cache.jdbc.table.primarykey","jbosscache_pk" + TestingUtil.getThreadId());
props.put("cache.jdbc.fqn.column","fqn");
props.put("cache.jdbc.fqn.type", "varchar(255)");
props.put("cache.jdbc.node.column","node");
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,18 +2,19 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.Connection;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* To test the closing of JDBC connections
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class JDBCCacheLoaderConnectionTest extends AbstractCacheLoaderTestBase
{
private Cache cache;
@@ -36,7 +37,7 @@
" cache.jdbc.user=user1\n" +
" cache.jdbc.password=user1";
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", JDBCCacheLoader.class.getName(), props, false, false, true, false));
cache.start();
}
@@ -44,7 +45,8 @@
@AfterMethod
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testConnectionRelease() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -17,6 +17,8 @@
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import java.util.Properties;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.util.TestingUtil;
/**
* This test runs cache loader tests using Database as the cache loader store.
@@ -30,17 +32,17 @@
* @author <a href="hmesha(a)novell.com">Hany Mesha</a>
* @version <tt>$Revision$</tt>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class JDBCCacheLoaderDerbyDSTest
extends CacheLoaderTestsBase
{
- private String old_factory = null;
+ //private String old_factory = null;
private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/DerbyDS";
protected void configureCache() throws Exception
{
- old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
DummyTransactionManager.getInstance();
@@ -75,9 +77,11 @@
String props = "cache.jdbc.datasource =" + JNDI_NAME + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat= 1 || 2";
-
-
+ "cache.jdbc.sql-concat= 1 || 2" + "\n" +
+ "cache.jdbc.table.name=jbosscache" + TestingUtil.getThreadId() + "\n" +
+ "cache.jdbc.table.primarykey=jbosscache_pk" + TestingUtil.getThreadId();
+
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
cache.create();
@@ -88,6 +92,7 @@
public void testLargeObject()
{
+ CacheLoader loader = loaderTL.get();
try
{
String key = "LargeObj";
@@ -132,8 +137,11 @@
public void tearDown() throws Exception
{
super.tearDown();
- Context ctx = new InitialContext();
+ Properties icProps = new Properties();
+ icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
+ Context ctx = new InitialContext(icProps);
ctx.unbind(JNDI_NAME);
+ /*
if (old_factory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
@@ -142,5 +150,6 @@
{
System.getProperties().remove(Context.INITIAL_CONTEXT_FACTORY);
}
+ */
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,6 +11,9 @@
import org.testng.annotations.Test;
import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.util.TestingUtil;
/**
* This test runs cache loader tests using Database as the cache loader store.
@@ -34,6 +37,7 @@
Properties prop = getProperties();
String props = props2String(prop);
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", JDBCCacheLoader.class.getName(), props, false, true, false));
}
@@ -47,6 +51,7 @@
append("cache.jdbc.node.type", prop, p);
append("cache.jdbc.sql-concat", prop, p);
append("cache.jdbc.table.name", prop, p);
+ append("cache.jdbc.table.primarykey", prop, p);
return p.toString();
}
@@ -58,6 +63,7 @@
public void testLargeObject()
{
+ CacheLoader loader = loaderTL.get();
try
{
String key = "LargeObj";
@@ -94,6 +100,13 @@
try
{
properties.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
+
+ String tablePrefix = properties.getProperty("cache.jdbc.table.name", "jbosscache");
+ properties.setProperty("cache.jdbc.table.name", tablePrefix + TestingUtil.getThreadId());
+
+ String pkPrefix = properties.getProperty("cache.jdbc.table.primarykey", "jbosscache_pk");
+ properties.setProperty("cache.jdbc.table.primarykey", pkPrefix + TestingUtil.getThreadId());
+
return properties;
}
catch (Exception e)
@@ -104,6 +117,7 @@
public void testRootIsCreated() throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.put(Fqn.fromString("/a/b/c"), "a", "b");
assertTrue(loader.exists(Fqn.ROOT));
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
@@ -14,8 +15,10 @@
{
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
- String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoaderTest";
+ String threadId = Thread.currentThread().getName();
+ String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoaderTest-" + threadId;
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.jdbm.JdbmCacheLoader", "location=" + tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,20 +1,22 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LocalDelegatingCacheLoaderTest extends CacheLoaderTestsBase
{
CacheSPI delegating_cache;
protected void configureCache() throws Exception
{
- delegating_cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
+ delegating_cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
delegating_cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
delegating_cache.create();
delegating_cache.start();
@@ -30,7 +32,7 @@
protected void postConfigure()
{
- CacheLoader ldr = loader;
+ CacheLoader ldr = loaderTL.get();
LocalDelegatingCacheLoader ldcl = null;
do
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/PreloadTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,8 +1,8 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -10,7 +10,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class PreloadTest extends AbstractCacheLoaderTestBase
{
CacheSPI<Object, Object> cache;
@@ -21,19 +21,20 @@
public void tearDown()
{
if (cache != null) TestingUtil.killCaches(cache);
+ cache = null;
}
public void testPreload() throws Exception
{
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c.clone());
cache.put(fqn, key, value);
assertExists();
cache.destroy();
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c.clone());
assertExists();
}
@@ -41,22 +42,22 @@
{
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.LOCAL);
c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/a", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c.clone());
cache.put(fqn, key, value);
assertExists();
cache.destroy();
c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c,/a,/b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c.clone());
assertExists();
c.setCacheLoaderConfig(getSingleCacheLoaderConfig("/c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c.clone());
assertExists();
c.setCacheLoaderConfig(getSingleCacheLoaderConfig(" /c, /a, /b", DummySharedInMemoryCacheLoader.class.getName(), "", false, false, false));
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c.clone());
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c.clone());
assertExists();
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,6 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.testng.annotations.Test;
@@ -29,17 +30,20 @@
private static final Log log = LogFactory.getLog(S3CacheLoaderTest.class);
- private Server server;
+ private ThreadLocal<Server> serverTL = new ThreadLocal<Server>();
@Override
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
String accessKey = System.getProperty("accessKey");
String properties;
if (accessKey == null)
{
log.info("Testing using S3CacheLoader using emulator");
- server = new Server();
+ Server server = new Server();
+ serverTL.set(server);
server.start();
properties =
"cache.s3.accessKeyId=dummy\n" +
@@ -66,6 +70,7 @@
@Override
public void cleanup() {
+ Server server = serverTL.get();
if (server != null)
{
try
@@ -75,10 +80,12 @@
catch (IOException e) {
}
}
+ serverTL.set(null);
}
protected void postConfigure()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.removeNode(Fqn.root());
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/SharedCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.interceptors.CacheStoreInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import static org.testng.AssertJUnit.assertEquals;
@@ -16,13 +15,16 @@
import org.testng.annotations.Test;
import java.util.Iterator;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.util.TestingUtil;
/**
* See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3919374#3919374
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class SharedCacheLoaderTest extends AbstractCacheLoaderTestBase
{
private CacheSPI<Object, Object> cache1, cache2;
@@ -34,15 +36,19 @@
if (cache1 != null || cache2 != null) tearDown();
// set up 2 instances of CacheImpl with shared CacheLoaders.
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setCacheMode("REPL_SYNC");
- cache2.getConfiguration().setCacheMode("REPL_SYNC");
+ Configuration c1 = new Configuration();
+ Configuration c2 = new Configuration();
- cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyCountingCacheLoader.class.getName(), "", false, false, true));
- cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyCountingCacheLoader.class.getName(), "", false, false, true));
+ c1.setCacheMode("REPL_SYNC");
+ c2.setCacheMode("REPL_SYNC");
+ c1.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyCountingCacheLoader.class.getName(), "", false, false, true));
+ c2.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyCountingCacheLoader.class.getName(), "", false, false, true));
+
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c1, false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c2, false);
+
cache1.start();
cache2.start();
@@ -69,8 +75,8 @@
@AfterMethod(alwaysRun = true)
protected void tearDown()
{
- if (cache1 != null) cache1.stop();
- if (cache2 != null) cache2.stop();
+ if (cache1 != null) TestingUtil.killCaches(cache1);
+ if (cache2 != null) TestingUtil.killCaches(cache2);
cache1 = null;
cache2 = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -29,13 +28,15 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test class for SingletonStoreCacheLoader
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class SingletonStoreCacheLoaderTest extends AbstractCacheLoaderTestBase
{
private static final Log log = LogFactory.getLog(SingletonStoreCacheLoaderTest.class);
@@ -45,9 +46,9 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache3 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache3 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
@@ -314,7 +315,7 @@
{
if (cache1 != null)
{
- cache1.stop();
+ TestingUtil.killCaches(cache1);
}
cache1 = null;
@@ -324,7 +325,7 @@
{
if (cache2 != null)
{
- cache2.stop();
+ TestingUtil.killCaches(cache2);
}
cache2 = null;
@@ -334,7 +335,7 @@
{
if (cache3 != null)
{
- cache3.stop();
+ TestingUtil.killCaches(cache3);
}
cache3 = null;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.transaction.TransactionSetup;
@@ -16,12 +15,14 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
/**
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class TxCacheLoaderTest extends AbstractCacheLoaderTestBase
{
CacheSPI<Object, Object> cache1, cache2;
@@ -31,22 +32,26 @@
public void setUp() throws Exception
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setCacheMode("repl_sync");
- cache1.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
+ Configuration c1 = new Configuration();
+ c1.setCacheMode("repl_sync");
+ c1.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c1.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c1.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
// cache1.setReplQueueInterval(3000);
+
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c1, false);
cache1.create();
cache1.start();
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2.getConfiguration().setCacheMode("repl_sync");
- cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache2.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
- cache2.getConfiguration().setLockAcquisitionTimeout(2000);
+ Configuration c2 = new Configuration();
+ c2.setCacheMode("repl_sync");
+ c2.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c2.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c2.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false));
+ c2.setLockAcquisitionTimeout(2000);
// cache2.setReplQueueInterval(3000);
+
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c2, false);
cache2.create();
cache2.start();
}
@@ -57,10 +62,10 @@
// clean up cache loaders!!
cache1.removeNode(Fqn.ROOT);
- cache1.stop();
- cache1.destroy();
- cache2.stop();
- cache2.destroy();
+ TestingUtil.killCaches(cache1);
+ TestingUtil.killCaches(cache2);
+ cache1 = null;
+ cache2 = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import static org.easymock.EasyMock.*;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -17,12 +16,14 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class UnnecessaryLoadingTest
{
private CacheSPI<Object, Object> cache;
@@ -34,7 +35,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
CacheLoaderConfig clc = new CacheLoaderConfig();
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
clc.addIndividualCacheLoaderConfig(iclc);
@@ -82,7 +83,8 @@
expectLastCall().anyTimes();
replay(mockCacheLoader);
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
protected void assertDataLoaded(Fqn f)
Modified: core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/loader/deadlock/ConcurrentCreationDeadlockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.loader.deadlock;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -18,6 +17,8 @@
import javax.transaction.UserTransaction;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* <b>Test based on a contribution by Marian Nokolov/Paul Miodonski at Siemens AG.</b>
@@ -63,7 +64,7 @@
* CacheLoader/StoreInterceptor's...</li>
* </ul>
*/
-@Test(groups = {"functional"}, enabled = true)
+@Test(groups = {"functional"}, enabled = false, sequential = true)
// Disabling since this has issues with ReadWriteWithUpgradeLock. See JBCACHE-461
public class ConcurrentCreationDeadlockTest extends AbstractCacheLoaderTestBase
{
@@ -92,7 +93,7 @@
/**
* The original context factory to be restored after the test.
*/
- private String m_contextFactory = null;
+ // private String m_contextFactory = null;
/**
* Exception recorded if any of the worker threads fails.
@@ -118,12 +119,12 @@
public void setUp() throws Exception
{
mcl_exception = null;
- m_contextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //m_contextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, CONTEXT_FACTORY);
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c, false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
}
/**
@@ -131,16 +132,19 @@
*/
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
- {
- DummyTransactionManager.destroy();
- cache.stop();
+ {
+ // We just can't destroy DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(DummyTransactionManager.getInstance());
+ TestingUtil.killCaches(cache);
cache = null;
+ /*
if (m_contextFactory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
m_contextFactory);
m_contextFactory = null;
}
+ */
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -20,22 +20,31 @@
@Test(groups = "unit")
public abstract class AbstractLockManagerRecordingTest
{
- LockManager lm;
- InvocationContextContainer icc;
+ protected class AbstractLockManagerRecordingTestTL {
+ public LockManager lm;
+ public InvocationContextContainer icc;
+ protected ContextFactory contextFactory;
+ }
+ protected ThreadLocal<AbstractLockManagerRecordingTestTL> threadLocal = new ThreadLocal<AbstractLockManagerRecordingTestTL>();
protected boolean fqnBasedLocking = true;
- protected ContextFactory contextFactory;
@AfterMethod
public void tearDown()
{
- lm = null;
+ AbstractLockManagerRecordingTestTL tl = threadLocal.get();
+ if (tl != null) {
+ tl.lm = null;
+ threadLocal.set(null);
+ }
}
public void testRecordingLocksNoTx() throws InterruptedException
{
+ AbstractLockManagerRecordingTestTL tl = threadLocal.get();
+ LockManager lm = tl.lm;
Fqn fqn = Fqn.fromString("/a/b/c");
NodeSPI node = createNode(fqn);
- InvocationContext ctx = icc.get();
+ InvocationContext ctx = tl.icc.get();
// lock and record.
lm.lockAndRecord(node, WRITE, ctx);
@@ -48,12 +57,14 @@
public void testRecordingLocksWithTx() throws InterruptedException, SystemException, RollbackException
{
+ AbstractLockManagerRecordingTestTL tl = threadLocal.get();
+ LockManager lm = tl.lm;
Fqn fqn = Fqn.fromString("/a/b/c");
NodeSPI node = createNode(fqn);
- InvocationContext ctx = icc.get();
+ InvocationContext ctx = tl.icc.get();
ctx.setGlobalTransaction(new GlobalTransaction());
ctx.setTransaction(new DummyTransaction(DummyTransactionManager.getInstance()));
- ctx.setTransactionContext(contextFactory.createTransactionContext(ctx.getTransaction()));
+ ctx.setTransactionContext(tl.contextFactory.createTransactionContext(ctx.getTransaction()));
// lock and record.
lm.lockAndRecord(node, WRITE, ctx);
Modified: core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -23,7 +23,6 @@
package org.jboss.cache.lock;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration;
@@ -40,6 +39,7 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the breaking of locks held by dead members.
@@ -47,7 +47,7 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class BreakDeadMemberLocksTest
{
private Map<String, CacheSPI<Object, Object>> caches;
@@ -154,7 +154,7 @@
throw new IllegalStateException(cacheID + " already created");
}
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache.create();
@@ -172,7 +172,7 @@
{
stopCache(cacheID);
}
- caches.clear();
+ caches.clear();
}
protected void stopCache(String id)
Modified: core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
* @author Ben Wang
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class IdentityLockTest
{
NodeLock lock_;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockMapTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockMapTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockMapTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -15,7 +15,7 @@
/**
* @author Ben Wang
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LockMapTest
{
private LockMap map_;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockParentRootFlagTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockParentRootFlagTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockParentRootFlagTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -22,7 +22,7 @@
package org.jboss.cache.lock;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
@@ -69,7 +69,7 @@
Cache c = null;
try
{
- c = new DefaultCacheFactory().createCache(false);
+ c = new UnitTestCacheFactory().createCache(false);
c.getConfiguration().setNodeLockingScheme(nls);
c.getConfiguration().setLockParentForChildInsertRemove(set);
if (nls.isVersionedScheme())
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,7 +10,6 @@
import org.apache.commons.logging.Log;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.transaction.GenericTransactionManagerLookup;
@@ -25,6 +24,8 @@
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Verifies that there are no read locks held when a transaction ends.
@@ -32,7 +33,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LockReleaseTest
{
CacheSPI<Object, Object> cache = null;
@@ -55,11 +56,12 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
- // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
- TransactionSetup.cleanup();
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(TransactionSetup.getManager());
if (tx != null)
{
@@ -76,7 +78,7 @@
CacheSPI<Object, Object> createCache(IsolationLevel level) throws Exception
{
- CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
c.getConfiguration().setClusterName("test");
c.getConfiguration().setStateRetrievalTimeout(10000);
c.getConfiguration().setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -17,7 +17,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LockTest
{
int value = 10;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerRecordingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,20 +24,23 @@
@BeforeMethod
public void setUp()
{
- icc = new InvocationContextContainer();
+ AbstractLockManagerRecordingTestTL tl = new AbstractLockManagerRecordingTestTL();
+ threadLocal.set(tl);
+ tl.icc = new InvocationContextContainer();
MVCCLockManager mvccLockManager = new MVCCLockManager();
TransactionManager tm = DummyTransactionManager.getInstance();
mvccLockManager.injectConfiguration(new Configuration());
- mvccLockManager.injectDependencies(null, null, tm, icc);
+ mvccLockManager.injectDependencies(null, null, tm, tl.icc);
mvccLockManager.startLockManager();
- lm = mvccLockManager;
- contextFactory = new MVCCContextFactory();
- icc.injectContextFactory(contextFactory);
+ tl.lm = mvccLockManager;
+ tl.contextFactory = new MVCCContextFactory();
+ tl.icc.injectContextFactory(tl.contextFactory);
}
public void testFqnHashing()
{
- LockContainer lc = (LockContainer) TestingUtil.extractField(lm, "lockContainer");
+ AbstractLockManagerRecordingTestTL tl = threadLocal.get();
+ LockContainer lc = (LockContainer) TestingUtil.extractField(tl.lm, "lockContainer");
List<Fqn> fqns = new ArrayList<Fqn>();
fqns.add(Fqn.ROOT);
fqns.add(Fqn.fromString("/1"));
Modified: core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/MVCCLockManagerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -18,7 +18,7 @@
import java.util.ArrayList;
import java.util.List;
-@Test(groups = {"unit", "mvcc"})
+@Test(groups = {"unit", "mvcc"}, sequential = true)
public class MVCCLockManagerTest
{
MVCCLockManager lm;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/NodeBasedLockManagerRecordingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -19,11 +19,13 @@
@BeforeMethod
public void setUp()
{
- icc = new InvocationContextContainer();
- lm = new NodeBasedLockManager();
+ AbstractLockManagerRecordingTestTL tl = new AbstractLockManagerRecordingTestTL();
+ threadLocal.set(tl);
+ tl.icc = new InvocationContextContainer();
+ tl.lm = new NodeBasedLockManager();
PessimisticContextFactory pcf = new PessimisticContextFactory();
- icc.injectContextFactory(pcf);
- contextFactory = pcf;
+ tl.icc.injectContextFactory(pcf);
+ tl.contextFactory = pcf;
fqnBasedLocking = false;
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.lock;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.util.TestingUtil;
@@ -27,6 +27,8 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache, cache2);
+ cache = null;
+ cache2 = null;
}
@@ -81,7 +83,7 @@
private CacheSPI<Object, Object> createCache(Configuration.CacheMode mode, IsolationLevel level)
{
- CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.getConfiguration().setCacheMode(mode);
c.getConfiguration().setIsolationLevel(level);
Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -17,6 +16,7 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* basic locking test
@@ -24,7 +24,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class PessimisticLockTest
{
private Cache<Object, Object> cache;
@@ -35,7 +35,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache.start();
@@ -47,6 +47,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
private void assertNoStaleLocks()
Modified: core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,7 +14,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = { "functional" })
+@Test(groups = { "functional" }, sequential = true)
public class ReadWriteLockTest
{
ReadWriteLock lock;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockWithUpgradeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockWithUpgradeTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/ReadWriteLockWithUpgradeTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -25,7 +25,7 @@
* @author <a href="mailto:cavin_song@yahoo.com">Cavin Song</a> April 22, 2004
* @version 1.0
*/
-@Test(groups = { "functional" })
+@Test(groups = { "functional" }, sequential = true)
public class ReadWriteLockWithUpgradeTest
{
static final ReadWriteLockWithUpgrade lock_ = new ReadWriteLockWithUpgrade();
Modified: core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,7 +16,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ReentrantWriterPreferenceReadWriteLockTest
{
ReentrantReadWriteLock lock;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
package org.jboss.cache.lock;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManager;
import static org.testng.AssertJUnit.assertEquals;
@@ -21,6 +20,8 @@
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
import java.util.Properties;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests upgrade locks from read -> write
@@ -28,13 +29,13 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class UpgradeLockTest
{
CacheSPI<Object, Object> cache = null;
UserTransaction tx = null;
Properties p = null;
- String old_factory = null;
+ //String old_factory = null;
final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
final String NODE1 = "/test";
final String NODE2 = "/my/test";
@@ -45,7 +46,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
DummyTransactionManager.getInstance();
if (p == null)
@@ -61,17 +62,20 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
-
- // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
- DummyTransactionManager.destroy();
+
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(DummyTransactionManager.getInstance());
+ /*
if (old_factory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
old_factory = null;
}
-
+ */
+
if (tx != null)
{
try
@@ -87,7 +91,7 @@
private CacheSPI<Object, Object> createCache(IsolationLevel level)
{
- CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.getConfiguration().setClusterName("test");
c.getConfiguration().setStateRetrievalTimeout(10000);
Modified: core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.lock;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static org.testng.AssertJUnit.*;
@@ -12,8 +11,10 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.Collections;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class WriteLockOnParentTest
{
private CacheSPI<Object, Object> cache;
@@ -23,7 +24,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
// reduce LAT so the test runs faster
@@ -47,7 +48,8 @@
// do sweet F.A.
}
}
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testDefaultCfg()
Modified: core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
@@ -40,7 +40,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
@@ -54,6 +54,7 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache);
+ cache = null;
for (SeparateThread st : threads)
{
st.interrupt();
Modified: core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -20,13 +20,14 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests CacheRegistryImpl.
*
* @author Brian Stansberry
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class CacheManagerTest
{
/**
@@ -41,16 +42,9 @@
{
for (Cache<Object, Object> cache : caches)
{
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- e.printStackTrace(System.out);
- }
+ TestingUtil.killCaches(cache);
}
+ caches.clear();
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,10 +12,11 @@
*/
public abstract class AbstractVersionAwareMarshallerTest
{
- protected ComponentRegistry cr;
+ protected ThreadLocal<ComponentRegistry> crTL = new ThreadLocal<ComponentRegistry>();
protected VersionAwareMarshaller createVAMandRestartCache(String replVersion)
{
+ ComponentRegistry cr = crTL.get();
Configuration c = cr.getComponent(Configuration.class);
c.setReplVersionString(replVersion);
return createVAMandRestartCache(new RegionManagerImpl());
@@ -23,6 +24,7 @@
protected VersionAwareMarshaller createVAMandRestartCache(RegionManager rm)
{
+ ComponentRegistry cr = crTL.get();
if (cr.getState() == CacheStatus.STARTED) cr.stop();
cr.registerComponent(rm, RegionManager.class);
cr.create();
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,14 +8,15 @@
package org.jboss.cache.marshall;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -28,7 +29,7 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class ActiveInactiveTest extends AbstractVersionAwareMarshallerTest
{
RegionManager rman;
@@ -41,12 +42,13 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
c = cache.getConfiguration();
c.setUseRegionBasedMarshalling(true);
c.setFetchInMemoryState(false);
cache.start();
- cr = TestingUtil.extractComponentRegistry(cache);
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
+ crTL.set(cr);
rman = TestingUtil.extractComponentRegistry(cache).getComponent(RegionManager.class);
}
@@ -54,6 +56,7 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testDefaultActive() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,7 +10,6 @@
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand;
@@ -34,6 +33,8 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.lang.reflect.Method;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
/**
* Test marshalling for async mode.
@@ -41,7 +42,7 @@
* @author Ben Wang
* @version $Revision$
*/
-@Test(groups = {"functional", "jgroups"})
+@Test(groups = {"functional", "jgroups"}, sequential = true)
public class AsyncReplTest extends RegionBasedMarshallingTestBase
{
CacheSPI<Object, Object> cache1, cache2;
@@ -57,7 +58,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- resetContextClassLoader();
+ super.setUp();
log("creating cache1");
cache1 = createCache("TestCache");
@@ -79,12 +80,13 @@
private CacheSPI<Object, Object> createCache(String name)
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC), false);
- cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache.getConfiguration().setClusterName(name);
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
+ c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c.setClusterName(name + "-" + Thread.currentThread().getName());
// Use marshaller
- cache.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
- cache.getConfiguration().setUseRegionBasedMarshalling(!useMarshalledValues);
+ c.setUseLazyDeserialization(useMarshalledValues);
+ c.setUseRegionBasedMarshalling(!useMarshalledValues);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache.create();
cache.start();
@@ -92,10 +94,12 @@
}
@AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
+ @Override public void tearDown() throws Exception
{
TestingUtil.killCaches(cache1, cache2);
- resetContextClassLoader();
+ super.tearDown();
+ cache1 = null;
+ cache2 = null;
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -19,6 +18,7 @@
import java.util.Collections;
import java.util.Properties;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests marshalling/unmarshalling during cache loader operations involving types
@@ -27,7 +27,7 @@
* @author <a href="mailto:brian.stansberry@jboss.org">Brian Stansberry</a>
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheLoaderMarshallingJDBCTest extends RegionBasedMarshallingTestBase
{
private static final String className = "org.jboss.cache.marshall.MyUUID";
@@ -35,17 +35,13 @@
private Cache<Object, Object> cache;
private Fqn fqn = Fqn.fromString("/a");
- @BeforeMethod(alwaysRun = true)
- protected void setUp() throws Exception
- {
- originalClassLoader = Thread.currentThread().getContextClassLoader();
- }
@AfterMethod(alwaysRun = true)
- protected void tearDown()
+ @Override public void tearDown() throws Exception
{
- resetContextClassLoader();
TestingUtil.killCaches(cache);
+ super.tearDown();
+ cache = null;
}
@Override
@@ -72,7 +68,7 @@
cache = createCache(useRegionBased);
cache.start();
- FooClassLoader loader = new FooClassLoader(originalClassLoader);
+ FooClassLoader loader = new FooClassLoader(originalClassLoaderTL.get());
if (useRegionBased)
{
@@ -101,7 +97,7 @@
// ensure cleanup after each test
prop.setProperty("cache.jdbc.table.drop", "true");
- Cache cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ Cache cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
Configuration config = cache.getConfiguration();
config.setUseRegionBasedMarshalling(useRegionBased);
config.setInactiveOnStartup(useRegionBased);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
@@ -21,6 +20,7 @@
import java.io.File;
import java.util.Collections;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests marshalling/unmarshalling during cache loader operations involving types
@@ -30,7 +30,7 @@
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheLoaderMarshallingTest extends RegionBasedMarshallingTestBase
{
private static final String tmpDir = System.getProperty("java.io.tmpdir") + File.separatorChar + "CacheLoaderMarshallingTest";
@@ -38,22 +38,17 @@
private Cache<Object, Object> cache;
private Fqn fqn = Fqn.fromString("/a");
- @BeforeMethod(alwaysRun = true)
- protected void setUp() throws Exception
- {
- originalClassLoader = Thread.currentThread().getContextClassLoader();
- }
@AfterMethod(alwaysRun = true)
- protected void tearDown()
+ public void tearDown() throws Exception
{
- resetContextClassLoader();
TestingUtil.killCaches(cache);
-
+ cache = null;
File f = new File(tmpDir);
if (f.exists())
if (!f.delete())
f.deleteOnExit();
+ super.tearDown();
}
public void testCacheLoaderMarshalling() throws Exception
@@ -106,7 +101,7 @@
cache = createCache(useRegionBased);
cache.start();
- FooClassLoader loader = new FooClassLoader(originalClassLoader);
+ FooClassLoader loader = new FooClassLoader(originalClassLoaderTL.get());
if (useRegionBased)
{
@@ -130,10 +125,10 @@
private Cache createCache(boolean useRegionBased)
{
- Cache cache = new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration config = cache.getConfiguration();
+ Configuration config = new Configuration();
config.setUseRegionBasedMarshalling(useRegionBased);
config.setInactiveOnStartup(useRegionBased);
+ Cache cache = new UnitTestCacheFactory<Object, Object>().createCache(config, false);
EvictionConfig ec = new EvictionConfig();
ec.setWakeupInterval(1000000); // a long time; really disabled
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -25,6 +25,8 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.ComponentRegistry;
@Test(groups = {"functional"})
public class CacheMarshaller200Test extends CacheMarshallerTestBase
@@ -70,11 +72,12 @@
public void testRegionalisedStream() throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
CacheMarshaller200 cm200 = new CacheMarshaller200();
- c.setUseRegionBasedMarshalling(true);
+ tl.c.setUseRegionBasedMarshalling(true);
RegionManagerImpl rmi = new RegionManagerImpl();
- rmi.injectDependencies(null, c, null, null, null, new RegionRegistry());
- cm200.injectDependencies(rmi, c, getClass().getClassLoader());
+ rmi.injectDependencies(null, tl.c, null, null, null, new RegionRegistry());
+ cm200.injectDependencies(rmi, tl.c, getClass().getClassLoader());
cm200.init();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -107,6 +110,8 @@
*/
public void testLeakageOfFqn() throws Throwable
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ Configuration c = tl.c;
// Use a thread pool so that we know threads will be reused.
// You don't need any concurrency here to demonstrate the failure - a single thread is enough.
ExecutorService e = Executors.newFixedThreadPool(1);
@@ -124,6 +129,7 @@
c.setInactiveOnStartup(false);
c.setUseRegionBasedMarshalling(true);
c.setCacheMarshaller(cm200);
+ ComponentRegistry cr = crTL.get();
cr.registerComponent(cm200, CacheMarshaller200.class);
cr.rewire();
cr.start();
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -26,6 +26,8 @@
protected void doMapTest(int size) throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
Map map = createMap(size);
Fqn fqn = Fqn.fromString("/my/stuff");
String key = "key";
@@ -51,7 +53,9 @@
public void testVInts() throws IOException
{
-
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
+
CacheMarshaller210 cm210 = (CacheMarshaller210) marshaller.defaultMarshaller;
CacheMarshaller200 cm200 = (CacheMarshaller200) marshaller.getMarshaller(20);
int[] ints = {2, 100, 500, 12000, 20000, 500000, 2000000, Integer.MAX_VALUE};
@@ -65,6 +69,8 @@
public void testVLongs() throws IOException
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
CacheMarshaller210 cm210 = (CacheMarshaller210) marshaller.defaultMarshaller;
CacheMarshaller200 cm200 = (CacheMarshaller200) marshaller.getMarshaller(20);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -30,26 +30,34 @@
protected String currentVersion;
protected int currentVersionShort;
protected Class expectedMarshallerClass, latestMarshallerClass = CacheMarshaller300.class;
- protected VersionAwareMarshaller marshaller;
- protected RegionManager regionManager;
- protected Configuration c;
+
+ protected ThreadLocal<CacheMarshallerTestBaseTL> threadLocal = new ThreadLocal<CacheMarshallerTestBaseTL>();
+
+ protected class CacheMarshallerTestBaseTL {
+ protected VersionAwareMarshaller marshaller;
+ protected RegionManager regionManager;
+ protected Configuration c;
+ }
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- c = new Configuration();
- c.setUseRegionBasedMarshalling(false);
- c.setInactiveOnStartup(false);
- c.setReplVersionString(currentVersion);
- cr = new ComponentRegistry(c, new CacheInvocationDelegate());
- marshaller = createVAMandRestartCache(new RegionManagerImpl());
- regionManager = cr.getComponent(RegionManager.class);
+ CacheMarshallerTestBaseTL tl = new CacheMarshallerTestBaseTL();
+ threadLocal.set(tl);
+ tl.c = new Configuration();
+ tl.c.setUseRegionBasedMarshalling(false);
+ tl.c.setInactiveOnStartup(false);
+ tl.c.setReplVersionString(currentVersion);
+ ComponentRegistry cr = new ComponentRegistry(tl.c, new CacheInvocationDelegate());
+ crTL.set(cr);
+ tl.marshaller = createVAMandRestartCache(new RegionManagerImpl());
+ tl.regionManager = cr.getComponent(RegionManager.class);
}
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- marshaller = null;
+ threadLocal.set(null);
}
protected void assertObjectArraysAreEqual(Object[] a1, Object[] a2)
@@ -76,6 +84,8 @@
public void testGetMarshaller()
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
assertEquals("Only one marshaller should be in the map by this stage", 1, marshaller.marshallers.size());
assertEquals(expectedMarshallerClass, marshaller.getMarshaller(currentVersionShort).getClass());
@@ -95,6 +105,8 @@
public void testStringBasedFqn() throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
Fqn fqn = Fqn.fromElements("JSESSIONID", "1010.10.5:3000", "1234567890", "1");
byte[] asBytes = marshaller.objectToByteBuffer(fqn);
System.out.println("Marshalled to " + asBytes.length + " bytes");
@@ -104,6 +116,8 @@
public void testNonStringBasedFqn() throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
Fqn fqn = Fqn.fromElements(3, false);
byte[] asBytes = marshaller.objectToByteBuffer(fqn);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -112,6 +126,8 @@
public void testMethodCall() throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
Fqn fqn = Fqn.fromElements(3, false);
ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value");
byte[] asBytes = marshaller.objectToByteBuffer(cmd);
@@ -125,6 +141,8 @@
public void testNestedMethodCall() throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
Fqn fqn = Fqn.fromElements(3, false);
ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value");
ReplicableCommand replicateCmd = new ReplicateCommand(cmd);
@@ -182,6 +200,8 @@
protected void doLargeStringTest(int stringSize, boolean multiByteChars) throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
StringBuilder sb = new StringBuilder();
int startingChar = multiByteChars ? 210 : 65;
@@ -203,13 +223,17 @@
public void testReplicationQueueWithRegionBasedMarshalling() throws Exception
{
- c.setUseRegionBasedMarshalling(true);
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
+ tl.c.setUseRegionBasedMarshalling(true);
marshaller.init();
doReplicationQueueTest();
}
protected void doReplicationQueueTest() throws Exception
{
+ CacheMarshallerTestBaseTL tl = threadLocal.get();
+ VersionAwareMarshaller marshaller = tl.marshaller;
// replication queue takes a list of replicate() MethodCalls and wraps them in a single replicate call.
List<ReplicableCommand> calls = new ArrayList<ReplicableCommand>();
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CustomCollectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CustomCollectionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CustomCollectionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
@@ -16,6 +15,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test to cover replication and marshalling of custom collections
@@ -23,7 +24,7 @@
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class CustomCollectionTest extends RegionBasedMarshallingTestBase implements Serializable
{
private transient Cache<Object, Object> cache1 = null;
@@ -35,6 +36,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+ super.setUp();
cache1 = createCache();
cache2 = createCache();
}
@@ -42,8 +44,10 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache1.stop();
- cache2.stop();
+ TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
+ super.tearDown();
}
public void testMap() throws Exception
@@ -273,10 +277,11 @@
private Cache<Object, Object> createCache()
{
- Cache<Object, Object> cache = new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ Cache<Object, Object> cache = new UnitTestCacheFactory<Object, Object>().createCache(c, false);
return cache;
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,9 +1,9 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -25,7 +25,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class InvalidRegionForStateTransferTest
{
Cache<Object, Object> c1, c2;
@@ -34,7 +34,7 @@
@BeforeMethod
public void setUp() throws CloneNotSupportedException
{
- c1 = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_ASYNC), false);
+ c1 = new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_ASYNC), false);
c1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
String jgroupsCfg = c1.getConfiguration().getClusterConfig();
@@ -49,7 +49,7 @@
c1.getConfiguration().setUseRegionBasedMarshalling(true);
c1.start();
- c2 = new DefaultCacheFactory<Object, Object>().createCache(c1.getConfiguration().clone());
+ c2 = new UnitTestCacheFactory<Object, Object>().createCache(c1.getConfiguration().clone());
replListener2 = new ReplicationListener(c2);
TestingUtil.blockUntilViewsReceived(60000, c1, c2);
@@ -59,6 +59,8 @@
public void tearDown()
{
TestingUtil.killCaches(c1, c2);
+ c1 = null;
+ c2 = null;
}
public void testUseOfInvalidRegion()
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.PutDataMapCommand;
@@ -32,6 +31,7 @@
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests implicit marshalled values
@@ -39,7 +39,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class MarshalledValueTest
{
private CacheSPI<Object, Object> cache1, cache2;
@@ -49,12 +49,12 @@
@BeforeMethod
public void setUp() throws CloneNotSupportedException
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC, false), false);
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC, false), false);
if (cache1.getConfiguration().getBuddyReplicationConfig() != null)
cache1.getConfiguration().setBuddyReplicationConfig(null);
cache1.getConfiguration().setUseLazyDeserialization(true);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cache1.getConfiguration().clone(), false);
cache1.start();
cache2.start();
@@ -70,6 +70,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
Pojo.serializationCount = 0;
Pojo.deserializationCount = 0;
}
@@ -257,8 +259,8 @@
public void testCacheLoaders() throws CloneNotSupportedException
{
tearDown();
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC), false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC), false);
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC), false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC), false);
CacheLoaderConfig clc = new CacheLoaderConfig();
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,19 +16,20 @@
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
+import org.testng.annotations.AfterMethod;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class MethodIdPreservationTest
{
private Marshaller m;
private ObjectOutputStream stream;
private ByteArrayOutputStream byteStream;
private WriteCommand command1;
- private List<WriteCommand> list = new ArrayList<WriteCommand>(2);
+ private List<WriteCommand> list;
private PrepareCommand prepareComand;
@BeforeMethod(alwaysRun = true)
@@ -39,7 +40,7 @@
stream = new ObjectOutputStream(byteStream);
command1 = new PutDataMapCommand(null, Fqn.ROOT, null);
- list.clear();
+ list = new ArrayList<WriteCommand>(2);
list.add(command1);
list.add(new PutDataMapCommand(null, Fqn.ROOT, null));
prepareComand = new PrepareCommand(null, list, null, true);
@@ -51,6 +52,18 @@
m = cm210;
}
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+
+ byteStream = null;
+ stream = null;
+ command1 = null;
+ list = null;
+ prepareComand = null;
+ m = null;
+ }
+
public void testSingleMethodCall() throws Exception
{
m.objectToObjectStream(command1, stream);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/RedeploymentEmulationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/RedeploymentEmulationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/RedeploymentEmulationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
@@ -23,13 +22,15 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test demonstrating usability of marshalling for application redeployment in application server.
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = {"functional"}, enabled = false)
+@Test(groups = {"functional"}, enabled = false, sequential = true)
// this relies on an old project structure that no longer exists
public class RedeploymentEmulationTest
{
@@ -47,7 +48,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setUseRegionBasedMarshalling(true);
@@ -57,7 +58,8 @@
public void tearDown()
{
log.info("**** IN TEAR DOWN ***");
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testClassCastException() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/RegionBasedMarshallingTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/RegionBasedMarshallingTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/RegionBasedMarshallingTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,7 @@
package org.jboss.cache.marshall;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups = {"functional"})
@@ -7,8 +9,25 @@
{
protected static final String ADDRESS_CLASSNAME = "org.jboss.cache.marshall.data.Address";
protected static final String PERSON_CLASSNAME = "org.jboss.cache.marshall.data.Person";
- protected ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ protected ThreadLocal<ClassLoader> originalClassLoaderTL = new ThreadLocal<ClassLoader>() {
+ @Override
+ protected ClassLoader initialValue() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ };
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ originalClassLoaderTL.get();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ resetContextClassLoader();
+ }
+
protected ClassLoader getClassLoader() throws Exception
{
String[] includesClasses = {PERSON_CLASSNAME, ADDRESS_CLASSNAME};
@@ -28,6 +47,6 @@
protected void resetContextClassLoader()
{
- Thread.currentThread().setContextClassLoader(originalClassLoader);
+ Thread.currentThread().setContextClassLoader(originalClassLoaderTL.get());
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/RegionManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/RegionManagerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/RegionManagerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
@@ -16,11 +15,12 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Test on ERegionManager class, from a marshalling perspective.
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class RegionManagerTest
{
private final Fqn DEFAULT_REGION = Fqn.ROOT;
@@ -30,7 +30,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheSPI cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache();
+ CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
r = cache.getRegionManager();
c = cache.getConfiguration();
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReplicateToInactiveRegionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ReplicateToInactiveRegionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ReplicateToInactiveRegionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.util.TestingUtil;
@@ -12,8 +11,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
-@Test(groups = {"functional", "jgroups"})
+@Test(groups = {"functional", "jgroups"}, sequential = true)
public class ReplicateToInactiveRegionTest
{
List<CacheSPI<Object, Object>> caches;
@@ -36,11 +37,12 @@
private CacheSPI<Object, Object> createCache()
{
- CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- c.getConfiguration().setCacheMode("REPL_SYNC");
- c.getConfiguration().setUseRegionBasedMarshalling(true);
- c.start();
- return c;
+ Configuration c = new Configuration();
+ c.setCacheMode("REPL_SYNC");
+ c.setUseRegionBasedMarshalling(true);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+ cache.start();
+ return cache;
}
public void testTransferToInactiveRegion()
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.marshall;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.buddyreplication.GravitateResult;
@@ -20,6 +19,7 @@
import org.testng.annotations.Test;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the marshalling of retvals
@@ -27,7 +27,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional", "jgroups"})
+@Test(groups = {"functional", "jgroups"}, sequential = true)
public class ReturnValueMarshallingTest extends RegionBasedMarshallingTestBase
{
protected boolean useMarshalledValues = false;
@@ -42,20 +42,23 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache1.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
- cache1.getConfiguration().setUseRegionBasedMarshalling(!useMarshalledValues);
- cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setSyncReplTimeout(60000);// to aid with debugging
+ super.setUp();
+ Configuration c1 = new Configuration();
+ c1.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c1.setUseLazyDeserialization(useMarshalledValues);
+ c1.setUseRegionBasedMarshalling(!useMarshalledValues);
+ c1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c1.setSyncReplTimeout(60000);// to aid with debugging
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c1, false);
cache1.start();
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache2.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
- cache2.getConfiguration().setUseRegionBasedMarshalling(!useMarshalledValues);
- cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache2.getConfiguration().setSyncReplTimeout(60000);// to aid with debugging
+ Configuration c2 = new Configuration();
+ c2.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c2.setUseLazyDeserialization(useMarshalledValues);
+ c2.setUseRegionBasedMarshalling(!useMarshalledValues);
+ c2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c2.setSyncReplTimeout(60000);// to aid with debugging
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c2, false);
cache2.start();
classLoader = getClassLoader();
@@ -76,10 +79,12 @@
}
@AfterMethod(alwaysRun = true)
- public void tearDown()
+ public void tearDown() throws Exception
{
TestingUtil.killCaches(cache1, cache2);
- resetContextClassLoader();
+ cache1 = null;
+ cache2 = null;
+ super.tearDown();
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,7 +10,6 @@
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -29,6 +28,7 @@
import javax.transaction.TransactionManager;
import java.lang.reflect.Method;
import java.util.HashMap;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Test case for marshalling using Sync mode.
@@ -36,41 +36,49 @@
* @author Ben Wang
* @version $Revision$
*/
-@Test(groups = {"functional", "jgroups"})
+@Test(groups = {"functional", "jgroups"}, sequential = true)
public class SyncReplTest extends RegionBasedMarshallingTestBase
{
- CacheSPI<Object, Object> cache1, cache2;
- String props = null;
- Person ben_;
- Address addr_;
- Throwable ex_;
+
+ protected class SyncReplTestTL {
+ CacheSPI<Object, Object> cache1, cache2;
+ String props = null;
+ Person ben_;
+ Address addr_;
+ Throwable ex_;
+ }
+ protected ThreadLocal<SyncReplTestTL> threadLocal = new ThreadLocal<SyncReplTestTL>();
+
private Fqn aop = Fqn.fromString("/aop");
protected boolean useMarshalledValues = false;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
- {
+ {
+ super.setUp();
+ SyncReplTestTL srtl = new SyncReplTestTL();
+ threadLocal.set(srtl);
log("creating cache1");
- cache1 = createCache("TestCache");
+ srtl.cache1 = createCache("TestCache");
log("creating cache2");
- cache2 = createCache("TestCache");
- addr_ = new Address();
- addr_.setCity("San Jose");
- ben_ = new Person();
- ben_.setName("Ben");
- ben_.setAddress(addr_);
+ srtl.cache2 = createCache("TestCache");
+ srtl.addr_ = new Address();
+ srtl.addr_.setCity("San Jose");
+ srtl.ben_ = new Person();
+ srtl.ben_.setName("Ben");
+ srtl.ben_.setAddress(srtl.addr_);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
+ TestingUtil.blockUntilViewsReceived(new CacheSPI[]{srtl.cache1, srtl.cache2}, 60000);
}
private CacheSPI<Object, Object> createCache(String name)
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache.getConfiguration().setClusterName(name);
+ cache.getConfiguration().setClusterName(name + "-" + Thread.currentThread().getName());
// Use marshaller
cache.getConfiguration().setUseLazyDeserialization(useMarshalledValues);
cache.getConfiguration().setUseRegionBasedMarshalling(!useMarshalledValues);
@@ -83,6 +91,9 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
cache1.removeNode(Fqn.ROOT);
if (cache1 != null)
{
@@ -96,19 +107,27 @@
cache2.stop();
}
- resetContextClassLoader();
+ super.tearDown();
+ threadLocal.set(null);
}
public void testPlainPut() throws Exception
{
- cache1.put(aop, "person", ben_);
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+ cache1.put(aop, "person", srtl.ben_);
Person ben2 = (Person) cache2.get(aop, "person");
assertNotNull("Person from 2nd cache should not be null ", ben2);
- assertEquals(ben_.toString(), ben2.toString());
+ assertEquals(srtl.ben_.toString(), ben2.toString());
}
public void testCCE() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader c1 = getClassLoader();
ClassLoader c2 = getClassLoader();
@@ -123,7 +142,7 @@
}
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(c1);
- cache1.put(aop, "person", ben_);
+ cache1.put(aop, "person", srtl.ben_);
if (useMarshalledValues) resetContextClassLoader();
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(getFailingClassLoader());
try
@@ -142,6 +161,10 @@
public void testPut() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
ClassLoader clb = getClassLoader();
if (!useMarshalledValues)
@@ -152,17 +175,21 @@
r2.registerContextClassLoader(clb);
}
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
- cache1.put(aop, "person", ben_);
+ cache1.put(aop, "person", srtl.ben_);
Object ben2;
// Can't cast it to Person. CCE will result.
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
ben2 = cache2.get(aop, "person");
- assertEquals(ben_.toString(), ben2.toString());
+ assertEquals(srtl.ben_.toString(), ben2.toString());
}
public void testCLSet() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
ClassLoader clb = getClassLoader();
if (!useMarshalledValues)
@@ -174,13 +201,13 @@
}
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
- cache1.put(aop, "person", ben_);
+ cache1.put(aop, "person", srtl.ben_);
Object ben2;
// Can't cast it to Person. CCE will result.
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
ben2 = cache2.get(aop, "person");
- assertEquals(ben_.toString(), ben2.toString());
+ assertEquals(srtl.ben_.toString(), ben2.toString());
Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
@@ -198,6 +225,10 @@
*/
public void testCLSet2() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
ClassLoader clb = getClassLoader();
@@ -210,13 +241,13 @@
}
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
- cache1.put(aop, "person", ben_);
+ cache1.put(aop, "person", srtl.ben_);
Object ben2;
// Can't cast it to Person. CCE will result.
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
ben2 = cache2.get(aop, "person");
- assertEquals(ben_.toString(), ben2.toString());
+ assertEquals(srtl.ben_.toString(), ben2.toString());
Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
@@ -237,6 +268,10 @@
public void testPuts() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
ClassLoader clb = getClassLoader();
@@ -254,7 +289,7 @@
Object scopedBen2 = getPersonFromClassloader(clb);
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
- cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
+ cache1.put(Fqn.fromString("/aop/1"), "person", srtl.ben_);
cache1.put(Fqn.fromString("/aop/2"), "person", scopedBen1);
if (useMarshalledValues) resetContextClassLoader();
Object ben2;
@@ -262,7 +297,7 @@
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
ben2 = cache2.get(Fqn.fromString("/aop/1"), "person");
if (useMarshalledValues) resetContextClassLoader();
- assertEquals(ben_.toString(), ben2.toString());
+ assertEquals(srtl.ben_.toString(), ben2.toString());
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
ben2 = cache2.get(Fqn.fromString("/aop/2"), "person");
@@ -274,6 +309,10 @@
public void testMethodCall() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
ClassLoader clb = getClassLoader();
@@ -287,7 +326,7 @@
}
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
- cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
+ cache1.put(Fqn.fromString("/aop/1"), "person", srtl.ben_);
cache1.remove(Fqn.fromString("/aop/1"), "person");
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("1", "1");
@@ -301,6 +340,10 @@
public void testTxMethodCall() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
ClassLoader clb = getClassLoader();
@@ -315,7 +358,7 @@
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
TransactionManager tm = beginTransaction();
- cache1.put(Fqn.fromString("/aop/1"), "person", ben_);
+ cache1.put(Fqn.fromString("/aop/1"), "person", srtl.ben_);
cache1.remove(Fqn.fromString("/aop/1"), "person");
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("1", "1");
@@ -330,6 +373,10 @@
public void testTxCLSet2() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
ClassLoader cla = getClassLoader();
if (!useMarshalledValues)
{
@@ -345,7 +392,7 @@
TransactionManager tm = beginTransaction();
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
- cache1.put(aop, "person", ben_);
+ cache1.put(aop, "person", srtl.ben_);
tm.commit();
if (useMarshalledValues) resetContextClassLoader();
@@ -354,7 +401,7 @@
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
ben2 = cache2.get(aop, "person");
if (useMarshalledValues) resetContextClassLoader();
- assertEquals(ben_.toString(), ben2.toString());
+ assertEquals(srtl.ben_.toString(), ben2.toString());
Class claz = clb.loadClass(ADDRESS_CLASSNAME);
Object add = claz.newInstance();
@@ -382,6 +429,10 @@
public void testCustomFqn() throws Exception
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+ CacheSPI<Object, Object> cache2 = srtl.cache2;
+
FooClassLoader cl1 = new FooClassLoader(Thread.currentThread().getContextClassLoader());
Region r1 = cache1.getRegion(aop, false) == null ? cache1.getRegion(aop, true) : cache1.getRegion(aop, false);
r1.registerContextClassLoader(cl1);
@@ -410,6 +461,9 @@
private TransactionManager beginTransaction() throws SystemException, NotSupportedException
{
+ SyncReplTestTL srtl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = srtl.cache1;
+
TransactionManager mgr = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
mgr.begin();
return mgr;
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -30,13 +30,14 @@
@BeforeMethod
public void setUp()
{
- cr = new ComponentRegistry(new Configuration(), new CacheInvocationDelegate());
+ ComponentRegistry cr = new ComponentRegistry(new Configuration(), new CacheInvocationDelegate());
+ crTL.set(cr);
}
@AfterMethod
public void tearDown()
{
- cr = null;
+ crTL.set(null);
}
public void testMarshallerSelection()
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/CacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,7 +14,7 @@
* @author Jerry Gauthier
* @version $Id$
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheLoaderTest extends MgmtTestBase
{
public void testCacheLoaderMgmt() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/InvalidationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/InvalidationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/InvalidationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,8 +1,8 @@
package org.jboss.cache.mgmt;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -21,7 +21,7 @@
* @author Jerry Gauthier
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class InvalidationTest
{
private static final String CLUSTER_NAME = "InvalidationTestCluster";
@@ -45,14 +45,12 @@
{
if (cache1 != null)
{
- cache1.stop();
- cache1.destroy();
+ TestingUtil.killCaches(cache1);
cache1 = null;
}
if (cache2 != null)
{
- cache2.stop();
- cache2.destroy();
+ TestingUtil.killCaches(cache2);
cache2 = null;
}
}
@@ -154,6 +152,6 @@
c.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
c.setExposeManagementStatistics(true);
c.setClusterName(clusterName);
- return (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c);
+ return (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtCoreTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtCoreTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtCoreTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,8 +1,8 @@
package org.jboss.cache.mgmt;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.CacheMgmtInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
@@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.List;
+import org.jboss.cache.util.TestingUtil;
/**
* Simple functional tests for CacheMgmtInterceptor
@@ -20,7 +21,7 @@
* @author Jerry Gauthier
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class MgmtCoreTest
{
private static final String CAPITAL = "capital";
@@ -33,7 +34,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setExposeManagementStatistics(true);
cache.create();
@@ -45,8 +46,7 @@
{
if (cache != null)
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -16,6 +15,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
@Test(groups = "functional")
public abstract class MgmtTestBase
@@ -50,8 +51,7 @@
{
if (cache != null)
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
@@ -92,7 +92,7 @@
private CacheSPI<String, Object> createCache() throws Exception
{
- CacheFactory<String, Object> instance = new DefaultCacheFactory<String, Object>();
+ CacheFactory<String, Object> instance = new UnitTestCacheFactory<String, Object>();
Configuration c = new Configuration();
c.setNodeLockingScheme(NodeLockingScheme.MVCC);
c.setCacheMode(Configuration.CacheMode.LOCAL);
Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/TxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/TxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/TxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.mgmt;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -15,6 +14,8 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Simple functional tests for TxInterceptor statistics
@@ -46,14 +47,12 @@
{
if (cache1 != null)
{
- cache1.stop();
- cache1.destroy();
+ TestingUtil.killCaches(cache1);
cache1 = null;
}
if (cache2 != null)
{
- cache2.stop();
- cache2.destroy();
+ TestingUtil.killCaches(cache2);
cache2 = null;
}
}
@@ -210,13 +209,16 @@
}
private CacheSPI<Object, Object> createCache(String clusterName)
- {
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache.getConfiguration().setUseRegionBasedMarshalling(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache.getConfiguration().setExposeManagementStatistics(true);
- cache.getConfiguration().setClusterName(clusterName);
+ {
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+ c.setUseRegionBasedMarshalling(false);
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ c.setExposeManagementStatistics(true);
+ c.setClusterName(clusterName);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>)
+ new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+
cache.create();
cache.start();
return cache;
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/AsyncReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/AsyncReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -33,15 +33,15 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional", "jgroups"}, enabled = true)
+@Test(groups = {"functional", "jgroups"})
public class AsyncReplTest extends org.jboss.cache.replicated.AsyncReplTest
{
- private MultiplexerTestHelper muxHelper;
+ private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- muxHelper = new MultiplexerTestHelper();
+ muxHelperTL.set(new MultiplexerTestHelper());
super.setUp();
}
@@ -55,10 +55,10 @@
}
finally
{
- if (muxHelper != null)
+ if (muxHelperTL.get() != null)
{
- muxHelper.tearDown();
- muxHelper = null;
+ muxHelperTL.get().tearDown();
+ muxHelperTL.set(null);
}
}
}
@@ -71,7 +71,7 @@
protected void configureMultiplexer(Cache cache) throws Exception
{
- muxHelper.configureCacheForMux(cache);
+ muxHelperTL.get().configureCacheForMux(cache);
}
protected void validateMultiplexer(Cache cache)
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/BadMuxConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BadMuxConfigTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BadMuxConfigTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,8 +1,10 @@
package org.jboss.cache.multiplexer;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.JChannel;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -16,7 +18,7 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional", "jgroups"}, enabled = true)
+@Test(groups = {"functional", "jgroups"}, enabled = true, sequential = true)
public class BadMuxConfigTest
{
private MultiplexerTestHelper muxHelper;
@@ -29,8 +31,8 @@
muxHelper = new MultiplexerTestHelper();
Configuration config = new Configuration();
config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- config.setClusterConfig(JChannel.DEFAULT_PROTOCOL_STACK);
- cache = new DefaultCacheFactory<Object, Object>().createCache(config, false);
+ config.setClusterConfig(UnitTestCacheConfigurationFactory.getClusterConfigFromProperties(JChannel.DEFAULT_PROTOCOL_STACK));
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(config, false);
cacheStarted = false;
}
@@ -39,10 +41,10 @@
{
try
{
- if (cacheStarted && cache != null)
+ if (cache != null)
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
}
finally
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyAssignmentStateTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyAssignmentStateTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -37,12 +37,12 @@
public class BuddyAssignmentStateTransferTest
extends org.jboss.cache.buddyreplication.BuddyAssignmentStateTransferTest
{
- private MultiplexerTestHelper muxHelper;
+ private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- muxHelper = new MultiplexerTestHelper();
+ muxHelperTL.set(new MultiplexerTestHelper());
}
@AfterMethod(alwaysRun = true)
@@ -54,16 +54,16 @@
}
finally
{
- if (muxHelper != null)
- muxHelper.tearDown();
- muxHelper = null;
+ if (muxHelperTL.get() != null)
+ muxHelperTL.get().tearDown();
+ muxHelperTL.set(null);
}
}
@Override
protected void configureMultiplexer(Cache cache) throws Exception
{
- muxHelper.configureCacheForMux(cache);
+ muxHelperTL.get().configureCacheForMux(cache);
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -37,12 +37,12 @@
public class BuddyBackupActivationInactivationTest
extends org.jboss.cache.buddyreplication.BuddyBackupActivationInactivationTest
{
- private MultiplexerTestHelper muxHelper;
+ private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
@BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- muxHelper = new MultiplexerTestHelper();
+ muxHelperTL.set(new MultiplexerTestHelper());
super.setUp();
}
@@ -56,16 +56,16 @@
}
finally
{
- if (muxHelper != null)
- muxHelper.tearDown();
- muxHelper = null;
+ if (muxHelperTL.get() != null)
+ muxHelperTL.get().tearDown();
+ muxHelperTL.set(null);
}
}
@Override
protected void configureMultiplexer(Cache cache) throws Exception
{
- muxHelper.configureCacheForMux(cache);
+ muxHelperTL.get().configureCacheForMux(cache);
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -38,12 +38,12 @@
public class BuddyReplicationFailoverTest
extends org.jboss.cache.buddyreplication.BuddyReplicationFailoverTest
{
- private MultiplexerTestHelper muxHelper;
+ private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- muxHelper = new MultiplexerTestHelper();
+ muxHelperTL.set(new MultiplexerTestHelper());
}
@AfterMethod(alwaysRun = true)
@@ -55,16 +55,16 @@
}
finally
{
- if (muxHelper != null)
- muxHelper.tearDown();
- muxHelper = null;
+ if (muxHelperTL.get() != null)
+ muxHelperTL.get().tearDown();
+ muxHelperTL.set(null);
}
}
@Override
protected void configureMultiplexer(Cache cache) throws Exception
{
- muxHelper.configureCacheForMux(cache);
+ muxHelperTL.get().configureCacheForMux(cache);
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/ChannelInjectionPreferenceTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/ChannelInjectionPreferenceTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/ChannelInjectionPreferenceTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,9 +1,11 @@
package org.jboss.cache.multiplexer;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.RuntimeConfig;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Channel;
import org.jgroups.JChannel;
import static org.testng.AssertJUnit.*;
@@ -18,7 +20,7 @@
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional", "jgroups"}, enabled = true)
+@Test(groups = {"functional", "jgroups"}, enabled = true, sequential = true)
public class ChannelInjectionPreferenceTest
{
private MultiplexerTestHelper muxHelper;
@@ -31,8 +33,8 @@
muxHelper = new MultiplexerTestHelper();
Configuration config = new Configuration();
config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- config.setClusterConfig(JChannel.DEFAULT_PROTOCOL_STACK);
- cache = new DefaultCacheFactory<Object, Object>().createCache(config, false);
+ config.setClusterConfig(UnitTestCacheConfigurationFactory.getClusterConfigFromProperties(JChannel.DEFAULT_PROTOCOL_STACK));
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(config, false);
cacheStarted = false;
}
@@ -43,8 +45,8 @@
{
if (cacheStarted && cache != null)
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
}
finally
@@ -61,7 +63,8 @@
{
muxHelper.configureCacheForMux(cache);
- Channel channel = new JChannel(JChannel.DEFAULT_PROTOCOL_STACK);
+ Channel channel = new JChannel(new UnitTestCacheFactory().mangleClusterConfiguration(
+ UnitTestCacheConfigurationFactory.getClusterConfigFromProperties(JChannel.DEFAULT_PROTOCOL_STACK)));
RuntimeConfig rtcfg = cache.getConfiguration().getRuntimeConfig();
rtcfg.setChannel(channel);
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/MultiplexerTestHelper.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/MultiplexerTestHelper.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/MultiplexerTestHelper.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -34,6 +34,8 @@
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
/**
* Utility class that can associate a cache with a multiplexer-enabled
@@ -64,7 +66,7 @@
{
ChannelFactory factory = createMuxChannelFactory(cache);
cache.getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory);
- cache.getConfiguration().setMultiplexerStack(MUX_STACK);
+ cache.getConfiguration().setMultiplexerStack(MUX_STACK + Thread.currentThread().getName());
}
}
@@ -86,7 +88,7 @@
private String getChannelProperties(Cache cache)
{
String props = cache.getConfiguration().getClusterConfig();
- return (props == null ? JChannel.DEFAULT_PROTOCOL_STACK : props);
+ return (props == null ? UnitTestCacheConfigurationFactory.getClusterConfigFromProperties(JChannel.DEFAULT_PROTOCOL_STACK) : props);
}
/**
@@ -103,6 +105,7 @@
{
synchronized (factories)
{
+ muxConfig = new UnitTestCacheFactory().mangleClusterConfiguration(muxConfig);
JChannelFactory factory = new JChannelFactory();
factory.setDomain("jbc.mux.test");
factory.setExposeChannels(false);
@@ -130,7 +133,7 @@
Element top = doc.createElement("protocol_stacks");
doc.appendChild(top);
Element stack = doc.createElement("stack");
- stack.setAttribute("name", MUX_STACK);
+ stack.setAttribute("name", MUX_STACK + Thread.currentThread().getName());
top.appendChild(stack);
Element config = doc.createElement("config");
Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/StateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/StateTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/StateTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -37,12 +37,12 @@
@Test(groups = {"functional", "jgroups"}, enabled = true)
public class StateTransferTest extends StateTransfer200Test
{
- private MultiplexerTestHelper muxHelper;
+ private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- muxHelper = new MultiplexerTestHelper();
+ muxHelperTL.set(new MultiplexerTestHelper());
super.setUp();
}
@@ -56,10 +56,10 @@
}
finally
{
- if (muxHelper != null)
+ if (muxHelperTL.get() != null)
{
- muxHelper.tearDown();
- muxHelper = null;
+ muxHelperTL.get().tearDown();
+ muxHelperTL.set(null);
}
}
}
@@ -67,7 +67,7 @@
@Override
protected void configureMultiplexer(Cache cache) throws Exception
{
- muxHelper.configureCacheForMux(cache);
+ muxHelperTL.get().configureCacheForMux(cache);
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/mvcc/MVCCFullStackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mvcc/MVCCFullStackTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/mvcc/MVCCFullStackTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.mvcc;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.interceptors.MVCCLockingInterceptor;
@@ -15,7 +15,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class MVCCFullStackTest
{
CacheSPI<Object, Object> cache;
@@ -24,11 +24,12 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testDefaultConfiguration()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache();
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache();
assert TestingUtil.findInterceptor(cache, MVCCLockingInterceptor.class) != null : "MVCC interceptor should be in stack";
assert cache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.MVCC;
@@ -64,7 +65,7 @@
Configuration c = new Configuration();
c.setNodeLockingScheme(NodeLockingScheme.MVCC);
c.setIsolationLevel(configuredWith);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c);
assert cache.getConfiguration().getIsolationLevel() == expected : "Expected to change isolation level from " + configuredWith + " to " + expected + " but was " + cache.getConfiguration().getIsolationLevel();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotificationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotificationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeCreated;
import org.jboss.cache.notifications.event.NodeCreatedEvent;
@@ -9,6 +8,7 @@
import org.testng.annotations.Test;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
@Test(groups = "functional")
public class AsyncNotificationTest
@@ -18,7 +18,7 @@
Cache<String, String> c = null;
try
{
- c = new DefaultCacheFactory<String, String>().createCache();
+ c = new UnitTestCacheFactory<String, String>().createCache();
CountDownLatch latch = new CountDownLatch(2);
AbstractListener syncListener = new Listener(latch);
AbstractListener asyncListener = new AsyncListener(latch);
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/BuddyGroupChangeNotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/BuddyGroupChangeNotificationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/BuddyGroupChangeNotificationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
import org.jboss.cache.config.BuddyReplicationConfig;
@@ -18,12 +17,13 @@
import org.testng.annotations.Test;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class BuddyGroupChangeNotificationTest extends BuddyReplicationTestsBase
{
Cache c1, c2, c3;
@@ -36,17 +36,17 @@
@BeforeMethod
public void setUp() throws CloneNotSupportedException
{
- CacheFactory cf = new DefaultCacheFactory<Object, Object>();
- c1 = cf.createCache(false);
-
- c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ CacheFactory cf = new UnitTestCacheFactory<Object, Object>();
+ Configuration conf = new Configuration();
+ conf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
BuddyReplicationConfig brc = new BuddyReplicationConfig();
brc.setEnabled(true);
- c1.getConfiguration().setBuddyReplicationConfig(brc);
+ conf.setBuddyReplicationConfig(brc);
+
+ c1 = cf.createCache(conf, false);
+ c2 = cf.createCache(conf.clone(), false);
+ c3 = cf.createCache(conf.clone(), false);
- c2 = cf.createCache(c1.getConfiguration().clone(), false);
- c3 = cf.createCache(c1.getConfiguration().clone(), false);
-
c1.start();
c2.start();
c3.start();
@@ -65,6 +65,9 @@
public void tearDown()
{
TestingUtil.killCaches(c1, c2, c3);
+ c1 = null;
+ c2 = null;
+ c3 = null;
}
@Test(timeOut = 60000)
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPassivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
@@ -26,8 +25,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheListenerPassivationTest
{
private Cache<Object, Object> cache;
@@ -49,7 +49,7 @@
clc.setPassivation(true);
c.setCacheLoaderConfig(clc);
- cache = new DefaultCacheFactory<Object, Object>().createCache(c);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(c);
eventLog.events.clear();
cache.addCacheListener(eventLog);
tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -59,6 +59,7 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testActivationAndPassivation() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
@@ -31,6 +30,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Note that this is significantly different from the old <b>TreeCacheListenerTest</b> of the JBoss Cache 1.x series, and
@@ -38,7 +39,7 @@
*
* @since 2.0.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class CacheListenerTest
{
protected boolean optLocking = false;
@@ -58,7 +59,7 @@
if (optLocking)
c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache = new DefaultCacheFactory<Object, Object>().createCache(c);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(c);
tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
eventLog.events.clear();
cache.addCacheListener(eventLog);
@@ -70,8 +71,9 @@
Transaction t = tm.getTransaction();
if (t != null)
tm.rollback();
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
+ cache = null;
+
}
// simple tests first
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/ConcurrentNotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/ConcurrentNotificationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/ConcurrentNotificationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeCreated;
@@ -21,12 +20,14 @@
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ConcurrentNotificationTest
{
private Cache<String, String> cache;
@@ -37,7 +38,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = instance.createCache();
listener = new Listener();
cache.addCacheListener(listener);
@@ -46,7 +47,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testNulls()
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
@@ -20,6 +19,7 @@
import javax.transaction.TransactionManager;
import java.util.LinkedList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the threading model used when calling notifications
@@ -27,7 +27,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class NotificationThreadTest extends AbstractCacheLoaderTestBase
{
private Cache<String, String> cache1, cache2;
@@ -39,19 +39,23 @@
{
// need 2 caches to test viewChange notifications
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache1 = instance.createCache(false);
- cache2 = instance.createCache(false);
- cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setSyncCommitPhase(true);
- cache2.getConfiguration().setSyncCommitPhase(true);
- cache1.getConfiguration().setSyncRollbackPhase(true);
- cache2.getConfiguration().setSyncRollbackPhase(true);
- cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), null, false, false, false));
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
+ Configuration conf1 = new Configuration();
+ Configuration conf2 = new Configuration();
+ conf1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ conf2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ conf1.setSyncCommitPhase(true);
+ conf2.setSyncCommitPhase(true);
+ conf1.setSyncRollbackPhase(true);
+ conf2.setSyncRollbackPhase(true);
+ conf1.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ conf2.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ conf1.setCacheLoaderConfig(getSingleCacheLoaderConfig("", DummyInMemoryCacheLoader.class.getName(), null, false, false, false));
+
+ cache1 = instance.createCache(conf1, false);
+ cache2 = instance.createCache(conf2, false);
+
listener = new TestCacheListener();
cache1.addCacheListener(listener);
}
@@ -59,8 +63,9 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- cache1.stop();
- cache2.stop();
+ TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
public void testPessimisticWithCacheLoader() throws Throwable
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -22,7 +22,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class NotifierAnnotationsTest
{
private NotifierImpl n;
@@ -40,6 +40,7 @@
{
n.stop();
n.destroy();
+ n = null;
}
public void testControl()
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-@Test(groups = "unit")
+@Test(groups = "unit", sequential = true)
public class NotifierTest
{
private NotifierImpl notifier;
@@ -51,6 +51,7 @@
{
notifier.stop();
notifier.destroy();
+ notifier = null;
}
public void testNotifyNodeCreated()
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvalidatedTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvalidatedTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvalidatedTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -15,6 +14,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
@Test(groups = "functional")
public class NotifyNodeInvalidatedTest
@@ -26,8 +26,8 @@
{
Configuration cfg = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.INVALIDATION_SYNC, false);
cfg.setNodeLockingScheme(NodeLockingScheme.MVCC);
- c1 = new DefaultCacheFactory<String, String>().createCache(cfg.clone());
- c2 = new DefaultCacheFactory<String, String>().createCache(cfg.clone());
+ c1 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone());
+ c2 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone());
EventLog eventLog = new EventLog();
c2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
c2.put("/a/b/c", "x", "y");
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -25,7 +25,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
@@ -50,13 +49,14 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Remote conterpart of CacheListenerTest. Main difference is event is originating as local.
*
* @since 2.0.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class RemoteCacheListenerTest
{
protected boolean optLocking = false;
@@ -65,7 +65,7 @@
@SuppressWarnings("unused")
private TransactionManager tm1;
private EventLog eventLog1 = new EventLog(), eventLog2 = new EventLog();
- private Fqn fqn = Fqn.fromString("/test");
+ private final Fqn fqn = Fqn.fromString("/test");
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -86,7 +86,7 @@
// more time to help with debugging
c.setSyncReplTimeout(60000);
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache1 = instance.createCache(c);
cache2 = instance.createCache(c.clone());
@@ -103,6 +103,8 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
/**
@@ -647,7 +649,7 @@
cache1.put(fqnB, data);
// create cache2
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache2 = instance.createCache(cache1.getConfiguration().clone(), false);
cache2.create();
eventLog2.events.clear();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -5,7 +5,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.WriteCommand;
@@ -41,6 +40,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author manik
@@ -60,7 +60,7 @@
protected CacheSPI<Object, Object> createCacheUnstarted(boolean optimistic) throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL), false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL), false);
if (optimistic) cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
return cache;
}
@@ -128,14 +128,15 @@
protected CacheSPI createPessimisticCache() throws Exception
{
- CacheSPI cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache.getConfiguration();
-
+ Configuration c = new Configuration();
c.setClusterName("name");
c.setStateRetrievalTimeout(5000);
c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
+ CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+
cache.create();
cache.start();
@@ -145,15 +146,15 @@
protected CacheSPI createPessimisticCacheLocal() throws Exception
{
- CacheSPI cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache.getConfiguration();
-
+ Configuration c = new Configuration();
c.setClusterName("name");
c.setStateRetrievalTimeout(5000);
c.setCacheMode(Configuration.CacheMode.LOCAL);
c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
+ CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.create();
cache.start();
@@ -173,8 +174,7 @@
protected CacheSPI<Object, Object> createReplicatedCache(String name, Configuration.CacheMode mode, boolean start) throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache.getConfiguration();
+ Configuration c = new Configuration();
c.setClusterName(name);
c.setStateRetrievalTimeout(5000);
@@ -188,6 +188,8 @@
c.setNodeLockingScheme("OPTIMISTIC");
c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+
if (start)
{
cache.create();
@@ -214,8 +216,7 @@
protected CacheSPI<Object, Object> createReplicatedCacheWithLoader(String name, boolean shared, Configuration.CacheMode cacheMode) throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache.getConfiguration();
+ Configuration c = new Configuration();
c.setClusterName(name);
c.setStateRetrievalTimeout(5000);
c.setCacheMode(cacheMode);
@@ -224,6 +225,7 @@
c.setNodeLockingScheme("OPTIMISTIC");
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.setCacheLoaderConfig(getCacheLoaderConfig(shared, false));
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache.create();
cache.start();
@@ -254,6 +256,9 @@
{
// do nothing
}
+
+ new UnitTestCacheFactory().cleanUp();
+
}
protected void setAlteredInterceptorChain(CommandInterceptor newLast, CacheSPI<Object, Object> spi)
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -18,7 +18,7 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-@Test(groups = {"functional", "transaction", "optimistic"})
+@Test(groups = {"functional", "transaction", "optimistic"}, sequential = true)
public class AsyncCacheTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache, cache2;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -23,7 +23,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "transaction", "optimistic"})
+@Test(groups = {"functional", "transaction", "optimistic"}, sequential = true)
public class AsyncFullStackInterceptorTest extends AbstractOptimisticTestCase
{
private int groupIncreaser = 0;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -33,7 +33,7 @@
import java.util.concurrent.CountDownLatch;
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class CacheTest extends AbstractOptimisticTestCase
{
Log log = LogFactory.getLog(CacheTest.class);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.optimistic;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
@@ -15,6 +14,8 @@
import javax.transaction.Transaction;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests that children maps in workspace nodes are only loaded lazily, when a move() or getChildrenNames()
@@ -22,7 +23,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ChildMapLazyLoadingTest
{
private CacheSPI<Object, Object> cache;
@@ -32,7 +33,7 @@
@BeforeMethod
public void setUp()
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.start();
@@ -43,18 +44,8 @@
@AfterMethod
public void tearDown()
{
- if (cache != null)
- {
- try
- {
- cache.getTransactionManager().rollback();
- }
- catch (Exception e)
- {
-
- }
- cache.stop();
- }
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testLazyLoadingOnCacheGet() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -31,7 +31,7 @@
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ConcurrentTransactionTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -56,11 +56,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- if (cache != null)
- {
- cache.stop();
- cache = null;
- }
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testConcurrentTransactions() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionPersistenceTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -15,6 +14,8 @@
import org.testng.annotations.Test;
import java.io.IOException;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests whether data versions are transferred along with state
@@ -22,7 +23,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class DataVersionPersistenceTest
{
private Cache cache;
@@ -32,7 +33,7 @@
public void setUp() throws IOException
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
@@ -60,8 +61,9 @@
{
// do nothing?
}
- ((DummySharedInMemoryCacheLoader) loader).wipe();
- cache.stop();
+ ((DummySharedInMemoryCacheLoader) loader).wipeBin();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testStateTransferDefaultVersions() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/DataVersionTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.optimistic;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -13,6 +12,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests whether data versions are transferred along with state
@@ -20,25 +20,27 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class DataVersionTransferTest
{
- private List<Cache<Object, Object>> caches = new ArrayList<Cache<Object, Object>>(2);
+ private List<Cache<Object, Object>> caches = null;
@BeforeMethod
public void setUp()
{
-
- caches.add(new DefaultCacheFactory<Object, Object>().createCache(false));
- caches.get(0).getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- caches.get(0).getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- caches.get(0).getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ Configuration c = new Configuration();
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ caches = new ArrayList<Cache<Object, Object>>(2);
+ caches.add(new UnitTestCacheFactory<Object, Object>().createCache(c, false));
caches.get(0).start();
- caches.add(new DefaultCacheFactory<Object, Object>().createCache(false));
- caches.get(1).getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- caches.get(1).getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
- caches.get(1).getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c = new Configuration();
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ caches.add(new UnitTestCacheFactory<Object, Object>().createCache(c, false));
}
@AfterMethod
@@ -46,18 +48,8 @@
{
if (caches != null)
{
- for (Cache cache : caches)
- {
- try
- {
- cache.getConfiguration().getRuntimeConfig().getTransactionManager().rollback();
- }
- catch (Exception e)
- {
- // do nothing?
- }
- cache.stop();
- }
+ for (Cache cache : caches) TestingUtil.killCaches(cache);
+ caches = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -22,7 +22,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class FullStackInterceptorTest extends AbstractOptimisticTestCase
{
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/HasChildTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/HasChildTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/HasChildTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -17,7 +17,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class HasChildTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -36,6 +36,7 @@
{
super.tearDown();
destroyCache(cache);
+ cache = null;
}
public void testExists() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -23,7 +23,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorGetChildrenNamesTest extends AbstractOptimisticTestCase
{
TestListener listener;
@@ -58,6 +58,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
@SuppressWarnings("unchecked")
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -21,7 +21,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorGetKeyValTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -49,6 +49,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionGetKeyMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -21,7 +21,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorGetKeysTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -49,6 +49,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionGetKeysMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -21,7 +21,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorKeyValTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -49,6 +49,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionPutKeyMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorPutEraseTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -52,6 +52,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionPutKeyMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorPutMapTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -52,6 +52,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionPutDataMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorRemoveDataTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -52,6 +52,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionRemoveNoNodeDataMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -30,7 +30,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorRemoveKeyValTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -58,6 +58,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionRemoveNoNodeKeyValMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -25,11 +25,12 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.util.TestingUtil;
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
@SuppressWarnings("unchecked")
public class NodeInterceptorRemoveNodeTest extends AbstractOptimisticTestCase
{
@@ -56,7 +57,8 @@
public void tearDown()
{
super.tearDown();
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testTransactionRemoveNotExistsNodeMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorTransactionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorTransactionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -20,7 +20,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class NodeInterceptorTransactionTest extends AbstractOptimisticTestCase
{
CacheSPI cache;
@@ -44,6 +44,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testNoTransactionCRUDMethod() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -29,7 +29,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class OptimisticCreateIfNotExistsInterceptorTest extends AbstractOptimisticTestCase
{
protected TransactionManager txManager;
@@ -61,6 +61,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -27,7 +27,7 @@
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class OptimisticLockInterceptorTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -53,7 +53,8 @@
@AfterMethod
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testPut() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -29,7 +29,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
@SuppressWarnings("unchecked")
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class OptimisticVersioningTest extends AbstractOptimisticTestCase
{
private static final Log log = LogFactory.getLog(OptimisticVersioningTest.class);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -20,7 +20,7 @@
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
*/
-@Test(groups = {"functional", "transaction", "optimistic"})
+@Test(groups = {"functional", "transaction", "optimistic"}, sequential = true)
public class OptimisticWithCacheLoaderTest extends AbstractOptimisticTestCase
{
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -20,7 +20,7 @@
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class OptimisticWithPassivationTest extends AbstractOptimisticTestCase
{
protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ParentVersionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ParentVersionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ParentVersionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,7 +16,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ParentVersionTest extends AbstractOptimisticTestCase
{
private Cache<Object, Object> cache;
@@ -46,6 +46,7 @@
public void tearDown()
{
destroyCache(cache);
+ cache = null;
}
private long getVersion(Node n)
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -16,7 +16,7 @@
/**
* Tests removal of a node before the node is even created.
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class RemoveBeforeCreateTest extends AbstractOptimisticTestCase
{
CacheSPI<Object, Object>[] c = null;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -19,7 +19,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ThreadedCacheAccessTest extends AbstractOptimisticTestCase
{
private static final Log log = LogFactory.getLog(ThreadedCacheAccessTest.class);
@@ -41,6 +41,8 @@
{
super.tearDown();
destroyCache(cache);
+ cache = null;
+ threads = null;
}
public void testThreadedMostlyReads() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ThreadedOptimisticCreateIfNotExistsInterceptorTest extends AbstractOptimisticTestCase
{
protected synchronized void setTransactionsInInvocationCtx(TransactionManager mgr, CacheSPI cache) throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -25,7 +25,7 @@
import javax.transaction.TransactionManager;
import java.util.List;
-@Test(groups = {"functional", "transaction", "optimistic"})
+@Test(groups = {"functional", "transaction", "optimistic"}, sequential = true)
public class TxInterceptorTest extends AbstractOptimisticTestCase
{
@Override
@@ -96,7 +96,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -128,7 +128,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -156,7 +156,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
public void testEmptyRollbackLocalTransaction() throws Exception
@@ -183,7 +183,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -226,7 +226,7 @@
assertNull(mgr.getTransaction());
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -262,7 +262,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -332,7 +332,7 @@
//assert we have the tx in th table
assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
public void testRemotePrepareSuspendTransaction() throws Exception
@@ -413,7 +413,7 @@
assertNull(table.getLocalTransaction(gtx));
//assert we are no longer associated
assertEquals(null, mgr.getTransaction());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
public void testRemoteCommitSuspendTransaction() throws Exception
@@ -501,7 +501,7 @@
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
assertEquals(null, mgr.getTransaction());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
public void testRemoteRollbackSuspendTransaction() throws Exception
@@ -588,7 +588,7 @@
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
assertEquals(null, mgr.getTransaction());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
public void testRemoteCommitTransaction() throws Exception
@@ -679,7 +679,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
assertNull(mgr.getTransaction());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -763,7 +763,7 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@@ -802,7 +802,7 @@
assertEquals(OptimisticPrepareCommand.METHOD_ID, calls.get(2));
assertEquals(CommitCommand.METHOD_ID, calls.get(3));
- cache.stop();
+ TestingUtil.killCaches(cache);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidationFailureTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidationFailureTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidationFailureTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -19,7 +19,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ValidationFailureTest extends AbstractOptimisticTestCase
{
public void testValidationFailureLockRelease() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -40,7 +40,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ValidatorInterceptorTest extends AbstractOptimisticTestCase
{
private CacheSPI<Object, Object> cache;
@@ -73,6 +73,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/VersioningOnReadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/VersioningOnReadTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/VersioningOnReadTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -14,7 +14,7 @@
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class VersioningOnReadTest extends AbstractOptimisticTestCase
{
CacheSPI cache;
@@ -33,6 +33,7 @@
{
super.tearDown();
destroyCache(cache);
+ cache = null;
}
public void testUpdateOnWrite() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/options/CacheModeLocalSimpleTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/CacheModeLocalSimpleTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/CacheModeLocalSimpleTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.options;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
@@ -19,11 +18,12 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class CacheModeLocalSimpleTest
{
private CacheSPI<Object, Object> cache1, cache2;
@@ -32,15 +32,15 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache1.getConfiguration();
+ Configuration c = new Configuration();
c.setCacheMode("REPL_SYNC");
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- c = cache2.getConfiguration();
+ c = new Configuration();
c.setCacheMode("REPL_SYNC");
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cacheModeLocal = new Option();
cacheModeLocal.setCacheModeLocal(true);
@@ -50,6 +50,8 @@
public void tearDown()
{
TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
public void testCacheModeLocalWithTx() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.options;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -15,13 +14,14 @@
import javax.transaction.RollbackException;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the passing in of explicit {@see DataVersion} instances when using optimistic locking + replication.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ExplicitVersionsReplTest
{
private CacheSPI<Object, Object> cache[];
@@ -52,7 +52,7 @@
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- return (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c);
+ return (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c);
}
@AfterMethod(alwaysRun = true)
Modified: core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -21,13 +20,15 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests the passing in of explicit {@see DataVersion} instances when using optimistic locking.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "optimistic"})
+@Test(groups = {"functional", "optimistic"}, sequential = true)
public class ExplicitVersionsTest
{
private CacheSPI<String, String> cache;
@@ -39,7 +40,7 @@
{
if (cache != null)
tearDown();
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
@@ -52,7 +53,7 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,7 +10,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -29,6 +28,7 @@
import javax.transaction.TransactionManager;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests functionality of {@link Option#setForceAsynchronous(boolean)} and
@@ -36,7 +36,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true, enabled = false)
public class ForceCacheModeTest
{
private static final Log log = LogFactory.getLog(ForceCacheModeTest.class);
@@ -54,17 +54,20 @@
private void createCaches(NodeLockingScheme scheme, CacheMode mode)
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache1.getConfiguration();
+
+ Configuration c = new Configuration();
c.setNodeLockingScheme(scheme);
c.setCacheMode(mode);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- c = cache2.getConfiguration();
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+
+ c = new Configuration();
c.setNodeLockingScheme(scheme);
c.setCacheMode(mode);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache1.start();
cache2.start();
@@ -107,8 +110,7 @@
{
if (cache1 != null)
{
- cache1.stop();
- cache1.destroy();
+ TestingUtil.killCaches(cache1);
cache1 = null;
}
@@ -116,8 +118,7 @@
{
if (listener != null)
cache2.removeCacheListener(listener);
- cache2.stop();
- cache2.destroy();
+ TestingUtil.killCaches(cache2);
cache2 = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
@@ -17,6 +16,7 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests forcing a write lock to be obtained on a node
@@ -24,7 +24,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional", "pessimistic"})
+@Test(groups = {"functional", "pessimistic"}, sequential = true)
public class ForceWriteLockTest
{
protected CacheSPI<String, String> cache;
@@ -38,7 +38,7 @@
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.setNodeLockingScheme(nodeLockingScheme);
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(c);
tm = cache.getTransactionManager();
}
@@ -47,6 +47,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
public void testControl() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,7 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import static org.testng.AssertJUnit.assertEquals;
@@ -20,13 +20,14 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests passing in the failSilently option in various scenarios.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class PessimisticFailSilentlyTest
{
private CacheSPI cache;
@@ -40,7 +41,7 @@
{
if (cache != null)
tearDown();
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI) instance.createCache(false);
// very short acquisition timeout
cache.getConfiguration().setLockAcquisitionTimeout(100);
@@ -68,7 +69,7 @@
}
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
@@ -20,13 +20,14 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.util.TestingUtil;
/**
* Test functionality of {@link Option#setLockAcquisitionTimeout(int)}.
*
* @author Brian Stansberry
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class PessimisticLockAcquisitionTimeoutTest
{
private static final Log log = LogFactory.getLog(PessimisticLockAcquisitionTimeoutTest.class);
@@ -43,12 +44,13 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache.getConfiguration();
+ Configuration c = new Configuration();
c.setCacheMode("REPL_SYNC");
- cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+
cache.start();
option = new Option();
@@ -60,7 +62,7 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,7 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
@@ -20,13 +20,14 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests the suppression of locking nodes
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class PessimisticSuppressLockingTest
{
private Fqn fqn = Fqn.fromString("/blah");
@@ -42,7 +43,7 @@
Configuration config = new Configuration();
config.setCacheMode(Configuration.CacheMode.LOCAL);
config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
config.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache = (CacheSPI<String, String>) instance.createCache(config);
m = cache.getTransactionManager();
@@ -53,7 +54,7 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
m = null;
Modified: core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -22,6 +21,7 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the cache mode local override in various scenarios. To be subclassed to test REPL_SYNC, REPL_ASYNC, INVALIDATION_SYNC, INVALIDATION_ASYNC for Opt and Pess locking.
@@ -41,49 +41,70 @@
*/
protected boolean isInvalidation;
- private CacheSPI<String, String> cache1;
- private CacheSPI<String, String> cache2;
- private NodeSPI<String, String> root1, root2;
+ private ThreadLocal<CacheSPI<String, String>> cache1TL = new ThreadLocal<CacheSPI<String, String>>();
+ private ThreadLocal<CacheSPI<String, String>> cache2TL = new ThreadLocal<CacheSPI<String, String>>();
+ private ThreadLocal<NodeSPI<String, String>> root1TL = new ThreadLocal<NodeSPI<String, String>>();
+ private ThreadLocal<NodeSPI<String, String>> root2TL = new ThreadLocal<NodeSPI<String, String>>();
- private Fqn fqn = Fqn.fromString("/a");
- private String key = "key";
+ private final Fqn fqn = Fqn.fromString("/a");
+ private final String key = "key";
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
// force a tear down if the test runner didn't run one before (happens in IDEA)
if (cache1 != null || cache2 != null)
tearDown();
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache1 = (CacheSPI<String, String>) instance.createCache(false);
- cache1.getConfiguration().setClusterName("test");
- cache1.getConfiguration().setStateRetrievalTimeout(1000);
- cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
- cache1.getConfiguration().setCacheMode(cacheMode);
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
+
+ Configuration c = new Configuration();
+ c.setClusterName("test");
+ c.setStateRetrievalTimeout(1000);
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c.setNodeLockingScheme(nodeLockingScheme);
+ c.setCacheMode(cacheMode);
+
+ cache1 = (CacheSPI<String, String>) instance.createCache(c, false);
cache1.start();
- cache2 = (CacheSPI<String, String>) instance.createCache(false);
- cache2.getConfiguration().setClusterName("test");
- cache2.getConfiguration().setStateRetrievalTimeout(1000);
- cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
- cache2.getConfiguration().setCacheMode(cacheMode);
+ c = new Configuration();
+ c.setClusterName("test");
+ c.setStateRetrievalTimeout(1000);
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c.setNodeLockingScheme(nodeLockingScheme);
+ c.setCacheMode(cacheMode);
+
+ cache2 = (CacheSPI<String, String>) instance.createCache(c, false);
cache2.start();
- root1 = cache1.getRoot();
- root2 = cache2.getRoot();
+ cache1TL.set(cache1);
+ cache2TL.set(cache2);
+
+ root1TL.set(cache1.getRoot());
+ root2TL.set(cache2.getRoot());
}
@AfterMethod(alwaysRun = true)
public void tearDown()
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
TestingUtil.killCaches(cache1, cache2);
+ cache1TL.set(null);
+ cache2TL.set(null);
}
public void testPutKeyValue() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(fqn, key, "value");
delay();
@@ -133,6 +154,11 @@
public void testPutKeyValueViaNodeAPI() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+ NodeSPI<String, String> root1 = root1TL.get();
+ NodeSPI<String, String> root2 = root2TL.get();
+
Node node1 = root1.addChild(fqn);
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node1.put(key, "value");
@@ -185,6 +211,9 @@
public void testPutData() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
Map<String, String> map = new HashMap<String, String>();
map.put(key, "value");
@@ -236,6 +265,11 @@
public void testPutDataViaNodeAPI() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+ NodeSPI<String, String> root1 = root1TL.get();
+ NodeSPI<String, String> root2 = root2TL.get();
+
Map<String, String> map = new HashMap<String, String>();
map.put(key, "value");
@@ -290,6 +324,9 @@
public void testRemoveNode() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
// put some stuff in the cache first
// make sure we cleanup thread local vars.
cache1.getInvocationContext().setOptionOverrides(null);
@@ -346,6 +383,11 @@
public void testRemoveNodeViaNodeAPI() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+ NodeSPI<String, String> root1 = root1TL.get();
+ NodeSPI<String, String> root2 = root2TL.get();
+
// put some stuff in the cache first
// make sure we cleanup thread local vars.
cache1.getInvocationContext().setOptionOverrides(null);
@@ -402,6 +444,9 @@
public void testRemoveKey() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
// put some stuff in the cache first
cache1.getInvocationContext().setOptionOverrides(null);
cache1.put(fqn, key, "value");
@@ -457,6 +502,11 @@
public void testRemoveKeyViaNodeAPI() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+ NodeSPI<String, String> root1 = root1TL.get();
+ NodeSPI<String, String> root2 = root2TL.get();
+
// put some stuff in the cache first
Node node1 = root1.addChild(fqn);
cache1.getInvocationContext().setOptionOverrides(null);
@@ -513,6 +563,9 @@
public void testTransactionalBehaviourCommit() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
cache1.getInvocationContext().getOptionOverrides().reset();
@@ -596,6 +649,9 @@
public void testTransactionalBehaviourRollback() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+
TransactionManager mgr = cache1.getTransactionManager();
// create these first ...
@@ -627,6 +683,11 @@
public void testTransactionalBehaviourViaNodeAPI() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+ NodeSPI<String, String> root1 = root1TL.get();
+ NodeSPI<String, String> root2 = root2TL.get();
+
Node node1 = root1.addChild(fqn);
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
@@ -712,6 +773,11 @@
public void testAddChild() throws Exception
{
+ CacheSPI<String, String> cache1 = cache1TL.get();
+ CacheSPI<String, String> cache2 = cache2TL.get();
+ NodeSPI<String, String> root1 = root1TL.get();
+ NodeSPI<String, String> root2 = root2TL.get();
+
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
root1.addChild(fqn);
delay();
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,8 +9,8 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -28,7 +28,7 @@
* @author Ben Wang
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class BasicPassivationTest
{
CacheSPI cache;
@@ -58,7 +58,7 @@
private void initCaches()
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI) instance.createCache(new XmlConfigurationParser().parseFile("configs/local-passivation.xml"), false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
Object listener = new TestCacheListener();
@@ -70,7 +70,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testBasic()
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,10 +9,11 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.fail;
import org.testng.annotations.AfterMethod;
@@ -26,7 +27,7 @@
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ConcurrentPassivationTest
{
private CacheSPI cache;
@@ -46,7 +47,7 @@
private void initCaches()
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI) instance.createCache(new XmlConfigurationParser().parseFile("configs/local-passivation.xml"), false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
@@ -56,7 +57,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,8 +11,8 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -31,7 +31,7 @@
/**
* @author Ben Wang, Feb 11, 2004
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class LocalPassivationIntegrationTest
{
CacheSPI<String, String> cache;
@@ -43,7 +43,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(new XmlConfigurationParser().parseFile("configs/local-passivation.xml"), false);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
@@ -67,7 +67,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,7 +11,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.EvictionConfig;
@@ -30,13 +29,15 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests that the TreeCacheListener implementation used by EJB3 SFSBs works.
*
* @author Brian Stansberry
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class PassivationActivationCallbacksTestCase
{
private static final Fqn BASE = Fqn.fromString("/base");
@@ -50,7 +51,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setCacheMode("local");
configureEviction();
@@ -103,8 +104,8 @@
{
cache.removeNode(Fqn.ROOT);
loader.remove(Fqn.fromString("/"));
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public void testSimpleLifecycle() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Node;
@@ -31,6 +30,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Base tests for passivation using any of the cache loaders
@@ -45,21 +45,26 @@
Log log = LogFactory.getLog(getClass());
//Cache Loader fields
- protected CacheSPI<Object, Object> cache;
- CacheLoader loader = null;
+ protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new ThreadLocal<CacheSPI<Object, Object>>();
+ ThreadLocal<CacheLoader> loaderTL = new ThreadLocal<CacheLoader>();
static final Fqn FQN = Fqn.fromString("/key");
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode("local");
+
+ cacheTL.set(cache);
+
configureCache();
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.create();
cache.start();
- loader = cache.getCacheLoaderManager().getCacheLoader();
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+
+ loaderTL.set(loader);
}
abstract protected void configureCache() throws Exception;
@@ -68,9 +73,14 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
log.info("**** TEARING DOWN ****");
- loader.remove(Fqn.ROOT);
+ if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
+ cacheTL.set(null);
+ loaderTL.set(null);
}
@@ -87,6 +97,7 @@
*/
protected boolean exists(String fqn, String key)
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
if (key == null) return n != null;
return n != null && n.getKeysDirect().contains(key);
@@ -99,6 +110,9 @@
public void testPutPassivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval;
@@ -118,6 +132,9 @@
public void testPut2Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
final Fqn NODE = Fqn.fromString("/a/b/c");
final String KEY = "key";
Object retval;
@@ -141,6 +158,9 @@
public void testSerializationPassivation() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
Fqn fqn = Fqn.fromString("/mypojo");
SamplePojo pojo = new SamplePojo(39, "Hany");
pojo.getHobbies().add("Running");
@@ -178,6 +198,8 @@
*/
public void testPopulate()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -215,6 +237,9 @@
public void testPreloadingPassivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.removeNode(Fqn.ROOT);// remove nothing
cache.put("1/2/3/4/5/d", "key", "val");// put in memory
cache.evict(Fqn.fromString("1/2/3/4/5/d"));// passivate node
@@ -239,6 +264,8 @@
public void testCacheLoading2() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
Set<Object> keys = null;
cache.put("/a/b/c", "key", "val");
keys = cache.getNode(Fqn.fromString("/a/b/c")).getKeys();
@@ -249,6 +276,8 @@
public void testExists() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/eins/zwei/drei", "key1", "val1");
assert (exists("/eins/zwei/drei"));
assert (exists("/eins/zwei/drei", "key1"));
@@ -259,6 +288,8 @@
public void testGetChildren() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/d/one", null);
cache.put("/d/two", null);
cache.put("/d/three", null);
@@ -274,6 +305,9 @@
public void testGetChildrenWithEvictionPassivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
cache.put("/a/b/c/3", null);
@@ -307,6 +341,7 @@
public void testGetChildren2()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -325,6 +360,7 @@
public void testGetChildren3()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -343,6 +379,8 @@
public void testGetChildren4()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
if (!cache.exists("/a/b/c"))
{
cache.put("/a/b/c", null);
@@ -354,6 +392,7 @@
public void testGetChildren5()
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/a/1", null);
@@ -376,6 +415,9 @@
public void testGetChildren6Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/1", null);// put node in memory
cache.put("/a/2", null);// put node in memory
cache.put("/a/3", null);// put node in memory
@@ -403,6 +445,9 @@
public void testGetChildren7Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -432,6 +477,9 @@
public void testGetChildren8Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -455,6 +503,9 @@
public void testGetChildren9Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -501,6 +552,9 @@
public void testGetChildren10Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -531,6 +585,8 @@
public void testRemoveData() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -547,6 +603,9 @@
public void testRemoveData2Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
Set<Object> keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -566,6 +625,9 @@
public void testRemoveData3Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
Set<Object> keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -583,6 +645,8 @@
public void testRemoveKey() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -595,6 +659,8 @@
public void testRemoveKey2() throws CacheException
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval = null;
@@ -611,6 +677,9 @@
public void testRemoveKey3Passivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval = null;
@@ -636,6 +705,8 @@
public void testRemove() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -651,6 +722,8 @@
public void testRemoveRoot() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+
assertEquals(0, cache.getRoot().getKeys().size());
cache.put("/1/2/3/4/5", null);
cache.put("uno/due/tre", null);
@@ -664,6 +737,9 @@
public void testEvictionWithCacheLoaderPassivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/first/second", "key1", "val1");
cache.put("/first/second/third", "key2", "val2");
cache.evict(Fqn.fromString("/first/second"));// pasivate node to cache loader
@@ -684,6 +760,9 @@
public void testEvictionWithCacheLoaderPassivation2() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/first/second/third", "key1", "val1");// stored in cache loader
cache.evict(Fqn.fromString("/first/second/third"));// passivate node, note: it has no children
addDelay();
@@ -701,6 +780,9 @@
public void testEvictionWithGetChildrenNamesPassivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -727,6 +809,8 @@
public void testTxPutCommit() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
@@ -755,6 +839,9 @@
public void testTxPutRollback() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
cache.removeNode("/one");
@@ -775,6 +862,9 @@
public void testPassivationAndActivation() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+
Object val, val2;
Fqn NODE = Fqn.fromString("/test");
loader.remove(Fqn.fromString("/"));
@@ -823,6 +913,7 @@
*/
private void doTestBasicOperations() throws Exception
{
+ CacheLoader loader = loaderTL.get();
/* One FQN only. */
doPutTests(Fqn.fromString("/key"));
@@ -853,6 +944,7 @@
private void doPutTests(Fqn fqn)
throws Exception
{
+ CacheLoader loader = loaderTL.get();
assertTrue(!loader.exists(fqn));
@@ -900,6 +992,7 @@
private void doRemoveTests(Fqn fqn)
throws Exception
{
+ CacheLoader loader = loaderTL.get();
/* remove(Fqn,Object) */
Object oldVal;
@@ -933,6 +1026,7 @@
public void testMultiLevelTree()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
/* Create top level node implicitly. */
Fqn k0 = Fqn.fromString("/key0");
@@ -1099,6 +1193,7 @@
public void testGetChildrenNames()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
@@ -1168,6 +1263,7 @@
private void checkChildren(Fqn fqn, String[] names)
throws Exception
{
+ CacheLoader loader = loaderTL.get();
Set set = loader.getChildrenNames(fqn);
if (names != null)
@@ -1212,6 +1308,7 @@
private void doTestModifications()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
/* PUT_KEY_VALUE, PUT_DATA */
List<Modification> list = createUpdates();
@@ -1259,6 +1356,8 @@
public void testOnePhaseTransaction()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
checkModifications(mods);
@@ -1270,6 +1369,7 @@
public void testTwoPhaseTransactionPassivation()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
Object txnKey = new Object();
List<Modification> mods = createUpdates();
@@ -1289,6 +1389,7 @@
public void testTransactionRollbackPassivation()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.remove(Fqn.fromString("/"));
@@ -1351,6 +1452,8 @@
private void checkModifications(List<Modification> list)
throws Exception
{
+ CacheLoader loader = loaderTL.get();
+
for (Modification mod : list)
{
Fqn fqn = mod.getFqn();
@@ -1390,6 +1493,7 @@
public void testNullKeysAndValues()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.put(FQN, null, "x");
addDelay();
@@ -1445,6 +1549,7 @@
public void testDatabaseNamePassivation()
throws Exception
{
+ CacheLoader loader = loaderTL.get();
loader.put(FQN, "one", "two");
addDelay();
@@ -1457,6 +1562,8 @@
public void testLoadAndStore()
throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
/* Empty state. */
loader.remove(Fqn.fromString("/"));
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -5,6 +5,7 @@
import java.io.File;
import java.io.FileFilter;
+import org.jboss.cache.CacheSPI;
/**
* Runs the same tests as {@link PassivationToFileCacheLoaderTest}, but with
@@ -50,7 +51,12 @@
}
}
}
-
- cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "", false, false, false, false, false));
+
+ String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
+ String threadId = Thread.currentThread().getName();
+ String tmpCLLoc = tmpDir + "/JBossCache-PassivationToBdbjeCacheLoaderTest-" + threadId;
+
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpCLLoc, false, false, false, false, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.passivation;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.testng.annotations.Test;
@@ -9,6 +10,7 @@
{
protected void configureCache() throws Exception
{
+ CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig clc = new CacheLoaderConfig();
cache.getConfiguration().setCacheLoaderConfig(clc);
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,5 +1,6 @@
package org.jboss.cache.passivation;
+import org.jboss.cache.CacheSPI;
import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig;
import org.testng.annotations.Test;
@@ -26,6 +27,10 @@
tmpLocation = System.getProperty("jva.io.tmpdir", "/tmp");
}
- cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.FileCacheLoader", "", false, false, false, false, false));
+ String threadId = Thread.currentThread().getName();
+ String tmpCLLoc = tmpLocation + "/JBossCache-PassivationToFileCacheLoaderTest-" + threadId;
+
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.FileCacheLoader", "location=" + tmpCLLoc, false, false, false, false, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,8 +7,10 @@
package org.jboss.cache.passivation;
import java.util.Properties;
+import org.jboss.cache.CacheSPI;
import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;
/**
@@ -37,13 +39,17 @@
"cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
"cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat");
+ "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
+ "cache.jdbc.table.name=passivationtojdbc" + TestingUtil.getThreadId() + "\n" +
+ "cache.jdbc.table.primarykey=passivationtojdbc_pk" + TestingUtil.getThreadId();
+
}
protected void configureCache() throws Exception
{
CacheLoaderConfig loaderConfig = buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.JDBCCacheLoader",
getJDBCProps(), false, false, false, false, false);
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(loaderConfig);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,11 +1,12 @@
package org.jboss.cache.passivation;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.LocalDelegatingCacheLoaderConfig;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -18,15 +19,16 @@
@Test(groups = "functional")
public class PassivationToLocalDelegatingCacheLoaderTest extends PassivationTestsBase
{
- CacheSPI delegating_cache;
- CacheLoader cache_loader;
+ ThreadLocal<CacheSPI> delegating_cacheTL = new ThreadLocal<CacheSPI>();
+ //ThreadLocal<CacheLoader> cache_loaderTL = new ThreadLocal<CacheLoader>();
protected void configureCache() throws Exception
{
- delegating_cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ CacheSPI delegating_cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
delegating_cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
delegating_cache.create();
delegating_cache.start();
+ delegating_cacheTL.set(delegating_cache);
LocalDelegatingCacheLoaderConfig cfg = new LocalDelegatingCacheLoaderConfig();
cfg.setDelegate(delegating_cache);
@@ -35,6 +37,7 @@
CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
cacheLoaderConfig.addIndividualCacheLoaderConfig(cfg);
cacheLoaderConfig.setPassivation(true);
+ CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(cacheLoaderConfig);
}
@@ -42,8 +45,11 @@
public void tearDown() throws Exception
{
super.tearDown();
- delegating_cache.stop();
- delegating_cache.destroy();
+ CacheSPI delegating_cache = delegating_cacheTL.get();
+ delegating_cacheTL.set(null);
+ TestingUtil.killCaches(delegating_cache);
+ delegating_cache = null;
+
}
public void testLoadAndStore() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -26,7 +26,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -68,7 +68,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache1 = (CacheSPI<String, String>) instance.createCache(getCfg(), false);
cache1.getConfiguration().setUseRegionBasedMarshalling(true);
cache1.start();
@@ -136,8 +136,9 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache1.stop();
- cache2.stop();
+ TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
public void testActivationEvent() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,11 +1,12 @@
package org.jboss.cache.profiling;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.parsing.JGroupsStackParser;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@@ -19,13 +20,14 @@
public void setUp()
{
Configuration cfg = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
- cache = new DefaultCacheFactory<Object, Object>().createCache(cfg, false);
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(cfg, false);
}
@AfterTest
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
public abstract void testReplSync() throws Exception;
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.profiling;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.testng.annotations.Test;
/**
@@ -19,7 +19,7 @@
public void testConstruction() throws InterruptedException
{
- for (int i = 0; i < WARMUP; i++) new DefaultCacheFactory<Object, Object>().createCache();
+ for (int i = 0; i < WARMUP; i++) new UnitTestCacheFactory<Object, Object>().createCache();
System.out.println("Finished warmup.");
System.gc();
Thread.sleep(1000);
@@ -31,7 +31,7 @@
{
for (int i = 0; i < LOOPS; i++)
{
- new DefaultCacheFactory<Object, Object>().createCache();
+ new UnitTestCacheFactory<Object, Object>().createCache();
if (i % 100 == 0) System.out.println("In loop num " + i);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/MemoryFootprintTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/MemoryFootprintTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/MemoryFootprintTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,7 @@
package org.jboss.cache.profiling;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.lock.IsolationLevel;
@@ -16,7 +16,7 @@
public void testLocal() throws IOException
{
- Cache<String, String> c = new DefaultCacheFactory<String, String>().createCache(false);
+ Cache<String, String> c = new UnitTestCacheFactory<String, String>().createCache(false);
c.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
c.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
// c.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -50,7 +50,7 @@
Configuration cfg = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL);
cfg.setNodeLockingScheme(NodeLockingScheme.MVCC);
cfg.setConcurrencyLevel(500);
- cache = new DefaultCacheFactory<String, String>().createCache(cfg, false);
+ cache = new UnitTestCacheFactory<String, String>().createCache(cfg, false);
}
@AfterTest
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,7 +10,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -22,6 +21,8 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
/**
* Unit test for replicated async CacheSPI. Use locking and multiple threads to test
@@ -32,26 +33,33 @@
@Test(groups = {"functional", "jgroups"})
public class AsyncReplTest
{
- private CacheSPI<Object, Object> cache1, cache2;
- private ReplicationListener replListener1, replListener2;
+ private class AsyncReplTestTL {
+ private CacheSPI<Object, Object> cache1, cache2;
+ private ReplicationListener replListener1, replListener2;
+ }
+
+ private ThreadLocal<AsyncReplTestTL> threadLocal = new ThreadLocal<AsyncReplTestTL>();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+ AsyncReplTestTL tl = new AsyncReplTestTL();
+ threadLocal.set(tl);
log("creating cache1");
- cache1 = createCache("CacheGroup");
- replListener1 = new ReplicationListener(cache1);
+ tl.cache1 = createCache("CacheGroup");
+ tl.replListener1 = new ReplicationListener(tl.cache1);
log("creating cache2");
- cache2 = createCache("CacheGroup");
- replListener2 = new ReplicationListener(cache2);
+ tl.cache2 = createCache("CacheGroup");
+ tl.replListener2 = new ReplicationListener(tl.cache2);
}
private CacheSPI<Object, Object> createCache(String name) throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC), false);
- cache.getConfiguration().setClusterName(name);
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
+ c.setClusterName(name);
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
// Call the hook that allows mux integration
configureMultiplexer(cache);
@@ -91,11 +99,19 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- TestingUtil.killCaches(cache1, cache2);
+ AsyncReplTestTL tl = threadLocal.get();
+ TestingUtil.killCaches(tl.cache1, tl.cache2);
+ threadLocal.set(null);
}
public void testTxCompletion() throws Exception
{
+ AsyncReplTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ ReplicationListener replListener1 = tl.replListener1;
+ ReplicationListener replListener2 = tl.replListener2;
+
// test a very simple replication.
Fqn fqn = Fqn.fromString("/a");
String key = "key";
@@ -135,6 +151,12 @@
public void testPutShouldNotReplicateToDifferentCluster()
{
+ AsyncReplTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ ReplicationListener replListener1 = tl.replListener1;
+ ReplicationListener replListener2 = tl.replListener2;
+
CacheSPI<Object, Object> cache3 = null, cache4 = null;
try
{
@@ -166,6 +188,12 @@
public void testStateTransfer()
{
+ AsyncReplTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ ReplicationListener replListener1 = tl.replListener1;
+ ReplicationListener replListener2 = tl.replListener2;
+
CacheSPI<Object, Object> cache4 = null;
try
{
@@ -192,6 +220,11 @@
public void testAsyncReplDelay()
{
Integer age;
+ AsyncReplTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ ReplicationListener replListener1 = tl.replListener1;
+ ReplicationListener replListener2 = tl.replListener2;
try
{
@@ -211,6 +244,11 @@
public void testAsyncReplTxDelay()
{
Integer age;
+ AsyncReplTestTL tl = threadLocal.get();
+ CacheSPI<Object, Object> cache1 = tl.cache1;
+ CacheSPI<Object, Object> cache2 = tl.cache2;
+ ReplicationListener replListener1 = tl.replListener1;
+ ReplicationListener replListener2 = tl.replListener2;
try
{
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.replicated;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -14,6 +13,7 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests the type of exceptions thrown for Lock Acquisition Timeouts versus Sync Repl Timeouts
@@ -21,7 +21,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ExceptionTest
{
private Cache cache1;
@@ -31,25 +31,27 @@
@BeforeMethod
public void setUp()
{
- cache1 = new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = new DefaultCacheFactory<Object, Object>().createCache(false);
+ Configuration c = new Configuration();
+ c.setSyncCommitPhase(true);
+ c.setSyncRollbackPhase(true);
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, false);
- cache1.getConfiguration().setSyncCommitPhase(true);
- cache1.getConfiguration().setSyncRollbackPhase(true);
- cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-
- cache2.getConfiguration().setSyncCommitPhase(true);
- cache2.getConfiguration().setSyncRollbackPhase(true);
- cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c = new Configuration();
+ c.setSyncCommitPhase(true);
+ c.setSyncRollbackPhase(true);
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache2 = new UnitTestCacheFactory<Object, Object>().createCache(c, false);
}
@AfterMethod
public void tearDown()
{
- if (cache1 != null) cache1.stop();
- if (cache2 != null) cache2.stop();
+ TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
@Test(groups = {"functional"}, expectedExceptions = {TimeoutException.class})
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -12,7 +12,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
@@ -46,7 +46,7 @@
*
* @version $Revision$
*/
-@Test(groups = {"functional", "jgroups", "transaction"})
+@Test(groups = {"functional", "jgroups", "transaction"}, sequential = true)
public class PessimisticSyncReplTxTest
{
private static Log log = LogFactory.getLog(PessimisticSyncReplTxTest.class);
@@ -67,7 +67,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- TransactionSetup.cleanup();
+ TestingUtil.killTransaction(TransactionSetup.getManager());
destroyCaches();
}
@@ -85,20 +85,24 @@
private void initCaches(Configuration.CacheMode caching_mode) throws Exception
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setCacheMode(caching_mode);
- cache2.getConfiguration().setCacheMode(caching_mode);
- cache1.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
- cache2.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
- cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ Configuration c1 = new Configuration();
+ Configuration c2 = new Configuration();
- cache1.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache2.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache1.getConfiguration().setLockAcquisitionTimeout(5000);
- cache2.getConfiguration().setLockAcquisitionTimeout(5000);
+ c1.setCacheMode(caching_mode);
+ c2.setCacheMode(caching_mode);
+ c1.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ c2.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ c1.setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ c2.setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ c1.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c2.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c1.setLockAcquisitionTimeout(5000);
+ c2.setLockAcquisitionTimeout(5000);
+
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c1, false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c2, false);
+
configureMultiplexer(cache1);
configureMultiplexer(cache2);
@@ -138,14 +142,7 @@
private void destroyCaches()
{
- if (cache1 != null)
- {
- cache1.stop();
- }
- if (cache2 != null)
- {
- cache2.stop();
- }
+ TestingUtil.killCaches(cache1, cache2);
cache1 = null;
cache2 = null;
}
@@ -596,22 +593,26 @@
{
Object myMutex = new Object();
- final CacheSPI<Object, Object> c1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- final CacheSPI<Object, Object> c2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- c1.getConfiguration().setClusterName("TempCluster");
- c2.getConfiguration().setClusterName("TempCluster");
- c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- c2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- c1.getConfiguration().setSyncCommitPhase(true);
- c2.getConfiguration().setSyncCommitPhase(true);
- c1.getConfiguration().setSyncRollbackPhase(true);
- c2.getConfiguration().setSyncRollbackPhase(true);
- c1.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- c2.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- c1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- c2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- c1.getConfiguration().setLockAcquisitionTimeout(5000);
- c2.getConfiguration().setLockAcquisitionTimeout(5000);
+ Configuration conf1 = new Configuration();
+ Configuration conf2 = new Configuration();
+ conf1.setClusterName("TempCluster");
+ conf2.setClusterName("TempCluster");
+ conf1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ conf2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ conf1.setSyncCommitPhase(true);
+ conf2.setSyncCommitPhase(true);
+ conf1.setSyncRollbackPhase(true);
+ conf2.setSyncRollbackPhase(true);
+ conf1.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ conf2.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ conf1.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ conf2.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ conf1.setLockAcquisitionTimeout(5000);
+ conf2.setLockAcquisitionTimeout(5000);
+
+ final CacheSPI<Object, Object> c1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf1, false);
+ final CacheSPI<Object, Object> c2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf2, false);
+
c1.start();
c2.start();
final List<Exception> exceptions = new ArrayList<Exception>();
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,7 +9,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.transaction.DummyTransactionManager;
@@ -26,6 +25,8 @@
import javax.transaction.TransactionManager;
import java.io.NotSerializableException;
import java.io.Serializable;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Teting of replication exception for a Nonerislizable object
@@ -33,31 +34,34 @@
* @author Ben Wang
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class ReplicationExceptionTest
{
private CacheSPI<String, ContainerData> cache1, cache2;
- String old_factory = null;
+ //String old_factory = null;
final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- DummyTransactionManager.destroy();
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(DummyTransactionManager.getInstance());
destroyCaches();
+ /*
if (old_factory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
old_factory = null;
}
+ */
}
private TransactionManager beginTransaction() throws SystemException, NotSupportedException
@@ -69,36 +73,35 @@
private void initCaches(Configuration.CacheMode caching_mode)
{
- CacheFactory<String, ContainerData> instance = new DefaultCacheFactory<String, ContainerData>();
- cache1 = (CacheSPI<String, ContainerData>) instance.createCache(false);
- cache2 = (CacheSPI<String, ContainerData>) instance.createCache(false);
- cache1.getConfiguration().setCacheMode(caching_mode);
- cache2.getConfiguration().setCacheMode(caching_mode);
- cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ CacheFactory<String, ContainerData> instance = new UnitTestCacheFactory<String, ContainerData>();
+ Configuration conf1 = new Configuration();
+ Configuration conf2 = new Configuration();
+
+ conf1.setCacheMode(caching_mode);
+ conf2.setCacheMode(caching_mode);
+ conf1.setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ conf2.setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ conf1.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ conf2.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
/*
cache1.setTransactionManagerLookupClass("org.jboss.cache.transaction.GenericTransactionManagerLookup");
cache2.setTransactionManagerLookupClass("org.jboss.cache.transaction.GenericTransactionManagerLookup");
*/
- cache1.getConfiguration().setLockAcquisitionTimeout(5000);
- cache2.getConfiguration().setLockAcquisitionTimeout(5000);
+ conf1.setLockAcquisitionTimeout(5000);
+ conf2.setLockAcquisitionTimeout(5000);
+
+ cache1 = (CacheSPI<String, ContainerData>) instance.createCache(conf1, false);
+ cache2 = (CacheSPI<String, ContainerData>) instance.createCache(conf2, false);
+
+
cache1.start();
cache2.start();
}
void destroyCaches() throws Exception
{
- if (cache1 != null)
- {
- cache1.stop();
- }
- if (cache2 != null)
- {
- cache2.stop();
- }
+ TestingUtil.killCaches(cache1, cache2);
cache1 = null;
cache2 = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,7 +11,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.lock.IsolationLevel;
@@ -31,25 +30,27 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Test out the TreeCacheListener
*
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class SyncCacheListenerTest
{
private CacheSPI<Object, Object> cache1, cache2;
private final static Log log_ = LogFactory.getLog(SyncCacheListenerTest.class);
- private String old_factory = null;
+ //private String old_factory = null;
private final static String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
System.out.println("*** starting setUp()");
- old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
initCaches();
@@ -60,50 +61,52 @@
public void tearDown() throws Exception
{
System.out.println("*** starting tearDown()");
- DummyTransactionManager.destroy();
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(DummyTransactionManager.getInstance());
destroyCaches();
+ /*
if (old_factory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
old_factory = null;
}
+ */
System.out.println("*** finished tearDown()");
}
private void initCaches()
{
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
- cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ Configuration conf1 = new Configuration();
+ Configuration conf2 = new Configuration();
+
+ conf1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ conf2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ conf1.setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ conf2.setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ conf1.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ conf2.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
-
- cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ conf1.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ conf2.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
/*
cache1.setTransactionManagerLookupClass("org.jboss.cache.transaction.GenericTransactionManagerLookup");
cache2.setTransactionManagerLookupClass("org.jboss.cache.transaction.GenericTransactionManagerLookup");
*/
- cache1.getConfiguration().setLockAcquisitionTimeout(5000);
- cache2.getConfiguration().setLockAcquisitionTimeout(5000);
+ conf1.setLockAcquisitionTimeout(5000);
+ conf2.setLockAcquisitionTimeout(5000);
+
+ cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf1, false);
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(conf2, false);
+
cache1.start();
cache2.start();
}
private void destroyCaches()
{
- if (cache1 != null)
- {
- cache1.stop();
- }
- if (cache2 != null)
- {
- cache2.stop();
- }
+ TestingUtil.killCaches(cache1, cache2);
+ cache1 = null;
+ cache2 = null;
}
public void testSyncTxRepl() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,11 +7,11 @@
package org.jboss.cache.replicated;
import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -27,16 +27,16 @@
@Test(groups = {"functional", "jgroups"})
public class SyncReplTest
{
- private Cache<Object, Object>[] caches;
+ private ThreadLocal<Cache<Object, Object>[]> cachesTL = new ThreadLocal<Cache<Object, Object>[]>();
@BeforeMethod(alwaysRun = true)
public void setUp()
{
System.out.println("*** In setUp()");
- caches = new Cache[2];
- caches[0] = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC));
- caches[1] = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC));
-
+ Cache<Object, Object>[] caches = new Cache[2];
+ caches[0] = new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC));
+ caches[1] = new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC));
+ cachesTL.set(caches);
TestingUtil.blockUntilViewsReceived(caches, 5000);
System.out.println("*** Finished setUp()");
}
@@ -44,11 +44,14 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
+ Cache<Object, Object>[] caches = cachesTL.get();
if (caches != null) TestingUtil.killCaches(caches);
+ cachesTL.set(null);
}
public void testBasicOperation()
{
+ Cache<Object, Object>[] caches = cachesTL.get();
assertClusterSize("Should only be 2 caches in the cluster!!!", 2);
assertInvocationContextInitState();
@@ -74,6 +77,7 @@
@SuppressWarnings("unchecked")
public void testSyncRepl()
{
+ Cache<Object, Object>[] caches = cachesTL.get();
assertClusterSize("Should only be 2 caches in the cluster!!!", 2);
assertInvocationContextInitState();
@@ -92,6 +96,7 @@
@SuppressWarnings("unchecked")
public void testNodeConvenienceNodeRemoval()
{
+ Cache<Object, Object>[] caches = cachesTL.get();
// this fqn is relative, but since it is from the root it may as well be absolute
Fqn fqn = Fqn.fromString("/test/fqn");
caches[0].getRoot().addChild(fqn);
@@ -117,6 +122,7 @@
private void assertClusterSize(String message, int size)
{
+ Cache<Object, Object>[] caches = cachesTL.get();
for (Cache c : caches)
{
assertClusterSize(message, size, c);
@@ -130,6 +136,7 @@
private void assertInvocationContextInitState()
{
+ Cache<Object, Object>[] caches = cachesTL.get();
for (Cache c : caches)
{
assertInvocationContextInitState(c);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Version;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.ComponentRegistry;
@@ -37,6 +36,10 @@
import org.testng.annotations.Test;
import java.io.InputStream;
+import java.util.Map;
+import org.jboss.cache.Cache;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
/**
* A FailedStateTransferTest.
@@ -44,17 +47,19 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, enabled=false)
public class FailedStateTransferTest extends StateTransferTestBase
{
public void testFailedStateTransfer() throws Exception
{
- CacheSPI cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC), false);
- cache.getConfiguration().setClusterName("VersionedTestBase");
- cache.getConfiguration().setReplVersionString(getReplicationVersion());
+ Map<String, Cache> caches = cachesTL.get();
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
+ //c.setClusterName("VersionedTestBase");
+ c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
- cache.getConfiguration().setStateRetrievalTimeout(60000);
+ c.setStateRetrievalTimeout(60000);
+ CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
// Put the cache in the map before starting, so if it fails in
// start it can still be destroyed later
@@ -69,11 +74,12 @@
cache.start();
- CacheSPI recipient = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC), false);
- recipient.getConfiguration().setClusterName("VersionedTestBase");
- recipient.getConfiguration().setReplVersionString(getReplicationVersion());
+ c= UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
+ //c.setClusterName("VersionedTestBase");
+ c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
- recipient.getConfiguration().setStateRetrievalTimeout(60000);
+ c.setStateRetrievalTimeout(60000);
+ CacheSPI recipient = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
//Put the cache in the map before starting, so if it fails in
// start it can still be destroyed later
@@ -91,7 +97,7 @@
catch (CacheException good)
{
// this is what we want
- }
+ }
}
protected String getReplicationVersion()
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,8 +3,8 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -25,7 +25,7 @@
* Pertains to JBCACHE-131
* <p/>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", enabled=false)
public class PersistingTransientStateTest
{
protected NodeLockingScheme nls = NodeLockingScheme.PESSIMISTIC;
@@ -37,7 +37,7 @@
Cache<String, String> c1 = null, c2 = null;
try
{
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
Configuration cfg = new Configuration();
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cfg.setCacheMode(CacheMode.REPL_SYNC);
@@ -73,7 +73,7 @@
Cache<String, String> c1 = null, c2 = null;
try
{
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
Configuration cfg = new Configuration();
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cfg.setCacheMode(CacheMode.REPL_SYNC);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -29,7 +29,7 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, enabled = false)
public class StateTransfer200Test extends StateTransferTestBase
{
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,7 @@
import org.testng.annotations.Test;
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, enabled = false)
public class StateTransferCompatibilityTest extends StateTransferTestBase
{
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,10 +7,11 @@
package org.jboss.cache.statetransfer;
+import java.util.Map;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
@@ -38,7 +39,7 @@
*
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", enabled = false)
public class StateTransferConcurrencyTest extends StateTransferTestBase
{
protected String getReplicationVersion()
@@ -169,7 +170,7 @@
{
for (int i = 0; i < count; i++)
{
- new ReplicationQueueNotifier(caches[i]).waitUntillAllReplicated(2000);
+ new ReplicationQueueNotifier(caches[i]).waitUntillAllReplicated(5000);
}
}
@@ -471,17 +472,18 @@
*/
public void testEvictionSeesStateTransfer() throws Exception
{
+ Map<String, Cache> caches = cachesTL.get();
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
- Cache<Object, Object> cache1 = new DefaultCacheFactory<Object, Object>().createCache(c);
+ Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c);
caches.put("evict1", cache1);
cache1.put(Fqn.fromString("/a/b/c"), "key", "value");
c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
- Cache<Object, Object> cache2 = new DefaultCacheFactory<Object, Object>().createCache(c);
+ Cache<Object, Object> cache2 = new UnitTestCacheFactory<Object, Object>().createCache(c);
caches.put("evict2", cache2);
RegionImpl region = (RegionImpl) cache2.getRegion(Fqn.ROOT, false);
@@ -505,7 +507,8 @@
{
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
- Cache<Object, Object> cache1 = new DefaultCacheFactory<Object, Object>().createCache(c);
+ Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c);
+ Map<String, Cache> caches = cachesTL.get();
caches.put("evict1", cache1);
for (int i = 0; i < 25000; i++)
@@ -528,7 +531,7 @@
c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
- final Cache<Object, Object> cache2 = new DefaultCacheFactory<Object, Object>().createCache(c);
+ final Cache<Object, Object> cache2 = new UnitTestCacheFactory<Object, Object>().createCache(c);
caches.put("evict2", cache2);
Node<Object, Object> parent;// = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -24,7 +24,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -48,6 +47,7 @@
import java.util.Properties;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Abstract superclass of the StateTransfer tests.
@@ -77,8 +77,8 @@
public static final Integer TWENTY = 20;
public static final Integer FORTY = 40;
- protected Map<String, Cache> caches;
- private ClassLoader orig_TCL;
+ protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
+ private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();
protected abstract String getReplicationVersion();
@@ -122,6 +122,7 @@
protected CacheSPI<Object, Object> createCache(String cacheID, boolean sync, boolean useMarshalling, String cacheLoaderClass,
boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState) throws Exception
{
+ Map<String, Cache> caches = cachesTL.get();
if (caches.get(cacheID) != null)
{
throw new IllegalStateException(cacheID + " already created");
@@ -135,7 +136,7 @@
c.setSyncRollbackPhase(true);
c.setSyncCommitPhase(true);
}
- c.setClusterName("VersionedTestBase");
+ //c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
c.setStateRetrievalTimeout(60000);
@@ -150,7 +151,7 @@
}
additionalConfiguration(c);
- CacheSPI<Object, Object> tree = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c, false);
+ CacheSPI<Object, Object> tree = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
configureMultiplexer(tree);
// Put the cache in the map before starting, so if it fails in
@@ -235,13 +236,18 @@
{
System.out.println("Error loading jdbc properties ");
}
+
+ String tablePrefix = prop.getProperty("cache.jdbc.table.name", "jbosscache");
+ prop.setProperty("cache.jdbc.table.name", tablePrefix + Thread.currentThread().getName());
+
String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + "cache.jdbc.url="
+ prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
+ prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
+ prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
- + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.sql-concat="
- + prop.getProperty("cache.jdbc.sql-concat");
-
+ + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.sql-concat="
+ + prop.getProperty("cache.jdbc.sql-concat") + "\n" + "cache.jdbc.table.name="
+ + prop.getProperty("cache.jdbc.table.name");
+
CacheLoaderConfig clc = getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
@@ -324,20 +330,23 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- caches = new HashMap<String, Cache>();
+ Map<String, Cache> caches = new HashMap<String, Cache>();
+ cachesTL.set(caches);
// Save the TCL in case a test changes it
- orig_TCL = Thread.currentThread().getContextClassLoader();
+ ClassLoader orig_TCL = Thread.currentThread().getContextClassLoader();
+ orig_TCL_TL.set(orig_TCL);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
+ Map<String, Cache> caches = cachesTL.get();
System.out.println("*** in tearDown()");
// Restore the TCL in case a test changed it
- Thread.currentThread().setContextClassLoader(orig_TCL);
+ Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
for (String cacheID : caches.keySet())
{
@@ -360,6 +369,7 @@
{
TestingUtil.killCaches(c);
}
+ cachesTL.set(null);
}
protected void stopCache(Cache cache)
@@ -368,8 +378,7 @@
{
try
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
}
catch (Exception e)
{
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManager;
@@ -29,13 +29,13 @@
{
Cache<Object, Object> cache1, cache2;
Properties p = null;
- String old_factory = null;
+ //String old_factory = null;
static final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
DummyTransactionManager.getInstance();
if (p == null)
@@ -50,22 +50,24 @@
{
if (cache2 != null)
{
- cache2.stop();
+ TestingUtil.killCaches(cache2);
cache2 = null;
}
if (cache1 != null)
{
- cache1.stop();
+ TestingUtil.killCaches(cache1);
cache1 = null;
}
- // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
- DummyTransactionManager.destroy();
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(DummyTransactionManager.getInstance());
+ /*
if (old_factory != null)
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
old_factory = null;
}
+ */
}
public void testStateTransferDeadlocksPessimistic() throws Exception
@@ -97,8 +99,8 @@
cfg1.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cfg2.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache1 = new DefaultCacheFactory<Object, Object>().createCache(cfg1, true);
- cache2 = new DefaultCacheFactory<Object, Object>().createCache(cfg2, false);
+ cache1 = new UnitTestCacheFactory<Object, Object>().createCache(cfg1, true);
+ cache2 = new UnitTestCacheFactory<Object, Object>().createCache(cfg2, false);
UserTransaction tx1 = (UserTransaction) new InitialContext(p).lookup("UserTransaction");
writer = new Writer(cache1, tx1);
try
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -5,7 +5,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -23,6 +22,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Unit test for local CacheImpl with concurrent transactions.
@@ -32,7 +32,7 @@
* @author Ben Wang
* @version $Revision$
*/
-@Test(groups = {"functional", "transaction"}, enabled = true)
+@Test(groups = {"functional", "transaction"}, enabled = true, sequential = true)
public class ConcurrentBankTest
{
private CacheSPI<Object, Integer> cache;
@@ -53,7 +53,7 @@
public void setUp() throws Exception
{
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- CacheFactory<Object, Integer> instance = new DefaultCacheFactory<Object, Integer>();
+ CacheFactory<Object, Integer> instance = new UnitTestCacheFactory<Object, Integer>();
cache = (CacheSPI<Object, Integer>) instance.createCache(conf, false);
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
@@ -64,9 +64,10 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
- // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
- TransactionSetup.cleanup();
+ TestingUtil.killCaches(cache);
+ cache = null;
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(TransactionSetup.getManager());
}
public void testConcurrentBooking() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/DeadlockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/DeadlockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/DeadlockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -13,7 +13,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
@@ -28,13 +27,14 @@
import javax.transaction.NotSupportedException;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests transactional access to a local Cache, with concurrent (deadlock-prone) access.
*
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true, enabled = false)
public class DeadlockTest
{
CacheSPI<String, String> cache = null;
@@ -49,15 +49,17 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setStateRetrievalTimeout(10000);
- cache.getConfiguration().setClusterName("test");
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- cache.getConfiguration().setLockParentForChildInsertRemove(true);
- cache.getConfiguration().setLockAcquisitionTimeout(3000);
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
+ Configuration c = new Configuration();
+ c.setStateRetrievalTimeout(10000);
+ c.setClusterName("test");
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c.setLockParentForChildInsertRemove(true);
+ c.setLockAcquisitionTimeout(3000);
+
+ cache = (CacheSPI<String, String>) instance.createCache(c, false);
cache.create();
cache.start();
thread_ex = null;
@@ -68,7 +70,8 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
if (thread_ex != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,7 +7,6 @@
package org.jboss.cache.transaction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.util.CachePrinter;
@@ -21,26 +20,28 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests cleaning of invocation contexts on completion of txs
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class InvocationContextCleanupTest
{
private CacheSPI[] caches;
private CacheSPI<?, ?> createCache(boolean optimistic)
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- if (optimistic)
- cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
- cache.getConfiguration().setClusterName("InvocationContextCleanupTest");
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.getConfiguration().setLockAcquisitionTimeout(2000);
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ if (optimistic) c.setNodeLockingScheme("OPTIMISTIC");
+ c.setClusterName("InvocationContextCleanupTest");
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setLockAcquisitionTimeout(2000);
+
+ CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
cache.start();
return cache;
}
@@ -54,7 +55,7 @@
{
if (caches[i] != null)
{
- caches[i].stop();
+ TestingUtil.killCaches(caches[i]);
caches[i] = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -8,7 +8,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
@@ -23,6 +22,8 @@
import javax.transaction.TransactionManager;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests READ_COMMITED isolation level.
@@ -30,7 +31,7 @@
* @author <a href="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class IsolationLevelReadCommittedNodeCreationRollbackTest
{
@@ -53,11 +54,12 @@
writerError = null;
readerError = null;
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache = (CacheSPI<String, String>) instance.createCache(c, false);
cache.start();
}
@@ -65,8 +67,7 @@
public void tearDown() throws Exception
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -18,6 +17,8 @@
import javax.transaction.TransactionManager;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests READ_COMMITED isolation level.
@@ -26,7 +27,7 @@
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class IsolationLevelReadCommittedTest
{
private Cache<String, String> cache = null;
@@ -54,7 +55,7 @@
config.setIsolationLevel(IsolationLevel.READ_COMMITTED);
config.setLockAcquisitionTimeout(1000);
config.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = instance.createCache(config);
}
@@ -62,8 +63,7 @@
public void tearDown() throws Exception
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.TimeoutException;
@@ -15,6 +14,9 @@
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests READ_COMMITED isolation level.
@@ -22,7 +24,7 @@
* @author <a href="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class IsolationLevelRepeatableReadTest
{
@@ -40,19 +42,21 @@
writerFailed = false;
writerError = null;
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setCacheMode("LOCAL");
- cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.getConfiguration().setLockAcquisitionTimeout(1000);
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
+ Configuration c = new Configuration();
+ c.setCacheMode("LOCAL");
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setLockAcquisitionTimeout(1000);
+ cache = (CacheSPI<String, String>) instance.createCache(c, false);
cache.start();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -17,6 +16,8 @@
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import java.util.concurrent.CountDownLatch;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests READ_COMMITED isolation level.
@@ -24,7 +25,7 @@
* @author <a href="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class IsolationLevelSerializableTest
{
@@ -48,15 +49,14 @@
config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
config.setLockAcquisitionTimeout(1000);
config.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = instance.createCache(config);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,7 +1,6 @@
package org.jboss.cache.transaction;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.ReplicableCommand;
@@ -23,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.Vector;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* This is to test the scenario described in http://jira.jboss.org/jira/browse/JBCACHE-1270
@@ -38,7 +38,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class PrepareCommitContentionTest
{
CacheSPI<Object, Object> c1;
@@ -46,13 +46,14 @@
@BeforeMethod
public void setUp() throws CloneNotSupportedException
{
- c1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(REPL_SYNC));
+ c1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(REPL_SYNC));
}
@AfterMethod
public void tearDown()
{
TestingUtil.killCaches(c1);
+ c1 = null;
}
public void testOOBFlag() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -14,6 +13,8 @@
import org.testng.annotations.Test;
import javax.transaction.UserTransaction;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* A test created to simulate an unexpected TimeoutException in JBossCache
@@ -59,7 +60,7 @@
* @author $Author$
* @version $Date$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class ReplicatedTransactionDeadlockTest
{
@@ -101,23 +102,24 @@
public void setUp() throws Exception
{
exception = null;
- CacheFactory<Boolean, Boolean> instance = new DefaultCacheFactory<Boolean, Boolean>();
+ CacheFactory<Boolean, Boolean> instance = new UnitTestCacheFactory<Boolean, Boolean>();
// setup and start the source cache
- srcCache = (CacheSPI<Boolean, Boolean>) instance.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- srcCache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- srcCache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
-
- srcCache.getConfiguration().setSyncCommitPhase(true);
- srcCache.getConfiguration().setLockAcquisitionTimeout(LOCK_ACQUISITION_TIMEOUT);
+ Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setSyncCommitPhase(true);
+ c.setLockAcquisitionTimeout(LOCK_ACQUISITION_TIMEOUT);
+ srcCache = (CacheSPI<Boolean, Boolean>) instance.createCache(c, false);
srcCache.create();
srcCache.start();
+
// setup and start the destination cache
- dstCache = (CacheSPI) instance.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- dstCache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- dstCache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
-
- dstCache.getConfiguration().setSyncCommitPhase(true);
- dstCache.getConfiguration().setLockAcquisitionTimeout(LOCK_ACQUISITION_TIMEOUT);
+ c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c.setSyncCommitPhase(true);
+ c.setLockAcquisitionTimeout(LOCK_ACQUISITION_TIMEOUT);
+ dstCache = (CacheSPI) instance.createCache(c, false);
dstCache.create();
dstCache.start();
}
@@ -128,11 +130,11 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- srcCache.stop();
+ TestingUtil.killCaches(srcCache, dstCache);
srcCache = null;
- dstCache.stop();
dstCache = null;
- TransactionSetup.cleanup();
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(TransactionSetup.getManager());
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/SimultaneousRollbackAndPutTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/SimultaneousRollbackAndPutTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/SimultaneousRollbackAndPutTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -4,14 +4,12 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import javax.transaction.RollbackException;
@@ -19,13 +17,15 @@
import javax.transaction.TransactionManager;
import java.util.ArrayList;
import java.util.List;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.BeforeMethod;
/**
* To test JBCACHE-923
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
*/
-@Test(groups = {"functional", "transaction"}, enabled = true)
+@Test(groups = {"functional", "transaction"}, enabled = true, sequential = true)
// Known issue - disabled because of JBCACHE-923
public class SimultaneousRollbackAndPutTest
{
@@ -34,20 +34,23 @@
private Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b");
private Log log = LogFactory.getLog(SimultaneousRollbackAndPutTest.class);
- @BeforeTest(alwaysRun = true)
+ @BeforeMethod(alwaysRun = true)
protected void setUp() throws Exception
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.start();
- tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- cache.put(A, "k", "v");
+ if (cache == null) {
+ cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
+ cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache.start();
+ tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ cache.put(A, "k", "v");
+ }
}
@AfterTest(alwaysRun = true)
protected void tearDown()
{
TestingUtil.killCaches(cache);
+ cache = null;
}
@AfterMethod(alwaysRun = true)
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/SuspendTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/SuspendTxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/SuspendTxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
@@ -11,6 +10,8 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Based on a contribution by Owen Taylor
@@ -18,7 +19,7 @@
* @author otaylor(a)redhat.com
* @author Manik Surtani (manik(a)jboss.org)
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class SuspendTxTest
{
CacheSPI<String, String> cache;
@@ -27,7 +28,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setCacheMode("local");
cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
@@ -38,7 +39,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
if (mgr.getTransaction() != null)
{
mgr.rollback();
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
@@ -17,6 +16,8 @@
import javax.transaction.TransactionManager;
import java.util.Collection;
import java.util.HashSet;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Base class for testing isolation levels.
@@ -24,7 +25,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public abstract class IsolationLevelTestBase
{
protected IsolationLevel isolationLevel;
@@ -39,7 +40,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
cache = cf.createCache(false);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setIsolationLevel(isolationLevel);
@@ -66,8 +67,7 @@
// no-op
}
}
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
allowedLevels = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -6,8 +6,8 @@
*/
package org.jboss.cache.transaction.pessimistic;
+import java.io.File;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.transaction.NotifyingTransactionManager.Notification;
@@ -26,11 +26,15 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jgroups.conf.ConfiguratorFactory;
+import org.jgroups.conf.XmlConfigurator;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class AbortionTest
{
private CacheSPI cache1, cache2, cache3;
@@ -48,15 +52,19 @@
public void tearDown() throws Exception
{
TestingUtil.killCaches(cache3, cache2, cache1);
+ cache1 = null;
+ cache2 = null;
+ cache3 = null;
}
- private CacheSPI initCache(boolean notifying)
- {
- CacheSPI c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
- c.getConfiguration().setCacheMode("REPL_SYNC");
- c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
- c.getConfiguration().setClusterConfig(getJGroupsStack());
- c.getConfiguration().setFetchInMemoryState(false);
+ private CacheSPI initCache(boolean notifying) throws Exception
+ {
+ Configuration conf = new Configuration();
+ conf.setCacheMode("REPL_SYNC");
+ conf.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ conf.setClusterConfig(getJGroupsStack());
+ conf.setFetchInMemoryState(false);
+ CacheSPI c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf, false);
if (!notifying)
{
c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
@@ -70,9 +78,9 @@
}
// we need a 'special' stack that does not attempt redelivery since we kill a channel midway during a tx in this test.
- private String getJGroupsStack()
+ private String getJGroupsStack() throws Exception
{
- return JChannel.DEFAULT_PROTOCOL_STACK;
+ return UnitTestCacheConfigurationFactory.getClusterConfigFromProperties(JChannel.DEFAULT_PROTOCOL_STACK);
}
private void destroyCache(CacheSPI c)
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import static org.testng.AssertJUnit.*;
@@ -12,6 +11,8 @@
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Test behaviour of async rollback timeouted transaction
@@ -19,7 +20,7 @@
* @author <a href="mailto:jhalat@infovide.pl">Jacek Halat</a>
* @since 1.4.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, sequential = true)
public class AsyncRollbackTxTest
{
private CacheSPI<String, String> cache;
@@ -36,7 +37,7 @@
Configuration c = new Configuration();
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.AsyncRollbackTransactionManagerLookup");
c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(c);
tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
tm.setTransactionTimeout(txTimeout);
@@ -63,8 +64,7 @@
{
// do nothing
}
- if (cache != null)
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
tm = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,7 +11,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.config.Configuration;
@@ -28,6 +27,8 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Unit test for local CacheSPI. Use locking and multiple threads to test
@@ -35,7 +36,7 @@
*
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class ConcurrentTransactionalTest
{
private CacheSPI<Integer, String> cache;
@@ -50,22 +51,23 @@
private void createCache(IsolationLevel level)
{
- CacheFactory<Integer, String> factory = new DefaultCacheFactory<Integer, String>();
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
conf.setCacheMode(Configuration.CacheMode.LOCAL);
conf.setIsolationLevel(level);
conf.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
conf.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(conf);
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf);
cache.put("/a/b/c", null);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
thread_ex = null;
- TransactionSetup.cleanup();
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ TestingUtil.killTransaction(TransactionSetup.getManager());
}
public void testConcurrentAccessWithRWLock() throws Throwable
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.transaction.TransactionSetup;
@@ -16,6 +15,8 @@
import javax.transaction.NotSupportedException;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
@@ -23,7 +24,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class IsolationLevelNoneTest
{
CacheSPI<String, String> cache = null;
@@ -37,15 +38,14 @@
{
if (cache != null)
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
cache = null;
}
}
public void testWithoutTransactions() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
@@ -61,7 +61,7 @@
public void testWithTransactions() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
@@ -80,7 +80,7 @@
public void testWithTransactionsRepeatableRead() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -11,7 +11,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -40,6 +39,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests transactional access to a local CacheImpl.
@@ -47,7 +47,7 @@
*
* @version $Id$
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class PessimisticTransactionTest
{
CacheSPI<String, Comparable> cache = null;
@@ -59,7 +59,7 @@
public void setUp() throws Exception
{
- CacheFactory<String, Comparable> instance = new DefaultCacheFactory<String, Comparable>();
+ CacheFactory<String, Comparable> instance = new UnitTestCacheFactory<String, Comparable>();
cache = (CacheSPI<String, Comparable>) instance.createCache(false);
cache.getConfiguration().setClusterName("test");
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
@@ -80,12 +80,13 @@
{
if (cache != null)
{
- cache.stop();
+ TestingUtil.killCaches(cache);
cache = null;
}
// BW. kind of a hack to destroy jndi binding and thread local tx before next run.
- TransactionSetup.cleanup();
+ Transaction c = TransactionSetup.getManager().getTransaction();
+ if (c != null) c.rollback();
if (tx != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -3,7 +3,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.config.Configuration;
@@ -12,10 +11,11 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import javax.transaction.NotSupportedException;
import javax.transaction.Synchronization;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* Created by IntelliJ IDEA.
@@ -23,7 +23,7 @@
* Date: Jun 9, 2004
* Time: 9:05:19 AM
*/
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class PrepareTxTest
{
CacheSPI<String, String> cache;
@@ -31,7 +31,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ CacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(false);
cache.getConfiguration().setCacheMode("local");
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
@@ -43,8 +43,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
+ cache = null;
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -2,7 +2,6 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.transaction.*;
import org.jboss.cache.config.Configuration;
@@ -11,9 +10,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
@@ -23,14 +19,15 @@
import javax.transaction.TransactionManager;
import java.util.LinkedList;
import java.util.List;
-import java.util.Properties;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.util.TestingUtil;
/**
* This test checks how the cache behaves when a JTA STATUS_UNKNOWN is passed in to the cache during afterCompletion().
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
*/
-@Test(groups = "functional")
+@Test(groups = "functional", sequential = true)
public class StatusUnknownTest
{
private Cache<String, String> cache;
@@ -39,7 +36,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = new DefaultCacheFactory<String, String>().createCache(false);
+ cache = new UnitTestCacheFactory<String, String>().createCache(false);
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
cache.getConfiguration().setTransactionManagerLookupClass(HeuristicFailingDummyTransactionManagerLookup.class.getName());
cache.start();
@@ -49,7 +46,9 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
+ cache = null;
+ tm = null;
}
public void testStatusUnknown() throws Exception
@@ -69,7 +68,10 @@
public static class HeuristicFailingDummyTransactionManager extends DummyTransactionManager
{
private static final long serialVersionUID = 6325631394461739211L;
-
+
+ // we can not share an instance with DummyTransactionManager
+ private static DummyTransactionManager instance;
+
@Override
public void begin() throws SystemException, NotSupportedException
{
@@ -80,22 +82,26 @@
}
public static DummyTransactionManager getInstance()
- {
+ {
if (instance == null)
{
instance = new HeuristicFailingDummyTransactionManager();
+ /*
try
{
+
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
Context ctx = new InitialContext(p);
ctx.bind("java:/TransactionManager", instance);
ctx.bind("UserTransaction", new DummyUserTransaction(instance));
+
}
catch (NamingException e)
{
log.error("binding of DummyTransactionManager failed", e);
}
+ */
}
return instance;
}
Modified: core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -1,10 +1,8 @@
package org.jboss.cache.util;
-import junit.framework.TestCase;
import org.jboss.cache.Cache;
import org.jboss.cache.DataContainer;
import org.jboss.cache.DataContainerImpl;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -14,11 +12,19 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.*;
+
+
/**
* Tests {@link Caches}.
*/
-public class CachesTest extends TestCase
+@Test(groups = "functional", sequential = true)
+public class CachesTest
{
String a = "a";
@@ -26,8 +32,21 @@
String c = "c";
- Cache cache = new DefaultCacheFactory().createCache();
+ Cache cache;
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ cache = new UnitTestCacheFactory().createCache();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ TestingUtil.killCaches(cache);
+ cache = null;
+ }
+
public void testSegment()
{
Map m = Caches.asPartitionedMap(cache);
Modified: core/trunk/src/test/java/org/jboss/cache/util/DeltaMapTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/DeltaMapTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/util/DeltaMapTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -9,10 +9,11 @@
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-@Test(groups = {"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class DeltaMapTest
{
@@ -40,6 +41,14 @@
assertEquals(false, dm.isModified());
assertEquals(hm, dm);
}
+
+ @AfterMethod
+ public void tearDown()
+ {
+ hm = null;
+ backup = null;
+ dm = null;
+ }
public void testSize()
{
Modified: core/trunk/src/test/java/org/jboss/cache/util/MinMapUtilTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/MinMapUtilTest.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/util/MinMapUtilTest.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -7,11 +7,11 @@
import java.util.Map;
import java.util.HashMap;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-@Test(groups =
-{"functional", "transaction"})
+@Test(groups = {"functional", "transaction"}, sequential = true)
public class MinMapUtilTest
{
@@ -26,6 +26,11 @@
map = empty;
}
+ @AfterMethod
+ public void tearDown() {
+ map = null;
+ }
+
public void testRemove()
{
assertSame(map, MinMapUtil.remove(map, key));
Modified: core/trunk/src/test/java/org/jboss/cache/util/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/TestingUtil.java 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/java/org/jboss/cache/util/TestingUtil.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -27,6 +27,10 @@
import java.util.Arrays;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.transaction.TransactionManager;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jgroups.Channel;
/**
* Utilities for unit testing JBossCache.
@@ -37,7 +41,22 @@
public class TestingUtil
{
private static Random random = new Random();
+
+ /**
+ * Holds unique mcast_port for each thread used for JGroups channel construction.
+ */
+ private static final ThreadLocal<Integer> threadID = new ThreadLocal<Integer>() {
+
+ private final AtomicInteger uniquePort = new AtomicInteger(0);
+
+ @Override protected Integer initialValue() {
+ return uniquePort.getAndIncrement();
+ }
+ };
+
+ private static UnitTestCacheFactory utf = new UnitTestCacheFactory();
+
/**
* Extracts the value of a field in a given target instance using reflection, able to extract private fields as well.
*
@@ -423,16 +442,23 @@
{
try
{
- if (c != null && c.getCacheStatus() == CacheStatus.STARTED)
+ if (c!= null) utf.removeCache(c);
+ if (c != null) // && ( (c.getCacheStatus() == CacheStatus.STARTED) || c.getCacheStatus() == CacheStatus.FAILED) )
{
CacheSPI spi = (CacheSPI) c;
+
+ Channel channel = null;
+ if (spi.getRPCManager() != null)
+ {
+ channel = spi.getRPCManager().getChannel();
+ }
if (spi.getTransactionManager() != null)
{
try
{
spi.getTransactionManager().rollback();
}
- catch (Exception e)
+ catch (Throwable t)
{
// don't care
}
@@ -446,20 +472,49 @@
{
cl.remove(Fqn.ROOT);
}
- catch (Exception e)
+ catch (Throwable t)
{
// don't care
}
}
- spi.stop();
- spi.destroy();
+ try
+ {
+ spi.stop();
+ } catch (Throwable t) {
+ System.out.println(Thread.currentThread().getName() + " !!!!!!!!!!!!!!!!!!!!! WARNING - Cache instance refused to stop.");
+ t.printStackTrace();
+ }
+ try {
+ spi.destroy();
+ } catch (Throwable t) {
+ System.out.println(Thread.currentThread().getName() + " !!!!!!!!!!!!!!!!!!!!! WARNING - Cache instance refused to destroy.");
+ t.printStackTrace();
+ }
+ if (channel != null)
+ {
+ if (channel.isOpen()) {
+ System.out.println(Thread.currentThread().getName() + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Channel still opened.");
+ Thread.dumpStack();
+ channel.close();
+ }
+ if (channel.isOpen()) {
+ System.out.println(Thread.currentThread().getName() + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Channel close failed.");
+ System.exit(-1);
+ }
+ if (channel.isConnected()) {
+ System.out.println(Thread.currentThread().getName() + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Channel still connected.");
+ Thread.dumpStack();
+ System.exit(-1);
+ }
+ }
}
}
catch (Throwable t)
{
-
- }
+ t.printStackTrace();
+ System.exit(-1);
+ }
}
}
@@ -489,6 +544,20 @@
}
/**
+ * Clears transaction with the current thread in the given transaction manager.
+ * @param txManager a TransactionManager to be cleared
+ */
+ public static void killTransaction(TransactionManager txManager) {
+ if (txManager != null) {
+ try {
+ txManager.rollback();
+ } catch (Exception e) {
+ // don't care
+ }
+ }
+ }
+
+ /**
* For testing only - introspects a cache and extracts the ComponentRegistry
*
* @param cache cache to introspect
@@ -639,4 +708,8 @@
{
dumpCacheContents(Arrays.asList(caches));
}
+
+ public static int getThreadId() {
+ return threadID.get();
+ }
}
Added: core/trunk/src/test/java/org/jboss/cache/util/UnitTestTestNGListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/UnitTestTestNGListener.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/util/UnitTestTestNGListener.java 2008-10-13 09:35:27 UTC (rev 6905)
@@ -0,0 +1,96 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jboss.cache.util;
+
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.testng.IClass;
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+/**
+ *
+ * @author dpospisi
+ */
+public class UnitTestTestNGListener implements ITestListener {
+
+ /**
+ * Holds test classes actually running in all threads.
+ */
+ private ThreadLocal<IClass> threadTestClass = new ThreadLocal<IClass>();
+
+ private int failed = 0;
+ private int succeded = 0;
+ private int skipped = 0;
+
+ public void onTestStart(ITestResult res) {
+ System.out.println(getThreadId() + " Starting test " + getTestDesc(res));
+
+ /*
+ IClass testClass = threadTestClass.get();
+ if ((testClass != null) && (! res.getTestClass().equals(testClass))) {
+
+ System.out.println(getThreadId() + " New test class" + res.getTestClass() + ", was " + testClass);
+
+ // the thread has started testing a new test class
+
+ // clean all possibly running caches created in current thread
+ boolean cleaned = new UnitTestCacheFactory().cleanUp();
+ if (cleaned) {
+ // previous test left a cache
+ System.out.println(getThreadId() +" WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ System.out.println(getThreadId() +" A test method in " + testClass.getName() + " did not clean all cache instances properly.");
+ System.out.println(getThreadId() +" Use UnitTestCacheFactory.cleanUp() or TestngUtil.killCaches(...) ");
+ System.out.println(getThreadId() +" WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ }
+ }
+ */
+
+ threadTestClass.set(res.getTestClass());
+ }
+
+ synchronized public void onTestSuccess(ITestResult arg0) {
+ System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " succeded.");
+ succeded++;
+ printStatus();
+ }
+
+ synchronized public void onTestFailure(ITestResult arg0) {
+ System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " failed.");
+ failed++;
+ printStatus();
+ }
+
+ synchronized public void onTestSkipped(ITestResult arg0) {
+ System.out.println(getThreadId() + " Test " + getTestDesc(arg0) + " skipped.");
+ skipped++;
+ printStatus();
+ }
+
+ public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
+ }
+
+ public void onStart(ITestContext arg0) {
+ }
+
+ public void onFinish(ITestContext arg0) {
+ }
+
+ private String getThreadId() {
+ return "["+ Thread.currentThread().getName() + "]";
+ }
+
+ private String getTestDesc(ITestResult res) {
+ return res.getMethod().getMethodName() + "(" + res.getTestClass().getName() + ")";
+ }
+
+ private void printStatus() {
+ System.out.println("Testsuite execution progress: tests succeded " + succeded + ", failed " + failed + ", skipped " + skipped + ".");
+ }
+
+}
Modified: core/trunk/src/test/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/test/resources/cache-jdbc.properties 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/resources/cache-jdbc.properties 2008-10-13 09:35:27 UTC (rev 6905)
@@ -66,4 +66,4 @@
cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
cache.jdbc.url=jdbc:derby:jbossdb;create=true
cache.jdbc.user=user1
-cache.jdbc.password=user1
\ No newline at end of file
+cache.jdbc.password=user1
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2008-10-12 21:29:19 UTC (rev 6904)
+++ core/trunk/src/test/resources/log4j.xml 2008-10-13 09:35:27 UTC (rev 6905)
@@ -10,7 +10,7 @@
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="../jbosscache.log"/>
- <param name="Append" value="true"/>
+ <param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
@@ -18,7 +18,7 @@
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
- <param name="Threshold" value="DEBUG"/>
+ <param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
@@ -46,11 +46,11 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="WARN"/>
+ <priority value="DEBUG"/>
</category>
<category name="org.jboss.cache.factories">
- <priority value="WARN"/>
+ <priority value="DEBUG"/>
</category>
<category name="org.jboss.tm">
16 years, 2 months
JBoss Cache SVN: r6904 - core/branches/2.2.X/src/test/java/org/jboss/cache/passivation.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-12 17:29:19 -0400 (Sun, 12 Oct 2008)
New Revision: 6904
Modified:
core/branches/2.2.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
Log:
[JBCACHE-1423] Add test
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-10-10 15:25:26 UTC (rev 6903)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-10-12 21:29:19 UTC (rev 6904)
@@ -765,6 +765,31 @@
assertEquals(5, cache.getNumberOfLocksHeld());
mgr.commit();
}
+
+ /** Test for JBCACHE-1423 */
+ public void testPutDataMapAfterPassivation() throws Exception
+ {
+ Fqn f = Fqn.fromString("/a");
+ assert !cache.exists(f);
+ assert !loader.exists(f);
+
+ Map<Object, Object> input = new HashMap();
+ input.put("one", "one");
+ input.put("two", "two");
+ cache.put(f, input);
+
+ cache.evict(f);
+
+ input = new HashMap();
+ input.put("one", "oneA");
+ cache.put(f, input);
+
+ Map data = cache.getRoot().getChild(f).getData();
+ assertEquals("incorrect # of entries", 2, data.size());
+ assertEquals("Has key 'one", "oneA", data.get("one"));
+ assertEquals("Has key 'two", "two", data.get("two"));
+
+ }
public void testTxPutCommit() throws Exception
16 years, 2 months
JBoss Cache SVN: r6903 - in core/branches/flat/src: main/java/org/jboss/cache/buddyreplication and 19 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-10 11:25:26 -0400 (Fri, 10 Oct 2008)
New Revision: 6903
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/IncorrectCacheListenerException.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/BuddyGroupChanged.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryActivated.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryCreated.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryEvicted.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryInvalidated.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryLoaded.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryModified.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryPassivated.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryRemoved.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryVisited.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheListener.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStarted.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStopped.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionCompleted.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionRegistered.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/ViewChanged.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/BuddyGroupChangedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryActivatedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryCreatedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvictedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryInvalidatedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryLoadedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryModifiedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryPassivatedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryRemovedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryVisitedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStartedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStoppedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/Event.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionCompletedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionRegisteredEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionalEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/ViewChangedEvent.java
core/branches/flat/src/test/java/org/jboss/starobrno/notifications/
Removed:
core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/
Modified:
core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationBroadcaster.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java
core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AnnounceBuddyPoolNameCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/RemoveFromBuddyGroupCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ReplicateCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/CommitCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/RollbackCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java
Log:
Part complete notifier code + tests
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -28,11 +28,11 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.notifications.Notifier;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -1,252 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.jboss.cache;
-
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.CacheStarted;
-import org.jboss.cache.notifications.annotation.CacheStopped;
-import org.jboss.cache.notifications.annotation.NodeActivated;
-import org.jboss.cache.notifications.annotation.NodeCreated;
-import org.jboss.cache.notifications.annotation.NodeEvicted;
-import org.jboss.cache.notifications.annotation.NodeLoaded;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.annotation.NodeMoved;
-import org.jboss.cache.notifications.annotation.NodePassivated;
-import org.jboss.cache.notifications.annotation.NodeRemoved;
-import org.jboss.cache.notifications.annotation.NodeVisited;
-import org.jboss.cache.notifications.annotation.ViewChanged;
-import org.jboss.cache.notifications.event.Event;
-import org.jboss.cache.notifications.event.NodeEvent;
-import org.jboss.cache.notifications.event.ViewChangedEvent;
-
-/**
- * This class provides a non-graphical view of <em>JBossCache</em> replication
- * events for a replicated cache.
- * <p/>
- * It can be utilized as a standalone application or as a component in other
- * applications.
- * <p/>
- * <strong>WARNING</strong>: take care when using this class in conjunction with
- * transactionally replicated cache's as it can cause deadlock situations due to
- * the reading of values for nodes in the cache.
- *
- * @author Jimmy Wilson 12-2004
- */
-@CacheListener
-public class ConsoleListener
-{
- private CacheSPI_Legacy cache;
- private boolean startCache;
-
- /**
- * Constructor.
- * <p/>
- * When using this constructor, this class with attempt to start and stop
- * the specified cache.
- *
- * @param cache the cache to monitor for replication events.
- */
- public ConsoleListener(CacheSPI_Legacy cache)
- throws Exception
- {
- this(cache, true, true);
- }
-
- /**
- * Constructor.
- *
- * @param cache the cache to monitor for replication events.
- * @param startCache indicates whether or not the cache should be started by
- * this class.
- * @param stopCache indicates whether or not the cache should be stopped by
- * this class.
- */
- public ConsoleListener(CacheSPI_Legacy cache,
- boolean startCache, boolean stopCache)
- throws Exception
- {
- this.cache = cache;
- this.startCache = startCache;
-
- if (stopCache)
- {
- new ListenerShutdownHook().register();
- }
- }
-
- /**
- * Instructs this class to listen for cache replication events.
- * <p/>
- * This method waits indefinately. Use the notify method of this class
- * (using traditional Java thread notification semantics) to cause this
- * method to return.
- */
- public void listen()
- throws Exception
- {
- listen(true);
- }
-
- /**
- * Instructs this class to listen for cache replication events.
- *
- * @param wait whether or not this method should wait indefinately.
- * <p/>
- * If this parameter is set to <code>true</code>, using the
- * notify method of this class (using traditional Java thread
- * notification semantics) will cause this method to return.
- */
- public void listen(boolean wait)
- throws Exception
- {
- cache.getNotifier().addCacheListener(this);
-
- if (startCache)
- {
- cache.start();
- }
-
- synchronized (this)
- {
- while (wait)
- {
- wait();
- }
- }
- }
-
-
- @CacheStarted
- @CacheStopped
- public void printDetails(Event e)
- {
- printEvent("Cache started.");
- }
-
-
- @NodeCreated
- @NodeLoaded
- @NodeModified
- @NodeRemoved
- @NodeVisited
- @NodeMoved
- @NodeEvicted
- @NodeActivated
- @NodePassivated
- public void printDetailsWithFqn(NodeEvent e)
- {
- if (e.isPre())
- {
- printEvent("Event " + e.getType() + " on node [" + e.getFqn() + "] about to be invoked");
- }
- else
- {
- printEvent("Event " + e.getType() + " on node [" + e.getFqn() + "] invoked");
- }
- }
-
- @ViewChanged
- public void printNewView(ViewChangedEvent e)
- {
- printEvent("View change: " + e.getNewView());
- }
-
- /**
- * Prints an event message.
- *
- * @param eventSuffix the suffix of the event message.
- */
- private void printEvent(String eventSuffix)
- {
- System.out.print("EVENT");
- System.out.print(' ');
-
- System.out.println(eventSuffix);
- }
-
- /**
- * This class provides a shutdown hook for shutting down the cache.
- */
- private class ListenerShutdownHook extends Thread
- {
- /**
- * Registers this hook for invocation during shutdown.
- */
- public void register()
- {
- Runtime.getRuntime().addShutdownHook(this);
- }
-
- /*
- * Thread overrides.
- */
-
- @Override
- public void run()
- {
- cache.stop();
- }
- }
-
- /**
- * The main method.
- *
- * @param args command line arguments dictated by convention.
- * <p/>
- * The first command line argument is the name of the
- * <code>JBossCache</code> configuration file to be utilized
- * for configuration of the cache. Only the name of the
- * configuration file is necessary as it is read off of the
- * classpath.
- * <p/>
- * If a configuration file is not specified on the command line,
- * <code>jboss-cache.xml</code> will be the assumed file name.
- * <p/>
- * All command line arguments after the first are ignored.
- */
- public static void main(String[] args)
- {
- final String DEFAULT_CONFIG_FILE_NAME = "jboss-cache.xml";
-
- try
- {
- String configFileName = DEFAULT_CONFIG_FILE_NAME;
-
- if (args.length >= 1)
- {
- configFileName = args[0];
- }
- else
- {
- System.out.print("No xml config file argument is supplied. Will use jboss-cache.xml from classpath");
- }
-
- CacheSPI_Legacy cache = (CacheSPI_Legacy) new DefaultCacheFactory<Object, Object>().createCache(configFileName);
- ConsoleListener listener = new ConsoleListener(cache);
- listener.listen();
- }
- catch (Throwable throwable)
- {
- throwable.printStackTrace();
- }
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -702,9 +702,6 @@
{
flushBlockGate.close();
if (log.isDebugEnabled()) log.debug("Block received at " + getLocalAddress());
- notifier.notifyCacheBlocked(true);
- notifier.notifyCacheBlocked(false);
-
if (log.isDebugEnabled()) log.debug("Block processed at " + getLocalAddress());
}
@@ -714,10 +711,6 @@
public void unblock()
{
if (log.isDebugEnabled()) log.debug("UnBlock received at " + getLocalAddress());
-
- notifier.notifyCacheUnblocked(true);
- notifier.notifyCacheUnblocked(false);
-
if (log.isDebugEnabled()) log.debug("UnBlock processed at " + getLocalAddress());
flushBlockGate.open();
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -41,10 +41,6 @@
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.ViewChanged;
-import org.jboss.cache.notifications.event.ViewChangedEvent;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.cache.util.reflect.ReflectionUtil;
@@ -56,6 +52,10 @@
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.notifications.annotation.CacheListener;
+import org.jboss.starobrno.notifications.annotation.ViewChanged;
+import org.jboss.starobrno.notifications.event.ViewChangedEvent;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.Address;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -54,12 +54,12 @@
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.notifications.Notifier;
import org.jgroups.Address;
import javax.transaction.TransactionManager;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -28,7 +28,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.notifications.Notifier;
+import org.jboss.starobrno.notifications.Notifier;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#get(String, Object)}
@@ -84,10 +84,10 @@
if (trace) log.trace("Node has been deleted and is of type " + n.getClass().getSimpleName());
return null;
}
- if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, ctx);
+// if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, ctx);
Object result = n.getDirect(key);
if (trace) log.trace("Found value " + result);
- if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
+// if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
return result;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -27,8 +27,8 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.notifications.Notifier;
/**
* Base version of {@link org.jboss.cache.commands.DataCommand} which handles common behaviour
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -27,7 +27,6 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -74,9 +73,9 @@
}
Map data = targetNode.getDataDirect();
- notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
+// notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
targetNode.clearDataDirect();
- notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
+// notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
return null;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -30,7 +30,7 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.notifications.Notifier;
+import org.jboss.starobrno.notifications.Notifier;
import java.util.Collection;
import java.util.Collections;
@@ -122,7 +122,7 @@
protected boolean evictNode(Fqn fqn, InvocationContext ctx, NodeSPI node)
{
- notifier.notifyNodeEvicted(fqn, true, ctx);
+// notifier.notifyNodeEvicted(fqn, true, ctx);
try
{
if (node == null) return true;
@@ -152,7 +152,7 @@
}
finally
{
- notifier.notifyNodeEvicted(fqn, false, ctx);
+// notifier.notifyNodeEvicted(fqn, false, ctx);
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -30,7 +30,7 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.notifications.Notifier;
+import org.jboss.starobrno.notifications.Notifier;
/**
* Removes a node's content from memory - never removes the node.
@@ -86,14 +86,14 @@
boolean evictNode(Fqn fqn, InvocationContext ctx)
{
- notifier.notifyNodeInvalidated(fqn, true, ctx);
+// notifier.notifyNodeInvalidated(fqn, true, ctx);
try
{
return dataContainer.evict(fqn);
}
finally
{
- notifier.notifyNodeInvalidated(fqn, false, ctx);
+// notifier.notifyNodeInvalidated(fqn, false, ctx);
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -31,8 +31,8 @@
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.notifications.Notifier;
import java.util.Map;
@@ -111,9 +111,9 @@
// at this stage all child node objects we need have been created and are available in the ctx.
// we just need to mark old ones as deleted, new ones as created, and move data across.
- notifier.notifyNodeMoved(fqn, newNodeFqn, true, ctx);
+// notifier.notifyNodeMoved(fqn, newNodeFqn, true, ctx);
moveRecursively(node, newNode, ctx);
- notifier.notifyNodeMoved(fqn, newNodeFqn, false, ctx);
+// notifier.notifyNodeMoved(fqn, newNodeFqn, false, ctx);
return null;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -28,10 +28,8 @@
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.transaction.GlobalTransaction;
-import java.util.Collections;
import java.util.Map;
/**
@@ -78,16 +76,16 @@
if (nodeSPI == null) throw new NodeNotExistsException("Node " + fqn + " does not exist!");
Map existingData = nodeSPI.getDataDirect();
- if (notifier.shouldNotifyOnNodeModified())
- {
- notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, existingData == null ? Collections.emptyMap() : existingData, ctx);
- }
-
+// if (notifier.shouldNotifyOnNodeModified())
+// {
+// notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, existingData == null ? Collections.emptyMap() : existingData, ctx);
+// }
+//
nodeSPI.putAllDirect(data);
- if (notifier.shouldNotifyOnNodeModified())
- {
- notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_MAP, nodeSPI.getDataDirect(), ctx);
- }
+// if (notifier.shouldNotifyOnNodeModified())
+// {
+// notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_MAP, nodeSPI.getDataDirect(), ctx);
+// }
return null;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -28,7 +28,6 @@
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Collections;
@@ -80,7 +79,7 @@
if (notifier.shouldNotifyOnNodeModified())
{
- notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_DATA, n.getDataDirect(), ctx);
+// notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_DATA, n.getDataDirect(), ctx);
}
Object oldValue = n.putDirect(key, value);
@@ -89,7 +88,7 @@
if (notifier.shouldNotifyOnNodeModified())
{
Map newData = Collections.singletonMap(key, value);
- notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_DATA, newData, ctx);
+// notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_DATA, newData, ctx);
}
return oldValue;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -27,7 +27,6 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Collections;
@@ -79,13 +78,13 @@
}
if (notifier.shouldNotifyOnNodeModified())
{
- notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, n.getDataDirect(), ctx);
+// notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, n.getDataDirect(), ctx);
}
Object oldValue = n.removeDirect(key);
if (notifier.shouldNotifyOnNodeModified())
{
Map removedData = Collections.singletonMap(key, oldValue);
- notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, removedData, ctx);
+// notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, removedData, ctx);
}
return oldValue;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -107,7 +107,7 @@
{
if (!skipSendingNodeEvents)
{
- notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
+// notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
}
}
@@ -115,7 +115,7 @@
{
if (!skipSendingNodeEvents)
{
- notifier.notifyNodeRemoved(fqn, false, null, ctx);
+// notifier.notifyNodeRemoved(fqn, false, null, ctx);
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -374,7 +374,7 @@
{
Modification mod = new Modification(Modification.ModificationType.REMOVE_NODE, fqn);
l.add(mod);
- notifier.notifyNodeActivated(fqn, false, data, ctx);
+// notifier.notifyNodeActivated(fqn, false, data, ctx);
}
public List<Modification> getCacheLoaderModifications()
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -44,14 +44,13 @@
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.notifications.Notifier;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
@@ -422,11 +421,11 @@
{
if (trace) log.trace("Node data is not null, loading");
- notifier.notifyNodeLoaded(fqn, true, Collections.emptyMap(), ctx);
- if (isActivation)
- {
- notifier.notifyNodeActivated(fqn, true, Collections.emptyMap(), ctx);
- }
+// notifier.notifyNodeLoaded(fqn, true, Collections.emptyMap(), ctx);
+// if (isActivation)
+// {
+// notifier.notifyNodeActivated(fqn, true, Collections.emptyMap(), ctx);
+// }
n.setInternalState(nodeData);
@@ -434,11 +433,11 @@
// if (usingVersionedInvalidation) n.setValid(true, false);
n.setValid(true, false);
- notifier.notifyNodeLoaded(fqn, false, nodeData, ctx);
- if (isActivation)
- {
- notifier.notifyNodeActivated(fqn, false, nodeData, ctx);
- }
+// notifier.notifyNodeLoaded(fqn, false, nodeData, ctx);
+// if (isActivation)
+// {
+// notifier.notifyNodeActivated(fqn, false, nodeData, ctx);
+// }
}
if (n != null && !n.isDataLoaded())
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -30,10 +30,9 @@
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.notifications.Notifier;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
@@ -88,10 +87,10 @@
// to get them manually
Map attributes = getNodeAttributes(ctx, fqn);
// notify listeners that this node is about to be passivated
- notifier.notifyNodePassivated(fqn, true, attributes, ctx);
+// notifier.notifyNodePassivated(fqn, true, attributes, ctx);
if (trace) log.trace("Passivating " + fqn);
loader.put(fqn, attributes);
- notifier.notifyNodePassivated(fqn, false, Collections.emptyMap(), ctx);
+// notifier.notifyNodePassivated(fqn, false, Collections.emptyMap(), ctx);
if (getStatisticsEnabled()) passivations.getAndIncrement();
}
catch (NodeNotLoadedException e)
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -54,7 +54,6 @@
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
@@ -67,6 +66,7 @@
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.notifications.Notifier;
import org.jgroups.Address;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationBroadcaster.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationBroadcaster.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationBroadcaster.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -30,15 +30,14 @@
String
NOTIF_CACHE_STARTED = "org.jboss.cache.CacheStarted",
NOTIF_CACHE_STOPPED = "org.jboss.cache.CacheStopped",
- NOTIF_NODE_CREATED = "org.jboss.cache.NodeCreated",
- NOTIF_NODE_MODIFIED = "org.jboss.cache.NodeModified",
- NOTIF_NODE_REMOVED = "org.jboss.cache.NodeRemoved",
- NOTIF_NODE_MOVED = "org.jboss.cache.NodeMoved",
- NOTIF_NODE_VISITED = "org.jboss.cache.NodeVisited",
- NOTIF_NODE_EVICTED = "org.jboss.cache.NodeEvicted",
- NOTIF_NODE_LOADED = "org.jboss.cache.NodeLoaded",
- NOTIF_NODE_ACTIVATED = "org.jboss.cache.NodeActivated",
- NOTIF_NODE_PASSIVATED = "org.jboss.cache.NodePassivated",
+ NOTIF_CACHE_ENTRY_CREATED = "org.jboss.cache.NodeCreated",
+ NOTIF_CACHE_ENTRY_MODIFIED = "org.jboss.cache.NodeModified",
+ NOTIF_CACHE_ENTRY_REMOVED = "org.jboss.cache.NodeRemoved",
+ NOTIF_CACHE_ENTRY_VISITED = "org.jboss.cache.NodeVisited",
+ NOTIF_CACHE_ENTRY_EVICTED = "org.jboss.cache.NodeEvicted",
+ NOTIF_CACHE_ENTRY_LOADED = "org.jboss.cache.NodeLoaded",
+ NOTIF_CACHE_ENTRY_ACTIVATED = "org.jboss.cache.NodeActivated",
+ NOTIF_CACHE_ENTRY_PASSIVATED = "org.jboss.cache.NodePassivated",
NOTIF_VIEW_CHANGED = "org.jboss.cache.ViewChanged";
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheNotificationListener.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -21,23 +21,21 @@
*/
package org.jboss.cache.jmx;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.CacheStarted;
-import org.jboss.cache.notifications.annotation.CacheStopped;
-import org.jboss.cache.notifications.annotation.NodeActivated;
-import org.jboss.cache.notifications.annotation.NodeCreated;
-import org.jboss.cache.notifications.annotation.NodeEvicted;
-import org.jboss.cache.notifications.annotation.NodeLoaded;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.annotation.NodeMoved;
-import org.jboss.cache.notifications.annotation.NodePassivated;
-import org.jboss.cache.notifications.annotation.NodeRemoved;
-import org.jboss.cache.notifications.annotation.NodeVisited;
-import org.jboss.cache.notifications.annotation.ViewChanged;
-import org.jboss.cache.notifications.event.Event;
-import org.jboss.cache.notifications.event.NodeEvent;
-import org.jboss.cache.notifications.event.NodeMovedEvent;
-import org.jboss.cache.notifications.event.ViewChangedEvent;
+import org.jboss.starobrno.notifications.annotation.CacheEntryActivated;
+import org.jboss.starobrno.notifications.annotation.CacheEntryCreated;
+import org.jboss.starobrno.notifications.annotation.CacheEntryEvicted;
+import org.jboss.starobrno.notifications.annotation.CacheEntryLoaded;
+import org.jboss.starobrno.notifications.annotation.CacheEntryModified;
+import org.jboss.starobrno.notifications.annotation.CacheEntryPassivated;
+import org.jboss.starobrno.notifications.annotation.CacheEntryRemoved;
+import org.jboss.starobrno.notifications.annotation.CacheEntryVisited;
+import org.jboss.starobrno.notifications.annotation.CacheListener;
+import org.jboss.starobrno.notifications.annotation.CacheStarted;
+import org.jboss.starobrno.notifications.annotation.CacheStopped;
+import org.jboss.starobrno.notifications.annotation.ViewChanged;
+import org.jboss.starobrno.notifications.event.CacheEntryEvent;
+import org.jboss.starobrno.notifications.event.Event;
+import org.jboss.starobrno.notifications.event.ViewChangedEvent;
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
@@ -55,15 +53,14 @@
// Notification Messages
private static final String MSG_CACHE_STARTED = "Cache has been started.";
private static final String MSG_CACHE_STOPPED = "Cache has been stopped.";
- private static final String MSG_NODE_CREATED = "Node has been created.";
- private static final String MSG_NODE_MODIFIED = "Node has been modifed.";
- private static final String MSG_NODE_REMOVED = "Node has been removed.";
- private static final String MSG_NODE_MOVED = "Node has been moved.";
- private static final String MSG_NODE_VISITED = "Node has been visited.";
- private static final String MSG_NODE_EVICTED = "Node has been evicted.";
- private static final String MSG_NODE_LOADED = "Node has been loaded.";
- private static final String MSG_NODE_ACTIVATED = "Node has been activated.";
- private static final String MSG_NODE_PASSIVATED = "Node has been passivated.";
+ private static final String MSG_CACHE_ENTRY_CREATED = "Node has been created.";
+ private static final String MSG_CACHE_ENTRY_MODIFIED = "Node has been modifed.";
+ private static final String MSG_CACHE_ENTRY_REMOVED = "Node has been removed.";
+ private static final String MSG_CACHE_ENTRY_VISITED = "Node has been visited.";
+ private static final String MSG_CACHE_ENTRY_EVICTED = "Node has been evicted.";
+ private static final String MSG_CACHE_ENTRY_LOADED = "Node has been loaded.";
+ private static final String MSG_CACHE_ENTRY_ACTIVATED = "Node has been activated.";
+ private static final String MSG_CACHE_ENTRY_PASSIVATED = "Node has been passivated.";
private static final String MSG_VIEW_CHANGED = "Cache cluster view has changed.";
// Notification Info
@@ -98,14 +95,14 @@
{
CacheNotificationBroadcaster.NOTIF_CACHE_STARTED,
CacheNotificationBroadcaster.NOTIF_CACHE_STOPPED,
- CacheNotificationBroadcaster.NOTIF_NODE_CREATED,
- CacheNotificationBroadcaster.NOTIF_NODE_EVICTED,
- CacheNotificationBroadcaster.NOTIF_NODE_LOADED,
- CacheNotificationBroadcaster.NOTIF_NODE_MODIFIED,
- CacheNotificationBroadcaster.NOTIF_NODE_ACTIVATED,
- CacheNotificationBroadcaster.NOTIF_NODE_PASSIVATED,
- CacheNotificationBroadcaster.NOTIF_NODE_REMOVED,
- CacheNotificationBroadcaster.NOTIF_NODE_VISITED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_CREATED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_EVICTED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_LOADED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_MODIFIED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_ACTIVATED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_PASSIVATED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_REMOVED,
+ CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_VISITED,
CacheNotificationBroadcaster.NOTIF_VIEW_CHANGED,
};
@@ -117,19 +114,18 @@
@CacheStarted
@CacheStopped
- @NodeCreated
- @NodeEvicted
- @NodeLoaded
- @NodeModified
- @NodeRemoved
- @NodeMoved
- @NodeVisited
- @NodeActivated
- @NodePassivated
+ @CacheEntryCreated
+ @CacheEntryEvicted
+ @CacheEntryLoaded
+ @CacheEntryModified
+ @CacheEntryRemoved
+ @CacheEntryVisited
+ @CacheEntryActivated
+ @CacheEntryPassivated
@ViewChanged
public void broadcast(Event e)
{
- NodeEvent ne;
+ CacheEntryEvent ne;
Notification n = null;
switch (e.getType())
{
@@ -141,51 +137,46 @@
n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_STOPPED, broadcaster, seq(), MSG_CACHE_STOPPED);
n.setUserData(serviceName);
break;
- case NODE_CREATED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_CREATED, broadcaster, seq(), MSG_NODE_CREATED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre(), ne.isOriginLocal()});
+ case CACHE_ENTRY_CREATED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_CREATED, broadcaster, seq(), MSG_CACHE_ENTRY_CREATED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre(), ne.isOriginLocal()});
break;
- case NODE_EVICTED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_EVICTED, broadcaster, seq(), MSG_NODE_EVICTED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre(), ne.isOriginLocal()});
+ case CACHE_ENTRY_EVICTED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_EVICTED, broadcaster, seq(), MSG_CACHE_ENTRY_EVICTED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre(), ne.isOriginLocal()});
break;
- case NODE_LOADED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_LOADED, broadcaster, seq(), MSG_NODE_LOADED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre()});
+ case CACHE_ENTRY_LOADED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_LOADED, broadcaster, seq(), MSG_CACHE_ENTRY_LOADED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre()});
break;
- case NODE_MODIFIED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_MODIFIED, broadcaster, seq(), MSG_NODE_MODIFIED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre(), ne.isOriginLocal()});
+ case CACHE_ENTRY_MODIFIED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_MODIFIED, broadcaster, seq(), MSG_CACHE_ENTRY_MODIFIED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre(), ne.isOriginLocal()});
break;
- case NODE_REMOVED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_REMOVED, broadcaster, seq(), MSG_NODE_REMOVED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre(), ne.isOriginLocal()});
+ case CACHE_ENTRY_REMOVED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_REMOVED, broadcaster, seq(), MSG_CACHE_ENTRY_REMOVED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre(), ne.isOriginLocal()});
break;
- case NODE_MOVED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_MOVED, broadcaster, seq(), MSG_NODE_MOVED);
- NodeMovedEvent nme = (NodeMovedEvent) e;
- n.setUserData(new Object[]{nme.getFqn().toString(), nme.getTargetFqn().toString(), e.isPre()});
+ case CACHE_ENTRY_VISITED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_VISITED, broadcaster, seq(), MSG_CACHE_ENTRY_VISITED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre()});
break;
- case NODE_VISITED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_VISITED, broadcaster, seq(), MSG_NODE_VISITED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre()});
+ case CACHE_ENTRY_ACTIVATED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_ACTIVATED, broadcaster, seq(), MSG_CACHE_ENTRY_ACTIVATED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre()});
break;
- case NODE_ACTIVATED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_ACTIVATED, broadcaster, seq(), MSG_NODE_ACTIVATED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre()});
+ case CACHE_ENTRY_PASSIVATED:
+ n = new Notification(CacheNotificationBroadcaster.NOTIF_CACHE_ENTRY_PASSIVATED, broadcaster, seq(), MSG_CACHE_ENTRY_PASSIVATED);
+ ne = (CacheEntryEvent) e;
+ n.setUserData(new Object[]{ne.getKey().toString(), e.isPre()});
break;
- case NODE_PASSIVATED:
- n = new Notification(CacheNotificationBroadcaster.NOTIF_NODE_PASSIVATED, broadcaster, seq(), MSG_NODE_PASSIVATED);
- ne = (NodeEvent) e;
- n.setUserData(new Object[]{ne.getFqn().toString(), e.isPre()});
- break;
case VIEW_CHANGED:
n = new Notification(CacheNotificationBroadcaster.NOTIF_VIEW_CHANGED, broadcaster, seq(), MSG_VIEW_CHANGED);
n.setUserData(((ViewChangedEvent) e).getNewView().toString());
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -27,14 +27,14 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.CacheStarted;
-import org.jboss.cache.notifications.annotation.CacheStopped;
-import org.jboss.cache.notifications.annotation.ViewChanged;
-import org.jboss.cache.notifications.event.Event;
-import org.jboss.cache.notifications.event.ViewChangedEvent;
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
+import org.jboss.starobrno.notifications.annotation.CacheListener;
+import org.jboss.starobrno.notifications.annotation.CacheStarted;
+import org.jboss.starobrno.notifications.annotation.CacheStopped;
+import org.jboss.starobrno.notifications.annotation.ViewChanged;
+import org.jboss.starobrno.notifications.event.Event;
+import org.jboss.starobrno.notifications.event.ViewChangedEvent;
import org.jgroups.Address;
import org.jgroups.View;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -35,7 +35,6 @@
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataExceptionMarker;
import org.jboss.cache.marshall.NodeDataMarker;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
@@ -43,7 +42,6 @@
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -192,13 +190,13 @@
{
if (curr == null) return;
ctx.setOriginLocal(false);
- cache.getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx);
- cache.getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx);
+// cache.getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx);
+// cache.getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx);
// AND notify that they have been modified!!
if (!curr.getKeys().isEmpty())
{
- cache.getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
- cache.getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getData(), ctx);
+// cache.getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
+// cache.getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getData(), ctx);
}
ctx.setOriginLocal(true);
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -59,7 +59,7 @@
public PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value)
{
- return new PutKeyValueCommand(key, value, false);
+ return new PutKeyValueCommand(key, value, false, notifier);
}
public RemoveCommand buildRemoveCommand(Object key, Object value)
@@ -84,7 +84,7 @@
public PutMapCommand buildPutMapCommand(Map map)
{
- return new PutMapCommand(map);
+ return new PutMapCommand(map, notifier);
}
public ClearCommand buildClearCommand()
@@ -120,9 +120,17 @@
case PutKeyValueCommand.METHOD_ID:
{
PutKeyValueCommand c = new PutKeyValueCommand();
+ c.init(notifier);
command = c;
break;
}
+ case PutMapCommand.METHOD_ID:
+ {
+ PutMapCommand c = new PutMapCommand();
+ c.init(notifier);
+ command = c;
+ break;
+ }
case RemoveCommand.METHOD_ID:
{
RemoveCommand c = new RemoveCommand();
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/ReplicableCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -50,7 +50,7 @@
*
* @return the method id of this command. This is compatible with pre-2.2.0 MethodCall ids.
*/
- int getCommandId();
+ byte getCommandId();
/**
* Used by marshallers to stream this command across a network
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -36,7 +36,7 @@
*/
public class GetKeyValueCommand extends AbstractDataCommand
{
- public static final int METHOD_ID = 26;
+ public static final byte METHOD_ID = 26;
private static final Log log = LogFactory.getLog(GetKeyValueCommand.class);
private static final boolean trace = log.isTraceEnabled();
private Notifier notifier;
@@ -77,7 +77,7 @@
return result;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -41,7 +41,7 @@
*/
public class GravitateDataCommand extends AbstractDataCommand
{
- public static final int METHOD_ID = 35;
+ public static final byte METHOD_ID = 35;
/* dependencies */
private CacheSPI spi;
@@ -202,7 +202,7 @@
return visitor.visitGravitateDataCommand(ctx, this);
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -51,7 +51,7 @@
return container.size();
}
- public int getCommandId()
+ public byte getCommandId()
{
return 0; // no-op
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AnnounceBuddyPoolNameCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -38,7 +38,7 @@
*/
public class AnnounceBuddyPoolNameCommand implements ReplicableCommand
{
- public static final int METHOD_ID = 28;
+ public static final byte METHOD_ID = 28;
private static final Log log = LogFactory.getLog(AnnounceBuddyPoolNameCommand.class);
/* dependencies*/
@@ -79,7 +79,7 @@
return null;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/AssignToBuddyGroupCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -40,7 +40,7 @@
*/
public class AssignToBuddyGroupCommand implements ReplicableCommand
{
- public static final int METHOD_ID = 29;
+ public static final byte METHOD_ID = 29;
/* dependencies */
private BuddyManager buddyManager;
@@ -78,7 +78,7 @@
return null;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -43,7 +43,7 @@
*/
public class ClusteredGetCommand implements ReplicableCommand
{
- public static final int METHOD_ID = 22;
+ public static final byte METHOD_ID = 22;
private DataCommand dataCommand;
private boolean searchBackupSubtrees;
@@ -110,7 +110,7 @@
return results;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -45,7 +45,7 @@
*/
public class DataGravitationCleanupCommand implements ReplicableCommand
{
- public static final int METHOD_ID = 34;
+ public static final byte METHOD_ID = 34;
private static final Log log = LogFactory.getLog(DataGravitationCleanupCommand.class);
private static final boolean trace = log.isTraceEnabled();
@@ -173,7 +173,7 @@
// }
// }
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/RemoveFromBuddyGroupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/RemoveFromBuddyGroupCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/RemoveFromBuddyGroupCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -35,7 +35,7 @@
*/
public class RemoveFromBuddyGroupCommand implements ReplicableCommand
{
- public static final int METHOD_ID = 30;
+ public static final byte METHOD_ID = 30;
private BuddyManager buddyManager;
@@ -68,7 +68,7 @@
return null;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ReplicateCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ReplicateCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ReplicateCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -45,8 +45,8 @@
*/
public class ReplicateCommand implements ReplicableCommand
{
- public static final int SINGLE_METHOD_ID = 13;
- public static final int MULTIPLE_METHOD_ID = 14;
+ public static final byte SINGLE_METHOD_ID = 13;
+ public static final byte MULTIPLE_METHOD_ID = 14;
private InterceptorChain invoker;
@@ -172,7 +172,7 @@
return cacheCommand instanceof GravitateDataCommand || cacheCommand instanceof ClusteredGetCommand;
}
- public int getCommandId()
+ public byte getCommandId()
{
return isSingleCommand() ? SINGLE_METHOD_ID : MULTIPLE_METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/CommitCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/CommitCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/CommitCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -33,7 +33,7 @@
*/
public class CommitCommand extends AbstractTransactionBoundaryCommand
{
- public static final int METHOD_ID = 11;
+ public static final byte METHOD_ID = 11;
public CommitCommand(GlobalTransaction gtx)
{
@@ -49,7 +49,7 @@
return visitor.visitCommitCommand(ctx, this);
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -40,7 +40,7 @@
*/
public class PrepareCommand extends AbstractTransactionBoundaryCommand
{
- public static final int METHOD_ID = 10;
+ public static final byte METHOD_ID = 10;
protected List<DataCommand> modifications;
protected Address localAddress;
@@ -93,7 +93,7 @@
return modifications != null ? modifications.size() : 0;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/RollbackCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/RollbackCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/RollbackCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -33,7 +33,7 @@
*/
public class RollbackCommand extends AbstractTransactionBoundaryCommand
{
- public static final int METHOD_ID = 12;
+ public static final byte METHOD_ID = 12;
public RollbackCommand(GlobalTransaction globalTransaction)
{
@@ -49,7 +49,7 @@
return visitor.visitRollbackCommand(ctx, this);
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -32,7 +32,7 @@
public class ClearCommand implements VisitableCommand
{
private static final Object[] params = new Object[0];
- public static final int METHOD_ID = 17;
+ public static final byte METHOD_ID = 17;
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
{
@@ -54,7 +54,7 @@
return params;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -31,7 +31,7 @@
*/
public class EvictCommand extends AbstractDataCommand
{
- public static final int METHOD_ID = 3000;
+ public static final byte METHOD_ID = 120;
public EvictCommand(Object key)
{
@@ -58,7 +58,7 @@
return null;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -25,6 +25,7 @@
import org.jboss.starobrno.commands.read.AbstractDataCommand;
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.notifications.Notifier;
/**
* Implements functionality defined by {@link Cache#put(org.jboss.cache.Fqn, Object, Object)}.
@@ -34,18 +35,25 @@
*/
public class PutKeyValueCommand extends AbstractDataCommand
{
- public static final int METHOD_ID = 3;
+ public static final byte METHOD_ID = 3;
protected Object value;
protected boolean putIfAbsent;
+ private Notifier notifier;
- public PutKeyValueCommand(Object key, Object value, boolean putIfAbsent)
+ public PutKeyValueCommand(Object key, Object value, boolean putIfAbsent, Notifier notifier)
{
super(key);
this.value = value;
this.putIfAbsent = putIfAbsent;
+ this.notifier = notifier;
}
+ public void init(Notifier notifier)
+ {
+ this.notifier = notifier;
+ }
+
public PutKeyValueCommand()
{
}
@@ -67,11 +75,14 @@
public Object perform(InvocationContext ctx) throws Throwable
{
+ notifier.notifyCacheEntryModified(key, true, ctx);
MVCCEntry e = ctx.lookupEntry(key);
- return e.setValue(value);
+ Object o = e.setValue(value);
+ notifier.notifyCacheEntryModified(key, false, ctx);
+ return o;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -25,6 +25,7 @@
import org.jboss.starobrno.commands.Visitor;
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.notifications.Notifier;
import java.util.Map;
import java.util.Map.Entry;
@@ -34,15 +35,22 @@
*/
public class PutMapCommand implements VisitableCommand
{
- public static final int METHOD_ID = 2000;
+ public static final byte METHOD_ID = 121;
private Map<Object, Object> map;
+ private Notifier notifier;
- public PutMapCommand(Map map)
+ public PutMapCommand(Map map, Notifier notifier)
{
this.map = map;
+ this.notifier = notifier;
}
+ public void init(Notifier notifier)
+ {
+ this.notifier = notifier;
+ }
+
public PutMapCommand()
{
}
@@ -56,8 +64,11 @@
{
for (Entry<Object, Object> e : map.entrySet())
{
- MVCCEntry me = ctx.lookupEntry(e.getKey());
+ Object key = e.getKey();
+ MVCCEntry me = ctx.lookupEntry(key);
+ notifier.notifyCacheEntryModified(key, true, ctx);
if (me != null) me.setValue(e.getValue());
+ notifier.notifyCacheEntryModified(key, false, ctx);
}
return null;
}
@@ -72,7 +83,7 @@
this.map = map;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -32,7 +32,7 @@
*/
public class RemoveCommand extends AbstractDataCommand
{
- public static final int METHOD_ID = 6;
+ public static final byte METHOD_ID = 6;
protected Object value;
@@ -60,7 +60,7 @@
return e.getValue();
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -32,7 +32,7 @@
*/
public class ReplaceCommand extends AbstractDataCommand
{
- public static final int METHOD_ID = 99;
+ public static final byte METHOD_ID = 122;
protected Object oldValue;
protected Object newValue;
@@ -65,7 +65,7 @@
return false;
}
- public int getCommandId()
+ public byte getCommandId()
{
return METHOD_ID;
}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/IncorrectCacheListenerException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/IncorrectCacheListenerException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/IncorrectCacheListenerException.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications;
+
+import org.jboss.starobrno.CacheException;
+
+/**
+ * Thrown when an incorrectly annotated class is added as a cache listener using the {@link org.jboss.cache.Cache_Legacy#addCacheListener(Object)} API.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public class IncorrectCacheListenerException extends CacheException
+{
+
+ private static final long serialVersionUID = 3847404572671886703L;
+
+ public IncorrectCacheListenerException(String s)
+ {
+ super(s);
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -23,11 +23,9 @@
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.notifications.event.NodeModifiedEvent;
import org.jgroups.View;
import javax.transaction.Transaction;
-import java.util.Map;
import java.util.Set;
/**
@@ -41,12 +39,12 @@
/**
* Notifies all registered listeners of a nodeCreated event.
*/
- void notifyNodeCreated(Object key, boolean pre, InvocationContext ctx);
+ void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodeModified event.
*/
- void notifyNodeModified(Object key, boolean pre, NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx);
+ void notifyCacheEntryModified(Object key, boolean pre, InvocationContext ctx);
/**
* When notifying about node modifications, in many scenarios there is a need of building a new Map object. If no
@@ -58,37 +56,37 @@
/**
* Notifies all registered listeners of a nodeRemoved event.
*/
- void notifyNodeRemoved(Object key, boolean pre, Map data, InvocationContext ctx);
+ void notifyCacheEntryRemoved(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodeVisited event.
*/
- void notifyNodeVisited(Object key, boolean pre, InvocationContext ctx);
+ void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodeEvicted event.
*/
- void notifyNodeEvicted(Object key, boolean pre, InvocationContext ctx);
+ void notifyCacheEntryEvicted(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodeInvalidated event.
*/
- void notifyNodeInvalidated(Object key, boolean pre, InvocationContext ctx);
+ void notifyCacheEntryInvalidated(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodeLoaded event.
*/
- void notifyNodeLoaded(Object key, boolean pre, Map data, InvocationContext ctx);
+ void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodeActivated event.
*/
- void notifyNodeActivated(Object key, boolean pre, Map data, InvocationContext ctx);
+ void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a nodePassivated event.
*/
- void notifyNodePassivated(Object key, boolean pre, Map data, InvocationContext ctx);
+ void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx);
/**
* Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
@@ -120,10 +118,6 @@
*/
void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx);
- void notifyCacheBlocked(boolean pre);
-
- void notifyCacheUnblocked(boolean pre);
-
/**
* Adds a cache listener to the list of cache listeners registered.
*
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -23,13 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.notifications.IncorrectCacheListenerException;
-import org.jboss.cache.notifications.annotation.*;
-import org.jboss.cache.notifications.event.*;
-import static org.jboss.cache.notifications.event.Event.Type.*;
-import org.jboss.cache.util.Immutables;
import org.jboss.cache.util.concurrent.WithinThreadExecutor;
import org.jboss.starobrno.Cache;
import org.jboss.starobrno.CacheException;
@@ -41,8 +35,9 @@
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.factories.annotations.Stop;
-import org.jboss.starobrno.marshall.MarshalledValueMap;
-import org.jboss.starobrno.notifications.event.NodeModifiedEvent;
+import org.jboss.starobrno.notifications.annotation.*;
+import org.jboss.starobrno.notifications.event.*;
+import static org.jboss.starobrno.notifications.event.Event.Type.*;
import org.jgroups.View;
import javax.transaction.Transaction;
@@ -77,27 +72,24 @@
private static final Class singletonMap = Collections.singletonMap(null, null).getClass();
private static final Class[] allowedMethodAnnotations =
{
- CacheStarted.class, CacheStopped.class, CacheBlocked.class, CacheUnblocked.class, NodeCreated.class, NodeRemoved.class, NodeVisited.class, NodeModified.class, NodeMoved.class,
- NodeActivated.class, NodePassivated.class, NodeLoaded.class, NodeEvicted.class, TransactionRegistered.class, TransactionCompleted.class, ViewChanged.class, BuddyGroupChanged.class,
- NodeInvalidated.class
+ CacheStarted.class, CacheStopped.class, CacheEntryCreated.class, CacheEntryRemoved.class, CacheEntryVisited.class, CacheEntryModified.class,
+ CacheEntryActivated.class, CacheEntryPassivated.class, CacheEntryLoaded.class, CacheEntryEvicted.class, TransactionRegistered.class, TransactionCompleted.class, ViewChanged.class, BuddyGroupChanged.class,
+ CacheEntryInvalidated.class
};
private static final Class[] parameterTypes =
{
- CacheStartedEvent.class, CacheStoppedEvent.class, CacheBlockedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemovedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedEvent.class,
- NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedEvent.class,
- NodeInvalidatedEvent.class
+ CacheStartedEvent.class, CacheStoppedEvent.class, CacheEntryCreatedEvent.class, CacheEntryRemovedEvent.class, CacheEntryVisitedEvent.class, CacheEntryModifiedEvent.class,
+ CacheEntryActivatedEvent.class, CacheEntryPassivatedEvent.class, CacheEntryLoadedEvent.class, CacheEntryEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedEvent.class,
+ CacheEntryInvalidatedEvent.class
};
- final Map<Class<? extends Annotation>, List<ListenerInvocation>> listenersMap = new HashMap<Class<? extends Annotation>, List<ListenerInvocation>>(32);
+ final Map<Class<? extends Annotation>, List<ListenerInvocation>> listenersMap = new HashMap<Class<? extends Annotation>, List<ListenerInvocation>>(16, 0.99f);
final List<ListenerInvocation> cacheStartedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> cacheStoppedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheBlockedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheUnblockedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodeCreatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodeRemovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodeVisitedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodeModifiedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> nodeMovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodeActivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodePassivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
final List<ListenerInvocation> nodeLoadedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
@@ -121,22 +113,19 @@
{
listenersMap.put(CacheStarted.class, cacheStartedListeners);
listenersMap.put(CacheStopped.class, cacheStoppedListeners);
- listenersMap.put(CacheBlocked.class, cacheBlockedListeners);
- listenersMap.put(CacheUnblocked.class, cacheUnblockedListeners);
- listenersMap.put(NodeCreated.class, nodeCreatedListeners);
- listenersMap.put(NodeRemoved.class, nodeRemovedListeners);
- listenersMap.put(NodeVisited.class, nodeVisitedListeners);
- listenersMap.put(NodeModified.class, nodeModifiedListeners);
- listenersMap.put(NodeMoved.class, nodeMovedListeners);
- listenersMap.put(NodeActivated.class, nodeActivatedListeners);
- listenersMap.put(NodePassivated.class, nodePassivatedListeners);
- listenersMap.put(NodeLoaded.class, nodeLoadedListeners);
- listenersMap.put(NodeEvicted.class, nodeEvictedListeners);
+ listenersMap.put(CacheEntryCreated.class, nodeCreatedListeners);
+ listenersMap.put(CacheEntryRemoved.class, nodeRemovedListeners);
+ listenersMap.put(CacheEntryVisited.class, nodeVisitedListeners);
+ listenersMap.put(CacheEntryModified.class, nodeModifiedListeners);
+ listenersMap.put(CacheEntryActivated.class, nodeActivatedListeners);
+ listenersMap.put(CacheEntryPassivated.class, nodePassivatedListeners);
+ listenersMap.put(CacheEntryLoaded.class, nodeLoadedListeners);
+ listenersMap.put(CacheEntryEvicted.class, nodeEvictedListeners);
listenersMap.put(TransactionRegistered.class, transactionRegisteredListeners);
listenersMap.put(TransactionCompleted.class, transactionCompletedListeners);
listenersMap.put(ViewChanged.class, viewChangedListeners);
listenersMap.put(BuddyGroupChanged.class, buddyGroupChangedListeners);
- listenersMap.put(NodeInvalidated.class, nodeInvalidatedListeners);
+ listenersMap.put(CacheEntryInvalidated.class, nodeInvalidatedListeners);
}
@Inject
@@ -280,13 +269,10 @@
{
cacheStartedListeners.clear();
cacheStoppedListeners.clear();
- cacheBlockedListeners.clear();
- cacheUnblockedListeners.clear();
nodeCreatedListeners.clear();
nodeRemovedListeners.clear();
nodeVisitedListeners.clear();
nodeModifiedListeners.clear();
- nodeMovedListeners.clear();
nodeActivatedListeners.clear();
nodePassivatedListeners.clear();
nodeLoadedListeners.clear();
@@ -307,7 +293,7 @@
return Collections.unmodifiableSet(result);
}
- public void notifyNodeCreated(Object key, boolean pre, InvocationContext ctx)
+ public void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx)
{
if (!nodeCreatedListeners.isEmpty())
{
@@ -318,31 +304,28 @@
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setType(NODE_CREATED);
+ e.setType(CACHE_ENTRY_CREATED);
for (ListenerInvocation listener : nodeCreatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodeModified(Object key, boolean pre, NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx)
+ public void notifyCacheEntryModified(Object key, boolean pre, InvocationContext ctx)
{
if (!nodeModifiedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
- Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
-// e.setModificationType(modificationType); // TODO fix types
- e.setData(dataCopy);
- e.setType(NODE_MODIFIED);
+ e.setType(CACHE_ENTRY_MODIFIED);
for (ListenerInvocation listener : nodeModifiedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -353,28 +336,26 @@
return !nodeModifiedListeners.isEmpty();
}
- public void notifyNodeRemoved(Object key, boolean pre, Map data, InvocationContext ctx)
+ public void notifyCacheEntryRemoved(Object key, boolean pre, InvocationContext ctx)
{
if (!nodeRemovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
- Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setData(dataCopy);
- e.setType(NODE_REMOVED);
+ e.setType(CACHE_ENTRY_REMOVED);
for (ListenerInvocation listener : nodeRemovedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodeVisited(Object key, boolean pre, InvocationContext ctx)
+ public void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx)
{
if (!nodeVisitedListeners.isEmpty())
{
@@ -383,36 +364,16 @@
EventImpl e = new EventImpl();
e.setCache(cache);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setType(NODE_VISITED);
+ e.setType(CACHE_ENTRY_VISITED);
for (ListenerInvocation listener : nodeVisitedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre, InvocationContext ctx)
+ public void notifyCacheEntryEvicted(final Object key, final boolean pre, InvocationContext ctx)
{
- if (!nodeMovedListeners.isEmpty())
- {
- boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setFqn(originalFqn);
- e.setTargetFqn(newFqn);
- e.setTransaction(tx);
- e.setType(NODE_MOVED);
- for (ListenerInvocation listener : nodeMovedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyNodeEvicted(final Object key, final boolean pre, InvocationContext ctx)
- {
if (!nodeEvictedListeners.isEmpty())
{
final boolean originLocal = ctx.isOriginLocal();
@@ -422,15 +383,15 @@
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setType(NODE_EVICTED);
+ e.setType(CACHE_ENTRY_EVICTED);
for (ListenerInvocation listener : nodeEvictedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodeInvalidated(final Object key, final boolean pre, InvocationContext ctx)
+ public void notifyCacheEntryInvalidated(final Object key, final boolean pre, InvocationContext ctx)
{
if (!nodeInvalidatedListeners.isEmpty())
{
@@ -441,70 +402,64 @@
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setType(NODE_INVALIDATED);
+ e.setType(CACHE_ENTRY_INVALIDATED);
for (ListenerInvocation listener : nodeInvalidatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodeLoaded(Object key, boolean pre, Map data, InvocationContext ctx)
+ public void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx)
{
if (!nodeLoadedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
- Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setData(dataCopy);
- e.setType(NODE_LOADED);
+ e.setType(CACHE_ENTRY_LOADED);
for (ListenerInvocation listener : nodeLoadedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodeActivated(Object key, boolean pre, Map data, InvocationContext ctx)
+ public void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx)
{
if (!nodeActivatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
- Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setOriginLocal(originLocal);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setData(dataCopy);
- e.setType(NODE_ACTIVATED);
+ e.setType(CACHE_ENTRY_ACTIVATED);
for (ListenerInvocation listener : nodeActivatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
- public void notifyNodePassivated(Object key, boolean pre, Map data, InvocationContext ctx)
+ public void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx)
{
if (!nodePassivatedListeners.isEmpty())
{
- Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setPre(pre);
-// e.setFqn(fqn); // TODO - attach key
+ e.setKey(key);
e.setTransaction(tx);
- e.setData(dataCopy);
- e.setType(NODE_PASSIVATED);
+ e.setType(CACHE_ENTRY_PASSIVATED);
for (ListenerInvocation listener : nodePassivatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -600,39 +555,6 @@
}
}
- public void notifyCacheBlocked(boolean pre)
- {
- if (!cacheBlockedListeners.isEmpty())
- {
- EventImpl e = new EventImpl();
- e.setCache(this.cache);
- e.setPre(pre);
- e.setType(CACHE_BLOCKED);
- for (ListenerInvocation listener : cacheBlockedListeners) listener.invoke(e);
- }
- }
-
- public void notifyCacheUnblocked(boolean pre)
- {
- if (!cacheUnblockedListeners.isEmpty())
- {
- EventImpl e = new EventImpl();
- e.setCache(this.cache);
- e.setPre(pre);
- e.setType(CACHE_UNBLOCKED);
- for (ListenerInvocation listener : cacheUnblockedListeners) listener.invoke(e);
- }
- }
-
- private static Map copy(Map data, boolean useMarshalledValueMaps)
- {
- if (data == null) return null;
- if (data.isEmpty()) return Collections.emptyMap();
- if (safe(data)) return useMarshalledValueMaps ? new MarshalledValueMap(data) : data;
- Map defensivelyCopiedData = Immutables.immutableMapCopy(data);
- return useMarshalledValueMaps ? new MarshalledValueMap(defensivelyCopiedData) : defensivelyCopiedData;
- }
-
private void restoreInvocationContext(InvocationContext backup)
{
InvocationContext currentIC = cache.getInvocationContext();
@@ -659,23 +581,6 @@
}
/**
- * A map is deemed 'safe' to be passed as-is to a listener, if either of the following are true:
- * <ul>
- * <li>It is null</li>
- * <li>It is an instance of {@link org.jboss.cache.util.ImmutableMapCopy}, which is immutable</li>
- * <li>It is an instance of {@link java.util.Collections#emptyMap()}, which is also immutable</li>
- * <li>It is an instance of {@link java.util.Collections#singletonMap(Object,Object)}, which is also immutable</li>
- * </ul>
- *
- * @param map
- * @return
- */
- private static boolean safe(Map map)
- {
- return map == null || Immutables.isImmutable(map) || map.getClass().equals(emptyMap) || map.getClass().equals(singletonMap);
- }
-
- /**
* Class that encapsulates a valid invocation for a given registered listener - containing a reference to the
* method to be invoked as well as the target object.
*/
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/BuddyGroupChanged.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/BuddyGroupChanged.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/BuddyGroupChanged.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a buddy group changes.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.BuddyGroupChangedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ * <p/>
+ * This call back only occurs when a buddy group structure is changed. In a cache setup where buddy replication is not
+ * enabled, this call back would never occur.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @see org.jboss.cache.notifications.event.CacheBlockedEvent
+ * @since 2.1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface BuddyGroupChanged
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryActivated.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryActivated.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryActivated.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is activated.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.NodeActivatedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @see org.jboss.cache.notifications.annotation.NodePassivated
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryActivated
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryCreated.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryCreated.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryCreated.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is created.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.NodeCreatedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryCreated
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryEvicted.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryEvicted.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryEvicted.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is evicted.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.NodeEvictedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @see org.jboss.cache.notifications.annotation.NodeLoaded
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryEvicted
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryInvalidated.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryInvalidated.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryInvalidated.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is invalidated.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.NodeInvalidatedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.jboss.cache.notifications.annotation.CacheListener
+ * @since 3.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryInvalidated
+{
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryLoaded.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryLoaded.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryLoaded.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is loaded from a {@link org.jboss.cache.loader.CacheLoader}.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.NodeEvictedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryLoaded
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryModified.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryModified.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryModified.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node has been modified.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
+ * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown when registering
+ * your cache listener.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryModified
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryPassivated.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryPassivated.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryPassivated.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is passivated.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.NodePassivatedEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryPassivated
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryRemoved.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryRemoved.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryRemoved.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is removed from the cache.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.TransactionRegisteredEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryRemoved
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryVisited.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryVisited.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheEntryVisited.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a node is visited.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.NodeVisitedEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryVisited
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheListener.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheListener.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,333 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Class-level annotation used to annotate an object as being a valid cache listener. Used with the
+ * {@link org.jboss.cache.Cache_Legacy#addCacheListener(Object)} and related APIs.
+ * <p/>
+ * Note that even if a class is annotated with this annotation, it still needs method-level annotation (such as
+ * {@link org.jboss.cache.notifications.annotation.CacheStarted}) to actually receive notifications.
+ * <p/>
+ * Objects annotated with this annotation - listeners - can be attached to a running {@link org.jboss.cache.Cache_Legacy} so
+ * users can be notified of {@link org.jboss.cache.Cache_Legacy} events.
+ * <p/>
+ * <p/>
+ * There can be multiple methods that are annotated to receive the same event,
+ * and a method may receive multiple events by using a super type.
+ * </p>
+ * <p/>
+ * <h4>Delivery Semantics</h4>
+ * <p/>
+ * An event is delivered immediately after the
+ * respective operation, but before the underlying cache call returns. For this
+ * reason it is important to keep listener processing logic short-lived. If a
+ * long running task needs to be performed, it's recommended to use another
+ * thread.
+ * </p>
+ * <p/>
+ * <h4>Transactional Semantics</h4>
+ * <p/>
+ * Since the event is delivered during the actual cache call, the transactional
+ * outcome is not yet known. For this reason, <i>events are always delivered, even
+ * if the changes they represent are discarded by their containing transaction</i>.
+ * For applications that must only process events that represent changes in a
+ * completed transaction, {@link org.jboss.cache.notifications.event.TransactionalEvent#getTransaction()} can be used,
+ * along with {@link org.jboss.cache.notifications.event.TransactionCompletedEvent#isSuccessful()} to record events and
+ * later process them once the transaction has been successfully committed.
+ * Example 4 demonstrates this.
+ * </p>
+ * <p/>
+ * <h4>Threading Semantics</h4>
+ * <p/>
+ * A listener implementation must be capable of handling concurrent invocations. Local
+ * notifications reuse the calling thread; remote notifications reuse the network thread.
+ * </p>
+ * <p/>
+ * Since notifications reuse the calling or network thread, it is important to realise that
+ * if your listener implementation blocks or performs a long-running task, the original caller which
+ * triggered the cache event may block until the listener callback completes. It is therefore a good idea to use
+ * the listener to be notified of an event but to perform any
+ * long running tasks in a separate thread so as not to block the original caller.
+ * </p>
+ * <p/>
+ * In addition, any locks acquired for the operation being performed will still be held for the callback. This needs to be kept in mind
+ * as locks may be held longer than necessary or intended to and may cause deadlocking in certain situations. See above paragraph
+ * on long-running tasks that should be run in a separate thread.
+ * </p>
+ * <b>Note</b>: Since 3.0, a new parameter, <tt>sync</tt>, has been introduced on this annotation. This defaults to <tt>true</tt>
+ * which provides the above semantics. Alternatively, if you set <tt>sync</tt> to <tt>false</tt>, then invocations are made in a
+ * <i>separate</i> thread, which will not cause any blocking on the caller or network thread. The separate thread is taken
+ * from a pool, which can be configured using {@link org.jboss.cache.config.Configuration#setListenerAsyncPoolSize(int)}.
+ * <p/>
+ * <b>Summary of Notification Annotations</b>
+ * <table border="1" cellpadding="1" cellspacing="1" summary="Summary of notification annotations">
+ * <tr>
+ * <th bgcolor="#CCCCFF" align="left">Annotation</th>
+ * <th bgcolor="#CCCCFF" align="left">Event</th>
+ * <th bgcolor="#CCCCFF" align="left">Description</th>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheStarted}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.CacheStartedEvent}</td>
+ * <td valign="top">A cache was started</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheStopped}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.CacheStoppedEvent}</td>
+ * <td valign="top">A cache was stopped</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheEntryModified}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeModifiedEvent}</td>
+ * <td valign="top">A node was modified</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link NodeMoved}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeMovedEvent}</td>
+ * <td valign="top">A node was moved</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheEntryCreated}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeCreatedEvent}</td>
+ * <td valign="top">A node was created</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheEntryRemoved}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeRemovedEvent}</td>
+ * <td valign="top">A node was removed</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheEntryVisited}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeVisitedEvent}</td>
+ * <td valign="top">A node was visited</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheEntryLoaded}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeLoadedEvent}</td>
+ * <td valign="top">A node was loaded</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link org.jboss.cache.notifications.annotation.NodeEvicted}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeEvictedEvent}</td>
+ * <td valign="top">A node was evicted</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link org.jboss.cache.notifications.annotation.NodeActivated}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodeActivatedEvent}</td>
+ * <td valign="top">A node was activated</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link org.jboss.cache.notifications.annotation.NodePassivated}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.NodePassivatedEvent}</td>
+ * <td valign="top">A node was passivated</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link org.jboss.cache.notifications.annotation.ViewChanged}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.ViewChangedEvent}</td>
+ * <td valign="top">A view change event was detected</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link org.jboss.cache.notifications.annotation.CacheBlocked}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.CacheBlockedEvent}</td>
+ * <td valign="top">A cache block event was detected</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheUnblocked}</td>
+ * <td valign="top">{@link org.jboss.cache.notifications.event.CacheUnblockedEvent}</td>
+ * <td valign="top">A cache unblock event was detected</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link TransactionRegistered}</td>
+ * <td valign@="top">{@link org.jboss.cache.notifications.event.TransactionRegisteredEvent}</td>
+ * <td valign="top">The cache has started to participate in a transaction</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link TransactionCompleted}</td>
+ * <td valign=@"top">{@link org.jboss.cache.notifications.event.TransactionCompletedEvent}</td>
+ * <td valign="top">The cache has completed its participation in a transaction</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link BuddyGroupChanged}</td>
+ * <td valign=@"top">{@link org.jboss.cache.notifications.event.BuddyGroupChangedEvent}</td>
+ * <td valign="top">Buddy replication is enabled and one of the buddy groups that the instance is a member of has changed its membership.</td>
+ * </tr>
+ * <tr>
+ * <td valign="top">{@link CacheEntryInvalidated}</td>
+ * <td valign=@"top">{@link org.jboss.cache.notifications.event.NodeInvalidatedEvent}</td>
+ * <td valign="top">A node was invalidated by a remote cache. Only if cache mode is INVALIDATION_SYNC or INVALIDATION_ASYNC.</td>
+ * </tr>
+ * <p/>
+ * </table>
+ * <p/>
+ * <h4>Example 1 - Method receiving a single event</h4>
+ * <pre>
+ * @CacheListener
+ * public class SingleEventListener
+ * {
+ * @CacheStarted
+ * public void doSomething(Event event)
+ * {
+ * System.out.println("Cache started. Details = " + event);
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <h4>Example 2 - Method receiving multiple events</h4>
+ * <pre>
+ * @CacheListener
+ * public class MultipleEventListener
+ * {
+ * @CacheStarted
+ * @CacheStopped
+ * public void doSomething(Event event)
+ * {
+ * if (event.getType() == Event.Type.CACHE_STARTED)
+ * System.out.println("Cache started. Details = " + event);
+ * else if (event.getType() == Event.Type.CACHE_STOPPED)
+ * System.out.println("Cache stopped. Details = " + event);
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <h4>Example 3 - Multiple methods receiving the same event</h4>
+ * <pre>
+ * @CAcheListener
+ * public class SingleEventListener
+ * {
+ * @CacheStarted
+ * public void handleStart(Event event)
+ * {
+ * System.out.println("Cache started");
+ * }
+ * <p/>
+ * @CacheStarted
+ * @CacheStopped
+ * @CacheBlocked
+ * @CacheUnblocked
+ * @ViewChanged
+ * public void logEvent(Event event)
+ * {
+ * logSystem.logEvent(event.getType());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <p/>
+ * <b>Example 4 - Processing only events with a committed transaction.</b>
+ * <p/>
+ * <pre>
+ * @CacheListener
+ * public class TxGuaranteedListener
+ * {
+ * private class TxEventQueue
+ * {
+ * private ConcurrentMap<Transaction, Queue<Event>> map = new ConcurrentHashMap<Transaction, Queue<Event>>();
+ * <p/>
+ * public void offer(Event event)
+ * {
+ * Queue<Event> queue = getQueue(event.getContext().getTransaction());
+ * queue.offer(event);
+ * }
+ * <p/>
+ * private Queue<Event> getQueue(Transaction transaction)
+ * {
+ * Queue<Event> queue = map.get(transaction);
+ * if (queue == null)
+ * {
+ * queue = new ConcurrentLinkedQueue<Event>();
+ * map.putIfAbsent(transaction, queue);
+ * }
+ * <p/>
+ * return queue;
+ * }
+ * <p/>
+ * public Queue<Event> takeAll(Transaction transaction)
+ * {
+ * return map.remove(transaction);
+ * }
+ * }
+ * <p/>
+ * private TxEventQueue events = new TxEventQueue();
+ * <p/>
+ * @NodeModified
+ * @NodeMoved
+ * @NodeCreated
+ * @NodeRemoved
+ * public void handle(Event event)
+ * {
+ * events.offer(event);
+ * }
+ * <p/>
+ * @TransactionCompleted
+ * public void handleTx(TransactionCompletedEvent event)
+ * {
+ * Queue<Event> completed = events.takeAll(event.getTransaction());
+ * if (completed != null && event.isSuccessful())
+ * System.out.println("Comitted events = " + completed);
+ * }
+ * }
+ * </pre>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @author Jason T. Greene
+ * @see CacheStarted
+ * @see CacheStopped
+ * @see CacheEntryModified
+ * @see NodeMoved
+ * @see CacheEntryCreated
+ * @see CacheEntryRemoved
+ * @see CacheEntryVisited
+ * @see CacheEntryLoaded
+ * @see CacheEntryEvicted
+ * @see CacheEntryActivated
+ * @see CacheEntryPassivated
+ * @see ViewChanged
+ * @see CacheBlocked
+ * @see CacheUnblocked
+ * @see TransactionCompleted
+ * @see TransactionRegistered
+ * @see BuddyGroupChanged
+ * @see CacheEntryInvalidated
+ * @see org.jboss.cache.Cache_Legacy#addCacheListener(Object)
+ * @see org.jboss.cache.Cache_Legacy#removeCacheListener(Object)
+ * @see org.jboss.cache.Cache_Legacy#getCacheListeners()
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+public @interface CacheListener
+{
+ /**
+ * Specifies whether callbacks on any class annotated with this annotation happens synchronously (in the caller's thread)
+ * or asynchronously (using a separate thread). Defaults to <tt>true</tt>.
+ *
+ * @return true if the expectation is that callbacks are called using the caller's thread; false if they are to be made in a separate thread.
+ * @since 3.0
+ */
+ boolean sync() default true;
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStarted.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStarted.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStarted.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache is started.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.CacheStartedEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheStarted
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStopped.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStopped.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/CacheStopped.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache is stopped.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.CacheStoppedEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheStopped
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionCompleted.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionCompleted.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionCompleted.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when the cache is called to participate in a transaction and
+ * the transaction completes, either with a commit or a rollback.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.TransactionCompletedEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ * <p/>
+ * Note that methods marked with this annotation will only be fired <i>after the fact</i>, i.e., your method will never be
+ * called with {@link org.jboss.cache.notifications.event.Event#isPre()} being set to <tt>true</tt>.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface TransactionCompleted
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionRegistered.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionRegistered.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/TransactionRegistered.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when the cache is called to participate in a transaction and
+ * registers a {@link javax.transaction.Synchronization} with a registered {@link javax.transaction.TransactionManager}.
+ * <p/>
+ * Methods annotated with this annotation should accept a single
+ * parameter, a {@link org.jboss.cache.notifications.event.TransactionRegisteredEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ * <p/>
+ * Note that methods marked with this annotation will only be fired <i>after the fact</i>, i.e., your method will never be
+ * called with {@link org.jboss.cache.notifications.event.Event#isPre()} being set to <tt>true</tt>.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface TransactionRegistered
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/ViewChanged.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/ViewChanged.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/annotation/ViewChanged.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when the cache is used in a cluster and the cluster topology
+ * changes (i.e., a member joins or leaves the cluster).
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter,
+ * a {@link org.jboss.cache.notifications.event.ViewChangedEvent} otherwise a {@link org.jboss.cache.notifications.IncorrectCacheListenerException}
+ * will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see CacheListener
+ * @since 2.0.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface ViewChanged
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/BuddyGroupChangedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/BuddyGroupChangedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/BuddyGroupChangedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+import org.jboss.cache.buddyreplication.BuddyGroup;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.BuddyGroupChanged}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.1.0
+ */
+public interface BuddyGroupChangedEvent extends Event
+{
+ /**
+ * @return the new buddy group
+ * @since 2.1.0
+ */
+ BuddyGroup getBuddyGroup();
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryActivatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryActivatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryActivatedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeActivated}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryActivatedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryCreatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryCreatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryCreatedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeCreated}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryCreatedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * Transactional events that additionally expose an Fqn as such events pertain to a specific node.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryEvent extends TransactionalEvent
+{
+ /**
+ * @return the Fqn pointing to the node that is affected.
+ */
+ Object getKey();
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvictedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvictedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryEvictedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeEvicted}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryEvictedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryInvalidatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryInvalidatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryInvalidatedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * Notifies a listener of an invalidation event
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface CacheEntryInvalidatedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryLoadedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryLoadedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryLoadedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeLoaded}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryLoadedEvent extends CacheEntryEvent
+{
+}
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryModifiedEvent.java (from rev 6899, core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/NodeModifiedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryModifiedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryModifiedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeModified}
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryModifiedEvent extends CacheEntryEvent
+{
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryModifiedEvent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryPassivatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryPassivatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryPassivatedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodePassivated}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryPassivatedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryRemovedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryRemovedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryRemovedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeRemoved}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryRemovedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryVisitedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryVisitedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheEntryVisitedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeVisited}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheEntryVisitedEvent extends CacheEntryEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStartedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStartedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStartedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.CacheStarted}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheStartedEvent extends Event
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStoppedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStoppedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/CacheStoppedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.CacheStopped}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface CacheStoppedEvent extends Event
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/Event.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/Event.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/Event.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+import org.jboss.starobrno.Cache;
+
+/**
+ * An interface that defines common characteristics of events
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface Event
+{
+ static enum Type
+ {
+ CACHE_STARTED, CACHE_STOPPED, CACHE_ENTRY_ACTIVATED, CACHE_ENTRY_PASSIVATED, CACHE_ENTRY_VISITED,
+ CACHE_ENTRY_LOADED, CACHE_ENTRY_EVICTED, CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED, CACHE_ENTRY_MODIFIED,
+ TRANSACTION_COMPLETED, TRANSACTION_REGISTERED, VIEW_CHANGED, BUDDY_GROUP_CHANGED, CACHE_ENTRY_INVALIDATED
+ }
+
+ /**
+ * @return the type of event represented by this instance.
+ */
+ Type getType();
+
+ /**
+ * @return true if the notification is before the event has occured, false if after the event has occured.
+ */
+ boolean isPre();
+
+ /**
+ * @return a handle to the cache instance that generated this notification.
+ */
+ Cache getCache();
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/EventImpl.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.starobrno.Cache;
+import org.jgroups.View;
+
+import javax.transaction.Transaction;
+
+/**
+ * Basic implementation of an event that covers all event types.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public class EventImpl implements CacheStartedEvent, CacheStoppedEvent,
+ CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent,
+ CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent,
+ ViewChangedEvent, BuddyGroupChangedEvent, CacheEntryInvalidatedEvent
+{
+ private boolean pre = false; // by default events are after the fact
+ private Cache cache;
+ private Object key;
+ private Transaction transaction;
+ private boolean originLocal = true; // by default events all originate locally
+ private Fqn targetFqn;
+ private boolean successful;
+ private View newView;
+ private Type type;
+ private BuddyGroup buddyGroup;
+
+
+ public EventImpl(boolean pre, Cache cache, Object key, Transaction transaction, boolean originLocal, Fqn targetFqn, boolean successful, View newView, Type type)
+ {
+ this.pre = pre;
+ this.cache = cache;
+ this.key = key;
+ this.transaction = transaction;
+ this.originLocal = originLocal;
+ this.targetFqn = targetFqn;
+ this.successful = successful;
+ this.newView = newView;
+ this.type = type;
+ }
+
+ public EventImpl()
+ {
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+
+ public boolean isPre()
+ {
+ return pre;
+ }
+
+ public Cache getCache()
+ {
+ return cache;
+ }
+
+ public Object getKey()
+ {
+ return key;
+ }
+
+ public Transaction getTransaction()
+ {
+ return transaction;
+ }
+
+ public boolean isOriginLocal()
+ {
+ return originLocal;
+ }
+
+ public Fqn getTargetFqn()
+ {
+ return targetFqn;
+ }
+
+ public boolean isSuccessful()
+ {
+ return successful;
+ }
+
+ public View getNewView()
+ {
+ return newView;
+ }
+
+ // ------------------------------ setters -----------------------------
+
+ public void setPre(boolean pre)
+ {
+ this.pre = pre;
+ }
+
+ public void setCache(Cache cache)
+ {
+ this.cache = cache;
+ }
+
+ public void setKey(Object key)
+ {
+ this.key = key;
+ }
+
+ public void setTransaction(Transaction transaction)
+ {
+ this.transaction = transaction;
+ }
+
+ public void setOriginLocal(boolean originLocal)
+ {
+ this.originLocal = originLocal;
+ }
+
+ public void setTargetFqn(Fqn targetFqn)
+ {
+ this.targetFqn = targetFqn;
+ }
+
+ public void setSuccessful(boolean successful)
+ {
+ this.successful = successful;
+ }
+
+ public void setNewView(View newView)
+ {
+ this.newView = newView;
+ }
+
+ public void setType(Type type)
+ {
+ this.type = type;
+ }
+
+ public void setBuddyGroup(BuddyGroup buddyGroup)
+ {
+ this.buddyGroup = buddyGroup;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EventImpl event = (EventImpl) o;
+
+ if (originLocal != event.originLocal) return false;
+ if (pre != event.pre) return false;
+ if (successful != event.successful) return false;
+ if (cache != null ? !cache.equals(event.cache) : event.cache != null) return false;
+ if (key != null ? !key.equals(event.key) : event.key != null) return false;
+ if (targetFqn != null ? !targetFqn.equals(event.targetFqn) : event.targetFqn != null) return false;
+ if (transaction != null ? !transaction.equals(event.transaction) : event.transaction != null) return false;
+ if (newView != null ? !newView.equals(event.newView) : event.newView != null) return false;
+ if (buddyGroup != null ? !buddyGroup.equals(event.buddyGroup) : event.buddyGroup != null) return false;
+ if (type != null ? !type.equals(event.type) : event.type != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (pre ? 1 : 0);
+ result = 31 * result + (cache != null ? cache.hashCode() : 0);
+ result = 31 * result + (key != null ? key.hashCode() : 0);
+ result = 31 * result + (transaction != null ? transaction.hashCode() : 0);
+ result = 31 * result + (originLocal ? 1 : 0);
+ result = 31 * result + (targetFqn != null ? targetFqn.hashCode() : 0);
+ result = 31 * result + (successful ? 1 : 0);
+ result = 31 * result + (newView != null ? newView.hashCode() : 0);
+ result = 31 * result + (buddyGroup != null ? buddyGroup.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ return result;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "EventImpl{" +
+ "type=" + type +
+ ",pre=" + pre +
+ ", cache=" + cache +
+ ", key=" + key +
+ ", transaction=" + transaction +
+ ", originLocal=" + originLocal +
+ ", targetFqn=" + targetFqn +
+ ", successful=" + successful +
+ ", newView=" + newView +
+ ", buddyGroup=" + buddyGroup +
+ '}';
+ }
+
+ public BuddyGroup getBuddyGroup()
+ {
+ return buddyGroup;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionCompletedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionCompletedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionCompletedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.TransactionCompleted}.
+ * <p/>
+ * Note that this event is only delivered <i>after the fact</i>, i.e., you will never see an instance of this event
+ * with {@link #isPre()} being set to <tt>true</tt>.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface TransactionCompletedEvent extends TransactionalEvent
+{
+ /**
+ * @return if <tt>true</tt>, the transaction completed by committing successfully. If <tt>false</tt>, the transaction
+ * completed with a rollback.
+ */
+ boolean isSuccessful();
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionRegisteredEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionRegisteredEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionRegisteredEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.TransactionRegistered}.
+ * <p/>
+ * Note that this event is only delivered <i>after the fact</i>, i.e., you will never see an instance of this event
+ * with {@link #isPre()} being set to <tt>true</tt>.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface TransactionRegisteredEvent extends TransactionalEvent
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionalEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionalEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/TransactionalEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+import javax.transaction.Transaction;
+
+/**
+ * An event type that includes a transaction context - if one exists - as well as a boolean as to whether the call
+ * originated locally or remotely.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface TransactionalEvent extends Event
+{
+ /**
+ * @return the Transaction associated with the current call. May be null if the current call is outside the
+ * scope of a transaction.
+ */
+ Transaction getTransaction();
+
+ /**
+ * @return true if the call originated on the local cache instance; false if originated from a remote one.
+ */
+ boolean isOriginLocal();
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/ViewChangedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/ViewChangedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/ViewChangedEvent.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.starobrno.notifications.event;
+
+import org.jgroups.View;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.ViewChanged}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface ViewChangedEvent extends Event
+{
+ /**
+ * @return the new view associated with this view change.
+ */
+ View getNewView();
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -715,8 +715,6 @@
{
flushBlockGate.close();
if (log.isDebugEnabled()) log.debug("Block received at " + getLocalAddress());
- notifier.notifyCacheBlocked(true);
- notifier.notifyCacheBlocked(false);
if (log.isDebugEnabled()) log.debug("Block processed at " + getLocalAddress());
}
@@ -727,10 +725,6 @@
public void unblock()
{
if (log.isDebugEnabled()) log.debug("UnBlock received at " + getLocalAddress());
-
- notifier.notifyCacheUnblocked(true);
- notifier.notifyCacheUnblocked(false);
-
if (log.isDebugEnabled()) log.debug("UnBlock processed at " + getLocalAddress());
flushBlockGate.open();
}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java 2008-10-10 12:52:50 UTC (rev 6902)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/util/internals/ViewChangeListener.java 2008-10-10 15:25:26 UTC (rev 6903)
@@ -1,9 +1,9 @@
package org.jboss.starobrno.util.internals;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.ViewChanged;
-import org.jboss.cache.notifications.event.ViewChangedEvent;
import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.notifications.annotation.CacheListener;
+import org.jboss.starobrno.notifications.annotation.ViewChanged;
+import org.jboss.starobrno.notifications.event.ViewChangedEvent;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
16 years, 2 months