cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daan Hoogland <daan.hoogl...@gmail.com>
Subject Re: Ask about 'Failed to load ApplicationContext' in unit tests during maven building
Date Tue, 03 Dec 2013 10:26:40 GMT
On Mon, Dec 2, 2013 at 5:26 PM, Alex Ough <alex.ough@sungard.com> wrote:
> can you give me some light on this?


I hope so Alex,

In general I would advice to minimize the use of dao's if there is a
manager for the type of object; i.e. do your coding inside AccountMgr
and call its methods instead of calling dao's

> Basically, I'd like use 'DomainDao/AccountDao/UserDao' and/or 'AccountMgr/DomainMgr'
by 'Injecting' them in


You say that the problem is in the main program not in the test and
this might be true but in the case of spring this may have a third
possibility. Spring usus a combination of annotations, reflection and
configuration to arrange for dependency injection (or inversion of
control). The @inject that causes the problem might indeed be in the
main program, but there also needs to be a spring context file, which
might be different for the program and its tests. In this way you can
easily inject mock object for use in test where heavy dependencies
would have been injected at runtime.

There are a lot of example context files for tests laying around. for
instance CreateNetworkOfferingTest.java
CreatePrivateNetworkTest.java is an example that uses only mock objects.


hope this helps,
Daan

Mime
View raw message