Update to latest Mockito mocking APIs
diff --git a/lib/mockito-core-1.9.1-SNAPSHOT.jar b/lib/mockito-core-1.9.1-SNAPSHOT.jar
index 4a310b4..7d05e5e 100644
--- a/lib/mockito-core-1.9.1-SNAPSHOT.jar
+++ b/lib/mockito-core-1.9.1-SNAPSHOT.jar
Binary files differ
diff --git a/src/mockito/java/com/google/dexmaker/mockito/DexmakerMockMaker.java b/src/mockito/java/com/google/dexmaker/mockito/DexmakerMockMaker.java
index e108ab9..bf33342 100644
--- a/src/mockito/java/com/google/dexmaker/mockito/DexmakerMockMaker.java
+++ b/src/mockito/java/com/google/dexmaker/mockito/DexmakerMockMaker.java
@@ -20,10 +20,11 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
+import java.util.Set;
import org.mockito.exceptions.base.MockitoException;
+import org.mockito.invocation.MockHandler;
+import org.mockito.mock.MockCreationSettings;
import org.mockito.plugins.MockMaker;
-import org.mockito.plugins.MockSettingsInfo;
-import org.mockito.plugins.MockitoInvocationHandler;
/**
* Generates mock instances on Android's runtime.
@@ -31,8 +32,10 @@
public final class DexmakerMockMaker implements MockMaker {
private final UnsafeAllocator unsafeAllocator = UnsafeAllocator.create();
- public <T> T createMock(Class<T> typeToMock, Class<?>[] extraInterfaces,
- MockitoInvocationHandler handler, MockSettingsInfo settings) {
+ public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {
+ Class<T> typeToMock = settings.getTypeToMock();
+ Set<Class> interfacesSet = settings.getExtraInterfaces();
+ Class<?>[] extraInterfaces = interfacesSet.toArray(new Class[interfacesSet.size()]);
InvocationHandler invocationHandler = new InvocationHandlerAdapter(handler);
if (typeToMock.isInterface()) {
@@ -64,16 +67,16 @@
}
}
- public void resetMock(Object mock, MockitoInvocationHandler newHandler, MockSettingsInfo settings) {
+ public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {
InvocationHandlerAdapter adapter = getInvocationHandlerAdapter(mock);
adapter.setHandler(newHandler);
}
- public MockitoInvocationHandler getHandler(Object mock) {
+ public MockHandler getHandler(Object mock) {
InvocationHandlerAdapter adapter = getInvocationHandlerAdapter(mock);
return adapter != null ? adapter.getHandler() : null;
}
-
+
private InvocationHandlerAdapter getInvocationHandlerAdapter(Object mock) {
if (Proxy.isProxyClass(mock.getClass())) {
InvocationHandler invocationHandler = Proxy.getInvocationHandler(mock);
diff --git a/src/mockito/java/com/google/dexmaker/mockito/InvocationHandlerAdapter.java b/src/mockito/java/com/google/dexmaker/mockito/InvocationHandlerAdapter.java
index c1e4720..268f2fd 100644
--- a/src/mockito/java/com/google/dexmaker/mockito/InvocationHandlerAdapter.java
+++ b/src/mockito/java/com/google/dexmaker/mockito/InvocationHandlerAdapter.java
@@ -19,22 +19,22 @@
import com.google.dexmaker.stock.ProxyBuilder;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import org.mockito.internal.invocation.Invocation;
+import org.mockito.internal.invocation.InvocationImpl;
import org.mockito.internal.invocation.MockitoMethod;
import org.mockito.internal.invocation.realmethod.RealMethod;
import org.mockito.internal.progress.SequenceNumber;
import org.mockito.internal.util.ObjectMethodsGuru;
-import org.mockito.plugins.MockitoInvocationHandler;
+import org.mockito.invocation.MockHandler;
/**
* Handles proxy method invocations to dexmaker's InvocationHandler by calling
* a MockitoInvocationHandler.
*/
final class InvocationHandlerAdapter implements InvocationHandler {
- private MockitoInvocationHandler handler;
+ private MockHandler handler;
private final ObjectMethodsGuru objectMethodsGuru = new ObjectMethodsGuru();
- public InvocationHandlerAdapter(MockitoInvocationHandler handler) {
+ public InvocationHandlerAdapter(MockHandler handler) {
this.handler = handler;
}
@@ -51,15 +51,15 @@
ProxiedMethod proxiedMethod = new ProxiedMethod(method);
- return handler.handle(new Invocation(proxy, proxiedMethod, args, SequenceNumber.next(),
+ return handler.handle(new InvocationImpl(proxy, proxiedMethod, args, SequenceNumber.next(),
proxiedMethod));
}
- public MockitoInvocationHandler getHandler() {
+ public MockHandler getHandler() {
return handler;
}
- public void setHandler(MockitoInvocationHandler handler) {
+ public void setHandler(MockHandler handler) {
this.handler = handler;
}