On Tue, Oct 09, 2012 at 04:38:21PM -0400, Mark H. Wood wrote:
> I'm trying to test a subclass of IdentifierProvider. I finally
> realized, duuh, of course the provider isn't getting
> configurationService injected if I just write "new
> BlahIdentifierProvider()" in the test; one has to get the correct
> instance from the ApplicationContext. But, how? Spring doesn't get
> fired up until we are deep in DSpaceKernel, courtesy of
> AbstractUnitTest. So the test itself is outside the DI container.
Obvious answer: tuck the test inside the container.
Least-invasive way: mark such a test:
and inject a reference to the ApplicationContext somehow. Dunno if
implementing ApplicationContextAware would work in this case. Anyway
it feels like bending things to make them fit.
A more rugged approach: get the ApplicationContext from the kernel.
DSpaceServiceManager could grow a method to return the value of
primaryServiceManager. Then ask that for its ApplicationContext. But
this requires augmenting DSpaceServiceManager.
Mark H. Wood, Lead System Programmer mwood@...
Asking whether markets are efficient is like asking whether people are smart.