0
我有下面的代码动态依赖我的班内注射弹簧
public void startListeners() throws Exception {
List<QueueConfiguration> queueConfigs = queueConfigResolver.getQueueConfigurations();
for(QueueConfiguration queueConfig : queueConfigs){
//TODO : work on this make it more testable
ICustomListener readerListener = new MyCustomListener(queueConfig);
readerListeners.add(readerListener);
readerListener.start();
}
}
我使用Spring依赖注入(在此情况下,但总体来说)。现在这个代码有两个问题。
- 我不能为每个创建的侦听器进行模拟,而进行测试。
- 我不想使用ApplicationContext.getBean(),因为它会有相同的影响。 AFAIK春天不能动态地做到这一点,但任何其他指针?
你能解释一下更详细一点你想测试什么吗?队列配置或侦听器?为什么你不想完全使用applicationcontext.getbean? Spring不能动态地做什么。这种情况下动态的意思是什么? – Omnaest 2011-06-15 17:19:33