Search in sources :

Example 1 with ResourceFactory

use of org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory 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 ResourceFactory

use of org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory 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 3 with ResourceFactory

use of org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory in project cxf by apache.

the class DeleteTest 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 4 with ResourceFactory

use of org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory in project cxf by apache.

the class GetTest method beforeClass.

@BeforeClass
public static void beforeClass() throws XMLStreamException {
    TestUtils.createStudentsServers(PORT, PORT2);
    TestUtils.createTeachersServers(PORT2);
    ResourceFactory rf = TestUtils.createResourceFactoryClient(PORT);
    Document createStudentXML = StaxUtils.read(GetTest.class.getResourceAsStream("/xml/createStudent.xml"));
    Create studentRequest = new Create();
    studentRequest.setRepresentation(new Representation());
    studentRequest.getRepresentation().setAny(createStudentXML.getDocumentElement());
    studentRef = rf.create(studentRequest).getResourceCreated();
    Document createTeacherXML = StaxUtils.read(GetTest.class.getResourceAsStream("/xml/createTeacher.xml"));
    Create teacherRequest = new Create();
    teacherRequest.setRepresentation(new Representation());
    teacherRequest.getRepresentation().setAny(createTeacherXML.getDocumentElement());
    teacherRef = rf.create(teacherRequest).getResourceCreated();
}
Also used : Create(org.apache.cxf.ws.transfer.Create) ResourceFactory(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory) Representation(org.apache.cxf.ws.transfer.Representation) Document(org.w3c.dom.Document) BeforeClass(org.junit.BeforeClass)

Example 5 with ResourceFactory

use of org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory in project cxf by apache.

the class CreateStudentTest method createStudentTest.

@Test
public void createStudentTest() 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);
    CreateResponse response = rf.create(request);
    Assert.assertEquals(RESOURCE_STUDENTS_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)

Aggregations

ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)16 Create (org.apache.cxf.ws.transfer.Create)14 Representation (org.apache.cxf.ws.transfer.Representation)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 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)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