import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.qa.base.BaseApi;
import com.qa.base.Constants;
import com.qa.restclient.RestClient;
public class LoginManagerAppTest2 extends BaseApi{
private final static Logger Log=Logger.getLogger(LoginManagerAppTest2.class);
/*@Test
public void loginManagerAppTest() throws ClientProtocolException, IOException{
String url=host2+"/parkingManager/applogin/loginIn";
Manager manager = new Manager("yanczapp","8ddcff3a80f4189ca1c9d4d902c3c909","0571001");
Map<String, String> map=FastjsonUtils.toMap(FastjsonUtils.toJson(manager));
System.out.println("my out**********"+map);
CloseableHttpResponse closeableHttpResponse = RestClient.postForm(url, map, null);
//断言状态码是不是200
int statusCode = closeableHttpResponse.getStatusLine().getStatusCode();
Assert.assertEquals(statusCode,Constants.RESPNSE_STATUS_CODE_200,"status code is not 200");
//断言响应json内容中name和job是不是期待结果
String responseString = EntityUtils.toString(closeableHttpResponse.getEntity());
System.out.println("my out**********"+responseString);
JSONObject res = FastjsonUtils.toJsonObject(responseString);
sessionKey = FastjsonUtils.toMap(res.getString("data")).get("session_key");
System.out.println("data**********: " + res.getString("message"));
System.out.println("data**********: " + sessionKey);
String account=FastjsonUtils.toMap(res.getString("data")).get("account");
Assert.assertEquals(account,"yanczapp" ,"account code is not error");
}
*/
//依赖那个方法,如果依赖多个方法可使用逗号分隔loginManagerAppTestd,loginManagerApp
@Test(dependsOnMethods = {"loginManagerAppTestd"})
public void query() throws ClientProtocolException, IOException {
// http://m.test.mwpark.cn/parkingManager/apprecovered/querySumOrderAmountByCondition?session_key=MANAGER_SESSIONMANAGER_18853b5985274ae8893e96e916141830765.5753283230537
String url=host2+"/parkingManager/apprecovered/querySumOrderAmountByCondition";
Map<String, String> headers = new HashMap<String, String>();
headers.put("token", "aaaa");
Map<String, String> params = new HashMap<String, String>();
params.put("session_key", sessionKey);
CloseableHttpResponse closeableHttpResponse = RestClient.postForm(url, params, headers);
//断言状态码是不是200
int statusCode = RestClient.getStatusCode(closeableHttpResponse);
Assert.assertEquals(statusCode,Constants.RESPNSE_STATUS_CODE_200,"status code is not 200");
}
}