use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentGetQNameTest method qetEmptyResultTest.
@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();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentGetXPath10Test method getTest.
@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();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentGetXPath10Test method getNumberTest.
@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();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutAddTest method addSiblingTest.
@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.getEmptyDocument().createElement("c");
ValueType value = new ValueType();
value.getContent().add(addedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Element child0 = (Element) rootEl.getChildNodes().item(0);
Element child1 = (Element) rootEl.getChildNodes().item(1);
Assert.assertEquals("a", rootEl.getNodeName());
Assert.assertEquals("b", child0.getNodeName());
Assert.assertEquals("c", child1.getNodeName());
resource.destroy();
}
use of org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType in project cxf by apache.
the class FragmentPutAddTest method addToEmptyDocumentTest.
@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.getEmptyDocument().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();
}
Aggregations