Package org.easymock.internal

Examples of org.easymock.internal.MockInvocationHandler


            mock = control.createMock(type);
        } else if (type.getName().startsWith("java.") && Modifier.isFinal(type.getModifiers())) {
            Class<?> replicaType = createReplicaType(type, isStatic, constructorArgs);
            final Object replica = doCreateMock(replicaType, constructorArgs, control, methods);
            control = mockStrategy.createMockControl(replicaType);
            MockInvocationHandler h = new MockInvocationHandler((MocksControl) control);
            final Set<Method> methodsToMock = toSet(methods);
            if (isStatic) {
                MockRepository.putStaticMethodInvocationControl(type, new EasyMockMethodInvocationControl<Object>(h,
                        methodsToMock, replica));
                MockRepository.addObjectsToAutomaticallyReplayAndVerify(type);
                return null;
            } else {
                final T newInstance;
                if (constructorArgs == null) {
                    newInstance = Whitebox.newInstance(type);
                    DefaultFieldValueGenerator.fillWithDefaultValues(newInstance);
                } else {
                    try {
                        newInstance = (T) constructorArgs.getConstructor().newInstance(constructorArgs.getInitArgs());
                    } catch (Exception e) {
                        throw new RuntimeException("Internal error", e);
                    }
                }
                MockRepository.putInstanceMethodInvocationControl(newInstance,
                        new EasyMockMethodInvocationControl<Object>(h, methodsToMock, replica));
                if (newInstance instanceof InvocationSubstitute<?> == false) {
                    MockRepository.addObjectsToAutomaticallyReplayAndVerify(newInstance);
                }
                return newInstance;
            }
        } else {
            mock = doCreateMock(type, constructorArgs, control, methods);
        }
        MockInvocationHandler h = new MockInvocationHandler((MocksControl) control);
        final Set<Method> methodsToMock = toSet(methods);
        if (isStatic) {
            MockRepository.putStaticMethodInvocationControl(type, new EasyMockMethodInvocationControl<T>(h,
                    methodsToMock, mock));
            MockRepository.addObjectsToAutomaticallyReplayAndVerify(type);
View Full Code Here

TOP

Related Classes of org.easymock.internal.MockInvocationHandler

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.