Skip to content

Commit 1a81caf

Browse files
committed
Tests for Indent (or not) with XML serialization
1 parent d965c03 commit 1a81caf

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/test/java/com/fusiondb/studio/api/QueryIT.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
3131
import static java.nio.charset.StandardCharsets.UTF_8;
3232
import static org.apache.http.HttpStatus.*;
33+
import static org.hamcrest.CoreMatchers.is;
3334

3435
public class QueryIT {
3536

@@ -185,4 +186,48 @@ public void invalidStoredQuery() {
185186
assertThat().
186187
body(matchesJsonSchemaInClasspath("query-error-schema.json"));
187188
}
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+
}
188233
}

0 commit comments

Comments
 (0)