In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
When doing http interface testing, you always have to do a lot of parameters and values, and the whole interface looks quite awkward, so you put the combination of parameters into one method and the execution into one method, and the main function just needs to get the response string to do processing and make assertions, so this code looks much cleaner, and the jar packages of httpclient, dom4j and testng are used here.
Import java.io.IOException
Import java.io.UnsupportedEncodingException
Import java.util.ArrayList
Import java.util.List
Import org.apache.http.HttpEntity
Import org.apache.http.NameValuePair
Import org.apache.http.client.ClientProtocolException
Import org.apache.http.client.entity.UrlEncodedFormEntity
Import org.apache.http.client.methods.CloseableHttpResponse
Import org.apache.http.client.methods.HttpPost
Import org.apache.http.impl.client.CloseableHttpClient
Import org.apache.http.impl.client.HttpClients
Import org.apache.http.message.BasicNameValuePair
Import org.apache.http.util.EntityUtils
Import org.dom4j.Document
Import org.dom4j.DocumentException
Import org.dom4j.DocumentHelper
Import org.dom4j.Element
Import org.testng.AssertJUnit
Public class HttpInterfaceTest {
Private static String url
Private static String [] [] keyVlaueList = {{"cdkey", "6SDK"}, {"password", "160489"}}; / / customize the number and values of API parameters as needed
Private static List postPara = new ArrayList ()
Private static String responseEntiy
/ * *
* Assembly request parameters
* @ param keyVlaueList
, /
Public static List getPostPara (String [] keyVlaueList) throws DocumentException {
For (int I = 0 position I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.