SWS-1036 - Make SimpleXsdSchema's toString more resilient

Backported to 2.x.
This commit is contained in:
Greg Turnquist
2018-09-11 17:12:39 -05:00
parent 709948b6f6
commit 2780c52ad8
2 changed files with 12 additions and 0 deletions

View File

@@ -91,6 +91,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();
}
}