2
我正在使用基于java的配置的弹簧引导。我有以下课程结构Spring引导集成测试通过自动注入注入模拟对象
@Service
public class Service implements IService{
@autowire
private IProcessor processor;
public void perform(Parameter param){
processor.process(param);
}
}
@Service
public class Processor implements IProcessor {
@autowire
private ProxyFactory factory;
public void process(Parameter param){
final ExternalSysProxy proxy = factory.get(param.getValue(), param.getId());
proxy.call();
}
}
@Repository
public class ProxyFactory {
public Proxy get(String value, String id){
final ExternalSysProxy proxy = new proxy(value, id);
return proxy;
}
}
这里的代理对象调用外部系统。我想通过模仿代理对象来编写集成测试。你能给我一些指导,我可以如何在这个结构中注入模拟代理对象。
怎么能我在我的Processor类中注入了ProxyFactory的模拟,因为ProxyFactory在春天被自动发现并注入了 – amique 2015-02-24 07:49:29
我用一个示例编辑了我的答案。 – 2015-02-24 11:29:22