View | Details | Raw Unified | Return to bug 50943
Collapse All | Expand All

(-)src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (-4 / +118 lines)
Lines 28-39 Link Here
28
import java.net.URL;
28
import java.net.URL;
29
import java.security.MessageDigest;
29
import java.security.MessageDigest;
30
import java.security.NoSuchAlgorithmException;
30
import java.security.NoSuchAlgorithmException;
31
import java.util.ArrayList;
31
import java.util.Arrays;
32
import java.util.Arrays;
32
import java.util.Collections;
33
import java.util.Collections;
33
import java.util.HashMap;
34
import java.util.HashMap;
34
import java.util.Iterator;
35
import java.util.Iterator;
35
import java.util.List;
36
import java.util.List;
36
import java.util.Map;
37
import java.util.Map;
38
import java.util.concurrent.Callable;
39
import java.util.concurrent.ExecutionException;
40
import java.util.concurrent.Future;
41
import java.util.concurrent.LinkedBlockingQueue;
42
import java.util.concurrent.ThreadPoolExecutor;
43
import java.util.concurrent.TimeUnit;
37
44
38
import org.apache.commons.io.IOUtils;
45
import org.apache.commons.io.IOUtils;
39
import org.apache.jmeter.config.Argument;
46
import org.apache.jmeter.config.Argument;
Lines 48-56 Link Here
48
import org.apache.jmeter.protocol.http.util.ConversionUtils;
55
import org.apache.jmeter.protocol.http.util.ConversionUtils;
49
import org.apache.jmeter.protocol.http.util.EncoderCache;
56
import org.apache.jmeter.protocol.http.util.EncoderCache;
50
import org.apache.jmeter.protocol.http.util.HTTPArgument;
57
import org.apache.jmeter.protocol.http.util.HTTPArgument;
58
import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
51
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
59
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
52
import org.apache.jmeter.protocol.http.util.HTTPFileArgs;
60
import org.apache.jmeter.protocol.http.util.HTTPFileArgs;
53
import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
54
import org.apache.jmeter.samplers.AbstractSampler;
61
import org.apache.jmeter.samplers.AbstractSampler;
55
import org.apache.jmeter.samplers.Entry;
62
import org.apache.jmeter.samplers.Entry;
56
import org.apache.jmeter.samplers.SampleResult;
63
import org.apache.jmeter.samplers.SampleResult;
Lines 139-149 Link Here
139
    public static final String DO_MULTIPART_POST = "HTTPSampler.DO_MULTIPART_POST"; // $NON-NLS-1$
146
    public static final String DO_MULTIPART_POST = "HTTPSampler.DO_MULTIPART_POST"; // $NON-NLS-1$
140
147
141
    public static final String BROWSER_COMPATIBLE_MULTIPART  = "HTTPSampler.BROWSER_COMPATIBLE_MULTIPART"; // $NON-NLS-1$
148
    public static final String BROWSER_COMPATIBLE_MULTIPART  = "HTTPSampler.BROWSER_COMPATIBLE_MULTIPART"; // $NON-NLS-1$
149
    
150
    public static final String CONCURRENT_DWN = "HTTPSampler.concurrentDwn"; // $NON-NLS-1$
151
    
152
    public static final String CONCURRENT_POOL = "HTTPSampler.concurrentPool"; // $NON-NLS-1$
142
153
143
    //- JMX names
154
    //- JMX names
144
155
145
    public static final boolean BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT = false; // The default setting to be used (i.e. historic)
156
    public static final boolean BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT = false; // The default setting to be used (i.e. historic)
146
    
157
    
158
    private static final long KEEPALIVETIME = 0; // for Thread Pool for resources but no need to use a special value?
159
    
160
    private static final long AWAIT_TERMINATION_TIMEOUT = 
161
        JMeterUtils.getPropDefault("httpsampler.await_termination_timeout", 60); // $NON-NLS-1$ // default value: 60 secs 
162
    
163
    public static final int CONCURRENT_POOL_SIZE = 4; // Default concurrent pool size for download embedded resources
164
    
