Search in sources :

Example 16 with XmlPath

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"));
}
Also used : XmlPath(io.restassured.path.xml.XmlPath) Test(org.junit.Test)

Example 17 with XmlPath

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"));
}
Also used : XmlPath(io.restassured.path.xml.XmlPath) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 18 with XmlPath

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!"));
}
Also used : XmlPath(io.restassured.path.xml.XmlPath) Test(org.junit.Test)

Example 19 with XmlPath

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(""));
}
Also used : XmlPath(io.restassured.path.xml.XmlPath) Test(org.junit.Test)

Example 20 with XmlPath

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));
}
Also used : XmlPath(io.restassured.path.xml.XmlPath)

Aggregations

XmlPath (io.restassured.path.xml.XmlPath)21 Test (org.junit.Test)18 Node (io.restassured.path.xml.element.Node)2 HashMap (java.util.HashMap)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Call (com.xebialabs.restito.semantics.Call)1 XmlPathConfig (io.restassured.path.xml.config.XmlPathConfig)1 NodeChildren (io.restassured.path.xml.element.NodeChildren)1 ValidatableResponse (io.restassured.response.ValidatableResponse)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 FilterType (net.opengis.filter.v_1_1_0.FilterType)1 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)1 ConditionalIgnore (org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore)1 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 HasXPath.hasXPath (org.hamcrest.xml.HasXPath.hasXPath)1 JSONObject (org.json.simple.JSONObject)1 Ignore (org.junit.Ignore)1