Hi All,
I can't figure out why this simple test case fails.
Basically, when using com.google.inject.Inject - injection actually
occurs but when using javax.inject.Inject - no injection.
Using guice r1189 from SVN and 5.14 TestNG (though same test with
JUnit works as expected).
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
public class TestGuice {
@Inject
private Interface interf;
@javax.inject.Inject
private Interface interf2;
@BeforeClass
public void setUp() throws ClassNotFoundException {
Injector i = Guice.createInjector(new AbstractModule() {
protected void configure() {
bind(Interface.class).to(Implementation.class).asEagerSingleton();
}
});
i.injectMembers(this);
}
@Test
public void testInsertion() {
Assert.assertNotNull(interf); //pass
Assert.assertNotNull(interf2); //here fails
}
}
interface Interface {}
class Implementation implements Interface {}
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
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.