Open GoogleCodeExporter opened 8 years ago
Interesting. Yeah, this is a gap on the Spring side that doesn't exist on the
Guice
side, and it should definitely be closed.
I'd very much like to see your solution. Can you attach a patch and maybe a
sample
test so I can see what you've done?
Original comment by logan.jo...@gmail.com
on 9 Jan 2008 at 5:35
This is the code that makes it:
- a small modification to SpringContainer
- the new ContextInstance annotation
- a new Exception: TooManyContextInstancesException (only 1
ContextInstance-annotated field should exist, maybe it's not necessary...)
I don't have a simple and complete test sample available right now (I use
several
base test classes)
but I provide a modification of the mentioned Arenalist base test class for
Struts 2
(StrutsTestBase.java).
Original comment by migueldi...@gmail.com
on 9 Jan 2008 at 5:51
Attachments:
Thanks, I'll go through it in depth as soon as possible.
One thing that comes to mind immediately, though: Is the annotation really
necessary, or is it reasonable for AtUnit to just look for a field with a type
that
isAssignableFrom(ApplicationContext.class) and inject its context there?
Original comment by logan.jo...@gmail.com
on 9 Jan 2008 at 6:02
Yes, it could be done looking directly for a suitable field to be injected. I'm
just
preventing an scenario where the unit test has more than one such field.
I suppose that scenario would be very rare... but it's always better to be
cautious.
An intermediate way to simplify things would be to search for the suitable
fields and
choose the one that is annotated in case more than one exists.
Original comment by migueldi...@gmail.com
on 9 Jan 2008 at 6:20
Here is a version that doesn't require to annotate the spring context field,
alongside with the updated SpringContainer tests.
I've renamed @ContextInstance to @InjectedContext since it's more explanatory.
I'm not sure if the TooManyContextInstancesException name and package (it may be
better located in atunit.spring) are the best choice...
Original comment by migueldi...@gmail.com
on 10 Jan 2008 at 10:09
Attachments:
Original issue reported on code.google.com by
migueldi...@gmail.com
on 9 Jan 2008 at 5:23