Mantis - Resin
Viewing Issue Advanced Details
3741 minor always 11-04-09 10:21 01-11-10 10:01
ferg  
 
normal  
closed 4.0.2  
fixed  
none    
none 4.0.4  
0003741: CanDI in unit tests
(rep by Paul Campbell)

he problem with J2EE DI is that its very difficult to use any DI in unit tests because you have to run the container or something that emulates it (and as someone already mentioned, testing in the real environment is preferable to emulation).

Spring still has the drop here because you can selectively load only parts of your DI config and because it follows the library model i.e. it doesn't take away control over execution of code. Even when your only using partial configs in this way you are still testing very much against the "real thing" so behavior is very unlikely to change when you come to run your code in a web server.

So in a nutshell the practical annoyances with J2EE are more to do with the whole "container" idea than the semantics of the DI spec. Its all very well being able to inject POJOS but it isn't a great help if you cant do it in your junit tests IMO.

Notes
(0004378)
ferg   
01-11-10 10:01   
server/1e9- support/0410

The com.caucho.resin.ResinContext and @RunWith(ResinJUnitRunner.class) in Resin 4.0.4 will provide this capability.