use of org.apache.cxf.ws.transfer.Get 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.Get 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.Get in project cxf by apache.
the class DeleteTest method getDeletedTeacher.
@Test(expected = SOAPFaultException.class)
public void getDeletedTeacher() throws XMLStreamException {
CreateResponse response = createTeacher();
Resource client = TestUtils.createResourceClient(response.getResourceCreated());
client.delete(new Delete());
client.get(new Get());
}
use of org.apache.cxf.ws.transfer.Get in project cxf by apache.
the class DeleteTest method getDeletedStudent.
@Test(expected = SOAPFaultException.class)
public void getDeletedStudent() throws XMLStreamException {
CreateResponse response = createStudent();
Resource client = TestUtils.createResourceClient(response.getResourceCreated());
client.delete(new Delete());
client.get(new Get());
}
use of org.apache.cxf.ws.transfer.Get in project cxf by apache.
the class GetTest method getTeacherTest.
@Test
public void getTeacherTest() {
Resource client = TestUtils.createResourceClient(teacherRef);
GetResponse response = client.get(new Get());
Element representation = (Element) response.getRepresentation().getAny();
NodeList children = representation.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Element child = (Element) children.item(i);
if ("name".equals(child.getLocalName())) {
Assert.assertEquals("Bob", child.getTextContent());
} else if ("surname".equals(child.getLocalName())) {
Assert.assertEquals("Stuart", child.getTextContent());
} else if ("address".equals(child.getLocalName())) {
Assert.assertEquals("Street 526", child.getTextContent());
}
}
}
Aggregations