147
    
165
    
148
    public static final String DEFAULT_METHOD = GET; // $NON-NLS-1$
166
    public static final String DEFAULT_METHOD = GET; // $NON-NLS-1$
149
    // Supported methods:
167
    // Supported methods:
Lines 1107-1112 Link Here
1107
                    log.warn("Ignoring embedded URL match string: "+e.getMessage());
1125
                    log.warn("Ignoring embedded URL match string: "+e.getMessage());
1108
                }
1126
                }
1109
            }
1127
            }
1128
            
1129
            // For concurrent get resources
1130
            final ArrayList<ASyncSample> liste = new ArrayList<ASyncSample>();
1131
            
1110
            while (urls.hasNext()) {
1132
            while (urls.hasNext()) {
1111
                Object binURL = urls.next(); // See catch clause below
1133
                Object binURL = urls.next(); // See catch clause below
1112
                try {
1134
                try {
Lines 1129-1137 Link Here
1129
                        if (pattern != null && localMatcher != null && !localMatcher.matches(urlStrEnc, pattern)) {
1151
                        if (pattern != null && localMatcher != null && !localMatcher.matches(urlStrEnc, pattern)) {
1130
                            continue; // we have a pattern and the URL does not match, so skip it
1152
                            continue; // we have a pattern and the URL does not match, so skip it
1131
                        }
1153
                        }
1132
                        HTTPSampleResult binRes = sample(url, GET, false, frameDepth + 1);
1154
                        
1133
                        res.addSubResult(binRes);
1155
                        if (isConcurrentDwn()) {
1134
                        res.setSuccessful(res.isSuccessful() && binRes.isSuccessful());
1156
                            // if concurrent download emb. resources, add to a list for async gets later
1157
                            liste.add(new ASyncSample(url, GET, false, frameDepth + 1));
1158
                        } else {
1159
                            // default: serial download embedded resources
1160
                            HTTPSampleResult binRes = sample(url, GET, false, frameDepth + 1);
1161
                            res.addSubResult(binRes);
1162
                            res.setSuccessful(res.isSuccessful() && binRes.isSuccessful());
1163
                        }
1164
1135
                    }
1165
                    }
1136
                } catch (ClassCastException e) { // TODO can this happen?
1166
                } catch (ClassCastException e) { // TODO can this happen?
1137
                    res.addSubResult(errorResult(new Exception(binURL + " is not a correct URI"), res));
1167
                    res.addSubResult(errorResult(new Exception(binURL + " is not a correct URI"), res));
Lines 1139-1144 Link Here
1139
                    continue;
1169
                    continue;
1140
                }
1170
                }
1141
            }
1171
            }
1172
            
1173
            // IF for download concurrent embedded resources
1174
            if (isConcurrentDwn()) {
1175
                int poolSize = CONCURRENT_POOL_SIZE; // init with default value
1176
                try {
1177
                    poolSize = Integer.parseInt(getConcurrentPool());
1178
                } catch (NumberFormatException nfe) {
1179
                    log.warn("Concurrent download resources selected, "// $NON-NLS-1$
1180
                            + "but pool size value is bad. Use default value");// $NON-NLS-1$
1181
                }
1182
                // Thread pool Executor to get resources 
1183
                // use a LinkedBlockingQueue, note: max pool size doesn't effect
1184
                final ThreadPoolExecutor exec = new ThreadPoolExecutor(
1185
                        poolSize, poolSize, KEEPALIVETIME, TimeUnit.SECONDS,
1186
                        new LinkedBlockingQueue<Runnable>());
1187
1188
                try {
1189
                    // sample all resources with threadpool
1190
                    final List<Future<HTTPSampleResult>> retExec = exec.invokeAll(liste);
1191
                    // call normal shutdown (wait ending all tasks)
1192
                    exec.shutdown();
1193
                    // put a timeout if tasks couldn't terminate
1194
                    exec.awaitTermination(AWAIT_TERMINATION_TIMEOUT, TimeUnit.SECONDS);
1195
1196
                    // add result to main sampleResult
1197
                    for (Future<HTTPSampleResult> future : retExec) {
1198
                        final HTTPSampleResult binRes = future.get();
1199
                        res.addSubResult(binRes);
1200
                        res.setSuccessful(res.isSuccessful() && binRes.isSuccessful());
1201
                    }
1202
                } catch (InterruptedException ie) {
1203
                    log.warn("Interruped fetching embedded resources", ie); // $NON-NLS-1$
1204
                } catch (ExecutionException ee) {
1205
                    log.warn("Execution issue when fetching embedded resources", ee); // $NON-NLS-1$
1206
                }
1207
            }
