Search code examples
javadependency-injectionejb-3.0struts-1

Solution to dependency injection in ANT and EJB 3.0 for unit testing


I'm not a very experienced software engineer. We have a very large application that consists of 40 plus projects. We use EJB 3.0, Struts 1 framework.

Right now, we have issue unit testing Service layers having dependency on more than one beans. Because we can only inject one of them without a running server due to not having a container.

I've read that EJB3.1 does not have this issue. What changes in EJB3.1 has made it immune to this problem?

Also if you can direct me to a work around or a solution, I'd really appreciate it.

Another solution is to move from ANT to Maven, but I read in another question that it's not a good idea for very big projects like ours.

So my questions are:

  1. Is there absolutely no solution to this?
  2. What makes this dependency injection issue for unit testing work in Spring and Maven?

If giving multiple solutions, would appreciate it if you could also tell the scope of the changes required for the solution and effort it requires in phases of the project in general (analysis, design, testing, implementation, etc.)


Solution

  • Maven is definitely better than ant, and well used for big projects.

    You can mock in dependencies, during unit tests.

    EJB3.1 provides an embeddable container, which makes it easy to perform integration tests.