BATCH-1456: add dummy 2.0 schema and a detector for the wrong schema declaration.

This commit is contained in:
dsyer
2009-12-04 18:36:05 +00:00
parent f3cb6304a2
commit b451c219bf
6 changed files with 78 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -48,4 +49,20 @@ public class JobParserExceptionTests {
}
}
@Test
public void testWrongSchemaInRoot() {
try {
new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/JobParserWrongSchemaInRootTests-context.xml");
fail("Error expected");
}
catch (BeanDefinitionParsingException e) {
String message = e.getMessage();
assertTrue("Wrong message: "+message, message.matches("(?s).*You cannot use spring-batch-2.0.xsd.*"));
} catch (BeanDefinitionStoreException e) {
// Probably the internet is not available and the schema validation failed.
// We don't want an automated build to fail if that happens.
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<beans:import resource="common-context.xml" />
<job id="job1">
<step id="s1">
<tasklet ref="dummyTasklet" />
</step>
</job>
</beans:beans>