【发布时间】:2014-08-07 09:08:28
【问题描述】:
需要模拟 JmsTemplate 以在我的应用程序中进行集成测试。
在我的 appcontext.xml 中
<bean id="core_connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="core_jndiTemplate" />
</property>
<property name="jndiName">
<value>ConnectionFactory</value>
</property>
</bean>
<bean id="core_jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="core_connectionFactory" />
<property name="defaultDestination" ref="core_destination" />
</bean>
<bean id="core_destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="core_jndiTemplate" />
</property>
<property name="jndiName">
<value>queue/CoreQueue</value>
</property>
</bean>
需要在我的 testcontext.xml 中模拟 jmstemplete。 提前致谢。
【问题讨论】:
-
core_jmsTemplate 不在任何地方使用 - 对吗?我认为没有必要嘲笑。不过,您可以使用 Spring 配置文件来根据活动配置文件创建一个或另一个 bean。
-
我在 test-context.xml 中导入 app-context.xml,所以需要初始化。
标签: java spring spring-jms springmockito