You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2017/03/15 08:08:22 UTC
flink git commit: [hotfix] [tests] Improve mocking in
ZooKeeperCompletedCheckpointStore.testCheckpointRecovery
Repository: flink
Updated Branches:
refs/heads/master 6f7d7a025 -> 31ab4b247
[hotfix] [tests] Improve mocking in ZooKeeperCompletedCheckpointStore.testCheckpointRecovery
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/31ab4b24
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/31ab4b24
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/31ab4b24
Branch: refs/heads/master
Commit: 31ab4b2474cf4ac0e5add9ddf7d012731ed7232b
Parents: 6f7d7a0
Author: Till Rohrmann <tr...@apache.org>
Authored: Tue Mar 14 18:14:13 2017 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Wed Mar 15 09:07:06 2017 +0100
----------------------------------------------------------------------
.../ZooKeeperCompletedCheckpointStoreTest.java | 25 ++++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/31ab4b24/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStoreTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStoreTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStoreTest.java
index 6124dd3..66956e6 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStoreTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/ZooKeeperCompletedCheckpointStoreTest.java
@@ -20,10 +20,8 @@ package org.apache.flink.runtime.checkpoint;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.BackgroundCallback;
-import org.apache.curator.framework.api.BackgroundVersionable;
import org.apache.curator.framework.api.CuratorEvent;
import org.apache.curator.framework.api.CuratorEventType;
-import org.apache.curator.framework.api.DeleteBuilder;
import org.apache.curator.framework.api.Pathable;
import org.apache.curator.utils.EnsurePath;
import org.apache.flink.api.java.tuple.Tuple2;
@@ -34,6 +32,7 @@ import org.apache.flink.runtime.zookeeper.ZooKeeperStateHandleStore;
import org.apache.flink.util.TestLogger;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -101,7 +100,7 @@ public class ZooKeeperCompletedCheckpointStoreTest extends TestLogger {
checkpointsInZooKeeper.add(Tuple2.of(retrievableStateHandle2, "/foobar2"));
checkpointsInZooKeeper.add(Tuple2.of(failingRetrievableStateHandle, "/failing2"));
- final CuratorFramework client = mock(CuratorFramework.class);
+ final CuratorFramework client = mock(CuratorFramework.class, Mockito.RETURNS_DEEP_STUBS);
final RetrievableStateStorageHelper<CompletedCheckpoint> storageHelperMock = mock(RetrievableStateStorageHelper.class);
ZooKeeperStateHandleStore<CompletedCheckpoint> zooKeeperStateHandleStoreMock = spy(new ZooKeeperStateHandleStore<>(client, storageHelperMock, Executors.directExecutor()));
@@ -114,21 +113,21 @@ public class ZooKeeperCompletedCheckpointStoreTest extends TestLogger {
// It assures that the callback is executed synchronously
final EnsurePath ensurePathMock = mock(EnsurePath.class);
- final DeleteBuilder deleteBuilderMock = mock(DeleteBuilder.class);
- final BackgroundVersionable backgroundVersionableMock = mock(BackgroundVersionable.class);
-
+ final CuratorEvent curatorEventMock = mock(CuratorEvent.class);
+ when(curatorEventMock.getType()).thenReturn(CuratorEventType.DELETE);
+ when(curatorEventMock.getResultCode()).thenReturn(0);
when(client.newNamespaceAwareEnsurePath(anyString())).thenReturn(ensurePathMock);
- when(client.delete()).thenReturn(deleteBuilderMock);
- when(deleteBuilderMock.deletingChildrenIfNeeded()).thenReturn(backgroundVersionableMock);
- when(backgroundVersionableMock.inBackground(any(BackgroundCallback.class), any(Executor.class))).thenAnswer(new Answer<Pathable<Void>>() {
+
+ when(
+ client
+ .delete()
+ .deletingChildrenIfNeeded()
+ .inBackground(any(BackgroundCallback.class), any(Executor.class))
+ ).thenAnswer(new Answer<Pathable<Void>>() {
@Override
public Pathable<Void> answer(InvocationOnMock invocation) throws Throwable {
final BackgroundCallback callback = (BackgroundCallback) invocation.getArguments()[0];
- final CuratorEvent curatorEventMock = mock(CuratorEvent.class);
- when(curatorEventMock.getType()).thenReturn(CuratorEventType.DELETE);
- when(curatorEventMock.getResultCode()).thenReturn(0);
-
Pathable<Void> result = mock(Pathable.class);
when(result.forPath(anyString())).thenAnswer(new Answer<Void>() {