少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

          package org.abin.lee.file;

          import java.io.IOException;
          import java.util.ArrayList;
          import java.util.List;

          import junit.framework.TestCase;
          import net.sf.json.JSONObject;

          import org.apache.http.HttpEntity;
          import org.apache.http.HttpResponse;
          import org.apache.http.NameValuePair;
          import org.apache.http.client.ClientProtocolException;
          import org.apache.http.client.entity.UrlEncodedFormEntity;
          import org.apache.http.client.methods.HttpPost;
          import org.apache.http.impl.client.DefaultHttpClient;
          import org.apache.http.message.BasicNameValuePair;
          import org.apache.http.protocol.HTTP;
          import org.apache.http.util.EntityUtils;

          public class QueryCustomerManagerTestCase extends TestCase {
           
           private static final String jsonServerUrl = " 
           static DefaultHttpClient client = new DefaultHttpClient();

           public static String sendReq(String method, String jsonReq)
             throws ClientProtocolException, IOException {
            HttpPost post = new HttpPost(jsonServerUrl + method);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("json", jsonReq));

            post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

            HttpResponse response = client.execute(post);
            HttpEntity entity = response.getEntity();
            String entityStr = EntityUtils.toString(entity);

            return entityStr;
           }

           /**
            * 查詢產(chǎn)品客戶經(jīng)理接口
            */
           public void testQueryCustomerManager() throws ClientProtocolException,
             IOException {
            String jsonReq = "{" + "RequestID:'11111',"+ "ProductID:'SC9904348'," + "timestamp:'20120416121200',"
              + "Hashcode:'1324546asdfgfhr65432wsdfgt654eds'" + "}";

            String resStr = this.sendReq("query-customer-manager-json!queryCustomerManager.action", jsonReq);

            System.out.println(resStr);

            assertNotNull(resStr);
          //  JSONObject json = JSONObject.fromObject(resStr);
          //  assertNotNull(json.get("requestID"));
           }

          }

          主站蜘蛛池模板: 扎兰屯市| 凤山市| 龙泉市| 遂平县| 道孚县| 连云港市| 中超| 滕州市| 乐业县| 开原市| 淮阳县| 加查县| 泽库县| 中西区| 新宾| 汶上县| 花垣县| 屏东市| 瑞昌市| 清河县| 固镇县| 广饶县| 东光县| 二连浩特市| 峨山| 庆阳市| 信宜市| 浮梁县| 车致| 麻城市| 乌审旗| 佛冈县| 漾濞| 卢湾区| 邻水| 黔东| 通化市| 团风县| 云南省| 府谷县| 五家渠市|