如何在RestAssured测试用例中传递XML请求

时间:2013-12-18 12:39:39

标签: java xml xpath rest-assured

对于我的休息服务(创建学生),我必须传递XML请求(请求类型是application / xml),如下所示:

<student>
 <name>abc</name>
 </age>
 <addresses>
  <add1>
     <add_line1>pqr</add_line>
     <city>sdf</city>
  </add1>
  <add2>
    <add_line1>pqr</add_line>
    <city>sdf</city>
  </add2>
 <addresses>
</student>

我们如何将整个xml传递给测试用例?

@Test
public final void testCreateStudent() {
string xmlstring=//whole xml in double quote
          expect()
             .statusCode(200)
                     .body(hasXPath("/Response/status[text()='true']")
                 .with()
                     .body(xmlstring)
         .when()
                     .post("/service/student/create");
}

我是这个领域的新手。任何人都可以建议我如何有效地做到这一点?如果我的回答是这样的话,Xpath是否正确获取状态?

<response>
  <id>123</id>
  <status>true</status>
<response>

0 个答案:

没有答案
相关问题