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:

  @Configurable("blah")

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   [email protected]
Asking whether markets are efficient is like asking whether people are smart.

Attachment: pgpv3HMLrPdpb.pgp
Description: PGP signature

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to