Search in sources :

Example 6 with Representation

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

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

Example 8 with Representation

use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.

the class MemoryResourceManagerTest method getEmptyRepresentationTest.

@Test
public void getEmptyRepresentationTest() {
    ReferenceParametersType refParams = resourceManager.create(new Representation());
    Representation returnedRepresentation = resourceManager.get(refParams);
    Assert.assertNull(returnedRepresentation.getAny());
}
Also used : ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) Test(org.junit.Test)

Example 9 with Representation

use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.

the class MemoryResourceManagerTest method putUnknownReferenceParamsTest.

@Test(expected = UnknownResource.class)
public void putUnknownReferenceParamsTest() {
    ReferenceParametersType refParams = new ReferenceParametersType();
    Element uuid = DOMUtils.getEmptyDocument().createElementNS(MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
    uuid.setTextContent("123456");
    refParams.getAny().add(uuid);
    resourceManager.put(refParams, new Representation());
}
Also used : Element(org.w3c.dom.Element) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) Test(org.junit.Test)

Example 10 with Representation

use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.

the class XSDResourceValidatorTest method loadRepresentation.

private Representation loadRepresentation(InputStream input) throws XMLStreamException {
    Document doc = StaxUtils.read(input);
    Representation representation = new Representation();
    representation.setAny(doc.getDocumentElement());
    return representation;
}
Also used : Representation(org.apache.cxf.ws.transfer.Representation) Document(org.w3c.dom.Document)

Aggregations

Representation (org.apache.cxf.ws.transfer.Representation)48 Test (org.junit.Test)29 Document (org.w3c.dom.Document)25 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)21 Element (org.w3c.dom.Element)15 Create (org.apache.cxf.ws.transfer.Create)14 ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)14 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)12 Resource (org.apache.cxf.ws.transfer.resource.Resource)11 Put (org.apache.cxf.ws.transfer.Put)10 Server (org.apache.cxf.endpoint.Server)9 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)9 PutResponse (org.apache.cxf.ws.transfer.PutResponse)7 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)7 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)5 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)5 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)5 InvalidExpression (org.apache.cxf.ws.transfer.dialect.fragment.faults.InvalidExpression)5 InvalidRepresentation (org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation)5 Node (org.w3c.dom.Node)5