Java 类org.mockito.internal.configuration.GlobalConfiguration 实例源码

项目:astor    文件:MockitoAnnotations.java   
/**
 * Initializes objects annotated with Mockito annotations for given testClass:
 *  @{@link org.mockito.Mock}, @{@link Spy}, @{@link Captor}, @{@link InjectMocks} 
 * <p>
 * See examples in javadoc for {@link MockitoAnnotations} class.
 */
public static void initMocks(Object testClass) {
    if (testClass == null) {
        throw new MockitoException("testClass cannot be null. For info how to use @Mock annotations see examples in javadoc for MockitoAnnotations class");
    }

    AnnotationEngine annotationEngine = new GlobalConfiguration().getAnnotationEngine();
    Class<?> clazz = testClass.getClass();

    //below can be removed later, when we get read rid of deprecated stuff
    if (annotationEngine.getClass() != new DefaultMockitoConfiguration().getAnnotationEngine().getClass()) {
        //this means user has his own annotation engine and we have to respect that.
        //we will do annotation processing the old way so that we are backwards compatible
        while (clazz != Object.class) {
            scanDeprecatedWay(annotationEngine, testClass, clazz);
            clazz = clazz.getSuperclass();
        }
    }

    //anyway act 'the new' way
    annotationEngine.process(testClass.getClass(), testClass);
}
项目:astor    文件:MockitoAnnotations.java   
static void scan(Object testClass, Class<?> clazz) {
    AnnotationEngine annotationEngine = new GlobalConfiguration().getAnnotationEngine();
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        //below can be removed later, when we get rid of deprecated stuff
        if (annotationEngine.getClass() != new DefaultMockitoConfiguration().getAnnotationEngine().getClass()) {
            //this means user has his own annotation engine and we have to respect that.
            //we will do annotation processing the old way so that we are backwards compatible
            processAnnotationDeprecatedWay(annotationEngine, testClass, field);                
        } 
    }
    //act 'the new' way
    annotationEngine.process(clazz, testClass);
}
项目:astor    文件:MockingProgressImpl.java   
private void validateMostStuff() {
    //State is cool when GlobalConfiguration is already loaded
    //this cannot really be tested functionally because I cannot dynamically mess up org.mockito.configuration.MockitoConfiguration class
    GlobalConfiguration.validate();

    if (verificationMode != null) {
        Location location = verificationMode.getLocation();
        verificationMode = null;
        reporter.unfinishedVerificationException(location);
    }

    getArgumentMatcherStorage().validateState();
}
项目:astor    文件:MockingProgressImpl.java   
private void validateMostStuff() {
    //State is cool when GlobalConfiguration is already loaded
    //this cannot really be tested functionally because I cannot dynamically mess up org.mockito.configuration.MockitoConfiguration class
    GlobalConfiguration.validate();

    if (verificationMode != null) {
        Location location = verificationMode.getLocation();
        verificationMode = null;
        reporter.unfinishedVerificationException(location);
    }

    getArgumentMatcherStorage().validateState();
}
项目:powermock    文件:MockitoStateCleaner.java   
void clearConfiguration() {
    clearThreadLocalIn(GlobalConfiguration.class);
}
项目:astor    文件:GloballyConfiguredAnswer.java   
public Object answer(InvocationOnMock invocation) throws Throwable {
    return new GlobalConfiguration().getDefaultAnswer().answer(invocation);
}
项目:astor    文件:GloballyConfiguredAnswer.java   
public Object answer(InvocationOnMock invocation) throws Throwable {
    return new GlobalConfiguration().getDefaultAnswer().answer(invocation);
}