stackoverflowmailer / guiceberry

Automatically exported from code.google.com/p/guiceberry
Apache License 2.0
0 stars 0 forks source link

Cannot add @TestScoped to @Provides methods in module #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a @Provides method to a module.
2. Try to add @TestScoped to make that provision test scoped.
3. Will not compile, because annotation not allowed on method.

What is the expected output? What do you see instead?
Expected to be able to define a @Provides method in a test scope.

What version of the product are you using? On what operating system?
Trunk version of GuiceBerry, Guice snapshot 20080909.

Please provide any additional information below.
Attached is a patch to allow @TestScoped to be applied to methods, and an 
Eclipse project showing this binding used in a GuiceBerry test.

Original issue reported on code.google.com by lazer...@gmail.com on 31 Oct 2008 at 12:06

Attachments:

GoogleCodeExporter commented 9 years ago
I'll fix this problem (provider method did not exist when I first wrote the
@TestScoped annotation). Til then, you can work around this in your "bind" 
statement
instead of the provides method:

bind(Foo.class).to(Bar.class).in(TestScoped.class)

Original comment by zorze...@gmail.com on 12 Nov 2008 at 4:06

GoogleCodeExporter commented 9 years ago
More precisely, the workaround is to create a Provider class and

bind(Foo.class).toProvider(FooProvider.class).in(TestScoped);

(i.e. not use, for this one binding, a provider method). The truth is that 
provider
methods are not yet "officially released"... Guice 2.0 is coming in a couple of
months, I think.

Anyway I'll release the "fix" soon.

Original comment by zorze...@gmail.com on 12 Nov 2008 at 5:00

GoogleCodeExporter commented 9 years ago
Fixed in release 1.2.3

Original comment by zorze...@gmail.com on 22 Jan 2009 at 5:45