package com.test.jmeter;
import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
import org.apache.jmeter.testelement.TestElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
public class TestGuiHttpSampler extends AbstractSamplerGui {
private static final Logger log = LoggerFactory.getLogger(TestGuiHttpSampler.class);
private JTextField urlField = null;
private JTextField useridField = null;
public TestGuiHttpSampler(){
urlField = new JTextField();
useridField = new JTextField();
initUI();
}
private void initUI(){
JPanel topPanel = new JPanel(new GridBagLayout());
topPanel.add(new JLabel("http参数"), new GB(0,0,1,1).setInsets(5));
topPanel.add(new JLabel("访问地址:"), new GB(0,1,1,1).setInsets(5));
topPanel.add(urlField, new GB(1,1,1,1).setInsets(5).setFill(GB.BOTH).setWeight(100,0));
topPanel.add(new JPanel(), new GB(0,2,2,1).setInsets(5).setFill(GB.BOTH).setWeight(100,100));
JPanel bottomPanel = new JPanel(new GridBagLayout());
bottomPanel.add(new JLabel("Cookie参数"), new GB(0,0,1,1).setInsets(5));
bottomPanel.add(new JLabel("用户id:"), new GB(0,1,1,1).setInsets(5));
bottomPanel.add(useridField, new GB(1,1,1,1).setInsets(5).setFill(GB.BOTH).setWeight(100,0));
bottomPanel.add(new JPanel(), new GB(0,2,2,1).setInsets(5).setFill(GB.BOTH).setWeight(100,100));
JSplitPane splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);
splitPane.setContinuousLayout(true);
log.info("====TestGuiHttpSampler size:" + this.getSize());
splitPane.setDividerLocation(50);
splitPane.setPreferredSize(this.getSize());
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(topPanel);
splitPane.setBottomComponent(bottomPanel);
setLayout(new BorderLayout());
add(splitPane, BorderLayout.CENTER);
}
@Override
public String getLabelResource() {
return null;
}
@Override
public TestElement createTestElement() {
TestGuiSampler sample = new TestGuiSampler();
modifyTestElement(sample);
return sample;
}
@Override
public void modifyTestElement(TestElement testElement) {
testElement.clear();
configureTestElement(testElement);
testElement.setProperty(TestGuiSampler.URL, urlField.getText());
testElement.setProperty(TestGuiSampler.USERID, useridField.getText());
}
public void configure(TestElement testElement) {
super.configure(testElement);
testElement.setProperty(TestGuiSampler.URL, urlField.getText());
testElement.setProperty(TestGuiSampler.USERID, useridField.getText());
log.info("=====configure");
}
@Override
public boolean canBeAdded() {
return super.canBeAdded();
}
@Override
public String getStaticLabel() {
return "TestGuiHttpSampler测试";
}
// @Override
// public void clearGui() {
// super.clearGui();
// log.info("=====clearGui");
// urlField.setText("");
// useridField.setText("");
// }
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jmter_test.rar (5个子文件)
pom.xml 2KB
src
test
java
main
resources
java
com
test
jmeter
TestGuiHttpSampler.java 3KB
GB.java 1KB
TestHttpSampler.java 3KB
TestGuiSampler.java 3KB
共 5 条
- 1
资源评论
penngo
- 粉丝: 1w+
- 资源: 66
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功