cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/5] cxf git commit: Squash commit of ws-transfer implementation from Erich Duda (dudaerich) This closes #33
Date Tue, 24 May 2016 13:28:50 GMT
http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetQNameTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetQNameTest.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetQNameTest.java
new file mode 100644
index 0000000..9346dc7
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetQNameTest.java
@@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Get;
+import org.apache.cxf.ws.transfer.GetResponse;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory;
+import org.apache.cxf.ws.transfer.dialect.fragment.ValueType;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentGetQNameTest extends IntegrationBaseTest {
+    
+    @Test
+    public void getTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
+        expression.getContent().add("a");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("a", ((Element)value.getContent().get(0)).getLocalName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getWithNamespaceTest() throws XMLStreamException {
+        String content = "<ns:root xmlns:ns=\"www.example.org\"><ns:a><ns:b>Text</ns:b></ns:a></ns:root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
+        expression.getContent().add("ns:a");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("a", ((Element)value.getContent().get(0)).getLocalName());
+        Assert.assertEquals("www.example.org", ((Element)value.getContent().get(0)).getNamespaceURI());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void qetEmptyResultTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
+        expression.getContent().add("c");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(0, value.getContent().size());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getMoreValuesTest() throws XMLStreamException {
+        String content = "<root><b>Text1</b><b>Text2</b><b>Text3</b></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
+        expression.getContent().add("b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(3, value.getContent().size());
+        Assert.assertEquals("b", ((Element)value.getContent().get(0)).getLocalName());
+        Assert.assertEquals("b", ((Element)value.getContent().get(1)).getLocalName());
+        Assert.assertEquals("b", ((Element)value.getContent().get(2)).getLocalName());
+        
+        resource.destroy();
+    }
+    
+    @Test(expected = SOAPFaultException.class)
+    public void getWrongQNameTest() throws XMLStreamException {
+        String content = "<root><a><b>Text1</b><b>Text2</b><b>Text3</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
+        expression.getContent().add("//b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        client.get(request);
+    }
+    
+    private static ValueType getValue(GetResponse response) {
+        @SuppressWarnings("unchecked")
+        JAXBElement<ValueType> jaxb = (JAXBElement<ValueType>) response.getAny().get(0);
+        return jaxb.getValue();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetXPath10Test.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetXPath10Test.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetXPath10Test.java
new file mode 100644
index 0000000..56f8291
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentGetXPath10Test.java
@@ -0,0 +1,333 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.stream.XMLStreamException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Get;
+import org.apache.cxf.ws.transfer.GetResponse;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory;
+import org.apache.cxf.ws.transfer.dialect.fragment.ValueType;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentGetXPath10Test extends IntegrationBaseTest {
+    
+    @Test
+    public void getTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("/root/a/b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("b", ((Element)value.getContent().get(0)).getLocalName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getImpliedLanguageTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.getContent().add("/root/a/b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("b", ((Element)value.getContent().get(0)).getLocalName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getWithNamespaceTest() throws XMLStreamException {
+        String content = "<ns:root xmlns:ns=\"www.example.org\"><ns:a><ns:b>Text</ns:b></ns:a></ns:root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("/ns:root/ns:a/ns:b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("b", ((Element)value.getContent().get(0)).getLocalName());
+        Assert.assertEquals("www.example.org", ((Element)value.getContent().get(0)).getNamespaceURI());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void qetEmptyResultTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("//c");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(0, value.getContent().size());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getMoreValuesTest() throws XMLStreamException {
+        String content = "<root><a><b>Text1</b><b>Text2</b><b>Text3</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("//b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(3, value.getContent().size());
+        Assert.assertEquals("b", ((Element)value.getContent().get(0)).getLocalName());
+        Assert.assertEquals("b", ((Element)value.getContent().get(1)).getLocalName());
+        Assert.assertEquals("b", ((Element)value.getContent().get(2)).getLocalName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getMoreValues2Test() throws XMLStreamException {
+        String content = "<root><a><b>Text1</b><b>Text2</b><b><b>Text3</b></b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("//b");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("b", ((Element)value.getContent().get(0)).getLocalName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getAttrTest() throws XMLStreamException {
+        String content = "<root><a><b attr1=\"value1\">Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("/root/a/b/@attr1");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertTrue(value.getContent().get(0) instanceof Element);
+        Element attrEl = (Element) value.getContent().get(0);
+        Assert.assertEquals(FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME, attrEl.getLocalName());
+        Assert.assertEquals(FragmentDialectConstants.FRAGMENT_2011_03_IRI, attrEl.getNamespaceURI());
+        Assert.assertEquals("attr1", attrEl.getAttribute(FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR));
+        Assert.assertEquals("value1", attrEl.getTextContent());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getAttrNSTest() throws XMLStreamException {
+        String content = "<root xmlns:ns=\"www.example.org\"><a><b ns:attr1=\"value1\">Text</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("/root/a/b/@ns:attr1");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertTrue(value.getContent().get(0) instanceof Element);
+        Element attrEl = (Element) value.getContent().get(0);
+        Assert.assertEquals(FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME, attrEl.getLocalName());
+        Assert.assertEquals(FragmentDialectConstants.FRAGMENT_2011_03_IRI, attrEl.getNamespaceURI());
+        Assert.assertEquals("ns:attr1", attrEl.getAttribute(FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR));
+        Assert.assertEquals("value1", attrEl.getTextContent());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getNumberTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b><b>Text2</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("count(//b)");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("2", value.getContent().get(0));
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getBooleanTrueTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b><b>Text2</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("count(//b) = 2");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("true", value.getContent().get(0));
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void getBooleanFalseTest() throws XMLStreamException {
+        String content = "<root><a><b>Text</b><b>Text2</b></a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+
+        ObjectFactory objectFactory = new ObjectFactory();
+        
+        Get request = new Get();
+        request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
+        ExpressionType expression = new ExpressionType();
+        expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
+        expression.getContent().add("count(//b) != 2");
+        request.getAny().add(objectFactory.createExpression(expression));
+        
+        GetResponse response = client.get(request);
+        ValueType value = getValue(response);
+        Assert.assertEquals(1, value.getContent().size());
+        Assert.assertEquals("false", value.getContent().get(0));
+        
+        resource.destroy();
+    }
+    
+    private static ValueType getValue(GetResponse response) {
+        @SuppressWarnings("unchecked")
+        JAXBElement<ValueType> jaxb = (JAXBElement<ValueType>) response.getAny().get(0);
+        return jaxb.getValue();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
new file mode 100644
index 0000000..e971794
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
@@ -0,0 +1,238 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Put;
+import org.apache.cxf.ws.transfer.PutResponse;
+import org.apache.cxf.ws.transfer.Representation;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.Fragment;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.dialect.fragment.ValueType;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentPutAddTest extends IntegrationBaseTest {
+    
+    @Test
+    public void addToEmptyDocumentTest() {
+        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.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
+        expression.getContent().add("/");
+        Element addedElement = DOMUtils.createDocument().createElement("a");
+        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();
+        Assert.assertEquals("a", rootEl.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @Test(expected = SOAPFaultException.class)
+    public void addToNonEmptyDocumentTest() 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_ADD);
+        expression.getContent().add("/");
+        Element addedElement = DOMUtils.createDocument().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();
+    }
+    
+    @Test
+    public void addTextElementTest() throws XMLStreamException {
+        String content = "<a>f</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_ADD);
+        expression.getContent().add("/a");
+        ValueType value = new ValueType();
+        value.getContent().add("oo");
+        fragment.setExpression(expression);
+        fragment.setValue(value);
+        request.getAny().add(fragment);
+        
+        PutResponse response = client.put(request);
+        Element rootEl = (Element) response.getRepresentation().getAny();
+        Assert.assertEquals("foo", rootEl.getTextContent());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void addAttributeTest() 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_ADD);
+        expression.getContent().add("/a");
+
+        Document doc = DOMUtils.createDocument();
+        Element addedAttr = doc.createElementNS(
+                FragmentDialectConstants.FRAGMENT_2011_03_IRI,
+                FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME
+        );
+        addedAttr.setAttributeNS(
+                FragmentDialectConstants.FRAGMENT_2011_03_IRI,
+                FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR,
+                "foo"
+        );
+        addedAttr.setTextContent("1");
+        ValueType value = new ValueType();
+        value.getContent().add(addedAttr);
+        fragment.setExpression(expression);
+        fragment.setValue(value);
+        request.getAny().add(fragment);
+        
+        PutResponse response = client.put(request);
+        Element aEl = (Element) response.getRepresentation().getAny();
+        String attribute = aEl.getAttribute("foo");
+        Assert.assertEquals("1", attribute);
+        
+        resource.destroy();
+    }
+    
+    @Test(expected = SOAPFaultException.class)
+    public void addExistingAttributeTest() 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_ADD);
+        expression.getContent().add("/a");
+
+        Document doc = DOMUtils.createDocument();
+        Element addedAttr = doc.createElementNS(
+                FragmentDialectConstants.FRAGMENT_2011_03_IRI,
+                FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME
+        );
+        addedAttr.setAttributeNS(
+                FragmentDialectConstants.FRAGMENT_2011_03_IRI,
+                FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR,
+                "foo"
+        );
+        addedAttr.setTextContent("2");
+        ValueType value = new ValueType();
+        value.getContent().add(addedAttr);
+        fragment.setExpression(expression);
+        fragment.setValue(value);
+        request.getAny().add(fragment);
+        
+        client.put(request);
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void addSiblingTest() 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_ADD);
+        expression.getContent().add("/a");
+        Element addedElement = DOMUtils.createDocument().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);
+        Assert.assertEquals("a", rootEl.getNodeName());
+        Assert.assertEquals("b", child0.getNodeName());
+        Assert.assertEquals("c", child1.getNodeName());
+        
+        resource.destroy();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertAfterTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertAfterTest.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertAfterTest.java
new file mode 100644
index 0000000..57e5ed1
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertAfterTest.java
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Put;
+import org.apache.cxf.ws.transfer.PutResponse;
+import org.apache.cxf.ws.transfer.Representation;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.Fragment;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.dialect.fragment.ValueType;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentPutInsertAfterTest extends IntegrationBaseTest {
+    
+    @Test
+    public void insertAfter1Test() throws XMLStreamException {
+        String content = "<a><b/><c/></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");
+        Element addedElement = DOMUtils.createDocument().createElement("d");
+        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("d", child1.getNodeName());
+        Assert.assertEquals("c", child2.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @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.createDocument().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();
+    }
+    
+    @Test
+    public void insertAfterEmptyDocTest() {
+        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.setMode(FragmentDialectConstants.FRAGMENT_MODE_INSERT_AFTER);
+        expression.getContent().add("/");
+        Element addedElement = DOMUtils.createDocument().createElement("a");
+        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();
+        Assert.assertEquals("a", rootEl.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @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.createDocument().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();
+    }
+    
+    @Test(expected = SOAPFaultException.class)
+    public void insertAfterAttrTest() 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_AFTER);
+        expression.getContent().add("/a/@foo");
+        Element addedElement = DOMUtils.createDocument().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();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertBeforeTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertBeforeTest.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertBeforeTest.java
new file mode 100644
index 0000000..4ff59c9
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutInsertBeforeTest.java
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Put;
+import org.apache.cxf.ws.transfer.PutResponse;
+import org.apache.cxf.ws.transfer.Representation;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.Fragment;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.dialect.fragment.ValueType;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentPutInsertBeforeTest extends IntegrationBaseTest {
+    
+    @Test
+    public void insertBefore1Test() throws XMLStreamException {
+        String content = "<a><b/><c/></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_BEFORE);
+        expression.getContent().add("/a/b");
+        Element addedElement = DOMUtils.createDocument().createElement("d");
+        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("d", child0.getNodeName());
+        Assert.assertEquals("b", child1.getNodeName());
+        Assert.assertEquals("c", child2.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void insertBefore2Test() 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_BEFORE);
+        expression.getContent().add("/a/b[1]");
+        Element addedElement = DOMUtils.createDocument().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("c", child0.getNodeName());
+        Assert.assertEquals("b", child1.getNodeName());
+        Assert.assertEquals("b", child2.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void insertBeforeEmptyDocTest() {
+        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.setMode(FragmentDialectConstants.FRAGMENT_MODE_INSERT_BEFORE);
+        expression.getContent().add("/");
+        Element addedElement = DOMUtils.createDocument().createElement("a");
+        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();
+        Assert.assertEquals("a", rootEl.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @Test(expected = SOAPFaultException.class)
+    public void insertBeforeRootTest() 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_BEFORE);
+        expression.getContent().add("/");
+        Element addedElement = DOMUtils.createDocument().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();
+    }
+    
+    @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.createDocument().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();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutRemoveTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutRemoveTest.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutRemoveTest.java
new file mode 100644
index 0000000..2523011
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutRemoveTest.java
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Put;
+import org.apache.cxf.ws.transfer.PutResponse;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.Fragment;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentPutRemoveTest extends IntegrationBaseTest {
+    
+    @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();
+    }
+    
+    @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();
+    }
+    
+    @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();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutReplaceTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutReplaceTest.java b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutReplaceTest.java
new file mode 100644
index 0000000..b2b8072
--- /dev/null
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutReplaceTest.java
@@ -0,0 +1,419 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.transfer.integration;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
+import org.apache.cxf.ws.transfer.Put;
+import org.apache.cxf.ws.transfer.PutResponse;
+import org.apache.cxf.ws.transfer.Representation;
+import org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType;
+import org.apache.cxf.ws.transfer.dialect.fragment.Fragment;
+import org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialectConstants;
+import org.apache.cxf.ws.transfer.dialect.fragment.ValueType;
+import org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
+import org.apache.cxf.ws.transfer.manager.ResourceManager;
+import org.apache.cxf.ws.transfer.resource.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentPutReplaceTest extends IntegrationBaseTest {
+    
+    @Test
+    public void replaceElementTest() throws XMLStreamException {
+        String content = "<root><a>Text</a></root>";
+        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("/root/a");
+        Element replacedElement = DOMUtils.createDocument().createElement("b");
+        replacedElement.setTextContent("Better text");
+        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.getChildNodes().item(0).getNodeName());
+        Assert.assertEquals("Better text", rootEl.getChildNodes().item(0).getTextContent());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void replaceElement2Test() 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("/a");
+        Element replacedElement = DOMUtils.createDocument().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();
+    }
+    
+    @Test
+    public void replaceTextContentTest() throws XMLStreamException {
+        String content = "<root><a>Text</a></root>";
+        ResourceManager resourceManager = new MemoryResourceManager();
+        ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
+        Server resource = createLocalResource(resourceManager);
+        Resource client = createClient(refParams);
+        
+        //ObjectFactory objectFactory = new ObjectFactory();
+        
+        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("/root/a/text()");
+        ValueType value = new ValueType();
+        value.getContent().add("Better text");
+        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.getChildNodes().item(0).getNodeName());
+        Assert.assertEquals("Better text", rootEl.getChildNodes().item(0).getTextContent());
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void replaceAttributeTest() throws XMLStreamException {
+        String content = "<root><a foo=\"1\">Text</a></root>";
+        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("/root/a/@foo");
+        Element replacedAttr = DOMUtils.createDocument().createElementNS(
+                FragmentDialectConstants.FRAGMENT_2011_03_IRI,
+                FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME
+        );
+        replacedAttr.setAttributeNS(
+                FragmentDialectConstants.FRAGMENT_2011_03_IRI,
+                FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME_ATTR,
+                "bar"
+        );
+        replacedAttr.setTextContent("2");
+        ValueType value = new ValueType();
+        value.getContent().add(replacedAttr);
+        fragment.setExpression(expression);
+        fragment.setValue(value);
+        request.getAny().add(fragment);
+        
+        PutResponse response = client.put(request);
+        Element rootEl = (Element) response.getRepresentation().getAny();
+        Element aEl = (Element) rootEl.getChildNodes().item(0);
+        Assert.assertNotNull(aEl);
+        String attribute = aEl.getAttribute("bar");
+        Assert.assertEquals("2", attribute);
+        
+        resource.destroy();
+    }
+    
+    @Test
+    public void replaceEmptyDocumentTest() {
+        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("/");
+        Element replacedElement = DOMUtils.createDocument().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.getNodeName());
+        
+        resource.destroy();
+    }
+    
+    @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.createDocument().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();
+    }
+    
+    @Test
+    public void replaceDocument2Test() 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.createDocument().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();
+    }
+    
+    @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.createDocument().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();
+    }
+    
+    @Test
+    public void replaceAllElementsTest() 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");
+        Element replacedElement = DOMUtils.createDocument().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(1, rootEl.getChildNodes().getLength());
+        Assert.assertEquals("c", ((Element)rootEl.getChildNodes().item(0)).getLocalName());
+        
+        resource.destroy();
+    }
+
+    @Test
+    public  void replaceNonExistingElementTest() 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("/a/b");
+        Element replacedElement = DOMUtils.createDocument().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(1, rootEl.getChildNodes().getLength());
+        Assert.assertEquals("b", ((Element)rootEl.getChildNodes().item(0)).getLocalName());
+
+        resource.destroy();
+    }
+
+    @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.createDocument().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();
+    }
+
+    @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.createDocument().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();
+    }
+
+    @Test(expected = SOAPFaultException.class)
+    public  void replaceNonExistingElementFail2Test() 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("/a/[local-name() = 'b'");
+        Element replacedElement = DOMUtils.createDocument().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();
+    }
+}


Mime
View raw message