BATCH-1623: remove unnecessary validation

This commit is contained in:
dsyer
2010-09-06 13:08:24 +00:00
parent 2c3be8f37e
commit 85f721424a
2 changed files with 9 additions and 38 deletions

View File

@@ -463,8 +463,6 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
private void validateFaultTolerantSettings() {
validateDependency("skippable-exception-classes", skippableExceptionClasses, "skip-limit", skipLimit, true);
validateDependency("retryable-exception-classes", retryableExceptionClasses, "retry-limit", retryLimit, true);
validateAtLeastOneDependency("processor-transactional", processorTransactional,
"'retry-limit' or 'skip-limit'", retryLimit, skipLimit);
validateDependency("retry-listeners", retryListeners, "retry-limit", retryLimit, false);
if (isPresent(processorTransactional) && !processorTransactional && isPresent(readerTransactionalQueue)
&& readerTransactionalQueue) {
@@ -473,32 +471,6 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
}
}
/**
* Check if a field is present then a second (at least one taken from a
* list) is also.
*
* @param dependantName the name of the first field
* @param dependantValue the value of the first field
* @param names the names of the other fields (used to construct an
* exception message)
* @param values the other field values (one of which must be set if the
* first field is)
*/
private void validateAtLeastOneDependency(String dependantName, Boolean dependantValue, String names,
Object... values) {
boolean oneIsPresent = false;
for (Object value : values) {
if (isPresent(value)) {
oneIsPresent = true;
break;
}
}
if (isPresent(dependantValue) && !oneIsPresent) {
throw new IllegalArgumentException("The field '" + dependantName + "' is not permitted on the step ["
+ this.name + "] because " + names + " is not present.");
}
}
/**
* Check if a field is present then a second is also. If the
* twoWayDependency flag is set then the opposite must also be true: if the

View File

@@ -121,15 +121,13 @@ public class ChunkElementParserTests {
@Test
public void testProcessorTransactionalNotAllowedOnSimpleProcessor() throws Exception {
try {
new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalAttributeParserTests-context.xml");
fail("Expected BeanCreationException");
}
catch (BeanCreationException e) {
String msg = e.getMessage();
assertTrue("Wrong message: " + msg, msg.contains("The field 'processor-transactional' is not permitted"));
}
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalAttributeParserTests-context.xml");
Object step = context.getBean("s1", Step.class);
assertNotNull("Step not parsed", step);
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
assertTrue(chunkProcessor instanceof SimpleChunkProcessor<?, ?>);
}
@Test
@@ -260,7 +258,8 @@ public class ChunkElementParserTests {
private Object getPolicy(String stepName, ApplicationContext ctx, String componentName) throws Exception {
@SuppressWarnings("unchecked")
SubclassClassifier<Throwable, Object> classifier = (SubclassClassifier<Throwable, Object>) getNestedPathInStep(stepName, ctx, componentName);
SubclassClassifier<Throwable, Object> classifier = (SubclassClassifier<Throwable, Object>) getNestedPathInStep(
stepName, ctx, componentName);
Object policy = classifier.classify(new Exception());
return policy;
}