Java Code Examples for io.restassured.parsing.Parser#XML

The following examples show how to use io.restassured.parsing.Parser#XML . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JaxRSTestCase.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Test
public void testJaxbConsumption() throws Exception {
    TestResource.XmlObject xmlObject = new TestResource.XmlObject();
    xmlObject.setValue("test");

    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(TestResource.XmlObject.class);
    Marshaller m = context.createMarshaller();
    m.marshal(xmlObject, writer);

    try {
        // in the native image case, the right parser is not chosen, despite the content-type being correct
        RestAssured.defaultParser = Parser.XML;

        RestAssured.given().contentType("application/xml").body(writer.toString()).when().post("/test/consumeXml").then()
                .body(is("test"));
    } finally {
        RestAssured.reset();
    }
}
 
Example 2
Source File: JaxRSTestCase.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testJaxb() throws Exception {
    try {
        // in the native image case, the right parser is not chosen, despite the content-type being correct
        RestAssured.defaultParser = Parser.XML;

        RestAssured.when().get("/test/xml").then()
                .body("xmlObject.value.text()", is("A Value"));
    } finally {
        RestAssured.reset();
    }
}