[jbosscache-commits] JBoss Cache SVN: r6929 - core/trunk/src/test/java/org/jboss/cache.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Oct 14 07:19:00 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-10-14 07:19:00 -0400 (Tue, 14 Oct 2008)
New Revision: 6929
Modified:
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
Log:
Internal cleanups
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-14 09:38:28 UTC (rev 6928)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-14 11:19:00 UTC (rev 6929)
@@ -16,7 +16,8 @@
import org.jboss.cache.util.TestingUtil;
import java.io.InputStream;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -35,13 +36,12 @@
*/
private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>()
{
-
private final AtomicInteger uniqueAddr = new AtomicInteger(11);
@Override
protected String initialValue()
{
- return "228.10.10." + String.valueOf(uniqueAddr.getAndIncrement());
+ return "228.10.10." + uniqueAddr.getAndIncrement();
}
};
@@ -50,7 +50,6 @@
*/
private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>()
{
-
private final AtomicInteger uniquePort = new AtomicInteger(45589);
@Override
@@ -63,19 +62,17 @@
/**
* For each thread holds list of caches created using this factory.
*/
- private static final ThreadLocal<Vector<Cache>> threadCaches =
- new ThreadLocal<Vector<Cache>>()
+ private static final ThreadLocal<List<Cache>> threadCaches =
+ new ThreadLocal<List<Cache>>()
{
-
-
@Override
- protected Vector<Cache> initialValue()
+ protected List<Cache> initialValue()
{
- return new Vector<Cache>();
+ return new ArrayList<Cache>();
}
};
- private static Vector<Cache> allCaches = new Vector<Cache>();
+ private final static List<Cache> allCaches = new ArrayList<Cache>();
/**
* For each thread holds the name of the test class which executed createCache factory method.
@@ -135,14 +132,12 @@
public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
{
+ // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
+// if (!Thread.currentThread().getName().contains("pool"))
+// {
+// System.out.println("CreateCache called from wrong thread: " + Thread.currentThread().getName());
+// }
- 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())
@@ -163,7 +158,7 @@
Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
- Vector<Cache> caches = threadCaches.get();
+ List<Cache> caches = threadCaches.get();
caches.add(cache);
synchronized (allCaches)
@@ -181,7 +176,7 @@
*/
public boolean cleanUp()
{
- Vector<Cache> caches = new Vector<Cache>(threadCaches.get());
+ List<Cache> caches = new ArrayList<Cache>(threadCaches.get());
boolean ret = false;
for (Cache cache : caches)
@@ -195,14 +190,13 @@
public void removeCache(Cache c)
{
- if (!Thread.currentThread().getName().contains("pool"))
- {
- System.out.println("RemoveCache called from wrong thread.");
- //Thread.dumpStack();
- //System.exit(-1);
- }
+ // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
+// if (!Thread.currentThread().getName().contains("pool"))
+// {
+// System.out.println("RemoveCache called from wrong thread.");
+// }
- Vector<Cache> caches = threadCaches.get();
+ List<Cache> caches = threadCaches.get();
synchronized (allCaches)
{
if (caches.contains(c))
@@ -240,7 +234,7 @@
// System.out.println(getThreadId() + " Setting cluster name " + newClusterName);
}
- String testName = extractTestName();
+// String testName = extractTestName();
// prepend test name
/*
@@ -255,8 +249,6 @@
/**
* Updates cluster configuration to ensure mutual thread isolation.
- *
- * @param configuration Configuration to update.
*/
public String mangleClusterConfiguration(String clusterConfig)
{
@@ -299,7 +291,7 @@
m = pattern.matcher(clusterConfig);
if (m.find())
{
- String origPort = m.group().substring(m.group().indexOf("=") + 1);
+// String origPort = m.group().substring(m.group().indexOf("=") + 1);
String newPort = threadMcastPort.get().toString();
// System.out.println(getThreadId() + " Replacing mcast_port " + origPort + " with " + newPort);
clusterConfig = m.replaceFirst("mcast_port=" + newPort);
@@ -308,10 +300,10 @@
return clusterConfig;
}
- private String getThreadId()
- {
- return "[" + Thread.currentThread().getName() + "]";
- }
+// private String getThreadId()
+// {
+// return "[" + Thread.currentThread().getName() + "]";
+// }
private void checkCaches()
{
More information about the jbosscache-commits
mailing list