8 Replies Latest reply on May 12, 2008 7:23 PM by Tod Harter

    Recommended testing framework

    Adam Conroy Newbie

      Hi, I have spent the past 2 days implementing Cactus into my JBOSS 4.2.2 server with EJB 3.0 only to find, after much struggling, that it does not support (easily) JBOSS4x nor does it support EJB 3.0, nor even Ant 1.7.

      I've done quite a bit of research that is (hopefully) non-exhaustive. The options I've found to test with are:

      Cactus
      Seam (looks like it uses Cactus, though, is it beefed up for 1.5?)
      J2EEUnit (dead project)
      JBOSS Embedded

      My question is: what is the recommended way to test EJB3's? Ideally, from within a container, though not necessary.

      I'm coming from a Tomcat+Spring+Struts background where we just instantiated the Spring context and let the IoC do its thing and just not commit transactions in integration tests.

      Is there a comparable strategy in a JBOSS4 project? This is a mature product that I am working on so any drastic/large framework changes are out of the question.

      Thank you,
      Adam Conroy

        • 1. Re: Recommended testing framework
          Gerald Quintana Newbie

          I am using Cactus+EJB3+JBoss 4.2 with satisfaction.

          • 2. Re: Recommended testing framework
            Adam Conroy Newbie

             

            "gquintana" wrote:
            I am using Cactus+EJB3+JBoss 4.2 with satisfaction.


            May I ask how? A direct quote from a developer on their mailing list as of July 2007 states that it is not compatible with J2EE 1.5 (http://www.mail-archive.com/cactus-user%40jakarta.apache.org/msg07439.html).

            Jboss4 support seems like they are working on it but still, as of the latest release, it is not truly supported. I set up a custom container in my Ant build...but then I ran into the Ant 1.7 incompatibility. I got around this by running Ant 1.6.5 side by side.

            Do the EJB's 'just work' with the latest version of Cactus or did you have to do some customization? I spent a lot of time setting all of this up and would love to be able to continue down this path but it just seems kind of messy at the moment. The fact that they haven't had a release in a year and a half nor have any nightly builds operating (http://people.apache.org/builds/jakarta-cactus/nightly/) is distressing. Their JIRA also seems inactive, though perhaps they have moved to something else.

            Any guidance would be greatly appreciated. I was just referred to JBoss' Test Suite functionality and will most likely be going down that path, hopefully with some luck.

            Thank you.




            • 3. Re: Recommended testing framework
              Adam Conroy Newbie

              If anyone is curious as to how I ended up, I wrote custom Ant tasks to start and stop JBoss from the jars in the bin directory, on Unix OS's also using ps and kill to make sure that its really dead if the stop script doesn't succeed. I learned how to do this by looking at JBoss' own testsuite scripts.

              For running the tests I have a simple HttpServlet that runs the tests with JUnitCore.runClasses(...) and puts the results on the response in an easy to view HTML table.

              This took me one day and the framework amounts to maybe two pages of code. Really wish I went down this path from the beginning and didn't mess with Cactus for so long.

              • 4. Re: Recommended testing framework
                wayne baylor Apprentice

                junitee.org is another option. you're solution sounds very similar to this project. the only drawback i've found so far is that it uses junit 3.8.

                • 5. Re: Recommended testing framework
                  Adam Conroy Newbie

                  Thanks Wayne, I actually found JUnitEE after getting frustrated with Cactus. As far as I could tell Cactus was actually made by [a] former JUnitEE developer[s]. From the website it appears the last release was in 2004.

                  While not that impressed with the Annotation-based style of JUnit4 (I thought Java was a typed language for a reason? :) I decided to go with it so that was a requirement for me going forward.

                  My home-baked solution is working very well and I like how lightweight it is. I would recommend going down this path to anyone looking for a simple unit testing strategy in JBoss4.x.

                  Regards

                  • 6. Re: Recommended testing framework
                    None Given Newbie

                    I already posted a question regarding this in the beginners section, until I found this thread.

                    Adam, if you're still around, could you tell a bit more specifically how your solution was put together? We've been using embedded JBoss for unit testing so far, but now we are trying to get rid of it.

                    Other solutions would be welcome as well. As Adam pointed out, it seems that JUnitEE is a dead project nowadays. I have found Cactus too, but haven't really checked it out yet.

                    • 7. Re: Recommended testing framework
                      None Given Newbie

                      I just ran into Ejb3Unit, so I think I'll try that first. Does anyone have any experience of this framework?

                      • 8. Re: Recommended testing framework
                        Tod Harter Newbie

                        Heh, JUnitEE may be 'dead' but it works...

                        I even ginned up an Injector, so in my test cases I can use the

                        @EJB

                        and

                        @Resource

                        Annotation ;) In fact I even made annotations for DBunit and one that automagically auths my tests. Now, if only @Interceptors() only worked (at all) I'd be golden...