use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutRemoveTest method removeElement2Test.
@Test
public void removeElement2Test() throws XMLStreamException {
String content = "<a><b/><b/></a>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_REMOVE);
expression.getContent().add("/a/b[1]");
fragment.setExpression(expression);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals(1, rootEl.getChildNodes().getLength());
resource.destroy();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutRemoveTest method removeElementTest.
@Test
public void removeElementTest() throws XMLStreamException {
String content = "<a><b/></a>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_REMOVE);
expression.getContent().add("/a/b");
fragment.setExpression(expression);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals(0, rootEl.getChildNodes().getLength());
resource.destroy();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutReplaceTest method replaceOneElementTest.
@Test
public void replaceOneElementTest() throws XMLStreamException {
String content = "<a><b/><b/></a>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("/a/b[1]");
Element replacedElement = DOMUtils.getEmptyDocument().createElement("c");
ValueType value = new ValueType();
value.getContent().add(replacedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("c", ((Element) rootEl.getChildNodes().item(0)).getLocalName());
Assert.assertEquals("b", ((Element) rootEl.getChildNodes().item(1)).getLocalName());
resource.destroy();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutReplaceTest method replaceDocumentTest.
@Test
public void replaceDocumentTest() throws XMLStreamException {
String content = "<a/>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("/");
Element replacedElement = DOMUtils.getEmptyDocument().createElement("b");
ValueType value = new ValueType();
value.getContent().add(replacedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("b", rootEl.getNodeName());
resource.destroy();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutReplaceTest method replaceNonExistingRootTest.
@Test
public void replaceNonExistingRootTest() {
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(new Representation());
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("/a");
Element replacedElement = DOMUtils.getEmptyDocument().createElement("a");
ValueType value = new ValueType();
value.getContent().add(replacedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("a", rootEl.getLocalName());
resource.destroy();
}
Aggregations