我如何为下面的类编写单元测试用例,该类基本上是我们启用了jms的配置类-检查是否创建了bean。
@Configuration
@EnableJms
public class MQConfig {
@Autowired ErrorHandler myErrorHandler;
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() throws JMSException {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setErrorHandler(myErrorHandler);
return factory;
}
@Bean
@Autowired
MQConnectionFactory mqConnectionFactory() throws JMSException {
MQConnectionFactory mqConnectionFactory = new MQConnectionFactory();
// my code for setting connection factory properties
return mqConnectionFactory;
}
@Bean
@Autowired
JmsTemplate jmsTemplate(CachingConnectionFactory mqConnectionFactory) throws JMSException {
JmsTemplate jmsTemplate = new JmsTemplate(mqConnectionFactory);
return jmsTemplate;
}
}