标签:gpo use init post process before learning resource learn
转自 http://keeplearning.blog.51cto.com/6527662/1185751 感谢作者
PushMsgPostProcessorImpl是要测试的类,它有两个注解注入的类变量如下:
@Resource
private IMsgToUserService msgToUserService;
@Resource
private IPushMsgTaskLogService pushMsgTaskLogService;
则测试类中可以使用下面的方法注入
@Mock
private IMsgToUserService msgToUserService;
@Mock
private IPushMsgTaskLogService pushMsgTaskLogService;
private IPushMsgPostProcessor pushMsgPostProcessor;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
pushMsgPostProcessor = new PushMsgPostProcessorImpl();
ReflectionTestUtils.setField(pushMsgPostProcessor, "msgToUserService", msgToUserService);
ReflectionTestUtils.setField(pushMsgPostProcessor, "pushMsgTaskLogService", pushMsgTaskLogService);
}
标签:gpo use init post process before learning resource learn
原文地址:http://www.cnblogs.com/juniorMa/p/7475106.html