Skip to content

Commit

Permalink
Merge pull request Alluxio#2752 from alexnaspo/ALLUXIO-1588
Browse files Browse the repository at this point in the history
[ALLUXIO-1588] Add test coverage for WorkerClientHeartbeatExecutor
  • Loading branch information
yupeng9 committed Feb 25, 2016
2 parents 3936a26 + e15ffc0 commit dbf7ef3
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the “License”). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/

package alluxio.client.block;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.core.classloader.annotations.PrepareForTest;

/**
* Tests for the {@link BlockWorkerClientHeartbeatExecutor} class.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(BlockWorkerClient.class)
public class BlockWorkerClientHeartbeatExecutorTest {

/**
* Tests to ensure heartbeat calls BlockWorkerClient.periodicHeartbeat.
*
* @throws Exception when the periodicHeartbeat is not called once
*/
@Test
public void heartbeatCallsPeriodicHeartbeat() throws Exception {
BlockWorkerClient mock = PowerMockito.mock(BlockWorkerClient.class);
BlockWorkerClientHeartbeatExecutor heartbeatExecutor =
new BlockWorkerClientHeartbeatExecutor(mock);

heartbeatExecutor.heartbeat();

Mockito.verify(mock).periodicHeartbeat();
}
}

0 comments on commit dbf7ef3

Please sign in to comment.