1142
        }
1208
        }
1143
        return res;
1209
        return res;
1144
    }
1210
    }
Lines 1565-1569 Link Here
1565
    public String getIpSource() {
1631
    public String getIpSource() {
1566
        return getPropertyAsString(IP_SOURCE,"");
1632
        return getPropertyAsString(IP_SOURCE,"");
1567
    }
1633
    }
1634
    
1635
    /**
1636
     * Return if used a concurrent thread pool to get embedded resources.
1637
     *
1638
     * @return true if used
1639
     */
1640
    public boolean isConcurrentDwn() {
1641
        return getPropertyAsBoolean(CONCURRENT_DWN);
1642
    }
1643
1644
    public void setConcurrentDwn(boolean concurrentDwn) {
1645
        setProperty(new BooleanProperty(CONCURRENT_DWN, concurrentDwn));
1646
    }
1647
    /**
1648
     * Get the pool size for concurrent thread pool to get embedded resources.
1649
     *
1650
     * @return the pool size
1651
     */
1652
    public String getConcurrentPool() {
1653
        return getPropertyAsString(CONCURRENT_POOL,"4");
1654
    }
1655
1656
    public void setConcurrentPool(String poolSize) {
1657
        setProperty(new StringProperty(CONCURRENT_POOL, poolSize));
1658
    }
1659
1660
    /**
1661
     * Callable class to sample asynchronously resources embedded
1662
     *
1663
     */
1664
    public class ASyncSample implements Callable<HTTPSampleResult> {
1665
        final private URL url;
1666
        final private String method;
1667
        final private boolean areFollowingRedirect;
1668
        final private int depth;
1669
1670
        public ASyncSample(URL url, String method,
1671
                boolean areFollowingRedirect, int depth){
1672
            this.url = url;
1673
            this.method = method;
1674
            this.areFollowingRedirect = areFollowingRedirect;
1675
            this.depth = depth;
1676
        }
1677
1678
        public HTTPSampleResult call() {
1679
            return sample(url, method, areFollowingRedirect, depth);
1680
        }
1681
    }
1568
}
1682
}
1569
1683
(-)bin/jmeter.properties (+2 lines)
Lines 682-687 Link Here
682
#httpsampler.max_redirects=5
682
#httpsampler.max_redirects=5
683
# Maximum frame/iframe nesting depth (default 5)
683
# Maximum frame/iframe nesting depth (default 5)
684
#httpsampler.max_frame_depth=5
684
#httpsampler.max_frame_depth=5
685
# Maximum await termination timeout (secs) when concurrent download embedded resources (default 60)
686
#httpsampler.await_termination_timeout=60
685
687
686
# The encoding to be used if none is provided (default ISO-8859-1)
688
# The encoding to be used if none is provided (default ISO-8859-1)
687
#sampleresult.default.encoding=ISO-8859-1
689
#sampleresult.default.encoding=ISO-8859-1
(-)xdocs/usermanual/component_reference.xml (-2 / +6 lines)
Lines 81-87 Link Here
81
81
82
</component>
82
</component>
83
83
84
<component name="HTTP Request" index="&sect-num;.1.2"  width="851" height="661" screenshot="http-request.png">
84
<component name="HTTP Request" index="&sect-num;.1.2" screenshot="http-request.png">
85
85
86
<description>
86
<description>
87
        <p>This sampler lets you send an HTTP/HTTPS request to a web server.  It
87
        <p>This sampler lets you send an HTTP/HTTPS request to a web server.  It
