From 87c7671faa45a99791ebddade30feb684ad690c9 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 22 Mar 2011 09:10:10 +0000 Subject: [PATCH] Fix build - wrong assumption about expected rollbacks --- .../FootballJobSkipIntegrationTests.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobSkipIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobSkipIntegrationTests.java index ac3f3501e..596410b72 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobSkipIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobSkipIntegrationTests.java @@ -88,15 +88,25 @@ public class FootballJobSkipIntegrationTests { for (StepExecution stepExecution : execution.getStepExecutions()) { logger.info("Processed: " + stepExecution); } - // They all skip on the second execution because of a primary key violation - execution = jobLauncher.run(job, new JobParametersBuilder().addLong("skip.limit", 100000L).addLong("retry.limit", 2L) - .toJobParameters()); + // They all skip on the second execution because of a primary key + // violation + long retryLimit = 2L; + execution = jobLauncher.run(job, + new JobParametersBuilder().addLong("skip.limit", 100000L).addLong("retry.limit", retryLimit) + .toJobParameters()); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); for (StepExecution stepExecution : execution.getStepExecutions()) { logger.info("Processed: " + stepExecution); if (stepExecution.getStepName().equals("playerload")) { - // The effect of the retries - assertEquals(stepExecution.getReadCount()*2, stepExecution.getRollbackCount()); + // The effect of the retries is to increase the number of + // rollbacks + int commitInterval = stepExecution.getReadCount() / (stepExecution.getCommitCount() - 1); + // Account for the extra empty commit if the read count is + // commensurate with the commit interval + int effectiveCommitCount = stepExecution.getReadCount() % commitInterval == 0 ? stepExecution + .getCommitCount() - 1 : stepExecution.getCommitCount(); + long expectedRollbacks = Math.max(1, retryLimit) * effectiveCommitCount + stepExecution.getReadCount(); + assertEquals(expectedRollbacks, stepExecution.getRollbackCount()); assertEquals(stepExecution.getReadCount(), stepExecution.getWriteSkipCount()); } }