use of io.restassured.path.xml.config.XmlPathConfig in project ddf by codice.
the class WfsFilterDelegateTest method testPropertyIsRelative.
@Test
public void testPropertyIsRelative() throws JAXBException {
final WfsFilterDelegate delegate = createSinglePropertyDelegate();
final FilterType filter = delegate.relative(MOCK_PROPERTY, 100_000L);
final String xml = marshal(filter);
final XmlPathConfig config = new XmlPathConfig().declaredNamespace("ogc", "http://www.opengis.net/ogc");
final XmlPath xmlPath = new XmlPath(xml).using(config);
final String lowerBoundary = xmlPath.getString("ogc:Filter.ogc:PropertyIsBetween.ogc:LowerBoundary.ogc:Literal");
assertThat("There was no lower boundary in the filter XML.", lowerBoundary, not(isEmptyOrNullString()));
final String upperBoundary = xmlPath.getString("ogc:Filter.ogc:PropertyIsBetween.ogc:UpperBoundary.ogc:Literal");
assertThat("There was no upper boundary in the filter XML.", upperBoundary, not(isEmptyOrNullString()));
final long start = OffsetDateTime.parse(lowerBoundary).toInstant().toEpochMilli();
final long end = OffsetDateTime.parse(upperBoundary).toInstant().toEpochMilli();
assertThat("The dates were not 100 seconds apart.", end - start, is(100_000L));
}
use of io.restassured.path.xml.config.XmlPathConfig in project rest-assured by rest-assured.
the class XmlPathCharsetTest method xml_path_cannot_correctly_deserialize_input_stream_using_wrong_charset.
@Test
public void xml_path_cannot_correctly_deserialize_input_stream_using_wrong_charset() throws UnsupportedEncodingException {
// Given
InputStream is = new ByteArrayInputStream(GREETING_WITH_STRANGE_CHARS.getBytes("US-ASCII"));
XmlPath xmlPath = new XmlPath(is).using(new XmlPathConfig("ISO-8859-1"));
// When
final String firstName = xmlPath.getString("greeting.firstName");
final String lastName = xmlPath.getString("greeting.lastName");
// Then
assertThat(firstName, containsString("?%#??"));
assertThat(lastName, containsString("`?"));
}
use of io.restassured.path.xml.config.XmlPathConfig in project rest-assured by rest-assured.
the class XmlPathCharsetTest method xml_path_supports_deserializing_input_stream_using_with_given_charset.
@Test
public void xml_path_supports_deserializing_input_stream_using_with_given_charset() throws UnsupportedEncodingException {
// Given
InputStream is = new ByteArrayInputStream(GREETING_WITH_STRANGE_CHARS.getBytes("UTF-16"));
XmlPath xmlPath = new XmlPath(is).using(new XmlPathConfig("UTF-16"));
// When
final String firstName = xmlPath.getString("greeting.firstName");
final String lastName = xmlPath.getString("greeting.lastName");
// Then
assertThat(firstName, equalTo("€%#åö"));
assertThat(lastName, equalTo("`ü"));
}
Aggregations