Author: mircea.markus
Date: 2008-11-19 11:15:50 -0500 (Wed, 19 Nov 2008)
New Revision: 7167
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.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/lock/LockReleaseTest.java
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
Log:
fix tests
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-11-19
15:44:21 UTC (rev 7166)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-11-19
16:15:50 UTC (rev 7167)
@@ -286,7 +286,7 @@
catch (Throwable t)
{
retval = false;
- log.error("beforeCompletion() failed for " + s, t);
+ log.info("beforeCompletion() failed for " + s, t);
}
}
return retval;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-11-19
15:44:21 UTC (rev 7166)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-11-19
16:15:50 UTC (rev 7167)
@@ -53,10 +53,10 @@
public void testSetGetBatchInfo()
{
Properties props = new Properties();
- props.put("ache.jdbc.table.name","jbosscache" +
TestingUtil.getThreadId());
+ props.put("ache.jdbc.table.name","jbosscache");
props.put("cache.jdbc.table.create", "true");
props.put("cache.jdbc.table.drop","true");
- props.put("cache.jdbc.table.primarykey","jbosscache_pk" +
TestingUtil.getThreadId());
+ props.put("cache.jdbc.table.primarykey","jbosscache_pk");
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-11-19
15:44:21 UTC (rev 7166)
+++
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-11-19
16:15:50 UTC (rev 7167)
@@ -8,8 +8,11 @@
import org.testng.annotations.Test;
import java.sql.Connection;
+import java.util.Properties;
+
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.TestDbPropertiesFactory;
/**
* To test the closing of JDBC connections
@@ -22,23 +25,9 @@
@BeforeMethod
public void setUp() throws Exception
{
- String props = "
cache.jdbc.table.name=jbosscache_engine_cache\n" +
- " cache.jdbc.table.create=true\n" +
- " cache.jdbc.table.drop=true\n" +
- "
cache.jdbc.table.primarykey=jbosscache_engine_cache_pk\n" +
- " cache.jdbc.fqn.column=fqn\n" +
- " cache.jdbc.fqn.type=varchar(255)\n" +
- " cache.jdbc.node.column=node\n" +
- " cache.jdbc.node.type=blob\n" +
- " cache.jdbc.parent.column=parent\n" +
- " cache.jdbc.sql-concat=1 || 2\n" +
- "
cache.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver\n" +
- "
cache.jdbc.url=jdbc:derby:jbossdb;create=true\n" +
- " cache.jdbc.user=user1\n" +
- " cache.jdbc.password=user1";
-
+ Properties props = TestDbPropertiesFactory.getTestDbProperties();
cache = new UnitTestCacheFactory<Object, Object>().createCache(false);
-
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
JDBCCacheLoader.class.getName(), props, false, false, true, false));
+
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
JDBCCacheLoader.class.getName(), props, false, false, true));
cache.start();
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-11-19 15:44:21
UTC (rev 7166)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-11-19 16:15:50
UTC (rev 7167)
@@ -237,7 +237,6 @@
/**
* Tests that when an acquisition timeout occurs locks are being released.
*/
- @Test(invocationCount = 10)
public void testNodeReleaseOnAcquisitionTimeout() throws Exception
{
cache = createCache(IsolationLevel.REPEATABLE_READ);
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-11-19
15:44:21 UTC (rev 7166)
+++
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2008-11-19
16:15:50 UTC (rev 7167)
@@ -498,7 +498,7 @@
public void testRemoveKeyViaNodeAPI() throws Exception
{
// put some stuff in the cache first
- replListener2.expect(PutKeyValueCommand.class);
+ replListener2.expect(PutDataMapCommand.class, PutKeyValueCommand.class);
Node node1 = root1.addChild(fqn);
cache1.getInvocationContext().setOptionOverrides(null);
node1.put(key, "value");
@@ -676,7 +676,10 @@
public void testTransactionalBehaviourViaNodeAPI() throws Exception
{
+ replListener2.expect(PutDataMapCommand.class);
Node node1 = root1.addChild(fqn);
+ replListener2.waitForReplicationToOccur();
+
replListener2.expectWithTx(PutKeyValueCommand.class);
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
@@ -722,7 +725,10 @@
}
// now cache2
+ replListener1.expect(PutDataMapCommand.class);
Node node2 = root2.addChild(fqn);
+ replListener1.waitForReplicationToOccur();
+
mgr = cache2.getTransactionManager();
replListener1.expectWithTx(PutKeyValueCommand.class);
mgr.begin();
Modified: core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-11-19
15:44:21 UTC (rev 7166)
+++ core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-11-19
16:15:50 UTC (rev 7167)
@@ -1,6 +1,7 @@
package org.jboss.cache.util;
import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.IOException;
@@ -12,7 +13,7 @@
{
private static final Properties realProps = new Properties();
- private static int userIndex;
+ private static AtomicInteger userIndex = new AtomicInteger(0);
static {
//so that all individual databases are created here
@@ -43,7 +44,7 @@
Matcher matcher = pattern.matcher(jdbcUrl);
boolean found = matcher.find();
assert found;
- String newJdbcUrl = matcher.replaceFirst("jbossdb" + userIndex++);
+ String newJdbcUrl = matcher.replaceFirst("jbossdb" +
userIndex.incrementAndGet());
System.out.println("newJdbcUrl = " + newJdbcUrl);
toReturn.put("cache.jdbc.url", newJdbcUrl);
return toReturn;
@@ -53,7 +54,7 @@
{
Properties toReturn = (Properties) realProps.clone();
String tableName = toReturn.getProperty("cache.jdbc.table.name");
- int currentIndex = userIndex++;
+ int currentIndex = userIndex.incrementAndGet();
toReturn.setProperty("cache.jdbc.table.name", tableName + currentIndex);
String pk = toReturn.getProperty("cache.jdbc.table.primarykey");
toReturn.setProperty("cache.jdbc.table.primarykey", pk + currentIndex);