SWS-1036 - Make SimpleXsdSchema's toString more resilient
This commit is contained in:
@@ -43,6 +43,7 @@ import org.springframework.xml.validation.XmlValidatorFactory;
|
||||
*
|
||||
* @author Mark LaFond
|
||||
* @author Arjen Poutsma
|
||||
* @author Greg Turnquist
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class SimpleXsdSchema implements XsdSchema, InitializingBean {
|
||||
@@ -91,6 +92,9 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean {
|
||||
|
||||
@Override
|
||||
public String getTargetNamespace() {
|
||||
|
||||
Assert.notNull(schemaElement, "schemaElement must not be null! Did you run afterPropertiesSet() or register this as a Spring bean?");
|
||||
|
||||
return schemaElement.getAttribute("targetNamespace");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.xml.xsd;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
public class SimpleXsdSchemaTest extends AbstractXsdSchemaTestCase {
|
||||
@@ -27,4 +29,11 @@ public class SimpleXsdSchemaTest extends AbstractXsdSchemaTestCase {
|
||||
return schema;
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testBareXsdSchema() {
|
||||
|
||||
SimpleXsdSchema schema = new SimpleXsdSchema();
|
||||
schema.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user