From 84b488ff13e1e7fd0d29e10fb1a2266089692948 Mon Sep 17 00:00:00 2001 From: dsyer Date: Mon, 16 Nov 2009 09:55:23 +0000 Subject: [PATCH] RESOLVED - issue BATCH-1439: Fix samples tests --- .../batch/sample/CustomerFilterJobFunctionalTests.java | 6 ++++-- .../batch/sample/SkipSampleFunctionalTests.java | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java index 9038b7d60..07065d5a9 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java @@ -93,14 +93,16 @@ public class CustomerFilterJobFunctionalTests extends AbstractJobTests { } }); - Map step1Execution = this.getStepExecution(jobExecution.getId(), "uploadCustomer"); + Map step1Execution = this.getStepExecution(jobExecution, "uploadCustomer"); assertEquals(new Long(4), step1Execution.get("READ_COUNT")); assertEquals(new Long(1), step1Execution.get("FILTER_COUNT")); assertEquals(new Long(3), step1Execution.get("WRITE_COUNT")); } - private Map getStepExecution(long jobExecutionId, String stepName) { + private Map getStepExecution(JobExecution jobExecution, String stepName) { + Long jobExecutionId = jobExecution.getId(); + stepName = jobExecution.getJobInstance().getJobName()+"."+stepName; return simpleJdbcTemplate.queryForMap( "SELECT * from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? and STEP_NAME = ?", jobExecutionId, stepName); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java index bf8fb1a43..d225622b2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java @@ -174,14 +174,14 @@ public class SkipSampleFunctionalTests { assertEquals(2, SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "ERROR_LOG")); assertEquals("2 records were skipped!", simpleJdbcTemplate.queryForObject( - "SELECT MESSAGE from ERROR_LOG where JOB_NAME = ? and STEP_NAME = ?", String.class, "skipJob", "step1")); + "SELECT MESSAGE from ERROR_LOG where JOB_NAME = ? and STEP_NAME = ?", String.class, "skipJob", "skipJob.step1")); assertEquals("2 records were skipped!", simpleJdbcTemplate.queryForObject( - "SELECT MESSAGE from ERROR_LOG where JOB_NAME = ? and STEP_NAME = ?", String.class, "skipJob", "step2")); + "SELECT MESSAGE from ERROR_LOG where JOB_NAME = ? and STEP_NAME = ?", String.class, "skipJob", "skipJob.step2")); System.err.println(jobExecution.getExecutionContext()); assertEquals(new BigDecimal("340.45"), jobExecution.getExecutionContext().get(TradeWriter.TOTAL_AMOUNT_KEY)); - Map step1Execution = getStepExecutionAsMap(jobExecution.getId(), "step1"); + Map step1Execution = getStepExecutionAsMap(jobExecution, "step1"); assertEquals(new Long(4), step1Execution.get("COMMIT_COUNT")); assertEquals(new Long(8), step1Execution.get("READ_COUNT")); assertEquals(new Long(7), step1Execution.get("WRITE_COUNT")); @@ -202,7 +202,9 @@ public class SkipSampleFunctionalTests { } - private Map getStepExecutionAsMap(long jobExecutionId, String stepName) { + private Map getStepExecutionAsMap(JobExecution jobExecution, String stepName) { + long jobExecutionId = jobExecution.getId(); + stepName = jobExecution.getJobInstance().getJobName() + "." + stepName; return simpleJdbcTemplate.queryForMap( "SELECT * from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? and STEP_NAME = ?", jobExecutionId, stepName);