Search in sources :

Example 76 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class FragmentGetXPath10Test method getAttrNSTest.

@Test
public void getAttrNSTest() throws XMLStreamException {
    String content = "<root xmlns:ns=\"www.example.org\"><a><b ns:attr1=\"value1\">Text</b></a></root>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    ObjectFactory objectFactory = new ObjectFactory();
    Get request = new Get();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.getContent().add("/root/a/b/@ns:attr1");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(1, value.getContent().size());
    Assert.assertTrue(value.getContent().get(0) instanceof Element);
    Element attrEl = (Element) value.getContent().get(0);
    Assert.assertEquals(FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME, attrEl.getLocalName());
    Assert.assertEquals(FragmentDialectConstants.FRAGMENT_2011_03_IRI, attrEl.getNamespaceURI());
    Assert.assertEquals("ns:attr1", attrEl.getAttribute(FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR));
    Assert.assertEquals("value1", attrEl.getTextContent());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ObjectFactory(org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) Get(org.apache.cxf.ws.transfer.Get) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Aggregations

ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)76 Test (org.junit.Test)65 Server (org.apache.cxf.endpoint.Server)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)53 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)51 Resource (org.apache.cxf.ws.transfer.resource.Resource)51 Element (org.w3c.dom.Element)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)26 Representation (org.apache.cxf.ws.transfer.Representation)21 Get (org.apache.cxf.ws.transfer.Get)17 GetResponse (org.apache.cxf.ws.transfer.GetResponse)17 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 JAXBElement (javax.xml.bind.JAXBElement)8 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)8 QName (javax.xml.namespace.QName)4 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)4