Search in sources :

Example 21 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType 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 22 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class ResourceTest method putRequestTest.

@Test
public void putRequestTest() {
    ResourceManager manager = EasyMock.createMock(ResourceManager.class);
    EasyMock.expect(manager.get(EasyMock.isA(ReferenceParametersType.class))).andReturn(new Representation());
    EasyMock.expectLastCall().once();
    manager.put(EasyMock.isA(ReferenceParametersType.class), EasyMock.isA(Representation.class));
    EasyMock.expectLastCall().once();
    EasyMock.replay(manager);
    ReferenceParametersType refParams = new ReferenceParametersType();
    Element uuid = document.createElementNS(MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
    uuid.setTextContent(UUID_VALUE);
    refParams.getAny().add(uuid);
    Element representationEl = document.createElementNS(REPRESENTATION_NAMESPACE, REPRESENTATION_NAME);
    representationEl.setTextContent(REPRESENTATION_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    Server server = createLocalResource(manager);
    Resource client = createClient(refParams);
    Put putRequest = new Put();
    putRequest.setRepresentation(representation);
    PutResponse response = client.put(putRequest);
    EasyMock.verify(manager);
    representationEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals("Namespace is other than expected.", REPRESENTATION_NAMESPACE, representationEl.getNamespaceURI());
    Assert.assertEquals("Element name is other than expected", REPRESENTATION_NAME, representationEl.getLocalName());
    Assert.assertEquals("Value is other than expected.", REPRESENTATION_VALUE, representationEl.getTextContent());
    server.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) Element(org.w3c.dom.Element) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) PutResponse(org.apache.cxf.ws.transfer.PutResponse) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 23 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class ResourceTest method deleteRequestTest.

@Test
public void deleteRequestTest() {
    ResourceManager manager = EasyMock.createMock(ResourceManager.class);
    manager.delete(EasyMock.isA(ReferenceParametersType.class));
    EasyMock.expectLastCall().once();
    EasyMock.replay(manager);
    ReferenceParametersType refParams = new ReferenceParametersType();
    Element uuid = document.createElementNS(MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
    uuid.setTextContent(UUID_VALUE);
    refParams.getAny().add(uuid);
    Server server = createLocalResource(manager);
    Resource client = createClient(refParams);
    client.delete(new Delete());
    EasyMock.verify(manager);
    server.destroy();
}
Also used : Delete(org.apache.cxf.ws.transfer.Delete) Server(org.apache.cxf.endpoint.Server) Element(org.w3c.dom.Element) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) Test(org.junit.Test)

Example 24 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class MemoryResourceManagerTest method putTest.

@Test
public void putTest() {
    Element representationEl = document.createElementNS(ELEMENT_NAMESPACE, ELEMENT_NAME);
    representationEl.setTextContent(ELEMENT_VALUE);
    Representation representation = new Representation();
    representation.setAny(representationEl);
    Element representationElNew = document.createElementNS(ELEMENT_NAMESPACE, ELEMENT_NAME);
    representationElNew.setTextContent(ELEMENT_VALUE_NEW);
    Representation representationNew = new Representation();
    representationNew.setAny(representationElNew);
    ReferenceParametersType refParams = resourceManager.create(representation);
    resourceManager.put(refParams, representationNew);
    Representation returnedRepresentation = resourceManager.get(refParams);
    Element returnedEl = (Element) returnedRepresentation.getAny();
    Assert.assertEquals("Namespace is other than expected.", ELEMENT_NAMESPACE, returnedEl.getNamespaceURI());
    Assert.assertEquals("Element name is other than expected", ELEMENT_NAME, returnedEl.getLocalName());
    Assert.assertEquals("Value is other than expected.", ELEMENT_VALUE_NEW, returnedEl.getTextContent());
}
Also used : Element(org.w3c.dom.Element) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Test(org.junit.Test)

Example 25 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class MemoryResourceManagerTest method createEmptyRepresentationTest.

@Test
public void createEmptyRepresentationTest() {
    ReferenceParametersType refParams = resourceManager.create(new Representation());
    Assert.assertTrue("ResourceManager returned unexpected count of reference elements.", refParams.getAny().size() == 1);
}
Also used : ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) Test(org.junit.Test)

Aggregations

ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)76 Test (org.junit.Test)65 Server (org.apache.cxf.endpoint.Server)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)53 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)51 Resource (org.apache.cxf.ws.transfer.resource.Resource)51 Element (org.w3c.dom.Element)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)26 Representation (org.apache.cxf.ws.transfer.Representation)21 Get (org.apache.cxf.ws.transfer.Get)17 GetResponse (org.apache.cxf.ws.transfer.GetResponse)17 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 JAXBElement (javax.xml.bind.JAXBElement)8 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)8 QName (javax.xml.namespace.QName)4 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)4