Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sisu-users] InjectedTest access injector

On 20 Feb 2014, at 14:00, David Anthony Troiano <dtroiano@xxxxxxxxxxxxx> wrote:

I tried that but Guice complained, saying: ""Binding to core guice framework type is not allowed: Injector."

How/where are you injecting it in the testcase?  BTW, the other option is to use lookup(Injector.class)

On Thu, Feb 20, 2014 at 8:58 AM, Benson Margulies <benson@xxxxxxxxxxxxx> wrote:
Inject it!

On February 20, 2014 8:56:51 AM EST, David Anthony Troiano <dtroiano@xxxxxxxxxxxxx> wrote:
Hello,

I'm extending Sisu's InjectedTest class and adding bindings into the configure(Binder binder) method so that my tests can just inject and be happy.  One of my components is a web service that uses Guiced servlets as described here, which requires that you expose the injector to the servlet context.  I'd like the injector created in my InjectedTest class to flow into my GuiceServletContextListener so that it can access test-specific config that gets injected.

So, to make this work, I had to override InjectedTest.setup() and copy InjectedTest.SetupModule so that I could expose the injector.

It works but I'm wondering if there's a better way to get my hands on the injector.

Thanks,
Dave


Back to the top