OK, so I figured out a way that works for me. One thing that threw me off was the swapping of the bind().to()
from Guice to HK2. In Guice, you write:
bind(Abstract.class).to(Concrete.class)
Where as in HK2, you write:
bind(Concrete.class).to(Abstract.class)
The way to get the provides behaviour can be achieved with the following code:
public class MyResourceIT extends JerseyTest {
@Override
protected Application configure() {
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(MyResource.class);
resourceConfig.register(new AbstractBinder() {
@Override
protected void configure() {
bind(provideMyDaoMock()).to(MyDao.class);
}
private MyDao provideMyDaoMock() {
MyDao myDaoMock = mock(MyDao.class);
return myDaoMock;
}
});
return resourceConfig;
}
}