Lines 271-276 Link Here
271
        So if you only want to download embedded resources from http://example.com/, use the expression:
271
        So if you only want to download embedded resources from http://example.com/, use the expression:
272
        http://example\.com/.*
272
        http://example\.com/.*
273
        </property>
273
        </property>
274
        <property name="Use concurrent pool" required="No">Use a pool of concurrent connections to get embedded resources.</property>
275
        <property name="Size" required="No">Pool size for concurrent connections used to get embedded resources.</property>
274
        <property name="Source IP address:" required="No">
276
        <property name="Source IP address:" required="No">
275
        [Only for HTTP Request HTTPClient] 
277
        [Only for HTTP Request HTTPClient] 
276
        Override the default local IP address for this sample.
278
        Override the default local IP address for this sample.
Lines 3068-3074 Link Here
3068
</component>
3070
</component>
3069
3071
3070
<component name="HTTP Request Defaults" index="&sect-num;.4.5" 
3072
<component name="HTTP Request Defaults" index="&sect-num;.4.5" 
3071
         width="678" height="447" screenshot="http-config/http-request-defaults.png">
3073
         screenshot="http-config/http-request-defaults.png">
3072
<description><p>This element lets you set default values that your HTTP Request controllers use.  For example, if you are
3074
<description><p>This element lets you set default values that your HTTP Request controllers use.  For example, if you are
3073
creating a Test Plan with 25 HTTP Request controllers and all of the requests are being sent to the same server,
3075
creating a Test Plan with 25 HTTP Request controllers and all of the requests are being sent to the same server,
3074
you could add a single HTTP Request Defaults element with the "Server Name or IP" field filled in.  Then, when
3076
you could add a single HTTP Request Defaults element with the "Server Name or IP" field filled in.  Then, when
Lines 3110-3115 Link Here
3110
        <property name="Retrieve All Embedded Resources from HTML Files" required="No">Tell JMeter to parse the HTML file
3112
        <property name="Retrieve All Embedded Resources from HTML Files" required="No">Tell JMeter to parse the HTML file
3111
and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.
3113
and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.
3112
        </property>
3114
        </property>
3115
        <property name="Use concurrent pool" required="No">Use a pool of concurrent connections to get embedded resources.</property>
3116
        <property name="Size" required="No">Pool size for concurrent connections used to get embedded resources.</property>
