Search in sources :

Example 31 with Resource

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

Example 32 with Resource

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());
        }
    }
}
Also used : Get(org.apache.cxf.ws.transfer.Get) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Resource(org.apache.cxf.ws.transfer.resource.Resource) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Example 33 with Resource

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

Example 34 with Resource

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;
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Resource(org.apache.cxf.ws.transfer.resource.Resource) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties)

Example 35 with Resource

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

Resource (org.apache.cxf.ws.transfer.resource.Resource)66 Test (org.junit.Test)63 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)51 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)51 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)51 Server (org.apache.cxf.endpoint.Server)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)39 Put (org.apache.cxf.ws.transfer.Put)37 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Get (org.apache.cxf.ws.transfer.Get)21 GetResponse (org.apache.cxf.ws.transfer.GetResponse)18 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 Representation (org.apache.cxf.ws.transfer.Representation)11 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)10 Delete (org.apache.cxf.ws.transfer.Delete)7 Document (org.w3c.dom.Document)6 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)3