equal
deleted
inserted
replaced
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 8159058 |
26 * @bug 8159058 8186441 |
27 * @summary Test that empty default namespace declaration clears the |
27 * @summary Test that empty default namespace declaration clears the |
28 * default namespace value |
28 * default namespace value |
29 * @modules java.xml.ws/com.sun.xml.internal.ws.api |
29 * @modules java.xml.ws/com.sun.xml.internal.ws.api |
30 * java.xml.ws/com.sun.xml.internal.ws.api.message.saaj |
30 * java.xml.ws/com.sun.xml.internal.ws.api.message.saaj |
31 * java.xml.ws/com.sun.xml.internal.ws.message.stream |
31 * java.xml.ws/com.sun.xml.internal.ws.message.stream |
59 import org.w3c.dom.Node; |
59 import org.w3c.dom.Node; |
60 |
60 |
61 public class SaajEmptyNamespaceTest { |
61 public class SaajEmptyNamespaceTest { |
62 |
62 |
63 /* |
63 /* |
|
64 * Test that SOAP reader doesn't move namespaces declarations to SOAP body element |
|
65 * as reported in JDK-8186441 |
|
66 */ |
|
67 @Test |
|
68 public void testPreserveNamespacesPosition() throws Exception { |
|
69 // Create SOAP message from XML string and process it with SAAJ reader |
|
70 XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( |
|
71 new StringReader(INPUT_SOAP_MESSAGE_2)); |
|
72 StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, |
|
73 envelope, null); |
|
74 SAAJFactory saajFact = new SAAJFactory(); |
|
75 SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); |
|
76 |
|
77 //Get SOAP body and convert it to string representation |
|
78 SOAPBody body = soapMessage.getSOAPBody(); |
|
79 String bodyAsString = nodeToText(body); |
|
80 Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); |
|
81 } |
|
82 |
|
83 /* |
64 * Test that SOAP message with default namespace declaration that contains empty |
84 * Test that SOAP message with default namespace declaration that contains empty |
65 * string is properly processed by SAAJ reader. |
85 * string is properly processed by SAAJ reader. |
66 */ |
86 */ |
67 @Test |
87 @Test |
68 public void testResetDefaultNamespaceSAAJ() throws Exception { |
88 public void testResetDefaultNamespaceSAAJ() throws Exception { |
273 + "</s:Body>" |
293 + "</s:Body>" |
274 + "</s:Envelope>"; |
294 + "</s:Envelope>"; |
275 |
295 |
276 // Expected body content after SAAJ processing |
296 // Expected body content after SAAJ processing |
277 private static String EXPECTED_RESULT = "<SampleServiceRequest" |
297 private static String EXPECTED_RESULT = "<SampleServiceRequest" |
278 +" xmlns=\"http://example.org/test\">" |
298 + " xmlns=\"http://example.org/test\"" |
|
299 + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" |
279 + "<RequestParams xmlns=\"\">" |
300 + "<RequestParams xmlns=\"\">" |
280 + "<Param1>hogehoge</Param1>" |
301 + "<Param1>hogehoge</Param1>" |
281 + "<Param2>fugafuga</Param2>" |
302 + "<Param2>fugafuga</Param2>" |
282 + "</RequestParams>" |
303 + "</RequestParams>" |
283 + "</SampleServiceRequest>"; |
304 + "</SampleServiceRequest>"; |
|
305 |
|
306 private static String PRESERVE_NAMESPACES_EXPECTED_RESULT = |
|
307 "<s:Body xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" |
|
308 +"<Request xmlns=\"http://example.org/NS_1\">" |
|
309 +"<Item><Contact xmlns=\"http://example.org/NS_2\">Test_Contact</Contact>" |
|
310 +"</Item></Request></s:Body>"; |
|
311 |
|
312 private static String INPUT_SOAP_MESSAGE_2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
|
313 + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" |
|
314 + "<s:Body>" |
|
315 + "<Request xmlns=\"http://example.org/NS_1\">" |
|
316 + "<Item>" |
|
317 + "<Contact xmlns=\"http://example.org/NS_2\">Test_Contact</Contact>" |
|
318 + "</Item>" |
|
319 + "</Request>" |
|
320 + "</s:Body>" |
|
321 + "</s:Envelope>"; |
284 } |
322 } |