Search in sources :

Example 71 with OMNamespace

use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.

the class TestCloneUnknownName method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMDataSource ds = new StringOMDataSource("<p:element xmlns:p='urn:ns'>test</p:element>");
    OMSourcedElement element = factory.createOMElement(ds);
    OMCloneOptions options = new OMCloneOptions();
    options.setCopyOMDataSources(true);
    OMElement clone = (OMElement) element.clone(options);
    assertTrue(clone instanceof OMSourcedElement);
    assertFalse(element.isExpanded());
    OMNamespace expectedNS = factory.createOMNamespace("urn:ns", "p");
    assertEquals("element", element.getLocalName());
    assertEquals("element", clone.getLocalName());
    assertEquals(expectedNS, element.getNamespace());
    assertEquals(expectedNS, clone.getNamespace());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMDataSource(org.apache.axiom.om.OMDataSource) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) OMCloneOptions(org.apache.axiom.om.OMCloneOptions) OMElement(org.apache.axiom.om.OMElement) OMSourcedElement(org.apache.axiom.om.OMSourcedElement)

Example 72 with OMNamespace

use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.

the class TestObjectEqualsWithDifferentPrefixes method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace ns1 = factory.createOMNamespace("urn:ns", "ns1");
    OMNamespace ns2 = factory.createOMNamespace("urn:ns", "ns2");
    assertFalse(ns1.equals(ns2));
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace)

Example 73 with OMNamespace

use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.

the class TestObjectEqualsWithDifferentURIs method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "ns");
    OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "ns");
    assertFalse(ns1.equals(ns2));
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace)

Example 74 with OMNamespace

use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.

the class TestInsertSiblingAfterLastChild method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory fac = metaFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace("http://www.testuri.com", "ns");
    OMElement parent = fac.createOMElement("parent", ns);
    // Create three OMElements
    OMElement c1 = fac.createOMElement("c1", ns);
    OMElement c2 = fac.createOMElement("c2", ns);
    OMElement c3 = fac.createOMElement("c3", ns);
    // Add c1 to parent using parent.addChild()
    parent.addChild(c1);
    // Add c2 to c1 as a sibling after
    c1.insertSiblingAfter(c2);
    // Now add c3 to parent using parent.addChild()
    parent.addChild(c3);
    assertAbout(xml()).that(xml(OMElement.class, parent)).ignoringRedundantNamespaceDeclarations().hasSameContentAs("<ns:parent xmlns:ns=\"http://www.testuri.com\">" + "<ns:c1 /><ns:c2 /><ns:c3 /></ns:parent>");
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMElement(org.apache.axiom.om.OMElement)

Example 75 with OMNamespace

use of org.apache.axiom.om.OMNamespace in project webservices-axiom by apache.

the class TestComplete method runTest.

@Override
protected void runTest() throws Throwable {
    // Build a root element and child OMSE
    OMFactory f = metaFactory.getOMFactory();
    OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
    OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
    OMElement child = f.createOMElement(new PullOMDataSource(TestDocument.DOCUMENT1.getContent()), "library", ns);
    OMElement root = f.createOMElement("root", rootNS);
    // Trigger expansion of the child OMSE
    // This will cause the child to be partially parsed (i.e. incomplete)
    child.getFirstOMChild();
    // Add the child OMSE to the root.
    root.addChild(child);
    // Normally adding an incomplete child to a parent will 
    // cause the parent to be marked as incomplete.
    // But OMSE's are self-contained...therefore the root
    // should still be complete
    assertTrue(!child.isComplete());
    assertTrue(root.isComplete());
    // Now repeat the test, but this time trigger the 
    // partial parsing of the child after adding it to the root.
    child = f.createOMElement(new PullOMDataSource(TestDocument.DOCUMENT1.getContent()), "library", ns);
    root = f.createOMElement("root", rootNS);
    root.addChild(child);
    // causes partial parsing...i.e. incomplete child
    child.getFirstOMChild();
    assertTrue(!child.isComplete());
    assertTrue(root.isComplete());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) PullOMDataSource(org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource) OMElement(org.apache.axiom.om.OMElement)

Aggregations

OMNamespace (org.apache.axiom.om.OMNamespace)171 OMElement (org.apache.axiom.om.OMElement)108 OMFactory (org.apache.axiom.om.OMFactory)101 QName (javax.xml.namespace.QName)34 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)22 OMAttribute (org.apache.axiom.om.OMAttribute)18 PullOMDataSource (org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource)16 StringWriter (java.io.StringWriter)15 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)13 SOAPHeader (org.apache.axiom.soap.SOAPHeader)12 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)9 XMLStreamReader (javax.xml.stream.XMLStreamReader)8 OMText (org.apache.axiom.om.OMText)7 Iterator (java.util.Iterator)6 SOAPBody (org.apache.axiom.soap.SOAPBody)6 StringReader (java.io.StringReader)5 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)5 HashSet (java.util.HashSet)4 OMDataSource (org.apache.axiom.om.OMDataSource)4 OMNode (org.apache.axiom.om.OMNode)4