I'm trying to override a couple of injections for testing with a specific test module. This works fine as is for real singletons like so:
...custom module...
bind(SomeClass.class).toInstance(instanceOfMockedClass);
...
Now this imposes problems when ContextSingletons
need to be overwritten. Doing the same like above obviously injects the same instance for all contexts (services, activities), where a separate instance would have been correct. I tried to wrap my head around the ContextScopedProvider
but couldn't find a way to actually use this in a bind(...).toProvider(...)
construct, as this class itself does not implement Guice's Provider<T>
interface.
How can this be achieved?
(also asked on https://groups.google.com/forum/?fromgroups=#!topic/roboguice/MnWGrHFDOsQ)