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<NameValuePair> params = new ArrayList<NameValuePair>();
		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使用的方法-创新互联
网页URL:https://www.cdcxhl.com/article12/cspidc.html

成都网站建设公司_创新互联,为您提供企业网站制作网站排名企业建站软件开发网站策划营销型网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

网站托管运营