[ajug-members] Opinions on a project re-write - To EJB3 or Not

Thomas, Dave dthomas at tandbergtv.com
Fri May 30 11:31:57 EDT 2008


Excellent point.  You're absolutely right that for the sake of unit testing, objects are POJOs.  Out of the container, the annotations are just ignored; dependency injection doesn't occur.

For me, it's integration testing in EJB3 that has a longer edit-compile-debug cycle is longer than Spring.  At least until I got my testing frameworks organized in a way that wasn't realistic with EJB2.

First, let me ask a question for other agile folks.  Let's say I want to test everything that can possibly break:
> @Stateless
> public class SimpleStatelessSessionBean implements
> SimpleStatelessSessionRemote {
>     public int add(int first, int second) {
>         return first + second;
>     }
> }
Should I take the time to test trivial methods?  If so, how could "return first+second" possibly break?  I'd really like opinions on this.

In practice, and this is just me probably doing something wrong, I'd exercise this code with an integration (not unit) test that tests whatever nontrivial method is coupled to this.  That way the code is exercised, and I feel like I'm effectively prioritizing my time.  The most effective use of integration tests I've found is doing test-first on DAOs that have really complicated SQL.

This exposes a few issues.

First, maybe I'm not as agile as I should be.  But this balance is how I produce my highest quality my highest velocity.

Second, if you accept you sometimes test classes that have some kind of coupling, how do you wire objects together?  

In spring, I would have made another spring xml file (often cut-and-paste which is a maintenance hassle).  

Now that I do EJB3, I write code to wire the objects together (you can do with Spring too) or do a JNDI lookup to a running container (if all goes well, works the same on my dev station and the integration server).  Now it's down to what's faster: spring loading an XML or Jboss redeploying/restarting?

You can do injection with EJB3Unit, so maybe there's something there that I need to learn which matches or even improves on the spring way of testing that was so nice.

People exposed to Spring may expect to be spoiled enough to have something to complain about EJB3.  As far as I can tell, they are both great improvements from what existed before, they're both going to do what you want, and there's no clear winner.  Choose your poison.  


Dave
**********************************************************************

This email, its content and any attachments is PRIVATE AND 
CONFIDENTIAL to TANDBERG Television, Part of the Ericsson Group. 
If received in error please notify the sender and destroy the original 
message and attachments.

www.tandbergtv.com
**********************************************************************



More information about the ajug-members mailing list