java自定义jar包让jmeter使用的方法-创新互联

上一篇文章中,提到怎么生成jar包让jmeter使用,这次我们来试试做参数,因为发现调包的时候其实更多还是参数化,那么开始改造吧

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的泗阳网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

1.在httpclientpost这个类中替换参数,且打印参数

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;

public class httpclientPost {
	
	public static int sendpost(String email,String value) throws ClientProtocolException, IOException {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		HttpPost post = new HttpPost("https://user.zaful.com/m-users-a-act_sign.htm?pipeline=zf");
		List params = new ArrayList();
		params.add(new BasicNameValuePair("email", email));
		params.add(new BasicNameValuePair("password", value));
		post.setEntity(new UrlEncodedFormEntity(params));
		CloseableHttpResponse response2 = httpclient.execute(post);

		int code = response2.getStatusLine().getStatusCode();
		HttpEntity http = response2.getEntity();

		InputStream instreams = http.getContent();
		BufferedReader reader = new BufferedReader(new InputStreamReader(instreams));
		StringBuffer buffer = new StringBuffer();
		String line;
		while ((line = reader.readLine()) != null) {
			buffer.append(line + "br ");
		}
		reader.close();
		System.out.println("email:  "+email +" password:"+value);
		System.out.println(code +" respones:"+buffer);
		
		return code;
	}

}

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:java自定义jar包让jmeter使用的方法-创新互联
标题网址:http://azwzsj.com/article/cspidc.html