use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.
the class FragmentPutAddTest method addToNonEmptyDocumentTest.
@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.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();
}
use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.
the class FragmentPutAddTest method addTextElementTest.
@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();
}
use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.
the class FragmentPutInsertAfterTest method insertAfter1Test.
@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.getEmptyDocument().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();
}
use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.
the class FragmentPutInsertAfterTest method insertAfterAttrTest.
@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.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();
}
use of org.apache.cxf.ws.transfer.manager.ResourceManager 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();
}
Aggregations