[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/options ...
Manik Surtani
msurtani at jboss.com
Wed Dec 13 13:07:44 EST 2006
User: msurtani
Date: 06/12/13 13:07:44
Modified: tests/functional/org/jboss/cache/options Tag:
Branch_JBossCache_1_4_0 FailSilentlyTest.java
Log:
Added further tests
Revision Changes Path
No revision
No revision
1.2.4.1 +130 -208 JBossCache/tests/functional/org/jboss/cache/options/FailSilentlyTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FailSilentlyTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/options/FailSilentlyTest.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -b -r1.2 -r1.2.4.1
--- FailSilentlyTest.java 28 Nov 2005 15:55:59 -0000 1.2
+++ FailSilentlyTest.java 13 Dec 2006 18:07:44 -0000 1.2.4.1
@@ -7,14 +7,14 @@
package org.jboss.cache.options;
import junit.framework.TestCase;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Option;
-import javax.transaction.TransactionManager;
import javax.transaction.Transaction;
-import java.util.Map;
+import javax.transaction.TransactionManager;
import java.util.HashMap;
+import java.util.Map;
/**
* Tests passing in the failSilently option in various scenarios.
@@ -42,11 +42,23 @@
manager = cache.getTransactionManager();
failSilently = new Option();
- failSilently.setFailSilently( true );
+ failSilently.setFailSilently(true);
}
protected void tearDown()
{
+ if (tx != null)
+ {
+ try
+ {
+ manager.resume(tx);
+ manager.rollback();
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
if (cache != null)
{
cache.stopService();
@@ -56,58 +68,25 @@
public void testPutKeyValue() throws Exception
{
- try
- {
manager.begin();
cache.put(fqn, key, "value");
tx = manager.suspend();
cache.put(fqn, key, "value2", failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
public void testPutData() throws Exception
{
Map data = new HashMap();
data.put(key, "value");
- try
- {
manager.begin();
cache.put(fqn, data);
tx = manager.suspend();
cache.put(fqn, data, failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
-
public void testRemoveNode() throws Exception
{
- try
- {
cache.put(fqn, key, "value");
manager.begin();
// get a read lock
@@ -115,24 +94,9 @@
tx = manager.suspend();
cache.remove(fqn, failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
public void testRemoveKey() throws Exception
{
- try
- {
cache.put(fqn, key, "value");
manager.begin();
// get a read lock
@@ -140,24 +104,9 @@
tx = manager.suspend();
cache.remove(fqn, key, failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
public void testGetNode() throws Exception
{
- try
- {
cache.put(fqn, key, "value");
manager.begin();
// get a WL
@@ -165,24 +114,9 @@
tx = manager.suspend();
cache.get(fqn, failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
public void testGetKey() throws Exception
{
- try
- {
cache.put(fqn, key, "value");
manager.begin();
// get a WL
@@ -190,24 +124,9 @@
tx = manager.suspend();
cache.get(fqn, key, failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
public void testGetChildrenNames() throws Exception
{
- try
- {
cache.put(fqn, key, "value");
manager.begin();
// get a WL
@@ -215,17 +134,20 @@
tx = manager.suspend();
cache.getChildrenNames(fqn, failSilently);
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
+
+ public void testPutThatWillFail() throws Exception
{
- manager.resume(tx);
- manager.rollback();
- }
- }
+ manager.begin();
+ cache.put(fqn, "k", "v"); // this will get WLs on / and /a
+ tx = manager.suspend();
+
+ assertEquals(2, cache.getNumberOfLocksHeld());
+
+ // now this call WILL fail, but should fail silently - i.e., not roll back.
+ manager.begin();
+ cache.put(fqn, "x", "y", failSilently);
+
+ // should not roll back, despite the cache put call failing/timing out.
+ manager.commit();
}
}
More information about the jboss-cvs-commits
mailing list