Search in sources :

Example 21 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class ResourceTest method putRequestTest.

@Test
public void putRequestTest() {
    ResourceManager manager = EasyMock.createMock(ResourceManager.class);
    EasyMock.expect(manager.get(EasyMock.isA(ReferenceParametersType.class))).andReturn(new Representation());
    EasyMock.expectLastCall().once();
    manager.put(EasyMock.isA(ReferenceParametersType.class), EasyMock.isA(Representation.class));
    EasyMock.expectLastCall().once();
    EasyMock.replay(manager);
    ReferenceParametersType refParams = new ReferenceParametersType();
    Element uuid = document.createElementNS(MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
    uuid.setTextContent(UUID_VALUE);
    refParams.getAny().add(uuid);
    Element representationEl = document.createElementNS(REPRESENTATION_NAMESPACE, REPRESENTATION_NAME);
    representationEl.setTextContent(REPRESENTATION_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    Server server = createLocalResource(manager);
    Resource client = createClient(refParams);
    Put putRequest = new Put();
    putRequest.setRepresentation(representation);
    PutResponse response = client.put(putRequest);
    EasyMock.verify(manager);
    representationEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals("Namespace is other than expected.", REPRESENTATION_NAMESPACE, representationEl.getNamespaceURI());
    Assert.assertEquals("Element name is other than expected", REPRESENTATION_NAME, representationEl.getLocalName());
    Assert.assertEquals("Value is other than expected.", REPRESENTATION_VALUE, representationEl.getTextContent());
    server.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) Element(org.w3c.dom.Element) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) PutResponse(org.apache.cxf.ws.transfer.PutResponse) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 22 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class ResourceTest method deleteRequestTest.

@Test
public void deleteRequestTest() {
    ResourceManager manager = EasyMock.createMock(ResourceManager.class);
    manager.delete(EasyMock.isA(ReferenceParametersType.class));
    EasyMock.expectLastCall().once();
    EasyMock.replay(manager);
    ReferenceParametersType refParams = new ReferenceParametersType();
    Element uuid = document.createElementNS(MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
    uuid.setTextContent(UUID_VALUE);
    refParams.getAny().add(uuid);
    Server server = createLocalResource(manager);
    Resource client = createClient(refParams);
    client.delete(new Delete());
    EasyMock.verify(manager);
    server.destroy();
}
Also used : Delete(org.apache.cxf.ws.transfer.Delete) Server(org.apache.cxf.endpoint.Server) 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) Test(org.junit.Test)

Example 23 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class FragmentGetQNameTest method getMoreValuesTest.

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

use of org.apache.cxf.ws.transfer.resource.Resource 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 25 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource 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)

Aggregations

Resource (org.apache.cxf.ws.transfer.resource.Resource)66 Test (org.junit.Test)63 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)51 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)51 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)51 Server (org.apache.cxf.endpoint.Server)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)39 Put (org.apache.cxf.ws.transfer.Put)37 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Get (org.apache.cxf.ws.transfer.Get)21 GetResponse (org.apache.cxf.ws.transfer.GetResponse)18 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 Representation (org.apache.cxf.ws.transfer.Representation)11 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)10 Delete (org.apache.cxf.ws.transfer.Delete)7 Document (org.w3c.dom.Document)6 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)3