use of org.apache.cxf.endpoint.Server 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.endpoint.Server in project cxf by apache.
the class FragmentPutInsertAfterTest method insertAfterEmptyDocTest.
@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.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();
}
use of org.apache.cxf.endpoint.Server 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.endpoint.Server 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.endpoint.Server in project cxf by apache.
the class ResourceTest method deleteRequestTest.
@Test
public void deleteRequestTest() {
ResourceManager manager = EasyMock.createMock(ResourceManager.class);
manager.delete(EasyMock.isA(ReferenceParametersType.class));
EasyMock.expectLastCall().once();
EasyMock.replay(manager);
ReferenceParametersType refParams = new ReferenceParametersType();
Element uuid = DOMUtils.getEmptyDocument().createElementNS(MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
uuid.setTextContent(UUID_VALUE);
refParams.getAny().add(uuid);
Server server = createLocalResource(manager);
Resource client = createClient(refParams);
client.delete(new Delete());
EasyMock.verify(manager);
server.destroy();
}
Aggregations