use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method doesntNeedToEscapeListsWithHyphenWithoutBrackets.
@Test
public void doesntNeedToEscapeListsWithHyphenWithoutBrackets() throws Exception {
// Given
String xml = "<root><some-list>one</some-list><some-list>two</some-list></root>";
// When
XmlPath xmlPath = from(xml);
// Then
assertThat(xmlPath.getString("root.some-list[0]"), equalTo("one"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method setting_feature_works.
@Test
public void setting_feature_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>";
// When
final XmlPath xmlPath = new XmlPath(xml).using(XmlPathConfig.xmlPathConfig().with().feature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false).feature("http://apache.org/xml/features/disallow-doctype-decl", false));
// Then
assertThat(xmlPath.getString("LegacyService"), equalTo("Text"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method xmlPathWorksWithSoap.
@Test
public void xmlPathWorksWithSoap() 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);
// Then
assertThat(xmlPath.getString("Envelope.Body.importProjectResponse.ProjectImportResultCode.code"), equalTo("1"));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method trying_to_get_an_attribute_that_doesnt_exists_returns_null.
@Test
public void trying_to_get_an_attribute_that_doesnt_exists_returns_null() {
// Given
String xml = //
" <root>" + //
" <item type=\"normal\">item_1_content</item>" + //
" <item type=\"special\">item_1_content</item>" + //
" <item type=\"\">item_1_content</item>" + //
" <item>item_2_content</item>" + " </root>";
// When
XmlPath xmlPath = new XmlPath(xml).setRoot("root");
// Then
assertThat(xmlPath.getString("item[3].@type"), nullValue());
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method disableDtdValidationWorks.
@Test
public void disableDtdValidationWorks() 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>";
// When
final XmlPath xmlPath = new XmlPath(xml).using(XmlPathConfig.xmlPathConfig().with().disableLoadingOfExternalDtd());
// Then
assertThat(xmlPath.getString("LegacyService"), equalTo("Text"));
}
Aggregations