我正在尝试编写一个使用我创建的 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
它为空,但是我没有收到任何其他错误或警告。怎么了?