use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.
the class DeleteTest method getDeletedStudent.
@Test(expected = SOAPFaultException.class)
public void getDeletedStudent() throws XMLStreamException {
CreateResponse response = createStudent();
Resource client = TestUtils.createResourceClient(response.getResourceCreated());
client.delete(new Delete());
client.get(new Get());
}
use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.
the class GetTest method getTeacherTest.
@Test
public void getTeacherTest() {
Resource client = TestUtils.createResourceClient(teacherRef);
GetResponse response = client.get(new Get());
Element representation = (Element) response.getRepresentation().getAny();
NodeList children = representation.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Element child = (Element) children.item(i);
if ("name".equals(child.getLocalName())) {
Assert.assertEquals("Bob", child.getTextContent());
} else if ("surname".equals(child.getLocalName())) {
Assert.assertEquals("Stuart", child.getTextContent());
} else if ("address".equals(child.getLocalName())) {
Assert.assertEquals("Street 526", child.getTextContent());
}
}
}
use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.
the class PutTest method wrongStudentPutTest.
@Test(expected = SOAPFaultException.class)
public void wrongStudentPutTest() throws XMLStreamException {
createStudent();
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.resource.Resource in project cxf by apache.
the class TestUtils method createResourceClient.
protected static Resource createResourceClient(EndpointReferenceType ref) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Resource.class);
factory.setAddress(ref.getAddress().getValue());
Resource proxy = (Resource) factory.create();
// Add reference parameters
AddressingProperties addrProps = new AddressingProperties();
addrProps.setTo(ref);
((BindingProvider) proxy).getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProps);
return proxy;
}
use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.
the class DeleteTest method deleteDeletedStudent.
@Test(expected = SOAPFaultException.class)
public void deleteDeletedStudent() throws XMLStreamException {
CreateResponse response = createStudent();
Resource client = TestUtils.createResourceClient(response.getResourceCreated());
client.delete(new Delete());
client.delete(new Delete());
}
Aggregations