1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5package org.mockito.internal.stubbing.answers;
6
7import java.io.Serializable;
8import java.lang.reflect.Modifier;
9
10import org.mockito.internal.stubbing.defaultanswers.GloballyConfiguredAnswer;
11import org.mockito.invocation.InvocationOnMock;
12import org.mockito.stubbing.Answer;
13
14/**
15 * Optional Answer that adds partial mocking support
16 * <p>
…lines 17–31 unchanged (15 lines)
32 * <p>
33 */
34public class CallsRealMethods implements Answer<Object>, Serializable {
35 private static final long serialVersionUID = 9057165148930624087L;
36
37 public Object answer(InvocationOnMock invocation) throws Throwable {
38 if (Modifier.isAbstract(invocation.getMethod().getModifiers())) {
39 return new GloballyConfiguredAnswer().answer(invocation);
40 }
41 return invocation.callRealMethod();
42 }
43}