class Test extends junit.framework.TestCase {@Inject Repo repo;setUp() {...AutoTearDownGuiceBerry.setUp(this, TestEnv.class);...}test() {...// run X in a new thread...}}
class X {@Inject Repo repo;doStuff () {// do something with repo.}}
It's sometimes desirable to get ahold of your server injector's
bindings from your tests -- and, if server and test run in the same
JVM it's also quite easy to do so. I will eventually write about how
to do it elegantly, but, if you want to just hack it, store your
server injector in a public static Injector SERVER_INJECTOR variable
somewhere, and, from your tests, do
SERVER_INJECTOR.getInstance(Foo.class). Again, there are more elegant
ways of doing it...
Note: you *may* have a single injector (the GuiceBerry-created one),
but I won't really describe here how to do it -- you either know how,
or you probably don't want to...
Peace,
Z
> --
> You received this message because you are subscribed to the Google Groups
> "guiceberry-users" group.
> To post to this group, send email to guiceber...@googlegroups.com.
> To unsubscribe from this group, send email to
> guiceberry-use...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/guiceberry-users?hl=en.
>