From 9a073631f12be304ca1d73a058da8959e87027ba Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Fri, 8 Apr 2016 12:46:29 +0530 Subject: [PATCH] Modify poll interval assertion in DeployerPartitionHandlerTests - Greater than 20s poll interval check in the assertion might as well needs to be equal to 20s interval as the test could finish before the next second --- .../task/batch/partition/DeployerPartitionHandler.java | 10 +++++----- .../batch/partition/DeployerPartitionHandlerTests.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java index 9caf64c5..d526e925 100644 --- a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java +++ b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java @@ -190,7 +190,7 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw final Set executed = new HashSet<>(candidates.size()); - if(CollectionUtils.isEmpty(candidates)) { + if (CollectionUtils.isEmpty(candidates)) { return null; } @@ -203,7 +203,7 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw private void launchWorkers(Set candidates, Set executed) { for (StepExecution execution : candidates) { - if(this.currentWorkers < this.maxWorkers || this.maxWorkers < 0) { + if (this.currentWorkers < this.maxWorkers || this.maxWorkers < 0) { launchWorker(execution); this.currentWorkers++; @@ -271,7 +271,7 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw executed.addAll(newExecuted); - if(result.size() == size) { + if (result.size() == size) { return result; } else { @@ -283,7 +283,7 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw Poller> poller = new DirectPoller<>(this.pollInterval); Future> resultsFuture = poller.poll(callback); - if(timeout >= 0) { + if (timeout >= 0) { return resultsFuture.get(timeout, TimeUnit.MILLISECONDS); } else { @@ -316,7 +316,7 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw Set keys = new HashSet<>(); - for(Iterator it = ((AbstractEnvironment) this.environment).getPropertySources().iterator(); it.hasNext(); ) { + for (Iterator it = ((AbstractEnvironment) this.environment).getPropertySources().iterator(); it.hasNext(); ) { PropertySource propertySource = (PropertySource) it.next(); if (propertySource instanceof MapPropertySource) { keys.addAll(Arrays.asList(((MapPropertySource) propertySource).getPropertyNames())); diff --git a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandlerTests.java b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandlerTests.java index 7a08764f..05f711d8 100644 --- a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandlerTests.java +++ b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandlerTests.java @@ -297,7 +297,7 @@ public class DeployerPartitionHandlerTests { while (resultsIterator.hasNext()) { StepExecution curResult = resultsIterator.next(); - if(curResult.getStepName().equals("step1:partition2")) { + if (curResult.getStepName().equals("step1:partition2")) { assertEquals(BatchStatus.FAILED, curResult.getStatus()); } else { @@ -451,7 +451,6 @@ public class DeployerPartitionHandlerTests { Date startTime = new Date(); Collection results = handler.handle(this.splitter, masterStepExecution); Date endTime = new Date(); - verify(this.taskLauncher, times(2)).launch(this.appDeploymentRequestArgumentCaptor.capture()); List allRequests = this.appDeploymentRequestArgumentCaptor.getAllValues(); @@ -460,7 +459,8 @@ public class DeployerPartitionHandlerTests { validateStepExecutionResults(results); - assertTrue("Time difference was too small: " + (endTime.getTime() - startTime.getTime()), endTime.getTime() - startTime.getTime() > 20000); + assertTrue("Time difference was too small: " + (endTime.getTime() - startTime.getTime()), + endTime.getTime() - startTime.getTime() >= 20000); } @Test(expected = TimeoutException.class) @@ -585,7 +585,7 @@ public class DeployerPartitionHandlerTests { } }); - for(int i = 4; i < (numberOfPartitions + 4); i++) { + for (int i = 4; i < (numberOfPartitions + 4); i++) { AppDeploymentRequest request = allRequests.get(i - 4); assertEquals(this.resource, request.getResource()); assertEquals(0, request.getEnvironmentProperties().size());