我正在尝试使用我创建的GIN工厂编写Jukito测试。
我的工厂看起来像这样:
public interface ClientFactory {
public DOMModel create(Entity ref);
}
我将它绑定在我的gin模块中,如下所示:
public class ClientModule extends AbstractGinModule {
@Override
protected void configure() {
install(new GinFactoryModuleBuilder().build(ClientFactory.class));
}
}
DOMModel看起来像这样:
public class DOMModel {
...
@Inject
public DOMModel(CollabClientFactory collabFactory, @Assisted Entity ref, @Assisted Document domDoc){
this.colabClient = collabFactory.create("DOMMODEL:"+ref.getID(), "com.server.impl.DOMCollabSite.java", collaborator);
}
...
}
然后我的测试看起来像这样:
@RunWith(JukitoRunner.class)
public class Test {
public static class Module extends JukitoModule {
protected void configureTest() {
install(new GinModuleAdapter(new ClientModule()));
}
}
@Inject
ClientFactory modelFactory;
@Test
public void testSimple() throws Exception{
Entity entity = new Entity(){
@Override
public String getID() {
return "someID";
}
};
DOMModel model1 = modelFactory.create(entity);
assertNotNull(model1);
}
}
此测试失败,因为model1
为空,但我没有得到任何其他错误或警告。有什么问题?