Hello,

I'm using JBoss 3.2.1, the 1.4.2 Sun JDK on Mandrake Linux 9.1.

I have some test classes that need to send messages on a JMS queue and expect an answer on another queue. I also read some information from a database that I use to build the messages (namely, it's a getter method). Now, I cannot send the messages on the first queue and then use a blocking receive() to wait for replies, because that would cause an application deadlock. The cause for the deadlock, as far as I could understand, was that the testXXX method that would send the message was wrapped in a transaction (the test class inherits from EJBTestCase from JUnitEJB, which wraps all calls to testXXX methods, together with the setUp and tearDown methods, in a single transaction). When a MDB of mine would also need to read the info from the database, there would be a problem, because the first transaction wouldn't have committed yet (it would commit when receiving the message). The test class wasn't modifying the database, it would just look up a value (using a findByName method), so the situation was rather stupid. That's how the method is defined in the module ejb-jar.xml:

           <query-method>
              <method-name>findByName</method-name>
              <method-params>
                       <method-param>java.lang.String</method-param>
              </method-params>
           </query-method>
           <ejb-ql><![CDATA[
              SELECT OBJECT(c)
              FROM Profile c
              WHERE c.name=?1

           ]]></ejb-ql>
        </query>

And in my test class I do something like this:

        pHome = (ProfileHome) jndi.lookup ("ca/ProfileEJB");
        Profile profile = null;
        try {
           profile = (Profile) pHome.findByName("CA_Cert").toArray() [0];
        }
        catch (javax.ejb.FinderException fe) {
           throw new RuntimeException (fe);
        }
        profileId = profile.getValueObject().id;

For now I've made this go away by making the test class inherit from MessageListener and make it listen for replies, but this is kind of ugly since JUnit reports success when sending the message has completed, and it also makes it hard to have more than one test method in that class. How can I solve this? I think there was something on setting certain methods read-only on the O'Reilly site, but I don't have the link anymore. What would be a good way to run these kinds of tests? Would altering method settings for the findByName method suffice?



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to