vlsi commented on a change in pull request #640:
URL: https://github.com/apache/jmeter/pull/640#discussion_r778589318
##########
File path:
src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPHC4Impl.java
##########
@@ -119,4 +126,42 @@ public void
testNotifyFirstSampleAfterLoopRestartWhenThreadIterationIsANewUser()
hc.notifyFirstSampleAfterLoopRestart();
assertTrue("Users are different, the state should be reset",
HTTPHC4Impl.resetStateOnThreadGroupIteration.get());
}
+
+ @Test
+ public void testSocketTimeoutWithoutConfiguration() throws IOException {
+ HTTPSamplerBase sampler = (HTTPSamplerBase) new
HttpTestSampleGui().createTestElement();
+ sampler.setThreadContext(jmctx);
+ HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
+ assertEquals("HTTP socket timeout not found as expected", 0,
hc.getResponseTimeout());
+ }
+
+ @Test
+ public void testSocketTimeoutConfigurationFromJMeterProps() throws
IOException {
+ Path props = Files.createTempFile("hcdummy1", ".properties");
+ JMeterUtils.loadJMeterProperties(props.toString());
+ JMeterUtils.getJMeterProperties().setProperty("httpclient.timeout",
String.valueOf(100));
+ HTTPSamplerBase sampler = (HTTPSamplerBase) new
HttpTestSampleGui().createTestElement();
+ sampler.setThreadContext(jmctx);
+ HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
+ assertEquals("HTTP socket timeout not configured via
httpclient.timeout as expected", 100, hc.getResponseTimeout());
+ }
+
+ @Test
+ public void testSocketTimeoutConfigurationFromHCParams() throws
IOException {
+ Path props = Files.createTempFile("hcdummy2", ".properties");
+ JMeterUtils.loadJMeterProperties(props.toString());
+ JMeterUtils.getJMeterProperties().setProperty("httpclient.timeout",
String.valueOf(100));
+ JMeterUtils.getJMeterProperties().setProperty("hc.parameters.file",
props.toString());
+ Properties hcParams = new Properties();
+ try(OutputStream outputStream = new
FileOutputStream(props.toString())) {
+ hcParams.setProperty("http.socket.timeout$Integer",
String.valueOf(120));
+ hcParams.store(outputStream, null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
Review comment:
Is the exception expected?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]