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();
}
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());
}
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);
}
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();
}
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());
}
Aggregations