@Test
  public void submitCallablePartitionAware_WithExecutionCallback() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());

    String mapName = randomString();
    IMap map = client.getMap(mapName);
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    Member member = server.getCluster().getLocalMember();

    Callable<String> runnable = new MapPutPartitionAwareCallable<String, String>(mapName, key);

    final AtomicReference<String> result = new AtomicReference<String>();
    final CountDownLatch responseLatch = new CountDownLatch(1);

    service.submit(
        runnable,
        new ExecutionCallback<String>() {
          public void onResponse(String response) {
            result.set(response);
            responseLatch.countDown();
          }

          public void onFailure(Throwable t) {}
        });

    assertOpenEventually("responseLatch", responseLatch);
    assertEquals(member.getUuid(), result.get());
    assertTrue(map.containsKey(member.getUuid()));
  }
  @Test
  public void submitRunnablePartitionAware_withExecutionCallback() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());

    String mapName = randomString();
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    Member member = server.getCluster().getLocalMember();
    Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
    final CountDownLatch responseLatch = new CountDownLatch(1);

    service.submit(
        runnable,
        new ExecutionCallback() {
          @Override
          public void onResponse(Object response) {
            responseLatch.countDown();
          }

          @Override
          public void onFailure(Throwable t) {}
        });
    IMap map = client.getMap(mapName);

    assertOpenEventually("responseLatch", responseLatch);
    assertTrue(map.containsKey(member.getUuid()));
  }
  @Test
  public void submitCallablePartitionAware() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());

    String mapName = randomString();
    IMap map = client.getMap(mapName);
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    Member member = server.getCluster().getLocalMember();

    Callable<String> callable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
    Future<String> result = service.submit(callable);

    assertEquals(member.getUuid(), result.get());
    assertTrue(map.containsKey(member.getUuid()));
  }
  @Test
  public void submitRunnablePartitionAware_withResult() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());

    String expectedResult = "result";
    String mapName = randomString();
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    final Member member = server.getCluster().getLocalMember();

    Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);

    Future result = service.submit(runnable, expectedResult);
    final IMap map = client.getMap(mapName);

    assertEquals(expectedResult, result.get());
    assertTrueEventually(
        new AssertTask() {
          public void run() throws Exception {
            assertTrue(map.containsKey(member.getUuid()));
          }
        });
  }
  @Test
  public void submitRunnablePartitionAware() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());

    String mapName = randomString();
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    final Member member = server.getCluster().getLocalMember();

    // this task should execute on a node owning the given key argument,
    // the action is to put the UUid of the executing node into a map with the given name
    Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);

    service.submit(runnable);
    final IMap map = client.getMap(mapName);

    assertTrueEventually(
        new AssertTask() {
          public void run() throws Exception {
            assertTrue(map.containsKey(member.getUuid()));
          }
        });
  }