如何在spring中为@Lookup注释注入mock

时间:2015-12-07 12:43:06

标签: java spring unit-testing mockito

@Component
public class SomeFactory implements ISomeFactory {

    public someWatchFactory() {};
    @Override
    public boolean startWatch(MethodToWatch methodName, UUID uniqueID, Callable toRun) {
        IPerformanceStopWatch mywatch = getStartWatch(methodName,uniqueID,toRun);
        return mywatch.startWatchDeployTaskStatus();
    }

     @Lookup
    private IPerformanceStopWatch getStartWatch(MethodToWatch methodName, String uniqueID, Callable toRun) {
        IPerformanceStopWatch mywatch = getStartWatch(methodName,uniqueID,toRun);
        return null;  //stub implementation which will be replaced by the container
    }
}

我想测试工厂类,使用类似的东西:

@InjectMock
ISomeFactory someFactory;

@Mock
IPerformanceStopWatch performanceWatch

每当SomeFactory类中的查找注释试图获取实例时,它就会使用模拟。

我该怎么做?

0 个答案:

没有答案