Search in sources :

Example 36 with Representation

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

the class ResourceTest method getRequestTest.

@Test
public void getRequestTest() {
    Element representationEl = document.createElementNS(REPRESENTATION_NAMESPACE, REPRESENTATION_NAME);
    representationEl.setTextContent(REPRESENTATION_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    ResourceManager manager = EasyMock.createMock(ResourceManager.class);
    EasyMock.expect(manager.get(EasyMock.isA(ReferenceParametersType.class))).andReturn(representation);
    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);
    GetResponse response = client.get(new Get());
    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) Get(org.apache.cxf.ws.transfer.Get) Resource(org.apache.cxf.ws.transfer.resource.Resource) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Example 37 with Representation

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

the class MemoryResourceManagerTest method getTest.

@Test
public void getTest() {
    Element representationEl = document.createElementNS(ELEMENT_NAMESPACE, ELEMENT_NAME);
    representationEl.setTextContent(ELEMENT_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    ReferenceParametersType refParams = resourceManager.create(representation);
    Representation returnedRepresentation = resourceManager.get(refParams);
    Element returnedEl = (Element) returnedRepresentation.getAny();
    Assert.assertEquals("Namespace is other than expected.", ELEMENT_NAMESPACE, returnedEl.getNamespaceURI());
    Assert.assertEquals("Element name is other than expected", ELEMENT_NAME, returnedEl.getLocalName());
    Assert.assertEquals("Value is other than expected.", ELEMENT_VALUE, returnedEl.getTextContent());
}
Also used : Element(org.w3c.dom.Element) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Test(org.junit.Test)

Example 38 with Representation

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

the class MemoryResourceManagerTest method putEmptyRepresentationTest.

@Test
public void putEmptyRepresentationTest() {
    Element representationEl = document.createElementNS(ELEMENT_NAMESPACE, ELEMENT_NAME);
    representationEl.setTextContent(ELEMENT_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    ReferenceParametersType refParams = resourceManager.create(representation);
    resourceManager.put(refParams, new Representation());
}
Also used : Element(org.w3c.dom.Element) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Test(org.junit.Test)

Example 39 with Representation

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

the class MemoryResourceManagerTest method deleteTest.

@Test(expected = UnknownResource.class)
public void deleteTest() {
    ReferenceParametersType refParams = resourceManager.create(new Representation());
    resourceManager.delete(refParams);
    resourceManager.get(refParams);
}
Also used : ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) Test(org.junit.Test)

Example 40 with Representation

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

the class MemoryResourceManagerTest method createTest.

@Test
public void createTest() {
    Element representationEl = document.createElementNS(ELEMENT_NAMESPACE, ELEMENT_NAME);
    representationEl.setTextContent(ELEMENT_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    ReferenceParametersType refParams = resourceManager.create(representation);
    Assert.assertTrue("ResourceManager returned unexpected count of reference elements.", refParams.getAny().size() == 1);
}
Also used : Element(org.w3c.dom.Element) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Test(org.junit.Test)

Aggregations

Representation (org.apache.cxf.ws.transfer.Representation)48 Test (org.junit.Test)29 Document (org.w3c.dom.Document)25 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)21 Element (org.w3c.dom.Element)15 Create (org.apache.cxf.ws.transfer.Create)14 ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)14 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)12 Resource (org.apache.cxf.ws.transfer.resource.Resource)11 Put (org.apache.cxf.ws.transfer.Put)10 Server (org.apache.cxf.endpoint.Server)9 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)9 PutResponse (org.apache.cxf.ws.transfer.PutResponse)7 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)7 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)5 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)5 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)5 InvalidExpression (org.apache.cxf.ws.transfer.dialect.fragment.faults.InvalidExpression)5 InvalidRepresentation (org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation)5 Node (org.w3c.dom.Node)5