Search in sources :

Example 1 with XmlPath

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

Example 2 with XmlPath

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

Example 3 with XmlPath

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

Example 4 with XmlPath

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

Example 5 with XmlPath

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

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