Search in sources :

Example 11 with Create

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

the class DeleteTest method createStudent.

private CreateResponse createStudent() throws XMLStreamException {
    Document createStudentXML = StaxUtils.read(getClass().getResourceAsStream("/xml/createStudent.xml"));
    Create request = new Create();
    request.setRepresentation(new Representation());
    request.getRepresentation().setAny(createStudentXML.getDocumentElement());
    ResourceFactory rf = TestUtils.createResourceFactoryClient(PORT);
    return rf.create(request);
}
Also used : Create(org.apache.cxf.ws.transfer.Create) Representation(org.apache.cxf.ws.transfer.Representation) ResourceFactory(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory) Document(org.w3c.dom.Document)

Example 12 with Create

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

the class PutTest method createTeacher.

private CreateResponse createTeacher() 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);
    return rf.create(request);
}
Also used : Create(org.apache.cxf.ws.transfer.Create) Representation(org.apache.cxf.ws.transfer.Representation) ResourceFactory(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory) Document(org.w3c.dom.Document)

Example 13 with Create

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

the class PutTest method createStudent.

private CreateResponse createStudent() throws XMLStreamException {
    Document createStudentXML = StaxUtils.read(getClass().getResourceAsStream("/xml/createStudent.xml"));
    Create request = new Create();
    request.setRepresentation(new Representation());
    request.getRepresentation().setAny(createStudentXML.getDocumentElement());
    ResourceFactory rf = TestUtils.createResourceFactoryClient(PORT);
    return rf.create(request);
}
Also used : Create(org.apache.cxf.ws.transfer.Create) Representation(org.apache.cxf.ws.transfer.Representation) ResourceFactory(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory) Document(org.w3c.dom.Document)

Example 14 with Create

use of org.apache.cxf.ws.transfer.Create 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();
}
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)

Aggregations

Create (org.apache.cxf.ws.transfer.Create)14 Representation (org.apache.cxf.ws.transfer.Representation)14 ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)14 Document (org.w3c.dom.Document)12 Test (org.junit.Test)9 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)6 Server (org.apache.cxf.endpoint.Server)2 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)2 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)2 Element (org.w3c.dom.Element)2 BeforeClass (org.junit.BeforeClass)1