Author: genman
Date: 2007-08-24 13:12:24 -0400 (Fri, 24 Aug 2007)
New Revision: 4437
Modified:
core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java
core/trunk/src/test/java/org/jboss/cache/VersionConversionTest.java
core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java
core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreference2Readers1WriterLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java
core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.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/SyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java
Log:
Clean up unit test code issues found by "findbugs"
Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2007-08-24 17:11:30 UTC
(rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2007-08-24 17:12:24 UTC
(rev 4437)
@@ -21,12 +21,12 @@
*/
public class CallbackTest extends TestCase
{
- CacheImpl cache = null, cache2;
+ CacheImpl cache = null;
Transaction tx = null;
final Fqn FQN_A = Fqn.fromString("/a");
final Fqn FQN_B = Fqn.fromString("/b");
- final String KEY = "key";
- final String VALUE = "value";
+ static final String KEY = "key";
+ static final String VALUE = "value";
protected void setUp() throws Exception
{
Modified: core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/TreeCacheFunctionalTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -18,13 +18,8 @@
public class TreeCacheFunctionalTest extends TestCase
{
CacheImpl cache = null;
- Transaction tx = null;
final Fqn FQN = Fqn.fromString("/myNode");
- final String KEY = "key";
- final String VALUE = "value";
- Exception ex;
-
protected void setUp() throws Exception
{
super.setUp();
@@ -34,7 +29,6 @@
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
cache.create();
cache.start();
- ex = null;
}
protected void tearDown() throws Exception
@@ -46,10 +40,6 @@
cache.destroy();
cache = null;
}
- if (ex != null)
- {
- throw ex;
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/VersionConversionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/VersionConversionTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/VersionConversionTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -68,22 +68,10 @@
{
short defaultShort = Version.getVersionShort();
String versionString = Version.getVersionString(defaultShort);
- // if the current version is a DR, alpha, beta or RC, then only compare the main
version string.
+ // only compare the main version string.
String versionToCompareAgainst = Version.version;
- String lastElement =
versionToCompareAgainst.substring(versionToCompareAgainst.lastIndexOf('.')+1).toUpperCase();
+ versionToCompareAgainst =
versionToCompareAgainst.replaceAll("[\\-\\.]\\w+$", "");
- if (lastElement.startsWith("GA")
- || lastElement.startsWith("CR")
- || lastElement.startsWith("RC")
- || lastElement.startsWith("DR")
- || lastElement.startsWith("ALPHA")
- || lastElement.startsWith("BETA")
- || lastElement.startsWith("SP"))
- {
- // strip the last element
- versionToCompareAgainst = versionToCompareAgainst.substring(0,
versionToCompareAgainst.lastIndexOf('.'));
- }
-
assertEquals("Round-trip conversion consistent", versionToCompareAgainst,
versionString);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java 2007-08-24 17:11:30 UTC
(rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheSPITest.java 2007-08-24 17:12:24 UTC
(rev 4437)
@@ -78,7 +78,6 @@
public void testIsCoordinator() throws Exception
{
- XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration conf1 =
UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
Configuration conf2 =
UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -7,10 +7,13 @@
package org.jboss.cache.api;
import junit.framework.TestCase;
+
+import org.jboss.cache.CacheException;
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.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -119,15 +122,9 @@
// now make sure a node exists on cache 2
cache[1].getRoot().addChild(A);
- try
- {
- cache[0].move(cache[0].getRoot().getChild(B).getFqn(),
cache[0].getRoot().getChild(A).getFqn());// should throw an NPE
- fail("Expecting an exception");
- }
- catch (Exception e)
- {
- // expected
- }
+ NodeSPI root = cache[0].getRoot();
+ assertNull(root.getChild(A));
+ assertNotNull(root.getChild(B));
}
public void testReplTxCommit() throws Exception
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -10,6 +10,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheImpl;
import org.jboss.cache.misc.TestingUtil;
+import org.jgroups.Address;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -32,10 +33,12 @@
{
if (i != j)
{
- Map groupMap2 = caches[j].getBuddyManager().buddyPool;
+ Map<Address, String> groupMap2 =
caches[j].getBuddyManager().buddyPool;
for (CacheImpl cache : caches)
{
- assertEquals("Comparing contents of cache " + (i + 1) +
" pool map with cache " + (j + 1), groupMap.get(cache), groupMap2.get(cache));
+ Address a = cache.getLocalAddress();
+ assertEquals("Comparing contents of cache " + (i + 1) +
" pool map with cache " + (j + 1),
+ groupMap.get(a), groupMap2.get(a));
}
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -273,14 +273,10 @@
{
assertEquals("value", caches[0].get("/1",
"key"));
}
- catch (Exception e)
+ catch (RuntimeException e)
{
// may barf the first time around since we are unable to contact our buddy and
store this data.
- if (e instanceof RuntimeException)
- {
- assertEquals(IllegalArgumentException.class, e.getCause().getClass());
- }
- else throw e;
+ assertEquals(IllegalArgumentException.class, e.getCause().getClass());
}
// now try the assertion again since the local gravitation would have worked.
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -92,7 +92,7 @@
System.gc();
}
- protected static int VIEW_BLOCK_TIMEOUT = 5000;
+ protected final static int VIEW_BLOCK_TIMEOUT = 5000;
protected CacheImpl createCache(int numBuddies, String buddyPoolName) throws
Exception
{
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -29,7 +29,7 @@
private IpAddress dataOwner;
private List<Address> buddies_localhost, buddies_same_host_different_nic,
buddies_different_hosts;
- protected void setUp()
+ protected void setUp() throws Exception
{
buddies_localhost = new LinkedList<Address>();
buddies_same_host_different_nic = new LinkedList<Address>();
@@ -65,7 +65,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ throw e;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -21,13 +21,13 @@
*/
public class UnitTestCacheConfigurationFactory
{
- public static String JGROUPS_CHANNEL = "udp";//use udp by default
- public static String JGROUPS_STACK_TYPE = "jgroups.stack";
- public static String DEFAULT_CONFIGURATION_FILE =
"META-INF/unit-test-cache-service.xml";
+ public static final String JGROUPS_CHANNEL;
+ public static final String JGROUPS_STACK_TYPE = "jgroups.stack";
+ public static final String DEFAULT_CONFIGURATION_FILE =
"META-INF/unit-test-cache-service.xml";
static
{
- JGROUPS_CHANNEL = System.getProperty(JGROUPS_STACK_TYPE, JGROUPS_CHANNEL);
+ JGROUPS_CHANNEL = System.getProperty(JGROUPS_STACK_TYPE, "udp");
}
public static Configuration createConfiguration(CacheMode mode) throws
ConfigurationException
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -6,31 +6,28 @@
*/
package org.jboss.cache.loader;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheImpl;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.loader.SingletonStoreCacheLoader.PushStateException;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.xml.XmlHelper;
import org.w3c.dom.Element;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
/**
* Unit test class for SingletonStoreCacheLoader
*
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java 2007-08-24 17:11:30
UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java 2007-08-24 17:12:24
UTC (rev 4437)
@@ -19,7 +19,6 @@
public class AcquireAllTest extends TestCase
{
CacheImpl cache = null, cache2;
- Transaction tx = null;
final Fqn FQN = Fqn.fromString("/myNode");
final String KEY = "key";
final String VALUE = "value";
@@ -39,11 +38,6 @@
cache.destroy();
cache = null;
}
- if (tx != null)
- {
- tx.commit();
- tx = null;
- }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreference2Readers1WriterLockTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreference2Readers1WriterLockTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreference2Readers1WriterLockTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -24,7 +24,6 @@
ReentrantReadWriteLock lock;
ReentrantReadWriteLock.ReadLock rl;
ReentrantReadWriteLock.WriteLock wl;
- Exception thread_ex = null;
protected void setUp() throws Exception
{
@@ -32,15 +31,12 @@
lock = new ReentrantReadWriteLock();
rl = lock.readLock();
wl = lock.writeLock();
- thread_ex = null;
}
protected void tearDown() throws Exception
{
super.tearDown();
lock = null;
- if (thread_ex != null)
- throw thread_ex;
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java 2007-08-24 17:11:30
UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java 2007-08-24 17:12:24
UTC (rev 4437)
@@ -31,7 +31,6 @@
{
CacheImpl cache = null;
UserTransaction tx = null;
- Log log;
Properties p = null;
String old_factory = null;
final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
@@ -190,22 +189,4 @@
}
- void log(String msg)
- {
- log.info("-- [" + Thread.currentThread() + "]: " + msg);
- }
-
-
- public static Test suite() throws Exception
- {
- // return getDeploySetup(TxUnitTestCase.class, "cachetest.jar");
- return new TestSuite(UpgradeLockTest.class);
- }
-
- public static void main(String[] args) throws Exception
- {
- junit.textui.TestRunner.run(suite());
- }
-
-
}
Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-08-24 17:11:30 UTC
(rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-08-24 17:12:24 UTC
(rev 4437)
@@ -29,7 +29,8 @@
private static Random random = new Random();
public static final Object ALWAYS_EQUALS_OBJECT = new Object()
{
- public boolean equals()
+ @Override
+ public boolean equals(Object o)
{
return true;
}
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -32,7 +32,6 @@
public class AsyncReplTest extends TestCase
{
CacheImpl cache1, cache2;
- String props = null;
public AsyncReplTest(String name)
{
Modified:
core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/replicated/ReplicationExceptionTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -35,29 +35,9 @@
public class ReplicationExceptionTest extends TestCase
{
CacheImpl cache1, cache2;
- Configuration.CacheMode caching_mode = Configuration.CacheMode.REPL_SYNC;
- final String group_name = "TreeCacheTestGroup";
- String props =
- "UDP(ip_mcast=true;ip_ttl=64;loopback=false;mcast_addr=228.1.2.3;"
+
-
"mcast_port=45566;mcast_recv_buf_size=80000;mcast_send_buf_size=150000;" +
- "ucast_recv_buf_size=80000;ucast_send_buf_size=150000):" +
-
"PING(down_thread=true;num_initial_members=2;timeout=500;up_thread=true):" +
- "MERGE2(max_interval=20000;min_interval=10000):" +
- "FD(down_thread=true;shun=true;up_thread=true):" +
-
"VERIFY_SUSPECT(down_thread=true;timeout=1500;up_thread=true):" +
-
"pbcast.NAKACK(down_thread=true;gc_lag=50;retransmit_timeout=600,1200,2400,4800;"
+
- "up_thread=true):" +
-
"pbcast.STABLE(desired_avg_gossip=20000;down_thread=true;up_thread=true):" +
-
"UNICAST(down_thread=true;min_threshold=10;timeout=600,1200,2400;window_size=100):"
+
- "FRAG(down_thread=true;frag_size=8192;up_thread=true):" +
-
"pbcast.GMS(join_retry_timeout=2000;join_timeout=5000;print_local_addr=true;shun=true):"
+
- "pbcast.STATE_TRANSFER(down_thread=true;up_thread=true)";
-
- final static Log log_ = LogFactory.getLog(ReplicationExceptionTest.class);
+ private final static Log log_ = LogFactory.getLog(ReplicationExceptionTest.class);
String old_factory = null;
final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
- DummyTransactionManager tx_mgr;
- Throwable t1_ex, t2_ex, ex = null;
public ReplicationExceptionTest(String name)
{
@@ -67,10 +47,9 @@
public void setUp() throws Exception
{
super.setUp();
+ log_.debug("setUp " + getName());
old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
- tx_mgr = DummyTransactionManager.getInstance();
- t1_ex = t2_ex = ex = null;
}
public void tearDown() throws Exception
@@ -94,7 +73,6 @@
void initCaches(Configuration.CacheMode caching_mode) throws Exception
{
- this.caching_mode = caching_mode;
cache1 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache2 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
cache1.getConfiguration().setCacheMode(caching_mode);
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/replicated/SyncCacheListenerTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -41,7 +41,7 @@
private CacheImpl cache1, cache2;
private final static Log log_ = LogFactory.getLog(SyncCacheListenerTest.class);
private String old_factory = null;
- private final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
+ private final static String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
public SyncCacheListenerTest(String name)
{
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -52,7 +52,7 @@
private CacheImpl cache2;
private String old_factory = null;
- private final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
+ private final static String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
private Semaphore lock = new Semaphore(1);
private Throwable t1_ex;
private Throwable t2_ex;
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -1,8 +1,14 @@
package org.jboss.cache.statetransfer;
-import junit.framework.Test;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
import junit.framework.TestCase;
-import junit.framework.TestSuite;
+
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -11,12 +17,6 @@
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManager;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-import java.util.Properties;
-
/**
* Tests state transfer while the other node keeps sending transactional, synchronous
method calls
*
@@ -28,7 +28,7 @@
Cache cache1, cache2;
Properties p = null;
String old_factory = null;
- final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
+ static final String FACTORY =
"org.jboss.cache.transaction.DummyContextFactory";
public StateTransferUnderLoadTest(String name)
@@ -189,22 +189,4 @@
}
-
- private static void log(String msg)
- {
- System.out.println(Thread.currentThread().getName() + ": " + msg);
- }
-
-
- public static Test suite() throws Exception
- {
- return new TestSuite(StateTransferUnderLoadTest.class);
- }
-
- public static void main(String[] args) throws Exception
- {
- junit.textui.TestRunner.run(StateTransferUnderLoadTest.suite());
- }
-
-
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java 2007-08-24
17:11:30 UTC (rev 4436)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentBankTest.java 2007-08-24
17:12:24 UTC (rev 4437)
@@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
+import java.util.Random;
import java.util.Set;
/**
@@ -150,6 +151,7 @@
class Teller extends Thread
{
CacheImpl cache;
+ Random r = new Random();
public Teller(String str, CacheImpl cache)
{
@@ -174,9 +176,9 @@
{
if (!again)
{
- src = (int) (Math.random() * count);
- dst = (int) (Math.random() * (count - 1));
- amo = 1 + (int) (Math.random() * 20);
+ src = r.nextInt(count);
+ dst = r.nextInt(count - 1);
+ amo = 1 + r.nextInt(20);
if (dst >= src) dst++;
}