From 068df277230d176b244c04288a61ea880a52f924 Mon Sep 17 00:00:00 2001 From: Glenn Renfro Date: Mon, 14 Oct 2019 15:21:05 -0400 Subject: [PATCH] Updated the test so that it will now work. We will need to add a new task to the bamboo integration tests for SCT. In this task we will pass in the parameters This will be run after the other integration tasks. --- .../partitioned-batch-job/pom.xml | 1 - .../main/java/io/spring/JobConfiguration.java | 2 +- .../partitioner/TaskPartitionerTests.java | 23 +++++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/spring-cloud-task-samples/partitioned-batch-job/pom.xml b/spring-cloud-task-samples/partitioned-batch-job/pom.xml index 78ab4baf..f21014c5 100644 --- a/spring-cloud-task-samples/partitioned-batch-job/pom.xml +++ b/spring-cloud-task-samples/partitioned-batch-job/pom.xml @@ -63,7 +63,6 @@ com.h2database h2 - test org.springframework.boot diff --git a/spring-cloud-task-samples/partitioned-batch-job/src/main/java/io/spring/JobConfiguration.java b/spring-cloud-task-samples/partitioned-batch-job/src/main/java/io/spring/JobConfiguration.java index d8d79809..cd69b883 100644 --- a/spring-cloud-task-samples/partitioned-batch-job/src/main/java/io/spring/JobConfiguration.java +++ b/spring-cloud-task-samples/partitioned-batch-job/src/main/java/io/spring/JobConfiguration.java @@ -80,7 +80,7 @@ public class JobConfiguration { @Bean public PartitionHandler partitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer) throws Exception { Resource resource = this.resourceLoader - .getResource("maven://io.spring.cloud:partitioned-batch-job:1.1.0.RELEASE"); + .getResource("maven://io.spring.cloud:partitioned-batch-job:2.2.0.BUILD-SNAPSHOT"); DeployerPartitionHandler partitionHandler = new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, "workerStep"); diff --git a/spring-cloud-task-samples/partitioned-batch-job/src/test/java/org/springframework/cloud/task/partitioner/TaskPartitionerTests.java b/spring-cloud-task-samples/partitioned-batch-job/src/test/java/org/springframework/cloud/task/partitioner/TaskPartitionerTests.java index 6e025f29..00575850 100644 --- a/spring-cloud-task-samples/partitioned-batch-job/src/test/java/org/springframework/cloud/task/partitioner/TaskPartitionerTests.java +++ b/spring-cloud-task-samples/partitioned-batch-job/src/test/java/org/springframework/cloud/task/partitioner/TaskPartitionerTests.java @@ -17,6 +17,7 @@ package org.springframework.cloud.task.partitioner; import java.sql.SQLException; +import java.util.Properties; import javax.sql.DataSource; @@ -91,21 +92,21 @@ public class TaskPartitionerTests { public void testWithLocalDeployer() throws Exception { SpringApplication app = new SpringApplication(PartitionedBatchJobApplication.class); app.setAdditionalProfiles("master"); - app.run("--server.port=0", "--spring.datasource.url=" + DATASOURCE_URL, - "--spring.datasource.username=" + DATASOURCE_USER_NAME, - "--spring.datasource.driverClassName=" + DATASOURCE_DRIVER_CLASS_NAME, - "--spring.cloud.deployer.local.use-spring-application-json=false"); + Properties properties = new Properties(); + properties.setProperty("spring.datasource.url", DATASOURCE_URL); + properties.setProperty("spring.datasource.username", DATASOURCE_USER_NAME); + properties.setProperty("spring.datasource.driverClassName", DATASOURCE_DRIVER_CLASS_NAME); + properties.setProperty("spring.cloud.deployer.local.use-spring-application-json", "false"); + app.setDefaultProperties(properties); + app.run(); Page taskExecutions = this.taskExplorer .findAll(PageRequest.of(0, 10)); assertThat(taskExecutions.getTotalElements()).as("Five rows are expected") .isEqualTo(5); assertThat(this.taskExplorer - .getTaskExecutionCountByTaskName("Partitioned Batch Job Task:master:0")) + .getTaskExecutionCountByTaskName("PartitionedBatchJobTask")) .as("Only One master is expected").isEqualTo(1); - assertThat(this.taskExplorer - .getTaskExecutionCountByTaskName("Partitioned Batch Job Task:worker:0")) - .as("4 partitions is expected").isEqualTo(4); for (TaskExecution taskExecution : taskExecutions) { assertThat(taskExecution.getExitCode() .intValue()).as("return code should be 0").isEqualTo(0); @@ -119,8 +120,10 @@ public class TaskPartitionerTests { public org.h2.tools.Server initH2TCPServer() { Server server; try { - server = Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", - String.valueOf(randomPort)).start(); + server = Server + .createTcpServer("-tcp", "-ifNotExists", "-tcpAllowOthers", "-tcpPort", String + .valueOf(randomPort)) + .start(); } catch (SQLException e) { throw new IllegalStateException(e);