3113
</properties>
3117
</properties>
3114
</component>
3118
</component>
3115
3119
(-)src/core/org/apache/jmeter/resources/messages.properties (+1 lines)
Lines 1022-1027 Link Here
1022
web_server_port=Port Number\:
1022
web_server_port=Port Number\:
1023
web_testing2_source_ip=Source IP address:
1023
web_testing2_source_ip=Source IP address:
1024
web_testing2_title=HTTP Request HTTPClient
1024
web_testing2_title=HTTP Request HTTPClient
1025
web_testing_concurrent_download=Use concurrent pool. Size:
1025
web_testing_embedded_url_pattern=Embedded URLs must match\:
1026
web_testing_embedded_url_pattern=Embedded URLs must match\:
1026
web_testing_retrieve_images=Retrieve All Embedded Resources from HTML Files
1027
web_testing_retrieve_images=Retrieve All Embedded Resources from HTML Files
1027
web_testing_title=HTTP Request
1028
web_testing_title=HTTP Request
(-)src/core/org/apache/jmeter/resources/messages_fr.properties (+1 lines)
Lines 927-932 Link Here
927
web_server_timeout_title=D\u00E9lai expiration (ms)
927
web_server_timeout_title=D\u00E9lai expiration (ms)
928
web_testing2_source_ip=Adresse IP source \:
928
web_testing2_source_ip=Adresse IP source \:
929
web_testing2_title=Requ\u00EAte HTTP HTTPClient
929
web_testing2_title=Requ\u00EAte HTTP HTTPClient
930
web_testing_concurrent_download=Utiliser pool unit\u00E9. Nbre \:
930
web_testing_embedded_url_pattern=Les URL \u00E0 inclure doivent correspondre \u00E0 \:
931
web_testing_embedded_url_pattern=Les URL \u00E0 inclure doivent correspondre \u00E0 \:
931
web_testing_retrieve_images=R\u00E9cup\u00E9rer les ressources incluses
932
web_testing_retrieve_images=R\u00E9cup\u00E9rer les ressources incluses
932
web_testing_title=Requ\u00EAte HTTP
933
web_testing_title=Requ\u00EAte HTTP
(-)src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java (-1 / +73 lines)
Lines 20-34 Link Here
20
20
21
import java.awt.BorderLayout;
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
22
import java.awt.Dimension;
23
import java.awt.event.ItemEvent;
24
import java.awt.event.ItemListener;
23
25
26
import javax.swing.BorderFactory;
24
import javax.swing.JCheckBox;
27
import javax.swing.JCheckBox;
28
import javax.swing.JPanel;
29
import javax.swing.JTextField;
25
30
26
import org.apache.jmeter.config.ConfigTestElement;
31
import org.apache.jmeter.config.ConfigTestElement;
27
import org.apache.jmeter.config.gui.AbstractConfigGui;
32
import org.apache.jmeter.config.gui.AbstractConfigGui;
33
import org.apache.jmeter.gui.util.HorizontalPanel;
28
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
34
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
29
import org.apache.jmeter.testelement.AbstractTestElement;
35
import org.apache.jmeter.testelement.AbstractTestElement;
30
import org.apache.jmeter.testelement.TestElement;
36
import org.apache.jmeter.testelement.TestElement;
31
import org.apache.jmeter.testelement.property.BooleanProperty;
37
import org.apache.jmeter.testelement.property.BooleanProperty;
38
import org.apache.jmeter.testelement.property.StringProperty;
32
import org.apache.jmeter.util.JMeterUtils;
39
import org.apache.jmeter.util.JMeterUtils;
33
40
34
public class HttpDefaultsGui extends AbstractConfigGui {
41
public class HttpDefaultsGui extends AbstractConfigGui {
Lines 36-41 Link Here
36
    private static final long serialVersionUID = 240L;
43
    private static final long serialVersionUID = 240L;
37
44
38
    private JCheckBox imageParser;
45
    private JCheckBox imageParser;
46
    
47
    private JCheckBox concurrentDwn;
48
    
49
    private JTextField concurrentPool; 
39
50
40
    private UrlConfigGui urlConfig;
51
    private UrlConfigGui urlConfig;
41
52
Lines 70-78 Link Here
70
        super.configureTestElement(config);
81
        super.configureTestElement(config);
71
        if (imageParser.isSelected()) {
82
        if (imageParser.isSelected()) {
72
            config.setProperty(new BooleanProperty(HTTPSamplerBase.IMAGE_PARSER, true));
83
            config.setProperty(new BooleanProperty(HTTPSamplerBase.IMAGE_PARSER, true));
84
            enableConcurrentDwn(true);
73
        } else {
85
        } else {
74
            config.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
86
            config.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
87
            enableConcurrentDwn(false);
88
        }
89
        if (concurrentDwn.isSelected()) {
90
            config.setProperty(new BooleanProperty(HTTPSamplerBase.CONCURRENT_DWN, true));
91
        } else {
92
            // The default is false, so we can remove the property to simplify JMX files
93
            // This also allows HTTPDefaults to work for this checkbox
94
            config.removeProperty(HTTPSamplerBase.CONCURRENT_DWN);
75
        }
95
        }
96
        config.setProperty(new StringProperty(HTTPSamplerBase.CONCURRENT_POOL, 
97
                String.valueOf(HTTPSamplerBase.CONCURRENT_POOL_SIZE)));
76
    }
98
    }
