use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method multipleGetsWithOneInstanceOfXmlPath.
@Test
public void multipleGetsWithOneInstanceOfXmlPath() throws Exception {
final XmlPath xmlPath = new XmlPath(XML);
assertThat(xmlPath.getInt("shopping.category.item.size()"), equalTo(5));
assertThat(xmlPath.getList("shopping.category.item.children().list()", String.class), hasItem("Pens"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method setting_features_works.
@Test
public void setting_features_works() throws Exception {
// Given
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE LegacyService SYSTEM \"http://example.com/dtd/NonExistent.dtd\">\n" + "<LegacyService>Text</LegacyService>";
Map<String, Boolean> features = new HashMap<String, Boolean>();
features.put("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
features.put("http://apache.org/xml/features/disallow-doctype-decl", false);
features.put("http://xml.org/sax/features/namespaces", false);
// When
final XmlPath xmlPath = new XmlPath(xml).using(XmlPathConfig.xmlPathConfig().with().features(features));
// Then
assertThat(xmlPath.getString("LegacyService"), equalTo("Text"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class NamespaceResponseParsingITest method takes_namespaces_into_account_when_correct_namespace_is_declared.
@Test
public void takes_namespaces_into_account_when_correct_namespace_is_declared() {
XmlPath xmlPath = given().config(RestAssuredConfig.newConfig().xmlConfig(xmlConfig().declareNamespace("ns", "http://localhost/"))).when().get("/namespace-example").xmlPath();
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 NamespaceResponseParsingITest method doesnt_take_namespaces_into_account_when_no_namespace_is_declared.
@Test
public void doesnt_take_namespaces_into_account_when_no_namespace_is_declared() {
XmlPath xmlPath = get("/namespace-example").xmlPath();
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(""));
}
use of io.restassured.path.xml.XmlPath in project ddf by codice.
the class TestSpatial method assertMetacard.
private void assertMetacard(String responseXml, String expectedSource, String expectedType) {
XmlPath xmlPath = new XmlPath(responseXml);
int numMetacards = xmlPath.get("metacard.size()");
assertThat(numMetacards, equalTo(1));
assertThat(xmlPath.get("metacard.type"), equalTo(expectedType));
assertThat(xmlPath.get("metacard.source"), equalTo(expectedSource));
}
Aggregations