On Jan 21, 2010, at 8:36 PM, Luis Fernando Planella Gonzalez wrote:

Well, seems this first part was not hard at all.
I've attached a patch on https://issues.apache.org/jira/browse/OPENEJB-1165
Included the AsynchronousRunner and AsynchronousRunnerTest.

That's great!  All committed!

We'll need to get those Thread.sleeps out of there. There are some cool java.util.concurrent classes we can which are actually easier once you get the hang of them. The one I use most for testing multithreaded code is java.util.concurrent.CountDownLatch.

In your test case you could construct a "CountDownLatch latch = new CountDownLatch(1)" and pass that instance to your asynchronous method so both the test case and the target method have a reference to the same latch. The method will just call latch.await() which will cause the asynch thread to pause. Then in your test case you can test the 'isDone' logic on your future, then call latch.countDown() which will cause the asynch thread to resume and complete, then you can test your 'isDone' 'true' logic. Best to call get() on the future before calling isDone() or isDone() could return false.

Aside from the test case, the next step is updating the descriptor reading code[1] so that it can handle the new async method related ejb- jar.xml syntax [2].

1. container/openejb-jee/src/main/java/org/apache/openejb/jee/ SessionBean.java
 2. http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd

There's a test case[3] that reads in a sample ejb-jar.xml file[4]. It should be fairly easy to update the ejb-jar.xml file to have a few of the new async elements so that you can verify the reading/writing works fine.

3. container/openejb-jee/src/test/java/org/apache/openejb/jee/ JeeTest.java
 4. container/openejb-jee/src/test/resources/ejb-jar-example1.xml


-David

Reply via email to