|
30 | 30 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; |
31 | 31 | import static java.nio.charset.StandardCharsets.UTF_8; |
32 | 32 | import static org.apache.http.HttpStatus.*; |
| 33 | +import static org.hamcrest.CoreMatchers.is; |
33 | 34 |
|
34 | 35 | public class QueryIT { |
35 | 36 |
|
@@ -185,4 +186,48 @@ public void invalidStoredQuery() { |
185 | 186 | assertThat(). |
186 | 187 | body(matchesJsonSchemaInClasspath("query-error-schema.json")); |
187 | 188 | } |
| 189 | + |
| 190 | + @Test |
| 191 | + public void serializeQueryAsXmlNoIndent() { |
| 192 | + final Map<String, Object> requestBody = mapOf( |
| 193 | + Tuple("query", "<a><b>hello</b></a>"), |
| 194 | + Tuple("defaultSerialization", mapOf( |
| 195 | + Tuple("method", "xml"), |
| 196 | + Tuple("indent", false) |
| 197 | + )) |
| 198 | + ); |
| 199 | + |
| 200 | + given(). |
| 201 | + auth().preemptive().basic(DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD). |
| 202 | + contentType(JSON). |
| 203 | + body(requestBody). |
| 204 | + when(). |
| 205 | + post(getApiBaseUri() + "/query"). |
| 206 | + then(). |
| 207 | + statusCode(SC_OK). |
| 208 | + assertThat(). |
| 209 | + body("results", is("<a><b>hello</b></a>")); |
| 210 | + } |
| 211 | + |
| 212 | + @Test |
| 213 | + public void serializeQueryAsXmlIndent() { |
| 214 | + final Map<String, Object> requestBody = mapOf( |
| 215 | + Tuple("query", "<a><b>hello</b></a>"), |
| 216 | + Tuple("defaultSerialization", mapOf( |
| 217 | + Tuple("method", "xml"), |
| 218 | + Tuple("indent", true) |
| 219 | + )) |
| 220 | + ); |
| 221 | + |
| 222 | + given(). |
| 223 | + auth().preemptive().basic(DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD). |
| 224 | + contentType(JSON). |
| 225 | + body(requestBody). |
| 226 | + when(). |
| 227 | + post(getApiBaseUri() + "/query"). |
| 228 | + then(). |
| 229 | + statusCode(SC_OK). |
| 230 | + assertThat(). |
| 231 | + body("results", is("<a>\n <b>hello</b>\n</a>")); |
| 232 | + } |
188 | 233 | } |
0 commit comments