77
99
78
    /**
100
    /**
Lines 83-88 Link Here
83
        super.clearGui();
105
        super.clearGui();
84
        urlConfig.clear();
106
        urlConfig.clear();
85
        imageParser.setSelected(false);
107
        imageParser.setSelected(false);
108
        concurrentDwn.setSelected(false);
109
        concurrentPool.setText(String.valueOf(HTTPSamplerBase.CONCURRENT_POOL_SIZE));
86
    }
110
    }
87
111
88
    @Override
112
    @Override
Lines 90-95 Link Here
90
        super.configure(el);
114
        super.configure(el);
91
        urlConfig.configure(el);
115
        urlConfig.configure(el);
92
        imageParser.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.IMAGE_PARSER));
116
        imageParser.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.IMAGE_PARSER));
117
        concurrentDwn.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.CONCURRENT_DWN));
118
        concurrentPool.setText(((AbstractTestElement) el).getPropertyAsString(HTTPSamplerBase.CONCURRENT_POOL));
93
    }
119
    }
94
120
95
    private void init() {
121
    private void init() {
Lines 101-112 Link Here
101
        urlConfig = new UrlConfigGui(false);
127
        urlConfig = new UrlConfigGui(false);
102
        add(urlConfig, BorderLayout.CENTER);
128
        add(urlConfig, BorderLayout.CENTER);
103
129
130
        // OPTIONAL TASKS
131
        final JPanel optionalTasksPanel = new HorizontalPanel();
132
        optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils
133
                .getResString("optional_tasks"))); // $NON-NLS-1$
134
135
        final JPanel checkBoxPanel = new HorizontalPanel();
104
        imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
136
        imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
105
        add(imageParser, BorderLayout.SOUTH);
137
        checkBoxPanel.add(imageParser);
138
        imageParser.addItemListener(new ItemListener() {
139
            public void itemStateChanged(final ItemEvent e) {
140
                if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); }
141
                else { enableConcurrentDwn(false); }
142
            }
143
        });
144
        // Concurrent resources download
145
        concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$
146
        concurrentDwn.addItemListener(new ItemListener() {
147
            public void itemStateChanged(final ItemEvent e) {
148
                if (e.getStateChange() == ItemEvent.SELECTED) { concurrentPool.setEnabled(true); }
149
                else { concurrentPool.setEnabled(false); }
150
            }
151
        });
152
        concurrentPool = new JTextField(2); // 2 columns size
153
        concurrentPool.setMaximumSize(new Dimension(30,20));
154
        checkBoxPanel.add(concurrentDwn);
155
        checkBoxPanel.add(concurrentPool);
156
        optionalTasksPanel.add(checkBoxPanel);
157
        add(optionalTasksPanel, BorderLayout.SOUTH);
106
    }
158
    }
107
159
108
    @Override
160
    @Override
109
    public Dimension getPreferredSize() {
161
    public Dimension getPreferredSize() {
110
        return getMinimumSize();
162
        return getMinimumSize();
111
    }
163
    }
164
    
165
    private void enableConcurrentDwn(final boolean enable) {
166
        if (enable) {
167
            concurrentDwn.setEnabled(true);
168
            if (concurrentDwn.isSelected()) {
169
                concurrentPool.setEnabled(true);
170
            }
171
        } else {
172
            concurrentDwn.setEnabled(false);
173
            concurrentPool.setEnabled(false);
174
        }
175
    }
176
177
    public void itemStateChanged(final ItemEvent event) {
178
        if (event.getStateChange() == ItemEvent.SELECTED) {
179
            enableConcurrentDwn(true);
180
        } else {
181
            enableConcurrentDwn(false);
182
        }
183
    }
112
}
184
}
(-)src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java (-3 / +66 lines)
Lines 20-29 Link Here
20
20
21
import java.awt.BorderLayout;
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
22
import java.awt.Dimension;
23
import java.awt.event.ItemEvent;
24
import java.awt.event.ItemListener;
23
25
24
import javax.swing.BorderFactory;
26
import javax.swing.BorderFactory;
25
import javax.swing.JCheckBox;
27
import javax.swing.JCheckBox;
26
import javax.swing.JPanel;
28
import javax.swing.JPanel;
29
import javax.swing.JTextField;
27
30
28
import org.apache.jmeter.gui.util.HorizontalPanel;
31
import org.apache.jmeter.gui.util.HorizontalPanel;
29
import org.apache.jmeter.gui.util.VerticalPanel;
32
import org.apache.jmeter.gui.util.VerticalPanel;
Lines 41-52 Link Here
41
 * HTTP Sampler GUI
44
 * HTTP Sampler GUI
42
 *
45
 *
43
 */
