Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
Matko Medenjak committed Mar 22, 2018
1 parent 6e84405 commit 9f97122
Showing 1 changed file with 3 additions and 9 deletions.
Expand Up @@ -31,7 +31,6 @@
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static com.hazelcast.internal.util.InvocationUtil.executeLocallyWithRetry;
Expand Down Expand Up @@ -92,9 +91,8 @@ public void executeLocallyRetriesWhenPartitionIsMigrating() throws InterruptedEx
final InternalPartitionImpl partition = (InternalPartitionImpl) partitionService.getPartition(randomPartitionId);
partition.setMigrating(true);

final CountDownLatch completed = new CountDownLatch(1);
final String operationResponse = "operationResponse";
final Operation operation = new LocalOperation(completed, operationResponse)
final Operation operation = new LocalOperation(operationResponse)
.setPartitionId(randomPartitionId);
final LocalRetryableExecution execution = executeLocallyWithRetry(nodeEngineImpl, operation);

Expand All @@ -104,31 +102,27 @@ public void run() {
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();

}
partition.setMigrating(false);
}
});

assertTrue(execution.awaitCompletion(1, TimeUnit.MINUTES));
assertEquals(operationResponse, execution.getResponse());
assertEquals(0, completed.getCount());
}

public class LocalOperation extends AbstractLocalOperation {
private final CountDownLatch completed;
private final Object operationResponse;
private Object response;

public LocalOperation(CountDownLatch completed, Object operationResponse) {
this.completed = completed;
public LocalOperation(Object operationResponse) {
this.operationResponse = operationResponse;
}

@Override
public void run() throws Exception {
response = operationResponse;
completed.countDown();
}

@Override
Expand Down

0 comments on commit 9f97122

Please sign in to comment.