Search in sources :

Example 31 with OMAttribute

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

the class TestGetLangWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPFaultText faultText = envelope.getBody().getFault().getReason().getFirstSOAPText();
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - getLang method returns incorrect string", faultText.getLang().equals("en"));
    OMAttribute langAttribute = faultText.getAllAttributes().next();
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME));
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX));
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace uri mismatch", langAttribute.getNamespace().getNamespaceURI().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI));
}
Also used : SOAPFaultText(org.apache.axiom.soap.SOAPFaultText) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 32 with OMAttribute

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

the class TestSetLocalName method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMAttribute attr = factory.createOMAttribute("test", factory.createOMNamespace("urn:test", "p"), "value");
    attr.setLocalName("test2");
    assertEquals("test2", attr.getLocalName());
    QName qname = attr.getQName();
    assertEquals("test2", qname.getLocalPart());
    assertEquals("p", qname.getPrefix());
    assertEquals("urn:test", qname.getNamespaceURI());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 33 with OMAttribute

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

the class TestGetPrefixWithoutNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMAttribute attr = factory.createOMAttribute("name", null, "value");
    assertNull(attr.getPrefix());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 34 with OMAttribute

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

the class TestGetQNameWithNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    String localName = "attr";
    String uri = "http://ns1";
    OMFactory fac = metaFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace(uri, "p");
    OMAttribute attr = fac.createOMAttribute(localName, ns, "value");
    QName qname = attr.getQName();
    assertEquals("Wrong namespace", uri, qname.getNamespaceURI());
    assertEquals("Wrong localPart", localName, qname.getLocalPart());
    assertEquals("Wrong prefix", "p", qname.getPrefix());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 35 with OMAttribute

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

the class TestGetQNameWithoutNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    OMAttribute attr = metaFactory.getOMFactory().createOMAttribute("name", null, "value");
    QName qname = attr.getQName();
    assertEquals("name", qname.getLocalPart());
    assertEquals("", qname.getNamespaceURI());
    assertEquals("", qname.getPrefix());
}
Also used : QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Aggregations

OMAttribute (org.apache.axiom.om.OMAttribute)55 OMFactory (org.apache.axiom.om.OMFactory)31 OMElement (org.apache.axiom.om.OMElement)26 OMNamespace (org.apache.axiom.om.OMNamespace)18 QName (javax.xml.namespace.QName)16 OMNode (org.apache.axiom.om.OMNode)4 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)4 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)4 Attr (org.w3c.dom.Attr)4 StringReader (java.io.StringReader)3 OMException (org.apache.axiom.om.OMException)3 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)3 SOAPFaultText (org.apache.axiom.soap.SOAPFaultText)3 PullOMDataSource (org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource)3 Element (org.w3c.dom.Element)3 OMDocument (org.apache.axiom.om.OMDocument)2 OMText (org.apache.axiom.om.OMText)2 SOAPBody (org.apache.axiom.soap.SOAPBody)2 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)2 SOAPFault (org.apache.axiom.soap.SOAPFault)2