46
 */
44
public class HttpTestSampleGui extends AbstractSamplerGui {
47
public class HttpTestSampleGui extends AbstractSamplerGui 
48
    implements ItemListener {
45
    private static final long serialVersionUID = 240L;
49
    private static final long serialVersionUID = 240L;
46
50
47
    private MultipartUrlConfigGui urlConfigGui;
51
    private MultipartUrlConfigGui urlConfigGui;
48
52
49
    private JCheckBox getImages;
53
    private JCheckBox getImages;
54
    
55
    private JCheckBox concurrentDwn;
56
    
57
    private JTextField concurrentPool; 
50
58
51
    private JCheckBox isMon;
59
    private JCheckBox isMon;
52
60
Lines 78-83 Link Here
78
        final HTTPSamplerBase samplerBase = (HTTPSamplerBase) element;
86
        final HTTPSamplerBase samplerBase = (HTTPSamplerBase) element;
79
        urlConfigGui.configure(element);
87
        urlConfigGui.configure(element);
80
        getImages.setSelected(samplerBase.isImageParser());
88
        getImages.setSelected(samplerBase.isImageParser());
89
        concurrentDwn.setSelected(samplerBase.isConcurrentDwn());
90
        concurrentPool.setText(samplerBase.getConcurrentPool());
81
        isMon.setSelected(samplerBase.isMonitor());
91
        isMon.setSelected(samplerBase.isMonitor());
82
        useMD5.setSelected(samplerBase.useMD5());
92
        useMD5.setSelected(samplerBase.useMD5());
83
        embeddedRE.setText(samplerBase.getEmbeddedUrlRE());
93
        embeddedRE.setText(samplerBase.getEmbeddedUrlRE());
Lines 106-116 Link Here
106
        final HTTPSamplerBase samplerBase = (HTTPSamplerBase) sampler;
116
        final HTTPSamplerBase samplerBase = (HTTPSamplerBase) sampler;
107
        if (getImages.isSelected()) {
117
        if (getImages.isSelected()) {
108
            samplerBase.setImageParser(true);
118
            samplerBase.setImageParser(true);
119
            enableConcurrentDwn(true);
109
        } else {
120
        } else {
110
            // The default is false, so we can remove the property to simplify JMX files
121
            // The default is false, so we can remove the property to simplify JMX files
111
            // This also allows HTTPDefaults to work for this checkbox
122
            // This also allows HTTPDefaults to work for this checkbox
112
            sampler.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
123
            sampler.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
124
            enableConcurrentDwn(false);
125
        }
126
        if (concurrentDwn.isSelected()) {
127
            samplerBase.setConcurrentDwn(true);
128
        } else {
129
            // The default is false, so we can remove the property to simplify JMX files
130
            // This also allows HTTPDefaults to work for this checkbox
131
            sampler.removeProperty(HTTPSamplerBase.CONCURRENT_DWN);
113
        }
132
        }
133
        samplerBase.setConcurrentPool(concurrentPool.getText());
114
        samplerBase.setMonitor(isMon.isSelected());
134
        samplerBase.setMonitor(isMon.isSelected());
115
        samplerBase.setMD5(useMD5.isSelected());
135
        samplerBase.setMD5(useMD5.isSelected());
116
        samplerBase.setEmbeddedUrlRE(embeddedRE.getText());
136
        samplerBase.setEmbeddedUrlRE(embeddedRE.getText());
Lines 143-161 Link Here
143
163
144
    protected JPanel createOptionalTasksPanel() {
164
    protected JPanel createOptionalTasksPanel() {
145
        // OPTIONAL TASKS
165
        // OPTIONAL TASKS
146
        JPanel optionalTasksPanel = new VerticalPanel();
166
        final JPanel optionalTasksPanel = new VerticalPanel();
147
        optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils
167
        optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils
148
                .getResString("optional_tasks"))); // $NON-NLS-1$
168
                .getResString("optional_tasks"))); // $NON-NLS-1$
