安卓 與java後台 的介面測試

來源:互聯網
上載者:User

標籤:appjava後台介面測試 post 介面測試載入器   postman

1.安卓app用戶端與背景介面一般有兩種:@POST與@GET


        @POST

@Path("/updateuserdetail/")

@Consumes("application/x-www-form-urlencoded;encoding=utf-8")

@Override

public AppBean updateuserdetail(@FormParam("username") String username,

@FormParam("password") String password,

@FormParam("occupation") String occupation,

@FormParam("income") String income,

@FormParam("email") String email,

@FormParam("phonenum") String phonenum,

@FormParam("married") String married) {}

------------------------------------------------------------------------------------------

        @GET

@Path("/goodsListByType/{pageno}/{type}")

@Override

public AppBean getGoodsList(@PathParam("pageno") String pageno,

@PathParam("type") String type){}

-------------------------------------------------------------------------------------------


@POST介面可以通過地址欄直接擷取測試:

例如上面這個介面,地址欄直接輸入:

http://localhost:連接埠號碼/項目名稱/api/api/goodsListByType/pageno/type/

第一個api是Struts.xml配置的

(<constant name="struts.action.excludePattern" value="/api/.*" />),

後一個是applicationContext.xml配置的

      <jaxrs:server  address="/api">

<jaxrs:serviceBeans>

<ref bean="appService" />

</jaxrs:serviceBeans>

<jaxrs:providers>

      <bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider"/>    

   </jaxrs:providers>

</jaxrs:server>

但是@GET方法是不能直接在路徑中區擷取的,要借用外部工具或自己寫一個測試類別,當然我選擇了前者,網上百度找到了大神們說的postmanGoogle瀏覽器外掛程式,自己摸索著去測試,再也不擔心介面調試了。

get介面如下:

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/77/04/wKioL1ZhDvHRDajGAACgVP3Wq38086.png" title="get.png" alt="wKioL1ZhDvHRDajGAACgVP3Wq38086.png" />

post介面如下:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/77/05/wKiom1ZhDqPTEx0xAADL145zZ5o542.png" title="post.png" alt="wKiom1ZhDqPTEx0xAADL145zZ5o542.png" />



本文出自 “秦楓” 部落格,請務必保留此出處http://leoxia.blog.51cto.com/10825018/1719483

安卓 與java後台 的介面測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.