/
TailUrlConfigGui.java
105 lines (85 loc) · 3.28 KB
/
TailUrlConfigGui.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package ru.pflb.jmeter.protocol.http.config.gui;
import org.apache.jmeter.gui.util.JSyntaxTextArea;
import org.apache.jmeter.gui.util.JTextScrollPane;
import org.apache.jmeter.protocol.http.config.gui.MultipartUrlConfigGui;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import ru.pflb.jmeter.samplers.TailHTTPSamplerProxy;
import javax.swing.*;
import java.awt.*;
/**
* Basic URL / HTTP Request Tail configuration:
* <ul>
* <li>host and port</li>
* <li>connect and response timeouts</li>
* <li>path, method, encoding</li>
* <li>redirects and keepalive</li>
* <li>embedded resource links</li>
* </ul>
*/
public class TailUrlConfigGui extends MultipartUrlConfigGui {
/**
* Embedded resource links
*/
private JSyntaxTextArea requestData;
// used by HttpTestSampleGui
public TailUrlConfigGui() {
super();
init();
}
public TailUrlConfigGui(boolean showSamplerFields, boolean showImplementation) {
super(showSamplerFields, showImplementation);
init();
}
@Override
public void modifyTestElement(TestElement sampler) {
super.modifyTestElement(sampler);
sampler.setProperty(TailHTTPSamplerProxy.EMBRESLINKS, requestData.getText());
}
@Override
public void configure(TestElement element) {
super.configure(element);
requestData.setInitialText(element.getPropertyAsString(TailHTTPSamplerProxy.EMBRESLINKS));
requestData.setCaretPosition(0);
}
private void init() {// called from ctor, so must not be overridable
this.setLayout(new BorderLayout());
// WEB REQUEST PANEL
JPanel webRequestPanel = new JPanel();
webRequestPanel.setLayout(new BorderLayout());
webRequestPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("web_request"))); // $NON-NLS-1$
JPanel northPanel = new JPanel();
northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
northPanel.add(super.getProtocolAndMethodPanel());
northPanel.add(super.getPathPanel());
webRequestPanel.add(northPanel, BorderLayout.NORTH);
//EMBEDDED RESOURCE PANEL (Tail links)
webRequestPanel.add(createDataPanel(), BorderLayout.CENTER);
this.add(super.getWebServerTimeoutPanel(), BorderLayout.NORTH);
this.add(webRequestPanel, BorderLayout.CENTER);
this.add(super.getProxyServerPanel(), BorderLayout.SOUTH);
}
/*
* Create a embedded resource panel
*
* @return the panel for entering the data
*/
private JPanel createDataPanel() {
JLabel label = new JLabel("Embedded resources"); //$NON-NLS-1$
requestData = new JSyntaxTextArea(15, 80);
requestData.setLanguage("text");
requestData.setName(TailHTTPSamplerProxy.EMBRESLINKS);
label.setLabelFor(requestData);
JPanel dataPanel = new JPanel(new BorderLayout(5, 0));
dataPanel.add(label, BorderLayout.WEST);
dataPanel.add(new JTextScrollPane(requestData), BorderLayout.CENTER);
return dataPanel;
}
@Override
public void clear() {
super.clear();
requestData.setInitialText("");
requestData.setCaretPosition(0);
}
}