use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class ResourceFactoryTest method createRemoteResourceTest.
@Test
public void createRemoteResourceTest() {
ReferenceParametersType refParams = createReferenceParameters();
ResourceManager manager = EasyMock.createMock(ResourceManager.class);
EasyMock.expect(manager.create(EasyMock.isA(Representation.class))).andReturn(refParams);
EasyMock.expectLastCall().once();
EasyMock.replay(manager);
Server remoteResourceFactory = createRemoteResourceFactory();
Server remoteResource = createRemoteResource(manager);
ResourceFactory client = createClient();
Create createRequest = new Create();
Representation representation = new Representation();
representation.setAny(createXMLRepresentation());
createRequest.setRepresentation(representation);
CreateResponse response = client.create(createRequest);
EasyMock.verify(manager);
Assert.assertEquals("ResourceAddress is other than expected.", RESOURCE_REMOTE_ADDRESS, response.getResourceCreated().getAddress().getValue());
Element refParamEl = (Element) response.getResourceCreated().getReferenceParameters().getAny().get(0);
Assert.assertEquals(REF_PARAM_NAMESPACE, refParamEl.getNamespaceURI());
Assert.assertEquals(REF_PARAM_LOCAL_NAME, refParamEl.getLocalName());
Assert.assertEquals(RESOURCE_UUID, refParamEl.getTextContent());
Assert.assertEquals("root", ((Element) response.getRepresentation().getAny()).getLocalName());
Assert.assertEquals(2, ((Element) response.getRepresentation().getAny()).getChildNodes().getLength());
remoteResourceFactory.destroy();
remoteResource.destroy();
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class ResourceRemote method create.
@Override
public CreateResponse create(Create body) {
Representation representation = body.getRepresentation();
ValidAndTransformHelper.validationAndTransformation(getResourceTypeIdentifiers(), representation, null);
ReferenceParametersType refParams = getManager().create(representation);
CreateResponse response = new CreateResponse();
response.setResourceCreated(new EndpointReferenceType());
response.getResourceCreated().setReferenceParameters(refParams);
response.setRepresentation(body.getRepresentation());
return response;
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class CreateTeacherTest method createTeacherTest.
@Test
public void createTeacherTest() throws XMLStreamException {
Document createTeacherXML = StaxUtils.read(getClass().getResourceAsStream("/xml/createTeacher.xml"));
Create request = new Create();
request.setRepresentation(new Representation());
request.getRepresentation().setAny(createTeacherXML.getDocumentElement());
ResourceFactory rf = TestUtils.createResourceFactoryClient(PORT);
CreateResponse response = rf.create(request);
Assert.assertEquals(RESOURCE_TEACHERS_URL, response.getResourceCreated().getAddress().getValue());
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class DeleteTest method deleteTeacher.
@Test
public void deleteTeacher() throws XMLStreamException {
CreateResponse response = createTeacher();
Resource client = TestUtils.createResourceClient(response.getResourceCreated());
client.delete(new Delete());
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class DeleteTest method deleteStudent.
@Test
public void deleteStudent() throws XMLStreamException {
CreateResponse response = createStudent();
Resource client = TestUtils.createResourceClient(response.getResourceCreated());
client.delete(new Delete());
}
Aggregations