http??????????????????????????????????
???????????? ???????[ 2013/3/19 11:18:52 ] ????????
???????????????http????????????????????????????????????????????
???????????????????????????????λ???????????http???????????????????????????????????????????δ????????????????http???????json????????в????????????????????????????а??????????в?????????????????????json?????????????json??????????json?????????????в?????????????http???????json?????????????н???????????????????????????????????????????????
??????????http?????????????????????????????????Щ?????????????????Щ?????з?????????????http?????????????????????????????????????????????
????http????????????????????????????????????ip??????????????????????????http????????????????????????????????????????????????????????????????????http????????????·?????????itest??mvn????????HttpURLConnection???http???????????????????????????????itest??д??????????????????????????????????????????
????http?????????????£?
????1?? ????????itest??mvn????
????2?? ???pom.xml???????????json????????
????3?? ???mvn eclipse??????????????????eclipse??????????а?????itest??????????????
???????????????????????hsf??????????????????????????????
????4?? ??BaseTestCase??????http?????????????????????HttpURLConnection???http???????????????к????????????????????????httpClient???????????????????????
????public String urlToString(String strUrl?? String charset) {
????URL url = null;
????HttpURLConnection urlconnection = null;
????DataInputStream input = null;
????String str = “”;
????try {
????url = new URL(strUrl);
????urlconnection = (HttpURLConnection) url.openConnection();
????input = new DataInputStream(urlconnection.getInputStream());
????BufferedReader reader = new BufferedReader(new InputStreamReader(input?? charset));
????String line = “”;
????while ((line = reader.readLine()) != null) {
????if (null != line && line != “”){
????str += line;
????}
????}
????} catch (Exception e) {
????e.printStackTrace();
????} finally {
????if (urlconnection != null) {
????urlconnection.disconnect();
????}
????try {
????input.close();
????} catch (Exception e) {
????e.printStackTrace();
????}
????}
????return str;
????}
????5?? ????????BaseTestCase?????????????????????????????json????json?????????
????6?? ????????????д?????????????????
?????磺????????http????????ip????????????????????????????????????????
????http://ald.taobao.com/urlstring?parameter=someone
????public String daily_demo = “1.1.1.1″;
????public String prepub_demo = “2.2.2.2″;
????public String online_demo = “ald.taobao.com”;
????@Test
????public void test_demo(){
????String parameter= “someone”;
????String charset = “XXXX”;
????String str = urlToString(“http://”+online_demo+”/urlstring?parameter=”+parameter?? charset);
????//?????????й???json???????????
????String sub = str.substring(1?? str.length()-1);
????JSONObject jsonObject = jsonstringToObject(sub);
????//????????????
????JSONArray data = jsonObject.getJSONArray(“data”);
????//У?鷵?????е????
????for(Object dataContent : data){
????String field= ((JSONObject)dataContent).get(“field”).toString();
????Assert.assertTrue(field.indexOf(“XXXX”)>-1);
????}
????}
????7?? ????????kelude????????????????????????У???????????????????????飬???????????????
?????????aladdin-httptest?????η?????????bug
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11