SWS-1036 - Make SimpleXsdSchema's toString more resilient

This commit is contained in:
Greg Turnquist
2018-09-11 16:57:30 -05:00
parent 8c654a3880
commit fdf638a813
2 changed files with 13 additions and 0 deletions

View File

@@ -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");
}

View File

@@ -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();
}
}