You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2019/09/25 21:19:43 UTC
[jmeter] branch master updated: Enable concurrent execution of
certain tests
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new fb66808 Enable concurrent execution of certain tests
fb66808 is described below
commit fb66808dfa8bd6c8763249cd8ec385b1e49c0ce4
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Wed Sep 25 23:43:43 2019 +0300
Enable concurrent execution of certain tests
---
build.gradle.kts | 1 +
.../http/control/TestCacheManagerBase.java | 189 ++++++++++-----------
.../protocol/http/control/TestCacheManagerHC4.java | 47 ++---
.../control/TestCacheManagerUrlConnection.java | 14 +-
.../control/TestCacheManagerUrlConnectionBase.java | 4 +
.../protocol/http/proxy/TestHttpRequestHdr.java | 5 +-
.../protocol/http/sampler/TestHTTPHC4Impl.java | 9 +-
7 files changed, 140 insertions(+), 129 deletions(-)
diff --git a/build.gradle.kts b/build.gradle.kts
index 5f1a651..9046750 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -437,6 +437,7 @@ allprojects {
}
// Pass the property to tests
systemProperty("java.awt.headless", System.getProperty("java.awt.headless"))
+ systemProperty("junit.jupiter.execution.parallel.enabled", "true")
}
withType<SpotBugsTask>().configureEach {
group = LifecycleBasePlugin.VERIFICATION_GROUP
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java
index 6f20971..174db4f 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java
@@ -18,11 +18,11 @@
package org.apache.jmeter.protocol.http.control;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Field;
import java.net.URL;
@@ -35,10 +35,11 @@ import java.util.TimeZone;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Execution;
+import org.junit.jupiter.api.parallel.ExecutionMode;
+@Execution(ExecutionMode.CONCURRENT)
public abstract class TestCacheManagerBase extends JMeterTestCase {
protected static final String LOCAL_HOST = "http://localhost/";
protected static final String EXPECTED_ETAG = "0xCAFEBABEDEADBEEF";
@@ -55,7 +56,6 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
return simpleDateFormat.format(d);
}
- @Before
public void setUp() throws Exception {
this.cacheManager = new CacheManager();
this.currentTimeInGMT = makeDate(new Date());
@@ -64,7 +64,6 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
this.sampleResultOK = getSampleResultWithSpecifiedResponseCode("200");
}
- @After
public void tearDown() throws Exception {
this.url = null;
this.cacheManager = null;
@@ -102,61 +101,61 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
public void testExpiresBug59962() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(new Date(start + 2000)));
cacheResultWithGivenCode("304");
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + 2010);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testExpires() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(new Date(start + 2000)));
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + 2010);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testNoExpires() throws Exception {
this.cacheManager.setUseExpires(false);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
setExpires(makeDate(new Date(System.currentTimeMillis() + 2000)));
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testCacheControl() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(new Date(start)));
setCacheControl("public, max-age=1");
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + 1010);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
@@ -219,17 +218,17 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
private void testCacheVary(String vary, Header[] origHeaders, Header[] differentHeaders) throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url, origHeaders));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url, origHeaders), "Should not find valid entry");
setExpires(makeDate(new Date(System.currentTimeMillis())));
setCacheControl("public, max-age=5");
sampleResultOK.setRequestHeaders(asString(origHeaders));
this.vary = vary;
cacheResult(sampleResultOK);
- assertNotNull("Should find entry with vary header", getThreadCacheEntry(LOCAL_HOST).getVaryHeader());
- assertFalse("Should not find valid entry without headers", this.cacheManager.inCache(url));
- assertTrue("Should find valid entry with headers", this.cacheManager.inCache(url, origHeaders));
- assertFalse("Should not find valid entry with different header", this.cacheManager.inCache(url, differentHeaders));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST).getVaryHeader(), "Should find entry with vary header");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry without headers");
+ assertTrue(this.cacheManager.inCache(url, origHeaders), "Should find valid entry with headers");
+ assertFalse(this.cacheManager.inCache(url, differentHeaders), "Should not find valid entry with different header");
this.vary = null;
}
@@ -237,40 +236,40 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
public void testCacheHEAD() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
setExpires(makeDate(new Date(System.currentTimeMillis())));
setCacheControl("public, max-age=5");
HTTPSampleResult sampleResultHEAD = getSampleResultWithSpecifiedResponseCode("200");
sampleResultHEAD.setHTTPMethod("HEAD");
cacheResult(sampleResultHEAD);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testPrivateCache() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(new Date(start)));
setCacheControl("private, max-age=1");
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + 1010);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testNoCacheControlNoMaxAgeNoExpire() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
// No Cache-Control
// Expires is not set, however RFC recommends to use
// response_is_fresh = (freshness_lifetime > current_age)
@@ -280,19 +279,19 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
long age = 30 * 1000; // 30 seconds
setLastModified(makeDate(new Date(start - age)));
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + age / 10 + 10);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testPrivateCacheNoMaxAgeNoExpire() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
setCacheControl("private");
// Expires is not set, however RFC recommends to use
// response_is_fresh = (freshness_lifetime > current_age)
@@ -302,78 +301,78 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
long age = 30 * 1000; // 30 seconds
setLastModified(makeDate(new Date(start - age)));
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + age / 10 + 10);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testPrivateCacheExpireNoMaxAge() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(new Date(start + 2000)));
setCacheControl("private");
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + 2010);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testNoCache() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
setCacheControl("no-cache");
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testNoStore() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
setCacheControl("no-store");
cacheResult(sampleResultOK);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testCacheHttpClientBug51932() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(new Date(start)));
setCacheControl("public, max-age=1, no-transform");
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertTrue(this.cacheManager.inCache(url), "Should find valid entry");
sleepTill(start + 1010);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
}
@Test
public void testGetClearEachIteration() throws Exception {
- assertFalse("Should default not to clear after each iteration.", this.cacheManager.getClearEachIteration());
+ assertFalse(this.cacheManager.getClearEachIteration(), "Should default not to clear after each iteration.");
this.cacheManager.setClearEachIteration(true);
- assertTrue("Should be settable to clear after each iteration.", this.cacheManager.getClearEachIteration());
+ assertTrue(this.cacheManager.getClearEachIteration(), "Should be settable to clear after each iteration.");
this.cacheManager.setClearEachIteration(false);
- assertFalse("Should be settable not to clear after each iteration.", this.cacheManager.getClearEachIteration());
+ assertFalse(this.cacheManager.getClearEachIteration(), "Should be settable not to clear after each iteration.");
}
private void cacheResultWithGivenCode(String responseCode) throws Exception {
@@ -384,26 +383,22 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
@Test
public void testSaveDetailsWithEmptySampleResultGivesNoCacheEntry() throws Exception {
cacheResultWithGivenCode("");
- assertTrue("Saving details with empty SampleResult should not make cache entry.", getThreadCache().isEmpty());
+ assertTrue(getThreadCache().isEmpty(), "Saving details with empty SampleResult should not make cache entry.");
}
@Test
public void testSaveDetailsHttpMethodWithSampleResultWithResponseCode200GivesCacheEntry() throws Exception {
cacheResultWithGivenCode("200");
CacheManager.CacheEntry cacheEntry = getThreadCacheEntry(LOCAL_HOST);
- assertNotNull("Saving SampleResult with HttpMethod & 200 response should make cache entry.", cacheEntry);
- assertEquals(
- "Saving details with SampleResult & HttpMethod with 200 response should make cache entry with no etag.",
- EXPECTED_ETAG, cacheEntry.getEtag());
- assertEquals(
- "Saving details with SampleResult & HttpMethod with 200 response should make cache entry with no last modified date.",
- this.currentTimeInGMT, cacheEntry.getLastModified());
+ assertNotNull(cacheEntry, "Saving SampleResult with HttpMethod & 200 response should make cache entry.");
+ assertEquals(EXPECTED_ETAG, cacheEntry.getEtag());
+ assertEquals(this.currentTimeInGMT, cacheEntry.getLastModified());
}
@Test
public void testSaveDetailsHttpMethodWithSampleResultWithResponseCode404GivesNoCacheEntry() throws Exception {
cacheResultWithGivenCode("404");
- assertNull("Saving SampleResult with HttpMethod & 404 response should not make cache entry.", getThreadCacheEntry(LOCAL_HOST));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Saving SampleResult with HttpMethod & 404 response should not make cache entry.");
}
@Test
@@ -420,18 +415,18 @@ public abstract class TestCacheManagerBase extends JMeterTestCase {
public void testSetHeadersHttpMethodWithSampleResultWithResponseCode404GivesNoCacheEntry() throws Exception {
cacheResultWithGivenCode("404");
setRequestHeaders();
- assertNull("Saving SampleResult with HttpMethod & 404 response should not make cache entry.", getThreadCacheEntry(LOCAL_HOST));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Saving SampleResult with HttpMethod & 404 response should not make cache entry.");
}
@Test
public void testClearCache() throws Exception {
- assertTrue("ThreadCache should be empty initially.", getThreadCache().isEmpty());
+ assertTrue(getThreadCache().isEmpty(), "ThreadCache should be empty initially.");
cacheResultWithGivenCode("200");
assertFalse(
- "ThreadCache should be populated after saving details for HttpMethod with SampleResult with response code 200.",
- getThreadCache().isEmpty());
+ getThreadCache().isEmpty(),
+ "ThreadCache should be populated after saving details for HttpMethod with SampleResult with response code 200.");
this.cacheManager.clear();
- assertTrue("ThreadCache should be emptied by call to clear.", getThreadCache().isEmpty());
+ assertTrue(getThreadCache().isEmpty(), "ThreadCache should be emptied by call to clear.");
}
protected HTTPSampleResult getSampleResultWithSpecifiedResponseCode(String code) {
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerHC4.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerHC4.java
index 494a681..e582efa 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerHC4.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerHC4.java
@@ -18,10 +18,10 @@
package org.apache.jmeter.protocol.http.control;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.net.URISyntaxException;
import java.text.ParseException;
@@ -43,8 +43,10 @@ import org.apache.http.message.BasicHeader;
import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.protocol.http.util.HTTPConstantsInterface;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test {@link CacheManager} that uses HTTPHC4Impl
@@ -201,6 +203,7 @@ public class TestCacheManagerHC4 extends TestCacheManagerBase {
private HttpResponse httpResponse;
@Override
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
this.httpMethod = new HttpPostStub();
@@ -209,6 +212,7 @@ public class TestCacheManagerHC4 extends TestCacheManagerBase {
}
@Override
+ @AfterEach
public void tearDown() throws Exception {
this.httpMethod = null;
this.httpResponse = null;
@@ -249,19 +253,20 @@ public class TestCacheManagerHC4 extends TestCacheManagerBase {
@Override
protected void checkRequestHeader(String requestHeader, String expectedValue) {
org.apache.http.Header header = this.httpMethod.getLastHeader(requestHeader);
- assertEquals("Wrong name in header for " + requestHeader, requestHeader, header.getName());
- assertEquals("Wrong value for header " + header, expectedValue, header.getValue());
+ assertEquals(
+ requestHeader + ": " + expectedValue,
+ header.getName() + ": " + header.getValue());
}
@Test
public void testBug61321() throws Exception {
this.cacheManager.setUseExpires(false);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should find valid entry");
cacheManager.setHeaders(url, httpMethod);
checkIfModifiedSinceHeader(httpMethod);
@@ -269,8 +274,8 @@ public class TestCacheManagerHC4 extends TestCacheManagerBase {
sampleResultOK = getSampleResultWithSpecifiedResponseCode("304");
setLastModified(null);
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
cacheManager.setHeaders(url, httpMethod);
checkIfModifiedSinceHeader(httpMethod);
@@ -278,8 +283,8 @@ public class TestCacheManagerHC4 extends TestCacheManagerBase {
sampleResultOK = getSampleResultWithSpecifiedResponseCode("304");
setLastModified(null);
cacheResult(sampleResultOK);
- assertNotNull("Should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry");
+ assertFalse(this.cacheManager.inCache(url), "Should not find valid entry");
cacheManager.setHeaders(url, httpMethod);
checkIfModifiedSinceHeader(httpMethod);
}
@@ -287,13 +292,13 @@ public class TestCacheManagerHC4 extends TestCacheManagerBase {
protected void checkIfModifiedSinceHeader(HttpRequestBase httpMethod) {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
try {
- assertEquals("Should have found 1 header "+HTTPConstantsInterface.IF_MODIFIED_SINCE,
- 1,
- httpMethod.getHeaders(HTTPConstantsInterface.IF_MODIFIED_SINCE).length);
+ assertEquals(1,
+ httpMethod.getHeaders(HTTPConstantsInterface.IF_MODIFIED_SINCE).length,
+ "Should have found 1 header "+HTTPConstantsInterface.IF_MODIFIED_SINCE);
Date date = dateFormat.parse(httpMethod.getHeaders(HTTPConstantsInterface.IF_MODIFIED_SINCE)[0].getValue());
- assertNotNull("Should have found a valid entry", date);
+ assertNotNull(date, "Should have found a valid entry");
} catch(ParseException e) {
- Assert.fail("Invalid header format for:"+ HTTPConstantsInterface.IF_MODIFIED_SINCE);
+ Assertions.fail("Invalid header format for:"+ HTTPConstantsInterface.IF_MODIFIED_SINCE);
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java
index e77d7a8..2e50221 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnection.java
@@ -18,8 +18,8 @@
package org.apache.jmeter.protocol.http.control;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.net.HttpURLConnection;
import java.util.List;
@@ -78,14 +78,14 @@ public class TestCacheManagerUrlConnection extends TestCacheManagerUrlConnection
private static void checkProperty(Map<String, List<String>> properties, String property, String expectedPropertyValue) {
assertNotNull(
+ properties,
"Properties should not be null. Expected to find within it property = "
+ property + " with expected value = "
- + expectedPropertyValue,
- properties);
+ + expectedPropertyValue);
List<String> listOfPropertyValues = properties.get(property);
- assertNotNull("No property entry found for property " + property, listOfPropertyValues);
- assertEquals("Did not find single property for property " + property, 1, listOfPropertyValues.size());
- assertEquals("Unexpected value for property " + property, expectedPropertyValue, listOfPropertyValues.get(0));
+ assertNotNull(listOfPropertyValues, "No property entry found for property " + property);
+ assertEquals(1, listOfPropertyValues.size(), "Did not find single property for property " + property);
+ assertEquals(expectedPropertyValue, listOfPropertyValues.get(0), "Unexpected value for property " + property);
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java
index 14c9ad8..1fa5550 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerUrlConnectionBase.java
@@ -24,6 +24,8 @@ import java.net.URL;
import java.net.URLConnection;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
public abstract class TestCacheManagerUrlConnectionBase extends TestCacheManagerBase {
protected class URLConnectionStub extends HttpURLConnection {
@@ -79,12 +81,14 @@ public abstract class TestCacheManagerUrlConnectionBase extends TestCacheManager
protected URLConnection urlConnection;
@Override
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
this.urlConnection = new URLConnectionStub(this.url.openConnection());
}
@Override
+ @AfterEach
public void tearDown() throws Exception {
this.urlConnection = null;
super.tearDown();
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
index 0bf707f..9dd64c5 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
@@ -37,8 +37,11 @@ import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Execution;
+import org.junit.jupiter.api.parallel.ExecutionMode;
+@Execution(ExecutionMode.CONCURRENT)
public class TestHttpRequestHdr extends JMeterTestCase {
@Test
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPHC4Impl.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPHC4Impl.java
index 00ed8a0..b51f933 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPHC4Impl.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPHC4Impl.java
@@ -24,15 +24,18 @@ import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Execution;
+import org.junit.jupiter.api.parallel.ExecutionMode;
+@Execution(ExecutionMode.CONCURRENT)
public class TestHTTPHC4Impl {
private JMeterContext jmctx;
private JMeterVariables jmvars;
private static final String SAME_USER = "__jmv_SAME_USER";
- @Before
+ @BeforeEach
public void setUp() {
jmctx = JMeterContextService.getContext();
jmvars = new JMeterVariables();