From 9ddee60f5caadb156e2faef68ea87eee138240a3 Mon Sep 17 00:00:00 2001 From: aefimov Date: Sat, 2 Dec 2017 14:28:42 +0000 Subject: [PATCH] 8186441: Change of behavior in the getMessage () method of the SOAPMessageContextImpl class Reviewed-by: lancea --- .../ws/8159058/SaajEmptyNamespaceTest.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java b/test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java index 348617d45..bdc30da0e 100644 --- a/test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java +++ b/test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8159058 + * @bug 8159058 8186441 * @summary Test that empty default namespace declaration clears the * default namespace value * @compile -XDignore.symbol.file SaajEmptyNamespaceTest.java @@ -58,6 +58,26 @@ import org.w3c.dom.Node; public class SaajEmptyNamespaceTest { + /* + * Test that SOAP reader doesn't move namespaces declarations to SOAP body element + * as reported in JDK-8186441 + */ + @Test + public void testPreserveNamespacesPosition() throws Exception { + // Create SOAP message from XML string and process it with SAAJ reader + XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( + new StringReader(INPUT_SOAP_MESSAGE_2)); + StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, + envelope, null); + SAAJFactory saajFact = new SAAJFactory(); + SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); + + //Get SOAP body and convert it to string representation + SOAPBody body = soapMessage.getSOAPBody(); + String bodyAsString = nodeToText(body); + Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); + } + /* * Test that SOAP message with default namespace declaration that contains empty * string is properly processed by SAAJ reader. @@ -273,10 +293,28 @@ public class SaajEmptyNamespaceTest { // Expected body content after SAAJ processing private static String EXPECTED_RESULT = "" + + " xmlns=\"http://example.org/test\"" + + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "" + "hogehoge" + "fugafuga" + "" + ""; + + private static String PRESERVE_NAMESPACES_EXPECTED_RESULT = + "" + +"" + +"Test_Contact" + +""; + + private static String INPUT_SOAP_MESSAGE_2 = "" + + "" + + "" + + "" + + "" + + "Test_Contact" + + "" + + "" + + "" + + ""; } -- GitLab