接口测试中 对xml下发内容的解析断言
来源:互联网 发布:南海舰队编制 知乎 编辑:程序博客网 时间:2024/05/19 11:51
import com.app.util.EncryptUtil;
import com.juyun.test.util.Java2Xml;
import com.juyun.test.util.XmlUtil;
public class TestgetKeyword {
****
BufferedReader reader=null;
@Before
public void setUpBeforeEveryTime() throws Exception{
// flushCache.FlushAll(host, port);
System.out.println("+++setUpBefore");
System.out.println("flush cache...");
System.out.println("===========================");
}
@Test
public void testGetVersion() throws Exception {
httpClient = new HttpClient();
EntityEnclosingMethod postMethod = new PostMethod();
// String string = xUtil.xmltoString(file);
String string = getDocument();
byte[] request = string.getBytes("UTF-8");
byte[] requestcode =EncryptUtil.getInstance().encode(request);
RequestEntity requestEntity = new ByteArrayRequestEntity(requestcode);
postMethod.setRequestEntity(requestEntity);
postMethod.setPath(url);
postMethod.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30*1000);
httpClient.executeMethod(postMethod);
byte[] responsecode =postMethod.getResponseBody();
byte[] response =EncryptUtil.getInstance().decode(responsecode);
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(response) ;
reader = new BufferedReader(new InputStreamReader(byteArrayEntity.getContent()));
String xml = reader.readLine();
Document document =xUtil.StringtoXml(xml);
// System.out.println(document.asXML());
assertEquals("<result_code>1</result_code>", document.selectSingleNode("//result_code").asXML());
// assertEquals("<appid>894</appid>", document.selectSingleNode("//entry_total/appid").asXML());
}
@AfterClass //执行一次
public static void tearDownAfterClassOnce() throws Exception {
System.out.println("===========================");
System.out.println("tearDownAfterClass");
}
}
直接对document 进行内容选取,再对相关节点断言判断,以此来测试接口下发正确性
- 接口测试中 对xml下发内容的解析断言
- C#中解析XML的内容
- Android中解析xml文件的接口
- Ruby中对XML文档的解析
- Ruby中对XML文档的解析
- 接口中解析xml文件
- 解析调用接口内容和构建接口请求xml
- 如何用JS解析服务器中xml文件的内容
- LoadRunner中对接口进行性能测试的常用方法
- LoadRunner中对接口进行性能测试的常用方法
- Jmeter 接口测试中使用Beanshell断言: 将接口响应报文与数据库结果对比
- xml解析server.xml的内容
- .net CF中使用XmlTextReader对Xml的解析方法
- 在sql2005中对不同XML的解析.
- 在sql2005中对不同XML的解析
- android中数据存储及对xml的解析
- android中数据存储及对xml的解析
- Java中对xml文件的四种解析方式
- SharpICTCLAS分词系统简介(4)NShortPath-1
- 一道google的比较经典算法题
- 10个网页设计师必备的CSS技巧
- uImage、zImage、bzImage、vlinzx区别
- SharpICTCLAS分词系统简介(5)NShortPath-2
- 接口测试中 对xml下发内容的解析断言
- quotename用法
- TCP/IP四层模型和OSI七层模型的概念
- SharpICTCLAS分词系统简介(1)读取词典库
- 个人决定
- WinRAR 4.01破解方法
- SharpICTCLAS分词系统简介(2)初步分词
- 三角矩阵
- 8.7