Search in sources :

Example 11 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentPutRemoveTest method removeElement2Test.

@Test
public void removeElement2Test() throws XMLStreamException {
    String content = "<a><b/><b/></a>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_REMOVE);
    expression.getContent().add("/a/b[1]");
    fragment.setExpression(expression);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals(1, rootEl.getChildNodes().getLength());
    resource.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) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) PutResponse(org.apache.cxf.ws.transfer.PutResponse) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 12 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentPutRemoveTest method removeElementTest.

@Test
public void removeElementTest() throws XMLStreamException {
    String content = "<a><b/></a>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_REMOVE);
    expression.getContent().add("/a/b");
    fragment.setExpression(expression);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals(0, rootEl.getChildNodes().getLength());
    resource.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) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) PutResponse(org.apache.cxf.ws.transfer.PutResponse) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 13 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentPutReplaceTest method replaceOneElementTest.

@Test
public void replaceOneElementTest() throws XMLStreamException {
    String content = "<a><b/><b/></a>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.getContent().add("/a/b[1]");
    Element replacedElement = DOMUtils.getEmptyDocument().createElement("c");
    ValueType value = new ValueType();
    value.getContent().add(replacedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals("c", ((Element) rootEl.getChildNodes().item(0)).getLocalName());
    Assert.assertEquals("b", ((Element) rootEl.getChildNodes().item(1)).getLocalName());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) 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) PutResponse(org.apache.cxf.ws.transfer.PutResponse) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 14 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentPutReplaceTest method replaceDocumentTest.

@Test
public void replaceDocumentTest() throws XMLStreamException {
    String content = "<a/>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.getContent().add("/");
    Element replacedElement = DOMUtils.getEmptyDocument().createElement("b");
    ValueType value = new ValueType();
    value.getContent().add(replacedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals("b", rootEl.getNodeName());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) 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) PutResponse(org.apache.cxf.ws.transfer.PutResponse) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 15 with MemoryResourceManager

use of org.apache.cxf.ws.transfer.manager.MemoryResourceManager in project cxf by apache.

the class FragmentPutReplaceTest method replaceNonExistingRootTest.

@Test
public void replaceNonExistingRootTest() {
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(new Representation());
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.getContent().add("/a");
    Element replacedElement = DOMUtils.getEmptyDocument().createElement("a");
    ValueType value = new ValueType();
    value.getContent().add(replacedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals("a", rootEl.getLocalName());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) 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) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Aggregations

MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)50 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)50 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)48 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 Resource (org.apache.cxf.ws.transfer.resource.Resource)48 Test (org.junit.Test)48 Server (org.apache.cxf.endpoint.Server)47 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)34 Put (org.apache.cxf.ws.transfer.Put)32 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)24 Get (org.apache.cxf.ws.transfer.Get)16 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 GetResponse (org.apache.cxf.ws.transfer.GetResponse)15 Representation (org.apache.cxf.ws.transfer.Representation)5 JAXBElement (javax.xml.bind.JAXBElement)2 Document (org.w3c.dom.Document)2 StreamSource (javax.xml.transform.stream.StreamSource)1 TeacherResourceValidator (org.apache.cxf.systest.ws.transfer.validator.TeacherResourceValidator)1