[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/options ...
Manik Surtani
msurtani at jboss.com
Wed Dec 13 13:15:52 EST 2006
User: msurtani
Date: 06/12/13 13:15:52
Modified: tests/functional/org/jboss/cache/options
FailSilentlyTest.java
Log:
added tests
Revision Changes Path
1.6 +70 -159 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.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- FailSilentlyTest.java 7 Sep 2006 15:42:16 -0000 1.5
+++ FailSilentlyTest.java 13 Dec 2006 18:15:52 -0000 1.6
@@ -39,24 +39,22 @@
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.start();
manager = cache.getTransactionManager();
+ }
- // kill any ongoing tx's.
- if (manager.getTransaction() != null)
+ protected void tearDown()
+ {
+ if (tx != null)
{
try
{
+ manager.resume(tx);
manager.rollback();
}
catch (Exception e)
{
- // do nothing
- }
+ // who cares
}
-
}
-
- protected void tearDown()
- {
if (cache != null)
{
cache.stop();
@@ -66,59 +64,27 @@
public void testPutKeyValue() throws Exception
{
- try
- {
manager.begin();
cache.put(fqn, key, "value");
tx = manager.suspend();
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.put(fqn, key, "value2");
}
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- if (tx != null)
- {
- manager.resume(tx);
- manager.rollback();
- }
- }
- }
public void testPutData() throws Exception
{
- Map data = new HashMap();
+ Map<String, String> data = new HashMap<String, String>();
data.put(key, "value");
- try
- {
manager.begin();
cache.put(fqn, data);
tx = manager.suspend();
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.put(fqn, data);
}
- 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
@@ -127,24 +93,9 @@
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.remove(fqn);
}
- 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
@@ -153,24 +104,9 @@
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.remove(fqn, key);
}
- 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
@@ -179,24 +115,9 @@
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.get(fqn);
}
- 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
@@ -205,24 +126,9 @@
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.get(fqn, key);
}
- 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
@@ -230,18 +136,23 @@
tx = manager.suspend();
cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
cache.getChildrenNames(fqn);
+
}
- 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.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.put(fqn, "x", "y");
+
+ // should not roll back, despite the cache put call failing/timing out.
+ manager.commit();
}
}
More information about the jboss-cvs-commits
mailing list