149
169
150
        JPanel checkBoxPanel = new HorizontalPanel();
170
        final JPanel checkBoxPanel = new HorizontalPanel();
151
        // RETRIEVE IMAGES
171
        // RETRIEVE IMAGES
152
        getImages = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
172
        getImages = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
173
        // add a listener to activate or not concurrent dwn.
174
        getImages.addItemListener(new ItemListener() {
175
            public void itemStateChanged(final ItemEvent e) {
176
                if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); }
177
                else { enableConcurrentDwn(false); }
178
            }
179
        });
180
        // Download concurrent resources
181
        concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$
182
        concurrentDwn.addItemListener(new ItemListener() {
183
            public void itemStateChanged(final ItemEvent e) {
184
                if (e.getStateChange() == ItemEvent.SELECTED) { concurrentPool.setEnabled(true); }
185
                else { concurrentPool.setEnabled(false); }
186
            }
187
        });
188
        concurrentPool = new JTextField(2); // 2 column size
189
        concurrentPool.setMaximumSize(new Dimension(30,20));
153
        // Is monitor
190
        // Is monitor
154
        isMon = new JCheckBox(JMeterUtils.getResString("monitor_is_title")); // $NON-NLS-1$
191
        isMon = new JCheckBox(JMeterUtils.getResString("monitor_is_title")); // $NON-NLS-1$
155
        // Use MD5
192
        // Use MD5
156
        useMD5 = new JCheckBox(JMeterUtils.getResString("response_save_as_md5")); // $NON-NLS-1$
193
        useMD5 = new JCheckBox(JMeterUtils.getResString("response_save_as_md5")); // $NON-NLS-1$
157
194
158
        checkBoxPanel.add(getImages);
195
        checkBoxPanel.add(getImages);
196
        checkBoxPanel.add(concurrentDwn);
197
        checkBoxPanel.add(concurrentPool);
159
        checkBoxPanel.add(isMon);
198
        checkBoxPanel.add(isMon);
160
        checkBoxPanel.add(useMD5);
199
        checkBoxPanel.add(useMD5);
161
        optionalTasksPanel.add(checkBoxPanel);
200
        optionalTasksPanel.add(checkBoxPanel);
Lines 188-193 Link Here
188
    public void clearGui() {
227
    public void clearGui() {
189
        super.clearGui();
228
        super.clearGui();
190
        getImages.setSelected(false);
229
        getImages.setSelected(false);
230
        concurrentDwn.setSelected(false);
231
        concurrentPool.setText(String.valueOf(HTTPSamplerBase.CONCURRENT_POOL_SIZE));
232
        enableConcurrentDwn(false);
191
        isMon.setSelected(false);
233
        isMon.setSelected(false);
192
        useMD5.setSelected(false);
234
        useMD5.setSelected(false);
193
        urlConfigGui.clear();
235
        urlConfigGui.clear();
Lines 196-199 Link Here
196
            sourceIpAddr.setText(""); // $NON-NLS-1$
238
            sourceIpAddr.setText(""); // $NON-NLS-1$
197
        }
239
        }
198
    }
240
    }
241
    
242
    private void enableConcurrentDwn(boolean enable) {
243
        if (enable) {
244
            concurrentDwn.setEnabled(true);
245
            if (concurrentDwn.isSelected()) {
246
                concurrentPool.setEnabled(true);
247
            }
248
        } else {
249
            concurrentDwn.setEnabled(false);
250
            concurrentPool.setEnabled(false);
251
        }
252
    }
253
254
    public void itemStateChanged(ItemEvent event) {
255
        if (event.getStateChange() == ItemEvent.SELECTED) {
256
            enableConcurrentDwn(true);
257
        } else {
258
            enableConcurrentDwn(false);
259
        }
260
    }
261
199
}
262
}

Return to bug 50943