我无法嘲笑ApplicationContext。
private CommonAppContextProvider commonAppContextProvider;
ApplicationContext applicationContext = mock(ApplicationContext.class);
when(commonAppContextProvider.getApplicationContext()).thenReturn(applicationContext);
when(applicationContext.getBean("queueTemplate")).thenReturn(jmsTemplate);
我要测试的代码
JmsTemplate jmsTemplate = (JmsTemplate) CommonAppContextProvider.getApplicationContext()
.getBean("queueTemplate");