use of javax.xml.soap.SOAPElement in project jdk8u_jdk by JetBrains.
the class SaajEmptyNamespaceTest method testAddElementToGlobalNsNoDeclarations.
/*
* Test that adding element with explicitly empty namespace URI shall put
* the element into global namespace. Namespace declarations are not added
* explicitly.
*/
@Test
public void testAddElementToGlobalNsNoDeclarations() throws Exception {
// Create empty SOAP message
SOAPMessage msg = createSoapMessage();
SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();
// Add elements
SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", "");
SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");
// Check namespace URIs
Assert.assertNull(childGlobalNS.getNamespaceURI());
Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
use of javax.xml.soap.SOAPElement in project jdk8u_jdk by JetBrains.
the class SaajEmptyNamespaceTest method testAddElementToNullNs.
/*
* Test that adding element with explicitly null namespace URI shall put
* the element into global namespace.
*/
@Test
public void testAddElementToNullNs() throws Exception {
// Create empty SOAP message
SOAPMessage msg = createSoapMessage();
SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();
// Add elements
SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null);
childGlobalNS.addNamespaceDeclaration("", null);
SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");
// Check namespace URIs
Assert.assertNull(childGlobalNS.getNamespaceURI());
Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI());
}
use of javax.xml.soap.SOAPElement in project jdk8u_jdk by JetBrains.
the class SaajEmptyNamespaceTest method testAddElementToGlobalNsQName.
/*
* Test that adding element with explicitly empty namespace URI via QName
* shall put the element in global namespace.
*/
@Test
public void testAddElementToGlobalNsQName() throws Exception {
// Create empty SOAP message
SOAPMessage msg = createSoapMessage();
SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();
// Add elements
SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName("", "global-child"));
childGlobalNS.addNamespaceDeclaration("", "");
SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");
// Check namespace URIs
Assert.assertNull(childGlobalNS.getNamespaceURI());
Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
use of javax.xml.soap.SOAPElement in project webservices-axiom by apache.
the class TestSetParentElement method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFactory factory = saajImplementation.newSOAPFactory(protocol);
SOAPElement parent = factory.createElement(new QName("parent"));
SOAPElement child1 = parent.addChildElement(new QName("child1"));
SOAPElement child2 = (SOAPElement) parent.getOwnerDocument().createElementNS(null, "child2");
child2.setParentElement(parent);
NodeList children = parent.getChildNodes();
assertEquals(2, children.getLength());
assertSame(child1, children.item(0));
assertSame(child2, children.item(1));
}
Aggregations