接口測試學習筆記<一>

暫未整理脫水

  1. Java語法,Idea提示Usage of API Documented as @since 1.6+
    解決方案:File->Project structure->module->source->language Level 改為1.6+版本

  2. Java語法,接1。改完后編譯失敗,提示javacTask:源發(fā)行版1.6,需要目標發(fā)行版1.6
    解決方案:File->Settings->Build,Execution,Deployment->Complier->Java Complier->改為1.6+

  3. testNG執(zhí)行順序
    用例中有2個case需要順序執(zhí)行。按照很多教程寫了preserve-order="true"發(fā)現(xiàn)并沒有用……為什么需要查證。解決方法是給第二順序執(zhí)行的case加上@Test(dependsOnMethods = {"testname"}解決。

  4. httpspost:

public static String HttpsPost(String url, Object obj){    
 HttpClient httpClient = new DefaultHttpClient();    
 X509TrustManager xtm = new X509TrustManager() {        
   public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
   }        
   public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {        
   }        
   public X509Certificate[] getAcceptedIssuers() {
     return null;        
   }    
 };    
 try {        
   SSLContext ctx = SSLContext.getInstance("SSL");        
   ctx.init(null, new TrustManager[]{xtm}, null);        
   SSLSocketFactory socketFactory = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
   httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 443, socketFactory));        
   HttpPost httpPost = new HttpPost(url);        
   StringEntity se = new StringEntity(JSON.toJSONString(obj), StandardCharsets.UTF_8);        
   httpPost.setEntity(se);        
   HttpResponse rep = httpClient.execute(httpPost);        
   HttpEntity entity = rep.getEntity();        
   if(null != entity){            
     String responseContent = EntityUtils.toString(entity, "UTF-8");                  
     System.out.println(responseContent);            
     return responseContent;        
   }        
   return null;    
 } catch (NoSuchAlgorithmException | KeyManagementException | IOException e) {        
   e.printStackTrace();        
   return null;    
 }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • apache下的httpclient工具可大大簡化開發(fā)過程中的點對點通信,本人將以微信多媒體接口為例,展示http...
    劃破的天空閱讀 5,521評論 0 32
  • 1. Java基礎(chǔ)部分 基礎(chǔ)部分的順序:基本語法,類相關(guān)的語法,內(nèi)部類的語法,繼承相關(guān)的語法,異常的語法,線程的語...
    子非魚_t_閱讀 34,623評論 18 399
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,502評論 19 139
  • 該文僅對于中間這種支付方式有參考價值喲 一、開發(fā)背景 在微信公眾號中,需要進行微信支付且為微信公眾號網(wǎng)頁支付。 二...
    英文名叫夏天閱讀 2,003評論 0 7
  • ¥開啟¥ 【iAPP實現(xiàn)進入界面執(zhí)行逐一顯】 〖2017-08-25 15:22:14〗 《//首先開一個線程,因...
    小菜c閱讀 7,294評論 0 17

友情鏈接更多精彩內(nèi)容