diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java index 6c19dd964..4e39ff86d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java @@ -15,6 +15,8 @@ */ package org.springframework.batch.core.listener; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -43,14 +45,16 @@ import com.sun.org.apache.xerces.internal.impl.xpath.XPath.Step; */ public class ExecutionContextPromotionListener extends StepExecutionListenerSupport implements InitializingBean { - private List keys = null; + private Collection keys = null; + private List statuses = Collections.singletonList(ExitStatus.COMPLETED.getExitCode()); /* * (non-Javadoc) * - * @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution - * stepExecution) + * @see + * org.springframework.batch.core.domain.StepListener#afterStep(StepExecution + * stepExecution) */ public ExitStatus afterStep(StepExecution stepExecution) { if (statuses == null) { @@ -84,21 +88,19 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp } /** - * @param keys - * A list of keys corresponding to items in the {@link Step} - * {@link ExecutionContext} that must be promoted. + * @param keys A list of keys corresponding to items in the {@link Step} + * {@link ExecutionContext} that must be promoted. */ - public void setKeys(List keys) { - this.keys = keys; + public void setKeys(String[] keys) { + this.keys = Arrays.asList(keys); } /** - * @param statuses - * A list of statuses for which the promotion should occur. - * Statuses can may contain wildcards recognizable by the - * {@link PatternMatcher} class. + * @param statuses A list of statuses for which the promotion should occur. + * Statuses can may contain wildcards recognizable by a + * {@link PatternMatcher}. */ - public void setStatuses(List statuses) { - this.statuses = statuses; + public void setStatuses(String[] statuses) { + this.statuses = Arrays.asList(statuses); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java index c0b055294..f724b7427 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java @@ -1,8 +1,7 @@ package org.springframework.batch.core.listener; -import static org.junit.Assert.*; - -import java.util.Collections; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import org.junit.Test; import org.springframework.batch.core.ExitStatus; @@ -16,11 +15,17 @@ import org.springframework.util.Assert; public class ExecutionContextPromotionListenerTests { private static final String key = "testKey"; + private static final String value = "testValue"; + private static final String key2 = "testKey2"; + private static final String value2 = "testValue2"; + private static final String status = "COMPLETED WITH SKIPS"; + private static final String status2 = "FAILURE"; + private static final String statusWildcard = "COMPL*SKIPS"; /** @@ -43,7 +48,7 @@ public class ExecutionContextPromotionListenerTests { stepExecution.getExecutionContext().putString(key, value); stepExecution.getExecutionContext().putString(key2, value2); - listener.setKeys(Collections.singletonList(key)); + listener.setKeys(new String[] { key }); listener.afterPropertiesSet(); listener.afterStep(stepExecution); @@ -71,8 +76,8 @@ public class ExecutionContextPromotionListenerTests { stepExecution.getExecutionContext().putString(key, value); stepExecution.getExecutionContext().putString(key2, value2); - listener.setKeys(Collections.singletonList(key)); - listener.setStatuses(Collections.singletonList(status)); + listener.setKeys(new String[] { key }); + listener.setStatuses(new String[] { status }); listener.afterPropertiesSet(); listener.afterStep(stepExecution); @@ -100,8 +105,8 @@ public class ExecutionContextPromotionListenerTests { stepExecution.getExecutionContext().putString(key, value); stepExecution.getExecutionContext().putString(key2, value2); - listener.setKeys(Collections.singletonList(key)); - listener.setStatuses(Collections.singletonList(status)); + listener.setKeys(new String[] { key }); + listener.setStatuses(new String[] { status }); listener.afterPropertiesSet(); listener.afterStep(stepExecution); @@ -130,8 +135,8 @@ public class ExecutionContextPromotionListenerTests { stepExecution.getExecutionContext().putString(key, value); stepExecution.getExecutionContext().putString(key2, value2); - listener.setKeys(Collections.singletonList(key)); - listener.setStatuses(Collections.singletonList(statusWildcard)); + listener.setKeys(new String[] { key }); + listener.setStatuses(new String[] { statusWildcard }); listener.afterPropertiesSet(); listener.afterStep(stepExecution);