File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
main/java/org/springframework/ws/server/endpoint/support
test/java/org/springframework/ws/server/endpoint/support Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 2727import javax .xml .transform .dom .DOMResult ;
2828import javax .xml .transform .dom .DOMSource ;
2929
30- import org .springframework .xml .namespace .QNameUtils ;
31- import org .springframework .xml .transform .StaxSource ;
3230import org .w3c .dom .Document ;
3331import org .w3c .dom .Node ;
3432
33+ import org .springframework .xml .namespace .QNameUtils ;
34+ import org .springframework .xml .transform .StaxSource ;
35+
3536/**
3637 * Helper class for determining the root qualified name of a Web Service payload.
3738 *
@@ -49,11 +50,14 @@ private PayloadRootUtils() {
4950 *
5051 * @param source the source to get the root element from
5152 * @param transformerFactory a transformer factory, necessary if the given source is not a <code>DOMSource</code>
52- * @return the root element
53+ * @return the root element, or <code>null</code> if <code>source</code> is <code>null</code>
5354 */
5455 public static QName getPayloadRootQName (Source source , TransformerFactory transformerFactory )
5556 throws TransformerException , XMLStreamException {
56- if (source instanceof DOMSource ) {
57+ if (source == null ) {
58+ return null ;
59+ }
60+ else if (source instanceof DOMSource ) {
5761 DOMSource domSource = (DOMSource ) source ;
5862 Node node = domSource .getNode ();
5963 if (node .getNodeType () == Node .ELEMENT_NODE ) {
Original file line number Diff line number Diff line change 2929import javax .xml .transform .stream .StreamSource ;
3030
3131import junit .framework .TestCase ;
32- import org .springframework .xml .transform .StaxSource ;
3332import org .w3c .dom .Document ;
3433import org .w3c .dom .Element ;
3534import org .xml .sax .InputSource ;
3635
36+ import org .springframework .xml .transform .StaxSource ;
37+
3738public class PayloadRootUtilsTest extends TestCase {
3839
3940 public void testGetQNameForDomSource () throws Exception {
@@ -81,4 +82,9 @@ public void testGetQNameForSaxSource() throws Exception {
8182 assertEquals ("Qname has invalid namespace" , "namespace" , qName .getNamespaceURI ());
8283 assertEquals ("Qname has invalid prefix" , "prefix" , qName .getPrefix ());
8384 }
85+
86+ public void testGetQNameForNullSource () throws Exception {
87+ QName qName = PayloadRootUtils .getPayloadRootQName (null , TransformerFactory .newInstance ());
88+ assertNull ("Qname returned" , qName );
89+ }
8490}
You can’t perform that action at this time.
0 commit comments