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();
}
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());
}
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());
}
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);
}
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);
}
Aggregations