Search in sources :

Example 46 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class FragmentPutInsertAfterTest method insertAfterRootTest.

@Test(expected = SOAPFaultException.class)
public void insertAfterRootTest() 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.setMode(FragmentDialectConstants.FRAGMENT_MODE_INSERT_AFTER);
    expression.getContent().add("/");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("b");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    client.put(request);
    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) 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 47 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class FragmentPutInsertAfterTest method insertAfter2Test.

@Test
public void insertAfter2Test() 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_INSERT_AFTER);
    expression.getContent().add("/a/b[last()]");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("c");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Element child0 = (Element) rootEl.getChildNodes().item(0);
    Element child1 = (Element) rootEl.getChildNodes().item(1);
    Element child2 = (Element) rootEl.getChildNodes().item(2);
    Assert.assertEquals("a", rootEl.getNodeName());
    Assert.assertEquals("b", child0.getNodeName());
    Assert.assertEquals("b", child1.getNodeName());
    Assert.assertEquals("c", child2.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 48 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class FragmentPutInsertBeforeTest method insertBeforeAttrTest.

@Test(expected = SOAPFaultException.class)
public void insertBeforeAttrTest() throws XMLStreamException {
    String content = "<a foo=\"1\"/>";
    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_INSERT_BEFORE);
    expression.getContent().add("/a/@f");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("b");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    client.put(request);
    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) 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 49 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class FragmentPutRemoveTest method removeAttrTest.

@Test
public void removeAttrTest() throws XMLStreamException {
    String content = "<a foo=\"1\"/>";
    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/@foo");
    fragment.setExpression(expression);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertNull(rootEl.getAttributeNode("foo"));
    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 50 with Resource

use of org.apache.cxf.ws.transfer.resource.Resource in project cxf by apache.

the class FragmentPutReplaceTest method replaceNonExistingElementFailTest.

@Test(expected = SOAPFaultException.class)
public void replaceNonExistingElementFailTest() 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("//b");
    Element replacedElement = DOMUtils.getEmptyDocument().createElement("b");
    ValueType value = new ValueType();
    value.getContent().add(replacedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    client.put(request);
    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) 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

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