Search in sources :

Example 46 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentGetXPath10Test 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.XPATH10_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 47 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentGetXPath10Test method getBooleanFalseTest.

@Test
public void getBooleanFalseTest() 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) != 2");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(1, value.getContent().size());
    Assert.assertEquals("false", 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 48 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentGetXPath10Test method getMoreValuesTest.

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

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentGetXPath10Test method getMoreValues2Test.

@Test
public void getMoreValues2Test() throws XMLStreamException {
    String content = "<root><a><b>Text1</b><b>Text2</b><b><b>Text3</b></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("//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 50 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager 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

MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)50 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)50 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)48 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 Resource (org.apache.cxf.ws.transfer.resource.Resource)48 Test (org.junit.Test)48 Server (org.apache.cxf.endpoint.Server)47 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)34 Put (org.apache.cxf.ws.transfer.Put)32 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)24 Get (org.apache.cxf.ws.transfer.Get)16 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 GetResponse (org.apache.cxf.ws.transfer.GetResponse)15 Representation (org.apache.cxf.ws.transfer.Representation)5 JAXBElement (javax.xml.bind.JAXBElement)2 Document (org.w3c.dom.Document)2 StreamSource (javax.xml.transform.stream.StreamSource)1 TeacherResourceValidator (org.apache.cxf.systest.ws.transfer.validator.TeacherResourceValidator)1