[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/pojo/optimistic ...
Jason Thomas Greene
jgreene at jboss.com
Tue Apr 24 08:46:05 EDT 2007
User: jgreene
Date: 07/04/24 08:46:05
Modified: tests/functional/org/jboss/cache/pojo/optimistic
LocalTxTest.java
Log:
Temporarily fix optimistic test case by using an explicit transaction
Remove plain cache test which is known behavior
Revision Changes Path
1.3 +13 -95 JBossCache/tests/functional/org/jboss/cache/pojo/optimistic/LocalTxTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LocalTxTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/pojo/optimistic/LocalTxTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- LocalTxTest.java 23 Apr 2007 21:19:17 -0000 1.2
+++ LocalTxTest.java 24 Apr 2007 12:46:05 -0000 1.3
@@ -473,10 +473,14 @@
}
};
+ // FIXME - JBCACHE-1034 - This only works with an explicit transaction.
+ UserTransaction tx = getTransaction();
+ tx.begin();
Person p = createPerson("/person/test6", "p6", 50);
List<String> lang = new ArrayList<String>();
lang.add("German");
p.setLanguages(lang);
+ tx.commit();
t1.start();
t2.start();
@@ -486,105 +490,19 @@
// t2 should rollback due to timeout while t2 should succeed
if (t2_ex != null)
- fail("Thread1 failed: " + t2_ex);
- if (t1_ex != null)
- fail("Thread2 failed: " + t1_ex);
-
- int size = ((Person) cache.find("/person/test6")).getLanguages().size();
- assertEquals("number of languages ",
- 2, size);
- }
-
- public void testConcurrentPlainPuts() throws Exception
- {
- final CountDownLatch latch1 = new CountDownLatch(1);
- final CountDownLatch latch2 = new CountDownLatch(1);
- final Cache coreCache = cache.getCache();
-
- Thread t1 = new Thread("t1")
- {
- Transaction tx;
-
- public void run()
- {
- try
- {
- Node child = coreCache.getRoot().getChild(Fqn.fromString("/testing/root"));
- UserTransaction tx = getTransaction();
- tx.begin();
- child.addChild(Fqn.fromString("node1"));
- latch1.countDown();
- latch2.await();
- tx.commit();
- }
- catch (RollbackException rollback)
- {
- ;
- }
- catch (Exception ex)
- {
- t1_ex = ex;
- }
- finally
- {
- latch1.countDown();
- }
- }
- };
-
- Thread t2 = new Thread("t2")
{
- Transaction tx;
-
- public void run()
- {
- UserTransaction tx = null;
- try
- {
- latch1.await();
- Node child = coreCache.getRoot().getChild(Fqn.fromString("/testing/root"));
- tx = getTransaction();
- tx.begin();
- child.addChild(Fqn.fromString("node2"));
- tx.commit();
- }
- catch (RollbackException rollback)
- {
- ;
+ t2_ex.printStackTrace(System.err);
+ fail("Thread2 failed: " + t2_ex);
}
- catch (Exception ex)
- {
- try
- {
- tx.rollback();
- }
- catch (SystemException e)
- {
- e.printStackTrace();
- t2_ex = e;
- }
- }
- finally
+ if (t1_ex != null)
{
- latch2.countDown();
+ t1_ex.printStackTrace(System.err);
+ fail("Thread1 failed: " + t1_ex);
}
- }
- };
-
- Node child = coreCache.getRoot().addChild(Fqn.fromString("/testing/root"));
- t1.start();
- t2.start();
-
- t1.join();
- t2.join();
- // t2 should rollback due to timeout while t2 should succeed
- if (t2_ex != null)
- fail("Thread1 failed: " + t2_ex);
- if (t1_ex != null)
- fail("Thread2 failed: " + t1_ex);
-
- assertEquals("There should be one entry", 1, child.getChildren().size());
+ int size = ((Person) cache.find("/person/test6")).getLanguages().size();
+ assertEquals("number of languages ",
+ 2, size);
}
void log(String s)
More information about the jboss-cvs-commits
mailing list