use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class NamespaceResponseParsingITest method takes_namespaces_into_when_passing_xml_path_config_to_xml_path_method_in_response_object.
@Test
public void takes_namespaces_into_when_passing_xml_path_config_to_xml_path_method_in_response_object() {
final XmlPath xmlPath = get("/namespace-example").xmlPath(XmlPathConfig.xmlPathConfig().with().declaredNamespace("ns", "http://localhost/"));
assertThat(xmlPath.getString("foo.bar.text()"), equalTo("sudo make me a sandwich!"));
assertThat(xmlPath.getString(":foo.:bar.text()"), equalTo("sudo "));
assertThat(xmlPath.getString("foo.ns:bar.text()"), equalTo("make me a sandwich!"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method initializeUsingCtorAndGetList.
@Test
public void initializeUsingCtorAndGetList() throws Exception {
final NodeChildren categories = new XmlPath(XML).get("shopping.category");
assertThat(categories.size(), equalTo(3));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method xmlPathCanExtractNodeFromSoap.
@Test
public void xmlPathCanExtractNodeFromSoap() throws Exception {
// Given
String soap = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<env:Envelope \n" + " xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" \n" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n" + " xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" \n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <env:Header/>\n" + "\n" + "<env:Body>\n" + " <n1:importProjectResponse \n" + " xmlns:n1=\"n1\" \n" + " xmlns:n2=\"n2\" \n" + " xsi:type=\"n2:ArrayOfProjectImportResultCode\">\n" + " <n2:ProjectImportResultCode>\n" + " <n2:code>1</n2:code>\n" + " <n2:message>Project 'test1' import was successful.</n2:message>\n" + " </n2:ProjectImportResultCode>\n" + " </n1:importProjectResponse>\n" + "</env:Body></env:Envelope>";
// When
XmlPath xmlPath = new XmlPath(soap);
Node node = xmlPath.getNode("Envelope");
// Then
assertThat(node.<String>getPath("Body.importProjectResponse.ProjectImportResultCode.code"), equalTo("1"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method rootPathEndingWithDot.
@Test
public void rootPathEndingWithDot() throws Exception {
final XmlPath xmlPath = new XmlPath(XML).setRoot("shopping.category.item.");
assertThat(xmlPath.getInt("size()"), equalTo(5));
assertThat(xmlPath.getList("children().list()", String.class), hasItem("Pens"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method rootPathNotEndingWithDot.
@Test
public void rootPathNotEndingWithDot() throws Exception {
final XmlPath xmlPath = new XmlPath(XML).setRoot("shopping.category.item");
assertThat(xmlPath.getInt("size()"), equalTo(5));
assertThat(xmlPath.getList("children().list()", String.class), hasItem("Pens"));
}
Aggregations