Examples of OMNamespace


Examples of org.apache.axiom.om.OMNamespace


    }

    public void testChildDetachment() {
        OMNamespace testNamespace2 = factory.createOMNamespace("ftp://anotherTest.ws.org", "ws");

        secondElement.detach();
        assertTrue("OMElement children detachment has not worked properly",
                   !secondElement.equals(firstElement.getFirstElement()));
        assertNull("First Element should not contain elements after detaching. ",
                   firstElement.getFirstElement());
        assertNull("First Element should not contain elements after detaching. ",
                   firstElement.getFirstOMChild());
        assertNull(secondElement.findNamespace(testNamespace2.getNamespaceURI(),
                                               testNamespace2.getPrefix()));

        firstElement.addChild(secondElement);
        factory.createOMText(firstElement, "Some Sample Text");

        assertTrue("First added child must be the first child",
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement(new QName("test"));
        OMNamespace ns = factory.createOMNamespace("urn:test", "p");
        element.setNamespace(ns);
        assertEquals(new QName("urn:test", "test"), element.getQName());
        assertEquals(ns, element.getNamespace());
        Iterator it = element.getAllDeclaredNamespaces();
        assertTrue(it.hasNext());
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

   
    public static NamespaceContext getNamespaceContext(OMElement element, boolean detached) {
        if (detached) {
            Map namespaces = new HashMap();
            for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
                OMNamespace ns = (OMNamespace)it.next();
                namespaces.put(ns.getPrefix(), ns.getNamespaceURI());
            }
            return new MapBasedNamespaceContext(namespaces);
        } else {
            return new LiveNamespaceContext(element);
        }
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

            throws XMLStreamException, FactoryConfigurationError, IOException {

        SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
        SOAPEnvelope envelope = factory.getDefaultEnvelope();
        String ns = "http://testuri.org";
        OMNamespace namespace = factory.createOMNamespace(ns, "tst");

        String ln = "Child";

        OMElement bodyChild = factory.createOMElement(ln, namespace);
        bodyChild.addChild(factory.createOMText(value));
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

        boolean ns1seen = false;
        boolean ns2seen = false;
        Iterator it = element.getFirstElement().getNamespacesInScope();
        int count = 0;
        while (it.hasNext()) {
            OMNamespace ns = (OMNamespace)it.next();
            count++;
            if (ns.getPrefix().equals("ns1")) {
                ns1seen = true;
                assertEquals("urn:ns1", ns.getNamespaceURI());
            } else if (ns.getPrefix().equals("ns2")) {
                ns2seen = true;
                assertEquals("urn:ns2", ns.getNamespaceURI());
            } else {
                fail("Unexpected prefix: " + ns.getPrefix());
            }
        }
        assertEquals("Number of namespaces in scope", 2, count);
        assertTrue(ns1seen);
        assertTrue(ns2seen);
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

        if (!hasNextCalled) {
            while (true) {
                if (declaredNamespaces == null) {
                    declaredNamespaces = element.getAllDeclaredNamespaces();
                } else if (declaredNamespaces.hasNext()) {
                    OMNamespace namespace = (OMNamespace)declaredNamespaces.next();
                    // We only return a namespace declaration if it has not been overridden (i.e. if
                    // we have not seen another declaration with the same prefix yet) and if the namespace
                    // URI is not empty. The second part of the condition covers the case of namespace
                    // declarations such as xmlns="" (for which no OMNamespace object is returned, as
                    // described in the Javadoc of the getNamespacesInScope method) as well as undeclared
                    // prefixes (XML 1.1 only).
                    if (seenPrefixes.add(namespace.getPrefix()) && namespace.getNamespaceURI().length() > 0) {
                        next = namespace;
                        break;
                    }
                } else {
                    declaredNamespaces = null;
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

        return next != null;
    }

    public Object next() {
        if (hasNext()) {
            OMNamespace result = next;
            hasNextCalled = false;
            next = null;
            return result;
        } else {
            throw new NoSuchElementException();
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMElement element = metaFactory.getOMFactory().createOMElement(new QName("test"));
        OMNamespace ns = element.declareNamespace("urn:ns1", "ns1");
        assertEquals("urn:ns1", ns.getNamespaceURI());
        assertEquals("ns1", ns.getPrefix());
        Iterator it = element.getAllDeclaredNamespaces();
        assertTrue(it.hasNext());
        OMNamespace ns2 = (OMNamespace)it.next();
        assertEquals(ns, ns2);
        assertFalse(it.hasNext());
    }
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

                                                 OMXMLParserWrapper builder) {
        return new SOAP12FaultDetailImpl(parent, builder, this);
    }

    public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
        OMNamespace ns =
                new OMNamespaceImpl(
                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
                        SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(ns, this);
        createSOAPHeader(env);
View Full Code Here

Examples of org.apache.axiom.om.OMNamespace

        orgEnvelope.getBody().addChild(soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix()));
        String message = orgEnvelope.toString();
       
        SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(message)).getSOAPEnvelope();
        assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
        OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
        if (qname.getNamespaceURI().length() == 0) {
            assertNull(ns);
        } else {
            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
            assertEquals(qname.getPrefix(), ns.getPrefix());
        }
       
        // Also request an XMLStreamReader. The LLOM implementation triggers some special processing
        // in this case (because the getSOAPBodyFirstElementXXX calls put the builder in lookahead
        // mode). This is a regression test for r631687 (AXIOM-282).
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.