use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class PutTest method rightStudentPutTest.
@Test
public void rightStudentPutTest() throws XMLStreamException {
CreateResponse createResponse = createStudent();
Document putStudentXML = StaxUtils.read(getClass().getResourceAsStream("/xml/putStudent.xml"));
Put request = new Put();
request.setRepresentation(new Representation());
request.getRepresentation().setAny(putStudentXML.getDocumentElement());
Resource client = TestUtils.createResourceClient(createResponse.getResourceCreated());
client.put(request);
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class ResourceFactoryTest method createLocalResourceTest.
@Test
public void createLocalResourceTest() {
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 localResourceFactory = createLocalResourceFactory(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_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());
localResourceFactory.destroy();
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class ResourceFactoryImpl method createRemotely.
private CreateResponse createRemotely(Create body, ResourceReference ref) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ResourceFactory.class);
factory.setAddress(ref.getResourceURL() + TransferConstants.RESOURCE_REMOTE_SUFFIX);
ResourceFactory client = (ResourceFactory) factory.create();
CreateResponse response = client.create(body);
// Adding of endpoint address to the response.
response.getResourceCreated().setAddress(new AttributedURIType());
response.getResourceCreated().getAddress().setValue(ref.getResourceURL());
return response;
}
use of org.apache.cxf.ws.transfer.CreateResponse in project cxf by apache.
the class ResourceFactoryImpl method createLocally.
private CreateResponse createLocally(Create body, ResourceReference ref) {
Representation representation = body.getRepresentation();
ReferenceParametersType refParams = ref.getResourceManager().create(representation);
CreateResponse response = new CreateResponse();
response.setResourceCreated(new EndpointReferenceType());
response.getResourceCreated().setAddress(new AttributedURIType());
response.getResourceCreated().getAddress().setValue(ref.getResourceURL());
response.getResourceCreated().setReferenceParameters(refParams);
response.setRepresentation(body.getRepresentation());
return response;
}
Aggregations