public static HttpPost parseHttpTest(CloseableHttpClient httpclient,Node test) throws Exception {
  List<Node> headers=getNamedChildren("header",test);
  List<Node> cookies=getNamedChildren("cookie",test);
  List<Node> getParams=getNamedChildren("getparam",test);
  List<Node> formParams=getNamedChildren("formparam",test);
  String query="";
  String number=getAttributeValue("name",test);
  boolean first=true;
  for (  Node field : getParams) {
    if (!first) {
      first=false;
      query+="&";
    }
    String name=getAttributeValue("name",field);
    String value=getAttributeValue("value",field);
    query+=name + "=" + URLEncoder.encode(value);
  }
  String fullURL=getAttributeValue("URL",test);
  if (!query.isEmpty()) {
    fullURL+="?" + query;
  }
  HttpPost httpPost=new HttpPost(fullURL);
  for (  Node header : headers) {
    String name=getAttributeValue("name",header);
    String value=getAttributeValue("value",header);
    httpPost.addHeader(name,value);
  }
  for (  Node cookie : cookies) {
    String name=getAttributeValue("name",cookie);
    String value=getAttributeValue("value",cookie);
    httpPost.addHeader("Cookie",name + "=" + value);
  }
  List<NameValuePair> fields=new ArrayList<NameValuePair>();
  for (  Node field : formParams) {
    String name=getAttributeValue("name",field);
    String value=getAttributeValue("value",field);
    NameValuePair nvp=new BasicNameValuePair(name,value);
    fields.add(nvp);
  }
  httpPost.setEntity(new UrlEncodedFormEntity(fields));
  return httpPost;
}

public static HttpPost parseHttpTest ( CloseableHttpClient httpclient , Node test ) throws Exception { List < Node > headers = getNamedChildren ( "header" , test ) ; List < Node > cookies = getNamedChildren ( "cookie" , test ) ; List < Node > getParams = getNamedChildren ( "getparam" , test ) ; List < Node > formParams = getNamedChildren ( "formparam" , test ) ; String query = "" ; String number = getAttributeValue ( "name" , test ) ; boolean first = true ; for ( Node field : getParams ) { if ( ! first ) { first = false ; query += "&" ; } String name = getAttributeValue ( "name" , field ) ; String value = getAttributeValue ( "value" , field ) ; query += name + "=" + URLEncoder . encode ( value ) ; } String fullURL = getAttributeValue ( "URL" , test ) ; if ( ! query . isEmpty ( ) ) { fullURL += "?" + query ; } HttpPost httpPost = new HttpPost ( fullURL ) ; for ( Node header : headers ) { String name = getAttributeValue ( "name" , header ) ; String value = getAttributeValue ( "value" , header ) ; httpPost . addHeader ( name , value ) ; } for ( Node cookie : cookies ) { String name = getAttributeValue ( "name" , cookie ) ; String value = getAttributeValue ( "value" , cookie ) ; httpPost . addHeader ( "Cookie" , name + "=" + value ) ; } List < NameValuePair > fields = new ArrayList < NameValuePair > ( ) ; for ( Node field : formParams ) { String name = getAttributeValue ( "name" , field ) ; String value = getAttributeValue ( "value" , field ) ; NameValuePair nvp = new BasicNameValuePair ( name , value ) ; fields . add ( nvp ) ; } httpPost . setEntity ( new UrlEncodedFormEntity ( fields ) ) ; return httpPost ; }
read http request xml file
