BATCH-1285: Raise an exception if a step cannot be reached.

This commit is contained in:
dhgarrette
2009-06-11 05:15:59 +00:00
parent 8cabd9544f
commit 254c3b41f1
8 changed files with 190 additions and 37 deletions

View File

@@ -17,10 +17,12 @@ package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.batch.core.Job;
@@ -29,6 +31,7 @@ import org.springframework.batch.core.job.AbstractJob;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -40,8 +43,13 @@ import org.springframework.test.util.ReflectionTestUtils;
*/
public class JobParserTests {
ConfigurableApplicationContext jobParserParentAttributeTestsCtx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/JobParserParentAttributeTests-context.xml");
private static ConfigurableApplicationContext jobParserParentAttributeTestsCtx;
@BeforeClass
public static void loadAppCtx() {
jobParserParentAttributeTestsCtx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/JobParserParentAttributeTests-context.xml");
}
@Test
public void testInheritListeners() throws Exception {
@@ -136,4 +144,28 @@ public class JobParserTests {
assertTrue(jobRepository instanceof JobRepository);
return (JobRepository) jobRepository;
}
@Test
public void testUnreachableStep() {
try {
new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/JobParserUnreachableStepTests-context.xml");
fail("Error expected");
}
catch (BeanDefinitionParsingException e) {
assertTrue(e.getMessage().contains("The element [s2] is unreachable"));
}
}
@Test
public void testNextOutOfScope() {
try {
new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/JobParserNextOutOfScopeTests-context.xml");
fail("Error expected");
}
catch (BeanDefinitionParsingException e) {
assertTrue(e.getMessage().contains("Missing state for [StateTransition: [state=s2, pattern=*, next=s3]]"));
}
}
}

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.batch.core.Step;
@@ -52,8 +53,13 @@ import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
*/
public class StepParserTests {
private static final ApplicationContext stepParserParentAttributeTestsCtx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
private static ApplicationContext stepParserParentAttributeTestsCtx;
@BeforeClass
public static void loadAppCtx() {
stepParserParentAttributeTestsCtx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
}
@SuppressWarnings("unchecked")
@Test