Sorry, here's a less nonsensical test case:

    
    static class Foo { 
        public Bar bar;
        Foo(Bar bar) { this.bar = bar; }
    }
    
    static class Bar {  }
    
    static class FooProvider implements Provider<Foo> {
        @Inject(optional=true) public Bar bar;
        public Foo get() {
            return new Foo(bar);
        }
    }
    
    @Test
    public void test() throws Exception {
        Injector i = Guice.createInjector(new PrivateModule() {
            @Override
            protected void configure() {
                bind(Bar.class);
                bind(Foo.class).toProvider(FooProvider.class);
                expose(Foo.class);
            }
        });
        Foo foo = i.getInstance(Foo.class);
        assertTrue(foo.bar != null);
    }

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/Sx5F21B0facJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to