Search in sources :

Example 16 with ResourceFactory

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

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