Package org.mockito.internal.creation

Examples of org.mockito.internal.creation.MockSettingsImpl


        public PowerMockInternalMockHandler(Class<?> mock) {
            this.mock = mock;
        }

        public MockCreationSettings getMockSettings() {
            final MockSettingsImpl mockSettings = new MockSettingsImpl();
            mockSettings.setMockName(new MockNameImpl(mock.getName()));
            mockSettings.setTypeToMock(mock);
            return mockSettings;
        }
View Full Code Here


        return type.getName().startsWith("java.") && Modifier.isFinal(type.getModifiers());
    }

    private static <T> MockData<T> createMethodInvocationControl(final String mockName, Class<T> type,
                                                                 Method[] methods, boolean isSpy, Object delegator, MockSettings mockSettings) {
        final MockSettingsImpl settings;
        if (mockSettings == null) {
            // We change the context classloader to the current CL in order for the Mockito
            // framework to load it's plugins (such as MockMaker) correctly.
            final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(MockCreator.class.getClassLoader());
            try {
                settings = (MockSettingsImpl) Mockito.withSettings();
            } finally {
                Thread.currentThread().setContextClassLoader(originalCL);
            }
        } else {
            settings = (MockSettingsImpl) mockSettings;
        }

        if (isSpy) {
            settings.defaultAnswer(Mockito.CALLS_REAL_METHODS);
        }

        settings.setMockName(new MockNameImpl(mockName));
        InternalMockHandler mockHandler = new MockHandlerFactory().create(settings);
        MethodInterceptorFilter filter = new PowerMockMethodInterceptorFilter(
                mockHandler, settings);
        final T mock = (T) ClassImposterizer.INSTANCE.imposterise(filter, type);
        final MockitoMethodInvocationControl invocationControl = new MockitoMethodInvocationControl(filter,
View Full Code Here

     * <p>
     *
     * @return mock settings instance with defaults.
     */
    public static MockSettings withSettings() {
        return new MockSettingsImpl().defaultAnswer(RETURNS_DEFAULTS);
    }
View Full Code Here

        this(oldMockHandler.mockName, oldMockHandler.mockingProgress, oldMockHandler.matchersBinder, oldMockHandler.mockSettings);
    }
   
    //for tests
    MockHandler() {
        this(new MockName("mockie for tests", MockHandler.class), new ThreadSafeMockingProgress(), new MatchersBinder(), new MockSettingsImpl());
    }
View Full Code Here

    Object returnValueFor(Class<?> clazz) {
        if (!ClassImposterizer.INSTANCE.canImposterise(clazz)) {
            return null;
        }
       
        return mockitoCore.mock((Class) clazz, new MockSettingsImpl().defaultAnswer(this));
    }
View Full Code Here

     * <p>
     *
     * @return mock settings instance with defaults.
     */
    public static MockSettings withSettings() {
        return new MockSettingsImpl().defaultAnswer(RETURNS_DEFAULTS);
    }
View Full Code Here

        this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress);
    }

    // for tests
    MockHandler() {
        this(new MockSettingsImpl());
    }
View Full Code Here

    Object returnValueFor(Class<?> clazz) {
        if (!ClassImposterizer.INSTANCE.canImposterise(clazz)) {
            return null;
        }
       
        return mockitoCore.mock(clazz, new MockSettingsImpl().defaultAnswer(this));
    }
View Full Code Here

        this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress);
    }

    // for tests
    MockHandler() {
        this(new MockSettingsImpl());
    }
View Full Code Here

     * <p>
     *
     * @return mock settings instance with defaults.
     */
    public static MockSettings withSettings() {
        return new MockSettingsImpl().defaultAnswer(RETURNS_DEFAULTS);
    }
View Full Code Here

TOP

Related Classes of org.mockito.internal.creation.MockSettingsImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.