Search in sources :

Example 6 with GetResponse

use of org.apache.cxf.ws.transfer.GetResponse in project cxf by apache.

the class FragmentGetQNameTest method qetEmptyResultTest.

@Test
public void qetEmptyResultTest() throws XMLStreamException {
    String content = "<root><a><b>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.QNAME_LANGUAGE_IRI);
    expression.getContent().add("c");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(0, value.getContent().size());
    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) 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)

Example 7 with GetResponse

use of org.apache.cxf.ws.transfer.GetResponse in project cxf by apache.

the class FragmentGetXPath10Test method getTest.

@Test
public void getTest() throws XMLStreamException {
    String content = "<root><a><b>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");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(1, value.getContent().size());
    Assert.assertEquals("b", ((Element) value.getContent().get(0)).getLocalName());
    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) 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)

Example 8 with GetResponse

use of org.apache.cxf.ws.transfer.GetResponse in project cxf by apache.

the class FragmentGetXPath10Test method getNumberTest.

@Test
public void getNumberTest() throws XMLStreamException {
    String content = "<root><a><b>Text</b><b>Text2</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("count(//b)");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(1, value.getContent().size());
    Assert.assertEquals("2", value.getContent().get(0));
    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) 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)

Example 9 with GetResponse

use of org.apache.cxf.ws.transfer.GetResponse in project cxf by apache.

the class GetTest method getTeacherTest.

@Test
public void getTeacherTest() {
    Resource client = TestUtils.createResourceClient(teacherRef);
    GetResponse response = client.get(new Get());
    Element representation = (Element) response.getRepresentation().getAny();
    NodeList children = representation.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Element child = (Element) children.item(i);
        if ("name".equals(child.getLocalName())) {
            Assert.assertEquals("Bob", child.getTextContent());
        } else if ("surname".equals(child.getLocalName())) {
            Assert.assertEquals("Stuart", child.getTextContent());
        } else if ("address".equals(child.getLocalName())) {
            Assert.assertEquals("Street 526", child.getTextContent());
        }
    }
}
Also used : Get(org.apache.cxf.ws.transfer.Get) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Resource(org.apache.cxf.ws.transfer.resource.Resource) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Example 10 with GetResponse

use of org.apache.cxf.ws.transfer.GetResponse in project cxf by apache.

the class GetTest method getStudentTest.

@Test
public void getStudentTest() {
    Resource client = TestUtils.createResourceClient(studentRef);
    GetResponse response = client.get(new Get());
    Element representation = (Element) response.getRepresentation().getAny();
    NodeList children = representation.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Element child = (Element) children.item(i);
        if ("name".equals(child.getLocalName())) {
            Assert.assertEquals("John", child.getTextContent());
        } else if ("surname".equals(child.getLocalName())) {
            Assert.assertEquals("Smith", child.getTextContent());
        } else if ("address".equals(child.getLocalName())) {
            Assert.assertEquals("Street 21", child.getTextContent());
        }
    }
}
Also used : Get(org.apache.cxf.ws.transfer.Get) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Resource(org.apache.cxf.ws.transfer.resource.Resource) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Aggregations

GetResponse (org.apache.cxf.ws.transfer.GetResponse)19 Get (org.apache.cxf.ws.transfer.Get)18 Resource (org.apache.cxf.ws.transfer.resource.Resource)18 Test (org.junit.Test)18 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)17 Server (org.apache.cxf.endpoint.Server)16 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)16 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)16 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)15 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)15 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)15 Element (org.w3c.dom.Element)5 JAXBElement (javax.xml.bind.JAXBElement)2 Representation (org.apache.cxf.ws.transfer.Representation)2 NodeList (org.w3c.dom.NodeList)2 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 Dialect (org.apache.cxf.ws.transfer.dialect.Dialect)1 FragmentDialect (org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialect)1 UnknownDialect (org.apache.cxf.ws.transfer.shared.faults.UnknownDialect)1