Search in sources :

Example 1 with CreateResponse

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();
}
Also used : Server(org.apache.cxf.endpoint.Server) Create(org.apache.cxf.ws.transfer.Create) CreateResponse(org.apache.cxf.ws.transfer.CreateResponse) Element(org.w3c.dom.Element) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) ResourceFactory(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) Test(org.junit.Test)

Example 2 with CreateResponse

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;
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) CreateResponse(org.apache.cxf.ws.transfer.CreateResponse) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType)

Example 3 with CreateResponse

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());
}
Also used : Create(org.apache.cxf.ws.transfer.Create) CreateResponse(org.apache.cxf.ws.transfer.CreateResponse) Representation(org.apache.cxf.ws.transfer.Representation) ResourceFactory(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 4 with CreateResponse

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());
}
Also used : Delete(org.apache.cxf.ws.transfer.Delete) CreateResponse(org.apache.cxf.ws.transfer.CreateResponse) Resource(org.apache.cxf.ws.transfer.resource.Resource) Test(org.junit.Test)

Example 5 with CreateResponse

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());
}
Also used : Delete(org.apache.cxf.ws.transfer.Delete) CreateResponse(org.apache.cxf.ws.transfer.CreateResponse) Resource(org.apache.cxf.ws.transfer.resource.Resource) Test(org.junit.Test)

Aggregations

CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)19 Test (org.junit.Test)16 Representation (org.apache.cxf.ws.transfer.Representation)12 Resource (org.apache.cxf.ws.transfer.resource.Resource)10 Document (org.w3c.dom.Document)8 Create (org.apache.cxf.ws.transfer.Create)6 Delete (org.apache.cxf.ws.transfer.Delete)6 ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)6 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)4 Put (org.apache.cxf.ws.transfer.Put)4 Server (org.apache.cxf.endpoint.Server)2 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 Get (org.apache.cxf.ws.transfer.Get)2 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)2 Element (org.w3c.dom.Element)2 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1