refactor: replace org.junit.Assert with org.junit.jupiter.api.Assertions
It is a step towards removing junit:junit:4.x dependency
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/ResponseAssertionTest.java b/src/components/src/test/java/org/apache/jmeter/assertions/ResponseAssertionTest.java
index a556c40..7906381 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/ResponseAssertionTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/ResponseAssertionTest.java
@@ -17,11 +17,12 @@
package org.apache.jmeter.assertions;
-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.assertNotEquals;
+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.net.MalformedURLException;
import java.net.URL;
@@ -115,14 +116,13 @@
assertion.addTestString("[]");
result = assertion.getResult(sample);
assertNotNull(result.getFailureMessage());
- assertFalse("Should not be: Response was null","Response was null".equals(result.getFailureMessage()));
- assertTrue("Not expecting error: "+result.getFailureMessage(),result.isError());
+ assertNotEquals("Response was null", result.getFailureMessage(), "Should not be: Response was null");
+ assertTrue(result.isError(), "Not expecting error: "+result.getFailureMessage());
assertion.setCustomFailureMessage("Custom failure message");
result = assertion.getResult(sample);
- assertTrue("Did not get expected error: "+result.getFailureMessage(),result.isError());
- assertFalse("Failure message must not be custom failure message for error",
- "Custom failure message".equals(result.getFailureMessage()));
+ assertTrue(result.isError(), "Did not get expected error: "+result.getFailureMessage());
+ assertNotEquals("Custom failure message", result.getFailureMessage(), "Failure message must not be custom failure message for error");
}
@@ -311,17 +311,17 @@
//TODO - need a lot more tests
private void assertPassed() throws Exception{
- assertNull(result.getFailureMessage(),result.getFailureMessage());
- assertFalse("Not expecting error: "+result.getFailureMessage(),result.isError());
- assertFalse("Not expecting error",result.isError());
- assertFalse("Not expecting failure",result.isFailure());
+ assertNull(result.getFailureMessage(), result.getFailureMessage());
+ assertFalse(result.isError(), "Not expecting error: "+result.getFailureMessage());
+ assertFalse(result.isError(), "Not expecting error");
+ assertFalse(result.isFailure(), "Not expecting failure");
}
private void assertFailed() throws Exception{
assertNotNull(result.getFailureMessage());
- assertFalse("Should not be: Response was null","Response was null".equals(result.getFailureMessage()));
- assertFalse("Not expecting error: "+result.getFailureMessage(),result.isError());
- assertTrue("Expecting failure",result.isFailure());
+ assertNotEquals("Response was null", result.getFailureMessage(), "Should not be: Response was null");
+ assertFalse(result.isError(), "Not expecting error: "+result.getFailureMessage());
+ assertTrue(result.isFailure(), "Expecting failure");
}
private AtomicInteger failed;
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/SMIMEAssertionTest.java b/src/components/src/test/java/org/apache/jmeter/assertions/SMIMEAssertionTest.java
index d27c501..4b50c0a 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/SMIMEAssertionTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/SMIMEAssertionTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.assertions;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -111,9 +111,8 @@
testElement.setVerifySignature(true);
AssertionResult result = SMIMEAssertion.getResult(testElement, parent,
"Test");
- assertFalse("Result should not be an error", result.isError());
- assertFalse("Result should not fail: " + result.getFailureMessage(),
- result.isFailure());
+ assertFalse(result.isError(), "Result should not be an error");
+ assertFalse(result.isFailure(), "Result should not fail: " + result.getFailureMessage());
}
@Test
@@ -123,9 +122,8 @@
testElement.setSignerEmail("bob@b.example.com");
AssertionResult result = SMIMEAssertion.getResult(testElement, parent,
"Test");
- assertFalse("Result should not be an error", result.isError());
- assertFalse("Result should not fail: " + result.getFailureMessage(),
- result.isFailure());
+ assertFalse(result.isError(), "Result should not be an error");
+ assertFalse(result.isFailure(), "Result should not fail: " + result.getFailureMessage());
}
@Test
@@ -135,9 +133,8 @@
testElement.setSignerSerial("0xc8c46f8fbf9ebea4");
AssertionResult result = SMIMEAssertion.getResult(testElement, parent,
"Test");
- assertFalse("Result should not be an error", result.isError());
- assertFalse("Result should not fail: " + result.getFailureMessage(),
- result.isFailure());
+ assertFalse(result.isError(), "Result should not be an error");
+ assertFalse(result.isFailure(), "Result should not fail: " + result.getFailureMessage());
}
@Test
@@ -149,9 +146,8 @@
.setSignerDn(signerDn);
AssertionResult result = SMIMEAssertion.getResult(testElement, parent,
"Test");
- assertFalse("Result should not be an error", result.isError());
- assertFalse("Result should not fail: " + result.getFailureMessage(),
- result.isFailure());
+ assertFalse(result.isError(), "Result should not be an error");
+ assertFalse(result.isFailure(), "Result should not fail: " + result.getFailureMessage());
}
@Test
@@ -163,9 +159,8 @@
.setIssuerDn(issuerDn);
AssertionResult result = SMIMEAssertion.getResult(testElement, parent,
"Test");
- assertFalse("Result should not be an error", result.isError());
- assertFalse("Result should not fail: " + result.getFailureMessage(),
- result.isFailure());
+ assertFalse(result.isError(), "Result should not be an error");
+ assertFalse(result.isFailure(), "Result should not fail: " + result.getFailureMessage());
}
@Test
@@ -176,9 +171,8 @@
testElement.setSignerCertFile(new File(getClass().getResource("email.pem").toURI()).getAbsolutePath());
AssertionResult result = SMIMEAssertion.getResult(testElement, parent,
"Test");
- assertFalse("Result should not be an error", result.isError());
- assertFalse("Result should not fail: " + result.getFailureMessage(),
- result.isFailure());
+ assertFalse(result.isError(), "Result should not be an error");
+ assertFalse(result.isFailure(), "Result should not fail: " + result.getFailureMessage());
}
private SampleResult createChildSample() throws MessagingException,
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/SizeAssertionTest.java b/src/components/src/test/java/org/apache/jmeter/assertions/SizeAssertionTest.java
index b5b0a8e..00a3ea7 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/SizeAssertionTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/SizeAssertionTest.java
@@ -17,10 +17,11 @@
package org.apache.jmeter.assertions;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+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 org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.samplers.SampleResult;
@@ -162,14 +163,14 @@
// TODO - need a lot more tests
private void assertPassed() throws Exception {
- assertNull("Failure message should be null", result.getFailureMessage());
+ assertNull(result.getFailureMessage(), "Failure message should be null");
assertFalse(result.isError());
assertFalse(result.isFailure());
}
private void assertFailed() throws Exception {
- assertNotNull("Failure message should not be null", result.getFailureMessage());
- assertFalse("Should not be: Response was null", "Response was null".equals(result.getFailureMessage()));
+ assertNotNull(result.getFailureMessage(), "Failure message should not be null");
+ assertNotEquals("Response was null", result.getFailureMessage(), "Should not be: Response was null");
assertFalse(result.isError());
assertTrue(result.isFailure());
}
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/XMLSchemaAssertionTest.java b/src/components/src/test/java/org/apache/jmeter/assertions/XMLSchemaAssertionTest.java
index 236625a..62e60b5 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/XMLSchemaAssertionTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/XMLSchemaAssertionTest.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.assertions;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@@ -77,8 +77,8 @@
AssertionResult res = assertion.getResult(jmctx.getPreviousResult());
testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
testLog.debug("failure " + res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure", res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/XPath2AssertionTest.java b/src/components/src/test/java/org/apache/jmeter/assertions/XPath2AssertionTest.java
index e98fa2d..c4d826f 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/XPath2AssertionTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/XPath2AssertionTest.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.assertions;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
@@ -64,8 +64,8 @@
assertion.setXPathString(xPathQuery);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertFalse("When xpath2 conforms to xml, the result of assertion should be true ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertFalse(res.isFailure(), "When xpath2 conforms to xml, the result of assertion should be true ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
public void testXPath2AssertionPath1Negated() throws FactoryConfigurationError {
@@ -76,8 +76,8 @@
assertion.setNegated(true);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertTrue("When xpath2 conforms to xml, the result of assertion should be false ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertTrue(res.isFailure(), "When xpath2 conforms to xml, the result of assertion should be false ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
@@ -88,8 +88,8 @@
assertion.setXPathString(xPathQuery);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertTrue("When xpath2 doesn't conform to xml, the result of assertion should be false ", res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertTrue(res.isFailure(), "When xpath2 doesn't conform to xml, the result of assertion should be false ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
public void testXPath2AssertionPath2Negated() throws FactoryConfigurationError {
@@ -100,8 +100,8 @@
assertion.setNegated(true);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertFalse("When xpath2 doesn't conform to xml, the result of assertion should be true ", res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertFalse(res.isFailure(), "When xpath2 doesn't conform to xml, the result of assertion should be true ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
@@ -112,8 +112,8 @@
assertion.setXPathString(xPathQuery);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertFalse("When xpath2 conforms to xml, the result of assertion should be true ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertFalse(res.isFailure(), "When xpath2 conforms to xml, the result of assertion should be true ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
public void testXPath2AssertionBool1Negated() throws FactoryConfigurationError {
@@ -124,8 +124,8 @@
assertion.setNegated(true);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertTrue("When xpath2 conforms to xml, the result of assertion should be false ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertTrue(res.isFailure(), "When xpath2 conforms to xml, the result of assertion should be false ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
public void testXPath2AssertionBool2() throws FactoryConfigurationError {
@@ -135,8 +135,8 @@
assertion.setXPathString(xPathQuery);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertTrue("When xpath2 doesn't conforms to xml, the result of assertion should be false ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertTrue(res.isFailure(), "When xpath2 doesn't conforms to xml, the result of assertion should be false ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
public void testXPath2AssertionBool2Negated() throws FactoryConfigurationError {
@@ -147,8 +147,8 @@
assertion.setNegated(true);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertFalse("When xpath2 doesn't conforms to xml, the result of assertion should be true ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertFalse(res.isFailure(), "When xpath2 doesn't conforms to xml, the result of assertion should be true ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
@@ -162,8 +162,8 @@
jmctx.setPreviousResult(result);
assertion.setXPathString("/html/head/title");
AssertionResult res = assertion.getResult(result);
- assertFalse("When xpath conforms to xml, the result of assertion "
- + "should be true ",res.isFailure());
+ assertFalse(res.isFailure(), "When xpath conforms to xml, the result of assertion "
+ + "should be true ");
assertFalse(res.isError());
}
@Test
@@ -177,8 +177,8 @@
jmctx.setPreviousResult(result);
assertion.setXPathString("/html/head/tit");
AssertionResult res = assertion.getResult(result);
- assertTrue("When xpath doesn't conforms to xml, the result "
- + "of assertion should be false ",res.isFailure());
+ assertTrue(res.isFailure(), "When xpath doesn't conforms to xml, the result "
+ + "of assertion should be false ");
assertFalse(res.isError());
}
@Test
@@ -191,11 +191,10 @@
jmctx.setPreviousResult(result);
assertion.setXPathString("/html/head/tit");
AssertionResult res = assertion.getResult(result);
- assertTrue("When xpath doesn't conforms to xml, the result "
- + "of assertion should be false ",res.isFailure());
+ assertTrue(res.isFailure(), "When xpath doesn't conforms to xml, the result "
+ + "of assertion should be false ");
assertFalse(res.isError());
- assertEquals("When the response data is empty, the result of assertion should be false",
- "Response was null", res.getFailureMessage());
+ assertEquals("Response was null", res.getFailureMessage(), "When the response data is empty, the result of assertion should be false");
}
@Test
public void testBadXpathFormat() throws FactoryConfigurationError {
@@ -205,7 +204,7 @@
assertion.setXPathString(xPathQuery);
response.setResponseData(xmlDoc, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertTrue("When format of xpath is wrong, the test should failed",res.isError());
+ assertTrue(res.isError(), "When format of xpath is wrong, the test should failed");
assertTrue(res.getFailureMessage().contains("Exception occurred computing assertion with XPath"));
}
@@ -219,8 +218,8 @@
assertion.setXPathString(xPathQuery);
response.setResponseData(data, "UTF-8");
AssertionResult res = assertion.getResult(response);
- assertFalse("When xpath2 conforms to xml, the result of assertion should be true ",res.isFailure());
- assertFalse("When the format of xpath2 is right, assertion will run correctly ",res.isError());
+ assertFalse(res.isFailure(), "When xpath2 conforms to xml, the result of assertion should be true ");
+ assertFalse(res.isError(), "When the format of xpath2 is right, assertion will run correctly ");
}
@Test
@@ -230,10 +229,8 @@
testDoc.appendChild(el);
String namespaces = "a=http://www.w3.org/2003/01/geo/wgs84_pos# b=http://www.w3.org/2003/01/geo/wgs85_pos#";
String xPathQuery = "//Employees/b:Employee[1]/a:ag";
- assertTrue("When the user give namspaces, the result of validation should be true",
- XPath2Panel.validXPath(xPathQuery, false, namespaces));
+ assertTrue(XPath2Panel.validXPath(xPathQuery, false, namespaces), "When the user give namspaces, the result of validation should be true");
namespaces = "a=http://www.w3.org/2003/01/geo/wgs84_pos#";
- assertFalse("When the user doesn't give namspaces, the result of validation should be false",
- XPath2Panel.validXPath(xPathQuery, false, namespaces));
+ assertFalse(XPath2Panel.validXPath(xPathQuery, false, namespaces), "When the user doesn't give namspaces, the result of validation should be false");
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/XPathAssertionTest.java b/src/components/src/test/java/org/apache/jmeter/assertions/XPathAssertionTest.java
index b98f32a..14538a1 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/XPathAssertionTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/XPathAssertionTest.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.assertions;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@@ -89,8 +89,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure", res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
@@ -99,8 +99,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
}
@Test
@@ -109,8 +109,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
public void testAssertionPath1Negated() {
@@ -119,8 +119,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
}
@Test
@@ -130,8 +130,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
@@ -141,8 +141,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should not be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should not be a failure");
}
@Test
@@ -151,8 +151,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
@@ -162,10 +162,9 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should not be a failure",res.isFailure());
- assertEquals("when isNegated is true, when xpath matches, result should fail",
- "Nodes Matched for count(//error)=2" , res.getFailureMessage());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should not be a failure");
+ assertEquals("Nodes Matched for count(//error)=2", res.getFailureMessage(), "when isNegated is true, when xpath matches, result should fail");
}
@Test
@@ -174,8 +173,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
@@ -185,9 +184,9 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
- assertEquals("Nodes Matched for count(//*[code=1])=1" , res.getFailureMessage());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
+ assertEquals("Nodes Matched for count(//*[code=1])=1", res.getFailureMessage());
}
@@ -197,9 +196,9 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure", res.isFailure());
- assertEquals("No Nodes Matched for count(//error)=1" , res.getFailureMessage());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
+ assertEquals("No Nodes Matched for count(//error)=1", res.getFailureMessage());
}
@Test
public void testAssertionBool3Negated() {
@@ -208,8 +207,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertFalse("Should not be a failure", res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
@@ -218,8 +217,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
}
@Test
@@ -229,9 +228,9 @@
assertion.setNegated(true);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
- assertEquals("No Nodes Matched for count(//*[code=2])=1" , res.getFailureMessage());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
+ assertEquals("No Nodes Matched for count(//*[code=2])=1", res.getFailureMessage());
}
@Test
public void testAssertionNumber() throws Exception {
@@ -239,8 +238,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
}
@Test
@@ -251,8 +250,8 @@
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
assertEquals(AssertionResult.RESPONSE_WAS_NULL, res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
}
@Test
@@ -262,8 +261,8 @@
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
assertEquals(AssertionResult.RESPONSE_WAS_NULL, res.getFailureMessage());
- assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertFalse(res.isError(), "Should not be an error");
+ assertTrue(res.isFailure(), "Should be a failure");
}
@Test
@@ -273,8 +272,8 @@
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
assertTrue(res.getFailureMessage().indexOf("Premature end of file") > 0);
- assertTrue("Should be an error",res.isError());
- assertFalse("Should not be a failure", res.isFailure());
+ assertTrue(res.isError(), "Should be an error");
+ assertFalse(res.isFailure(), "Should not be a failure");
}
@Test
@@ -418,8 +417,8 @@
assertion.setTolerant(true);
AssertionResult res = assertion.getResult(result);
log.debug("failureMessage: {}", res.getFailureMessage());
- assertFalse("When xpath conforms to xml, the result of assertion "
- + "should be true ",res.isFailure());
+ assertFalse(res.isFailure(), "When xpath conforms to xml, the result of assertion "
+ + "should be true ");
assertFalse(res.isError());
}
@Test
@@ -436,8 +435,8 @@
assertion.setTolerant(true);
AssertionResult res = assertion.getResult(result);
log.debug("failureMessage: {}", res.getFailureMessage());
- assertTrue("When xpath doesn't conforms to xml, the result "
- + "of assertion should be false ",res.isFailure());
+ assertTrue(res.isFailure(), "When xpath doesn't conforms to xml, the result "
+ + "of assertion should be false ");
assertFalse(res.isError());
}
@@ -448,9 +447,8 @@
AssertionResult res = assertion.getResult(result);
testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
testLog.debug("failure message: {}", res.getFailureMessage());
- assertTrue("Should not be an error", res.isError());
- assertTrue("A TransformerException should be thrown",
- res.getFailureMessage().contains("TransformerException"));
+ assertTrue(res.isError(), "Should not be an error");
+ assertTrue(res.getFailureMessage().contains("TransformerException"), "A TransformerException should be thrown");
}
@Test
public void testWithoutSuitableNamespaces() {
@@ -460,7 +458,6 @@
AssertionResult res = assertion.getResult(jmctx.getPreviousResult());
log.debug(" res {}", res.isError());
log.debug(" failure {}", res.getFailureMessage());
- assertTrue("When the user activates namespaces, a TransformerException should be thrown",
- res.getFailureMessage().contains("TransformerException"));
+ assertTrue(res.getFailureMessage().contains("TransformerException"), "When the user activates namespaces, a TransformerException should be thrown");
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java b/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java
index 41a5ee1..2e38339 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.assertions.jmespath;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.stream.Stream;
diff --git a/src/components/src/test/java/org/apache/jmeter/config/TestCVSDataSet.java b/src/components/src/test/java/org/apache/jmeter/config/TestCVSDataSet.java
index 58bfce3..2edad0a 100644
--- a/src/components/src/test/java/org/apache/jmeter/config/TestCVSDataSet.java
+++ b/src/components/src/test/java/org/apache/jmeter/config/TestCVSDataSet.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
@@ -62,9 +62,7 @@
csv.iterationStart(null);
fail("Bad filename in CSVDataSet -> IllegalArgumentException: File No.such.filename must exist and be readable");
} catch (IllegalArgumentException ignored) {
- assertEquals("Bad filename in CSVDataSet -> exception",
- "File No.such.filename must exist and be readable",
- ignored.getMessage());
+ assertEquals("File No.such.filename must exist and be readable", ignored.getMessage(), "Bad filename in CSVDataSet -> exception");
}
csv = new CSVDataSet();
@@ -73,30 +71,30 @@
csv.setDelimiter(",");
csv.iterationStart(null);
- assertEquals("",threadVars.get("a"));
- assertEquals("b1",threadVars.get("b"));
- assertEquals("c1",threadVars.get("c"));
+ assertEquals("", threadVars.get("a"));
+ assertEquals("b1", threadVars.get("b"));
+ assertEquals("c1", threadVars.get("c"));
csv.iterationStart(null);
- assertEquals("a2",threadVars.get("a"));
- assertEquals("",threadVars.get("b"));
- assertEquals("c2",threadVars.get("c"));
+ assertEquals("a2", threadVars.get("a"));
+ assertEquals("", threadVars.get("b"));
+ assertEquals("c2", threadVars.get("c"));
csv.iterationStart(null);
- assertEquals("a3",threadVars.get("a"));
- assertEquals("b3",threadVars.get("b"));
- assertEquals("",threadVars.get("c"));
+ assertEquals("a3", threadVars.get("a"));
+ assertEquals("b3", threadVars.get("b"));
+ assertEquals("", threadVars.get("c"));
csv.iterationStart(null);
- assertEquals("a4",threadVars.get("a"));
- assertEquals("b4",threadVars.get("b"));
- assertEquals("c4",threadVars.get("c"));
+ assertEquals("a4", threadVars.get("a"));
+ assertEquals("b4", threadVars.get("b"));
+ assertEquals("c4", threadVars.get("c"));
csv.iterationStart(null); // Restart file
- assertEquals("",threadVars.get("a"));
- assertEquals("b1",threadVars.get("b"));
- assertEquals("c1",threadVars.get("c"));
+ assertEquals("", threadVars.get("a"));
+ assertEquals("b1", threadVars.get("b"));
+ assertEquals("c1", threadVars.get("c"));
}
@Test
@@ -110,28 +108,28 @@
csv.setFileEncoding( "UTF-8" );
csv.iterationStart(null);
- assertEquals("a1",threadVars.get("a"));
- assertEquals("b1",threadVars.get("b"));
- assertEquals("\u00e71",threadVars.get("c"));
- assertEquals("d1",threadVars.get("d"));
+ assertEquals("a1", threadVars.get("a"));
+ assertEquals("b1", threadVars.get("b"));
+ assertEquals("\u00e71", threadVars.get("c"));
+ assertEquals("d1", threadVars.get("d"));
csv.iterationStart(null);
- assertEquals("a2",threadVars.get("a"));
- assertEquals("b2",threadVars.get("b"));
- assertEquals("\u00e72",threadVars.get("c"));
- assertEquals("d2",threadVars.get("d"));
+ assertEquals("a2", threadVars.get("a"));
+ assertEquals("b2", threadVars.get("b"));
+ assertEquals("\u00e72", threadVars.get("c"));
+ assertEquals("d2", threadVars.get("d"));
csv.iterationStart(null);
- assertEquals("a3",threadVars.get("a"));
- assertEquals("b3",threadVars.get("b"));
- assertEquals("\u00e73",threadVars.get("c"));
- assertEquals("d3",threadVars.get("d"));
+ assertEquals("a3", threadVars.get("a"));
+ assertEquals("b3", threadVars.get("b"));
+ assertEquals("\u00e73", threadVars.get("c"));
+ assertEquals("d3", threadVars.get("d"));
csv.iterationStart(null);
- assertEquals("a4",threadVars.get("a"));
- assertEquals("b4",threadVars.get("b"));
- assertEquals("\u00e74",threadVars.get("c"));
- assertEquals("d4",threadVars.get("d"));
+ assertEquals("a4", threadVars.get("a"));
+ assertEquals("b4", threadVars.get("b"));
+ assertEquals("\u00e74", threadVars.get("c"));
+ assertEquals("d4", threadVars.get("d"));
}
// Test CSV file with a header line
@@ -143,16 +141,16 @@
assertNull(csv.getVariableNames());
csv.iterationStart(null);
assertNull(threadVars.get("a"));
- assertEquals("a1",threadVars.get("A"));
- assertEquals("b1",threadVars.get("B"));
- assertEquals("c1",threadVars.get("C"));
- assertEquals("d1",threadVars.get("D|1"));
+ assertEquals("a1", threadVars.get("A"));
+ assertEquals("b1", threadVars.get("B"));
+ assertEquals("c1", threadVars.get("C"));
+ assertEquals("d1", threadVars.get("D|1"));
csv.iterationStart(null);
assertNull(threadVars.get("a"));
- assertEquals("a2",threadVars.get("A"));
- assertEquals("b2",threadVars.get("B"));
- assertEquals("c2",threadVars.get("C"));
- assertEquals("d2",threadVars.get("D|1"));
+ assertEquals("a2", threadVars.get("A"));
+ assertEquals("b2", threadVars.get("B"));
+ assertEquals("c2", threadVars.get("C"));
+ assertEquals("d2", threadVars.get("D|1"));
}
// Test CSV file with a header line and recycle is true
@@ -169,10 +167,10 @@
csv.iterationStart(null); // line 4
csv.iterationStart(null); // line 5
csv.iterationStart(null); // return to 2nd line (first line is names)
- assertEquals("a1",threadVars.get("A"));
- assertEquals("b1",threadVars.get("B"));
- assertEquals("c1",threadVars.get("C"));
- assertEquals("d1",threadVars.get("D|1"));
+ assertEquals("a1", threadVars.get("A"));
+ assertEquals("b1", threadVars.get("B"));
+ assertEquals("c1", threadVars.get("C"));
+ assertEquals("d1", threadVars.get("D|1"));
}
// Test CSV file with a header line
@@ -187,22 +185,22 @@
assertNull(csv.getVariableNames());
csv.iterationStart(null);
assertNull(threadVars.get("a"));
- assertEquals("a1",threadVars.get("A"));
- assertEquals("b1",threadVars.get("B"));
- assertEquals("c1",threadVars.get("C"));
- assertEquals("d1",threadVars.get("D|1"));
+ assertEquals("a1", threadVars.get("A"));
+ assertEquals("b1", threadVars.get("B"));
+ assertEquals("c1", threadVars.get("C"));
+ assertEquals("d1", threadVars.get("D|1"));
csv.iterationStart(null);
assertNull(threadVars.get("a"));
- assertEquals("a2",threadVars.get("A"));
- assertEquals("b2",threadVars.get("B"));
- assertEquals("c2",threadVars.get("C"));
- assertEquals("d2",threadVars.get("D|1"));
+ assertEquals("a2", threadVars.get("A"));
+ assertEquals("b2", threadVars.get("B"));
+ assertEquals("c2", threadVars.get("C"));
+ assertEquals("d2", threadVars.get("D|1"));
csv.iterationStart(null);
assertNull(threadVars.get("a"));
- assertEquals("a3",threadVars.get("A"));
- assertEquals("b3",threadVars.get("B"));
- assertEquals("c3",threadVars.get("C"));
- assertEquals("d3",threadVars.get("D|1"));
+ assertEquals("a3", threadVars.get("A"));
+ assertEquals("b3", threadVars.get("B"));
+ assertEquals("c3", threadVars.get("C"));
+ assertEquals("d3", threadVars.get("D|1"));
try {
csv.iterationStart(null);
fail("Expected JMeterStopThreadException");
@@ -226,19 +224,19 @@
CSVDataSet csv1 = initCSV();
assertNull(csv1.getShareMode());
csv1.setShareMode("abc");
- assertEquals("abc",csv1.getShareMode());
+ assertEquals("abc", csv1.getShareMode());
csv1.iterationStart(null);
- assertEquals("a1",threadVars.get("a"));
+ assertEquals("a1", threadVars.get("a"));
csv1.iterationStart(null);
- assertEquals("a2",threadVars.get("a"));
+ assertEquals("a2", threadVars.get("a"));
CSVDataSet csv2 = initCSV();
csv2.setShareMode("abc");
- assertEquals("abc",csv2.getShareMode());
+ assertEquals("abc", csv2.getShareMode());
csv2.iterationStart(null);
- assertEquals("a3",threadVars.get("a"));
+ assertEquals("a3", threadVars.get("a"));
csv0.iterationStart(null);
- assertEquals("a1",threadVars.get("a"));
+ assertEquals("a1", threadVars.get("a"));
csv1.iterationStart(null);
- assertEquals("a4",threadVars.get("a"));
+ assertEquals("a4", threadVars.get("a"));
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/config/gui/TestArgumentsPanel.java b/src/components/src/test/java/org/apache/jmeter/config/gui/TestArgumentsPanel.java
index 19bf917..7fca36c 100644
--- a/src/components/src/test/java/org/apache/jmeter/config/gui/TestArgumentsPanel.java
+++ b/src/components/src/test/java/org/apache/jmeter/config/gui/TestArgumentsPanel.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.config.gui;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestGenericController.java b/src/components/src/test/java/org/apache/jmeter/control/TestGenericController.java
index cbb9a97..0a16f2c 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestGenericController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestGenericController.java
@@ -17,7 +17,8 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.junit.stubs.TestSampler;
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestIfController.java b/src/components/src/test/java/org/apache/jmeter/control/TestIfController.java
index 03805d4..d61c6ea 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestIfController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestIfController.java
@@ -17,6 +17,9 @@
package org.apache.jmeter.control;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.junit.stubs.TestSampler;
@@ -27,7 +30,6 @@
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -62,7 +64,7 @@
sampler.sample(null);
counter++;
}
- Assertions.assertEquals(0, counter);
+ assertEquals(0, counter);
} catch (StackOverflowError e) {
throw new AssertionError("Stackoverflow occurred in testStackOverflow", e);
}
@@ -122,10 +124,10 @@
Sampler sampler = controller.next();
sampler.sample(null);
- Assertions.assertEquals("0", vars.get("VAR1"));
+ assertEquals("0", vars.get("VAR1"));
sampler = controller.next();
sampler.sample(null);
- Assertions.assertEquals("0", vars.get("VAR1"));
+ assertEquals("0", vars.get("VAR1"));
} catch (StackOverflowError e) {
throw new AssertionError("Stackoverflow occurred in testStackOverflow", e);
@@ -167,10 +169,10 @@
Sampler sampler = null;
while ((sampler = controller.next()) != null) {
sampler.sample(null);
- Assertions.assertEquals(order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName());
counter++;
}
- Assertions.assertEquals(counter, 6);
+ assertEquals(counter, 6);
}
@Test
@@ -195,10 +197,10 @@
Sampler sampler = null;
while ((sampler = controller.next()) != null) {
sampler.sample(null);
- Assertions.assertEquals(order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName());
counter++;
}
- Assertions.assertEquals(counter, 6);
+ assertEquals(counter, 6);
}
@@ -232,10 +234,10 @@
if (sampler.getName().equals("Sample3")) {
ifCont.setCondition("true==false");
}
- Assertions.assertEquals(order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName());
counter++;
}
- Assertions.assertEquals(counter, 6);
+ assertEquals(counter, 6);
}
/**
@@ -271,10 +273,10 @@
if (sampler.getName().equals("Sample3")) {
ifCont.setCondition("true==false");
}
- Assertions.assertEquals(order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName());
counter++;
}
- Assertions.assertEquals(counter, 6);
+ assertEquals(counter, 6);
}
@Test
@@ -293,6 +295,6 @@
ifCont.setRunningVersion(true);
Sampler sampler = controller.next();
- Assertions.assertNotNull(sampler);
+ assertNotNull(sampler);
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestInterleaveControl.java b/src/components/src/test/java/org/apache/jmeter/control/TestInterleaveControl.java
index 21d2f0d..6320c2c 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestInterleaveControl.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestInterleaveControl.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.junit.stubs.TestSampler;
@@ -126,7 +126,7 @@
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
- assertEquals("failed on " + counter, order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName(), "failed on " + counter);
counter++;
}
}
@@ -162,7 +162,7 @@
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
- assertEquals("failed on" + counter, order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName(), "failed on" + counter);
counter++;
}
}
@@ -193,7 +193,7 @@
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
- assertEquals("failed on" + counter, order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName(), "failed on" + counter);
counter++;
}
}
@@ -224,7 +224,7 @@
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
- assertEquals("failed on" + counter, order[counter], sampler.getName());
+ assertEquals(order[counter], sampler.getName(), "failed on" + counter);
counter++;
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestLoopController.java b/src/components/src/test/java/org/apache/jmeter/control/TestLoopController.java
index dcaeb3a..162d966 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestLoopController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestLoopController.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.HashMap;
import java.util.Map;
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestOnceOnlyController.java b/src/components/src/test/java/org/apache/jmeter/control/TestOnceOnlyController.java
index e19fb45..ea3f030 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestOnceOnlyController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestOnceOnlyController.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.junit.stubs.TestSampler;
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestRandomController.java b/src/components/src/test/java/org/apache/jmeter/control/TestRandomController.java
index 2c26d43..3208144 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestRandomController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestRandomController.java
@@ -17,9 +17,10 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Arrays;
@@ -46,7 +47,7 @@
while ((sampler = roc.next()) != null) {
String samplerName = sampler.getName();
if (usedSamplers.contains(samplerName)) {
- assertTrue("Duplicate sampler returned from next()", false);
+ fail("Duplicate sampler returned from next()");
}
usedSamplers.add(samplerName);
}
@@ -71,7 +72,7 @@
while ((sampler = roc.next()) != null) {
String samplerName = sampler.getName();
if (usedSamplers.contains(samplerName)) {
- assertTrue("Duplicate sampler returned from next()", false);
+ fail("Duplicate sampler returned from next()");
}
usedSamplers.add(samplerName);
}
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestTransactionController.java b/src/components/src/test/java/org/apache/jmeter/control/TestTransactionController.java
index eb8c52f..3da0538 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestTransactionController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestTransactionController.java
@@ -17,6 +17,8 @@
package org.apache.jmeter.control;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.apache.jmeter.assertions.ResponseAssertion;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.sampler.DebugSampler;
@@ -28,7 +30,6 @@
import org.apache.jmeter.threads.TestCompiler;
import org.apache.jmeter.threads.ThreadGroup;
import org.apache.jorphan.collections.ListedHashTree;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -75,9 +76,9 @@
thread.setOnErrorStopThread(true);
thread.run();
- Assertions.assertEquals(1, listener.getEvents().size(),
+ assertEquals(1, listener.getEvents().size(),
"Must one transaction samples with parent debug sample");
- Assertions.assertEquals("Number of samples in transaction : 1, number of failing samples : 1",
+ assertEquals("Number of samples in transaction : 1, number of failing samples : 1",
listener.getEvents().get(0).getResult().getResponseMessage());
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/control/TestWhileController.java b/src/components/src/test/java/org/apache/jmeter/control/TestWhileController.java
index 5cb3090..2e1a877 100644
--- a/src/components/src/test/java/org/apache/jmeter/control/TestWhileController.java
+++ b/src/components/src/test/java/org/apache/jmeter/control/TestWhileController.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.jmeter.engine.util.ValueReplacer;
import org.apache.jmeter.junit.JMeterTestCase;
@@ -186,32 +186,32 @@
controller.addTestElement(new TestSampler("after"));
controller.initialize();
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop: " + i, "before", nextName(controller));
- assertEquals("Loop: " + i, "one", nextName(controller));
- assertEquals("Loop: " + i, "two", nextName(controller));
- assertEquals("Loop: " + i, "three", nextName(controller));
- assertEquals("Loop: " + i, "four", nextName(controller));
- assertEquals("Loop: " + i, "after", nextName(controller));
- assertNull("Loop: " + i, nextName(controller));
+ assertEquals("before", nextName(controller), "Loop: " + i);
+ assertEquals("one", nextName(controller), "Loop: " + i);
+ assertEquals("two", nextName(controller), "Loop: " + i);
+ assertEquals("three", nextName(controller), "Loop: " + i);
+ assertEquals("four", nextName(controller), "Loop: " + i);
+ assertEquals("after", nextName(controller), "Loop: " + i);
+ assertNull(nextName(controller), "Loop: " + i);
}
jmvars.put("VAR", "LAST"); // Should not enter the loop
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop: " + i, "before", nextName(controller));
- assertEquals("Loop: " + i, "after", nextName(controller));
- assertNull("Loop: " + i, nextName(controller));
+ assertEquals("before", nextName(controller), "Loop: " + i);
+ assertEquals("after", nextName(controller), "Loop: " + i);
+ assertNull(nextName(controller), "Loop: " + i);
}
jmvars.put("VAR", "");
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop: " + i, "before", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop: " + i);
if (i == 1) {
- assertEquals("Loop: " + i, "one", nextName(controller));
- assertEquals("Loop: " + i, "two", nextName(controller));
- assertEquals("Loop: " + i, "three", nextName(controller));
+ assertEquals("one", nextName(controller), "Loop: " + i);
+ assertEquals("two", nextName(controller), "Loop: " + i);
+ assertEquals("three", nextName(controller), "Loop: " + i);
jmvars.put("VAR", "LAST"); // Should not enter the loop next time
- assertEquals("Loop: " + i, "four", nextName(controller));
+ assertEquals("four", nextName(controller), "Loop: " + i);
}
- assertEquals("Loop: " + i, "after", nextName(controller));
- assertNull("Loop: " + i, nextName(controller));
+ assertEquals("after", nextName(controller), "Loop: " + i);
+ assertNull(nextName(controller), "Loop: " + i);
}
}
@@ -237,33 +237,33 @@
controller.addTestElement(new TestSampler("after"));
controller.initialize();
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop: " + i, "before", nextName(controller));
- assertEquals("Loop: " + i, "one", nextName(controller));
- assertEquals("Loop: " + i, "two", nextName(controller));
- assertEquals("Loop: " + i, "three", nextName(controller));
- assertEquals("Loop: " + i, "four", nextName(controller));
- assertEquals("Loop: " + i, "after", nextName(controller));
- assertNull("Loop: " + i, nextName(controller));
+ assertEquals("before", nextName(controller), "Loop: " + i);
+ assertEquals("one", nextName(controller), "Loop: " + i);
+ assertEquals("two", nextName(controller), "Loop: " + i);
+ assertEquals("three", nextName(controller), "Loop: " + i);
+ assertEquals("four", nextName(controller), "Loop: " + i);
+ assertEquals("after", nextName(controller), "Loop: " + i);
+ assertNull(nextName(controller), "Loop: " + i);
}
jmvars.put("VAR", "LAST"); // Should not enter the loop
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop: " + i, "before", nextName(controller));
- assertEquals("Loop: " + i, "after", nextName(controller));
- assertNull("Loop: " + i, nextName(controller));
+ assertEquals("before", nextName(controller), "Loop: " + i);
+ assertEquals("after", nextName(controller), "Loop: " + i);
+ assertNull(nextName(controller), "Loop: " + i);
}
jmvars.put("VAR", "");
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop: " + i, "before", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop: " + i);
if (i == 1) {
- assertEquals("Loop: " + i, "one", nextName(controller));
- assertEquals("Loop: " + i, "two", nextName(controller));
+ assertEquals("one", nextName(controller), "Loop: " + i);
+ assertEquals("two", nextName(controller), "Loop: " + i);
jmvars.put("VAR", "LAST"); // Should not enter the loop next time
// But should continue to the end of the loop
- assertEquals("Loop: " + i, "three", nextName(controller));
- assertEquals("Loop: " + i, "four", nextName(controller));
+ assertEquals("three", nextName(controller), "Loop: " + i);
+ assertEquals("four", nextName(controller), "Loop: " + i);
}
- assertEquals("Loop: " + i, "after", nextName(controller));
- assertNull("Loop: " + i, nextName(controller));
+ assertEquals("after", nextName(controller), "Loop: " + i);
+ assertNull(nextName(controller), "Loop: " + i);
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/TestHtmlExtractorJSoup.java b/src/components/src/test/java/org/apache/jmeter/extractor/TestHtmlExtractorJSoup.java
index 67035e4..0d45695 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/TestHtmlExtractorJSoup.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/TestHtmlExtractorJSoup.java
@@ -18,8 +18,8 @@
package org.apache.jmeter.extractor;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java b/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java
index 8e62a1d..c4d42b9 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java
@@ -19,11 +19,11 @@
import static org.hamcrest.MatcherAssert.assertThat;
-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.net.URL;
@@ -258,26 +258,26 @@
assertEquals("position", vars.get("regVal_1"));
assertEquals("1", vars.get("regVal_1_g"));
assertEquals("position", vars.get("regVal_1_g1"));
- assertNull("Unused variables should be null", vars.get("regVal_1_g2"));
+ assertNull(vars.get("regVal_1_g2"), "Unused variables should be null");
assertEquals("invalidpin", vars.get("regVal_2"));
assertEquals("1", vars.get("regVal_2_g"));
assertEquals("invalidpin", vars.get("regVal_2_g1"));
- assertNull("Unused variables should be null", vars.get("regVal_2_g2"));
+ assertNull(vars.get("regVal_2_g2"), "Unused variables should be null");
assertEquals("1", vars.get("regVal_1_g"));
- assertNull("Unused variables should be null", vars.get("regVal_3"));
- assertNull("Unused variables should be null", vars.get("regVal_3_g"));
- assertNull("Unused variables should be null", vars.get("regVal_3_g0"));
- assertNull("Unused variables should be null", vars.get("regVal_3_g1"));
- assertNull("Unused variables should be null", vars.get("regVal_3_g2"));
+ assertNull(vars.get("regVal_3"), "Unused variables should be null");
+ assertNull(vars.get("regVal_3_g"), "Unused variables should be null");
+ assertNull(vars.get("regVal_3_g0"), "Unused variables should be null");
+ assertNull(vars.get("regVal_3_g1"), "Unused variables should be null");
+ assertNull(vars.get("regVal_3_g2"), "Unused variables should be null");
// Check when match fails
extractor.setRegex("xxxx(.)(.)");
extractor.process();
assertEquals("0", vars.get("regVal_matchNr"));
- assertNull("Unused variables should be null", vars.get("regVal_1"));
- assertNull("Unused variables should be null", vars.get("regVal_1_g0"));
- assertNull("Unused variables should be null", vars.get("regVal_1_g1"));
- assertNull("Unused variables should be null", vars.get("regVal_1_g2"));
+ assertNull(vars.get("regVal_1"), "Unused variables should be null");
+ assertNull(vars.get("regVal_1_g0"), "Unused variables should be null");
+ assertNull(vars.get("regVal_1_g1"), "Unused variables should be null");
+ assertNull(vars.get("regVal_1_g2"), "Unused variables should be null");
}
@Test
@@ -285,23 +285,23 @@
extractor.setRegex("Header1: (\\S+)");
extractor.setTemplate("$1$");
extractor.setMatchNumber(1);
- assertTrue("useBody should be true", extractor.useBody());
- assertFalse("useHdrs should be false", extractor.useHeaders());
- assertFalse("useURL should be false", extractor.useUrl());
+ assertTrue(extractor.useBody(), "useBody should be true");
+ assertFalse(extractor.useHeaders(), "useHdrs should be false");
+ assertFalse(extractor.useUrl(), "useURL should be false");
extractor.setUseField(RegexExtractor.USE_BODY);
- assertTrue("useBody should be true", extractor.useBody());
- assertFalse("useHdrs should be false", extractor.useHeaders());
- assertFalse("useURL should be false", extractor.useUrl());
+ assertTrue(extractor.useBody(), "useBody should be true");
+ assertFalse(extractor.useHeaders(), "useHdrs should be false");
+ assertFalse(extractor.useUrl(), "useURL should be false");
extractor.setUseField(RegexExtractor.USE_HDRS);
- assertTrue("useHdrs should be true", extractor.useHeaders());
- assertFalse("useBody should be false", extractor.useBody());
- assertFalse("useURL should be false", extractor.useUrl());
+ assertTrue(extractor.useHeaders(), "useHdrs should be true");
+ assertFalse(extractor.useBody(), "useBody should be false");
+ assertFalse(extractor.useUrl(), "useURL should be false");
extractor.process();
assertEquals("Value1", vars.get("regVal"));
extractor.setUseField(RegexExtractor.USE_URL);
- assertFalse("useHdrs should be false", extractor.useHeaders());
- assertFalse("useBody should be false", extractor.useBody());
- assertTrue("useURL should be true", extractor.useUrl());
+ assertFalse(extractor.useHeaders(), "useHdrs should be false");
+ assertFalse(extractor.useBody(), "useBody should be false");
+ assertTrue(extractor.useUrl(), "useURL should be true");
}
@Test
@@ -310,9 +310,9 @@
extractor.setTemplate("$1$");
extractor.setMatchNumber(1);
extractor.setUseField(RegexExtractor.USE_URL);
- assertFalse("useHdrs should be false", extractor.useHeaders());
- assertFalse("useBody should be false", extractor.useBody());
- assertTrue("useURL should be true", extractor.useUrl());
+ assertFalse(extractor.useHeaders(), "useHdrs should be false");
+ assertFalse(extractor.useBody(), "useBody should be false");
+ assertTrue(extractor.useUrl(), "useURL should be true");
extractor.process();
assertNull(vars.get("regVal"));
result.setURL(new URL("http://jakarta.apache.org/index.html?abcd"));
@@ -326,19 +326,19 @@
extractor.setTemplate("$1$");
extractor.setMatchNumber(1);
extractor.setUseField(RegexExtractor.USE_CODE);
- assertFalse("useHdrs should be false", extractor.useHeaders());
- assertFalse("useBody should be false", extractor.useBody());
- assertFalse("useURL should be false", extractor.useUrl());
- assertFalse("useMessage should be false", extractor.useMessage());
- assertTrue("useCode should be true", extractor.useCode());
+ assertFalse(extractor.useHeaders(), "useHdrs should be false");
+ assertFalse(extractor.useBody(), "useBody should be false");
+ assertFalse(extractor.useUrl(), "useURL should be false");
+ assertFalse(extractor.useMessage(), "useMessage should be false");
+ assertTrue(extractor.useCode(), "useCode should be true");
extractor.process();
assertEquals("abcd", vars.get("regVal"));
extractor.setUseField(RegexExtractor.USE_MESSAGE);
- assertFalse("useHdrs should be false", extractor.useHeaders());
- assertFalse("useBody should be false", extractor.useBody());
- assertFalse("useURL should be false", extractor.useUrl());
- assertTrue("useMessage should be true", extractor.useMessage());
- assertFalse("useCode should be false", extractor.useCode());
+ assertFalse(extractor.useHeaders(), "useHdrs should be false");
+ assertFalse(extractor.useBody(), "useBody should be false");
+ assertFalse(extractor.useUrl(), "useURL should be false");
+ assertTrue(extractor.useMessage(), "useMessage should be true");
+ assertFalse(extractor.useCode(), "useCode should be false");
extractor.setMatchNumber(3);
extractor.process();
assertEquals("brown", vars.get("regVal"));
diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/TestXPath2Extractor.java b/src/components/src/test/java/org/apache/jmeter/extractor/TestXPath2Extractor.java
index 49c6b45..906f93a 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/TestXPath2Extractor.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/TestXPath2Extractor.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.extractor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.UnsupportedEncodingException;
diff --git a/src/components/src/test/java/org/apache/jmeter/gui/action/TestSave.java b/src/components/src/test/java/org/apache/jmeter/gui/action/TestSave.java
index 3cac569..ad20a90 100644
--- a/src/components/src/test/java/org/apache/jmeter/gui/action/TestSave.java
+++ b/src/components/src/test/java/org/apache/jmeter/gui/action/TestSave.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.gui.action;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
diff --git a/src/components/src/test/java/org/apache/jmeter/gui/action/template/TestTemplateManager.java b/src/components/src/test/java/org/apache/jmeter/gui/action/template/TestTemplateManager.java
index 7990339..92de576 100644
--- a/src/components/src/test/java/org/apache/jmeter/gui/action/template/TestTemplateManager.java
+++ b/src/components/src/test/java/org/apache/jmeter/gui/action/template/TestTemplateManager.java
@@ -17,11 +17,12 @@
package org.apache.jmeter.gui.action.template;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileNotFoundException;
@@ -34,7 +35,6 @@
import javax.xml.parsers.ParserConfigurationException;
import org.apache.jmeter.junit.JMeterTestCase;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
@@ -100,7 +100,7 @@
@Test
public void testNonExistantXmlFileThrowsFileNotFoundException() throws Exception {
File xmlTemplateFile = new File("missing.xml");
- Assertions.assertThrows(
+ assertThrows(
FileNotFoundException.class,
() -> TemplateManager.getInstance().parseTemplateFile(xmlTemplateFile));
}
@@ -111,8 +111,8 @@
File templateFile = getFileFromResource("invalidTemplates.xml");
TemplateManager.getInstance().parseTemplateFile(templateFile);
} catch (SAXParseException ex) {
- assertTrue("Exception did not contains expected message, got:" + ex.getMessage(),
- ex.getMessage().contains("Element type \"key\" must be declared."));
+ String message = ex.getMessage();
+ assertTrue(message.contains("Element type \"key\" must be declared."), "Exception did not contains expected message, got:" + message);
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java b/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java
index 1dfa745..38e6e51 100644
--- a/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java
@@ -17,13 +17,15 @@
package org.apache.jmeter.timers;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.UUID;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.TestJMeterContextService;
import org.apache.jmeter.util.BeanShellInterpreter;
import org.apache.jmeter.util.ScriptingTestElement;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
@@ -32,11 +34,11 @@
@Test
void testTimer1() throws Exception {
ConstantThroughputTimer timer = new ConstantThroughputTimer();
- Assertions.assertEquals(0, timer.getCalcMode());// Assume this thread only
+ assertEquals(0, timer.getCalcMode());// Assume this thread only
timer.setThroughput(60.0);// 1 per second
long start = System.currentTimeMillis();
long delay = timer.delay(); // Initialise
- Assertions.assertEquals(0, delay);
+ assertEquals(0, delay);
// The test tries to check if the calculated delay is correct.
// If the build machine is busy, then the sleep(500) may take longer in
// which case the calculated delay should be shorter.
@@ -55,39 +57,39 @@
private static void assertAlmostEquals(long expected, long actual, long delta) {
long actualDelta = Math.abs(actual - expected);
if (actualDelta > delta) {
- Assertions.fail(() -> "Expected " + expected + " within delta of " + delta
+ fail("Expected " + expected + " within delta of " + delta
+ ", but got " + actual + " which is a delta of " + actualDelta);
}
}
@Test
void testTimer2() throws Exception {
ConstantThroughputTimer timer = new ConstantThroughputTimer();
- Assertions.assertEquals(0, timer.getCalcMode());// Assume this thread only
+ assertEquals(0, timer.getCalcMode());// Assume this thread only
timer.setThroughput(60.0);// 1 per second
- Assertions.assertEquals(1000, timer.calculateCurrentTarget(0)); // Should delay for 1 second
+ assertEquals(1000, timer.calculateCurrentTarget(0)); // Should delay for 1 second
timer.setThroughput(60000.0);// 1 per milli-second
- Assertions.assertEquals(1, timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
+ assertEquals(1, timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
}
@Test
void testTimer3() throws Exception {
ConstantThroughputTimer timer = new ConstantThroughputTimer();
timer.setMode(ConstantThroughputTimer.Mode.AllActiveThreads); //$NON-NLS-1$ - all threads
- Assertions.assertEquals(1, timer.getCalcMode());// All threads
+ assertEquals(1, timer.getCalcMode());// All threads
for(int i=1; i<=10; i++){
TestJMeterContextService.incrNumberOfThreads();
}
- Assertions.assertEquals(10, JMeterContextService.getNumberOfThreads());
+ assertEquals(10, JMeterContextService.getNumberOfThreads());
timer.setThroughput(600.0);// 10 per second
- Assertions.assertEquals(1000, timer.calculateCurrentTarget(0)); // Should delay for 1 second
+ assertEquals(1000, timer.calculateCurrentTarget(0)); // Should delay for 1 second
timer.setThroughput(600000.0);// 10 per milli-second
- Assertions.assertEquals(1, timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
+ assertEquals(1, timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
for(int i=1; i<=990; i++){
TestJMeterContextService.incrNumberOfThreads();
}
- Assertions.assertEquals(1000, JMeterContextService.getNumberOfThreads());
+ assertEquals(1000, JMeterContextService.getNumberOfThreads());
timer.setThroughput(60000000.0);// 1000 per milli-second
- Assertions.assertEquals(1, timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
+ assertEquals(1, timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
}
@Test
@@ -97,13 +99,13 @@
BeanShellTimer timer = new BeanShellTimer();
timer.setScript("\"60\"");
- Assertions.assertEquals(60, timer.delay());
+ assertEquals(60, timer.delay());
timer.setScript("60");
- Assertions.assertEquals(60, timer.delay());
+ assertEquals(60, timer.delay());
timer.setScript("5*3*4");
- Assertions.assertEquals(60, timer.delay());
+ assertEquals(60, timer.delay());
}
@Test
@@ -113,13 +115,13 @@
timer.setCacheKey(UUID.randomUUID().toString());
timer.setScript("\"60\"");
- Assertions.assertEquals(60, timer.delay());
+ assertEquals(60, timer.delay());
timer.setScript("60");
- Assertions.assertEquals(60, timer.delay());
+ assertEquals(60, timer.delay());
timer.setScript("5*3*4");
- Assertions.assertEquals(60, timer.delay());
+ assertEquals(60, timer.delay());
}
@Test
@@ -133,7 +135,7 @@
private static void assertBetween(long expectedLow, long expectedHigh, long actual) {
if (actual < expectedLow || actual > expectedHigh) {
- Assertions.fail(() -> "delay not in expected range: expected " + actual
+ fail(() -> "delay not in expected range: expected " + actual
+ " to be within " + expectedLow + " and " + expectedHigh);
}
}
@@ -141,7 +143,7 @@
void testConstantTimer() throws Exception {
ConstantTimer timer = new ConstantTimer();
timer.setDelay("1000");
- Assertions.assertEquals(1000, timer.delay());
+ assertEquals(1000, timer.delay());
}
@Test
diff --git a/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java b/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java
index d6358fc..2f7d8a1 100644
--- a/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimerTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.timers.poissonarrivals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Arrays;
@@ -69,12 +69,9 @@
}
if (!ok) {
- assertEquals(
- "Schedule does not match expectation, " +
- "throughput=" + throughput + ", duration=" + duration +
- "seed=" + seed + ", batchSize=" + batchSize,
- Arrays.toString(expected), Arrays.toString(actual)
- );
+ assertEquals(Arrays.toString(expected), Arrays.toString(actual), "Schedule does not match expectation, " +
+ "throughput=" + throughput + ", duration=" + duration +
+ "seed=" + seed + ", batchSize=" + batchSize);
}
}
@@ -138,11 +135,9 @@
for (int i = 0; i < samplesPerTest; i++) {
double next = gen.next();
if (prev > next) {
- fail(
- "Schedule should be monotonic, so each new event comes later. " +
- "prev: " + prev + ", next: " + next +
- ". Full schedule so far: " + delays
- );
+ fail("Schedule should be monotonic, so each new event comes later. " +
+ "prev: " + prev + ", next: " + next +
+ ". Full schedule so far: " + delays);
}
prev = next;
delays.add(next);
@@ -151,12 +146,10 @@
// OK
continue;
}
- fail(
- "Throughput violation at second #" + time + ". Event #" + delays.size() +
- " is scheduled at " + next + ", however it should be " +
- " between " + time * testDuration + " and " + (time + 1) * testDuration +
- ". Full schedule so far: " + delays
- );
+ fail("Throughput violation at second #" + time + ". Event #" + delays.size() +
+ " is scheduled at " + next + ", however it should be " +
+ " between " + time * testDuration + " and " + (time + 1) * testDuration +
+ ". Full schedule so far: " + delays);
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/TestRenderAsJson.java b/src/components/src/test/java/org/apache/jmeter/visualizers/TestRenderAsJson.java
index b9bb912..9601036 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/TestRenderAsJson.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/TestRenderAsJson.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.visualizers;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.lang.reflect.Method;
@@ -49,8 +49,7 @@
}
json.append("\"");
- assertEquals("{\n" + TAB + json.toString() + "\n}",
- prettyJSON("{" + json.toString() + "}"));
+ assertEquals("{\n" + TAB + json.toString() + "\n}", prettyJSON("{" + json.toString() + "}"));
}
@Test
@@ -69,8 +68,7 @@
@Test
public void testRenderArrayInObject() throws Exception {
- assertEquals("{\n" + TAB + "\"foo\": [\n" + TAB + "]\n}",
- prettyJSON("{\"foo\":[]}"));
+ assertEquals("{\n" + TAB + "\"foo\": [\n" + TAB + "]\n}", prettyJSON("{\"foo\":[]}"));
}
@Test
@@ -85,11 +83,9 @@
@Test
public void testRenderResultSimpleStructure() throws Exception {
- assertEquals(
- "{\n" + TAB + "\"Hello\": \"World\",\n" + TAB + "\"more\": [\n"
- + TAB + TAB + "\"Something\",\n" + TAB
- + TAB + "\"else\"\n" + TAB + "]\n}",
- prettyJSON("{\"Hello\": \"World\", \"more\": [\"Something\", \"else\", ]}"));
+ assertEquals("{\n" + TAB + "\"Hello\": \"World\",\n" + TAB + "\"more\": [\n"
+ + TAB + TAB + "\"Something\",\n" + TAB
+ + TAB + "\"else\"\n" + TAB + "]\n}", prettyJSON("{\"Hello\": \"World\", \"more\": [\"Something\", \"else\", ]}"));
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/TestSamplingStatCalculator.java b/src/components/src/test/java/org/apache/jmeter/visualizers/TestSamplingStatCalculator.java
index 6e1aa76..2615e66 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/TestSamplingStatCalculator.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/TestSamplingStatCalculator.java
@@ -17,8 +17,10 @@
package org.apache.jmeter.visualizers;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import org.apache.jmeter.samplers.SampleResult;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -32,19 +34,19 @@
@Test
public void testGetCurrentSample() {
- Assert.assertNotNull(ssc.getCurrentSample()); // probably needed to avoid NPEs with GUIs
+ assertNotNull(ssc.getCurrentSample()); // probably needed to avoid NPEs with GUIs
}
@Test
public void testGetAvgPageBytes() {
SampleResult res = new SampleResult();
- Assert.assertEquals(0,ssc.getAvgPageBytes(),0);
+ assertEquals(0, ssc.getAvgPageBytes(), 0);
res.setResponseData("abcdef", "UTF-8");
ssc.addSample(res);
res.setResponseData("abcde", "UTF-8");
ssc.addSample(res);
res.setResponseData("abcd", "UTF-8");
ssc.addSample(res);
- Assert.assertEquals(5,ssc.getAvgPageBytes(),0);
+ assertEquals(5, ssc.getAvgPageBytes(), 0);
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
index 4286f58..8fdac49 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.visualizers.backend;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
@@ -41,40 +41,40 @@
public void checkResetOkAndAllStats() throws Exception {
SamplerMetric metric = new SamplerMetric();
metric.add(createSampleResult(true));
- assertEquals("Before reset ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
- assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
- assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001, "Before reset ok.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001, "Before reset all.max");
+ assertEquals(1, metric.getHits(), 0.0, "Before reset failure");
+ assertEquals(1000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(2000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
// In fixed mode DescriptiveStatistics are not reset, just sliding on a window
metric.resetForTimeInterval();
- assertEquals("After reset in FIXED mode ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
- assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0);
- assertEquals("After reset failure", 0, metric.getHits(), 0.0);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001, "After reset in FIXED mode ok.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0, "After reset in FIXED mode all.max");
+ assertEquals(0, metric.getHits(), 0.0, "After reset failure");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
@Test
public void checkResetKoAndAllStats() throws Exception {
SamplerMetric metric = new SamplerMetric();
metric.add(createSampleResult(false));
- assertEquals("Before reset ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
- assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
- assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001, "Before reset ko.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001, "Before reset all.max");
+ assertEquals(1, metric.getFailures(), 0.0, "Before reset failure");
+ assertEquals(1000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(2000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
// In fixed mode DescriptiveStatistics are not reset, just sliding on a window
metric.resetForTimeInterval();
- assertEquals("After reset in FIXED mode ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.0);
- assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0);
- assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.0, "After reset in FIXED mode ko.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0, "After reset in FIXED mode all.max");
+ assertEquals(0, metric.getFailures(), 0.001, "After reset failure");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
@Test
@@ -84,9 +84,9 @@
metric.add(createSampleResult("400", "Bad Request "));
metric.add(createSampleResult("500", "Internal Server Error"));
ErrorMetric error = new ErrorMetric(createSampleResult("400", "Bad request"));
- assertEquals("Count for '400 - bad request' error ", 2, metric.getErrors().get(error), 0.0);
+ assertEquals(2, metric.getErrors().get(error), 0.0, "Count for '400 - bad request' error ");
error = new ErrorMetric(createSampleResult("500", "Internal Server Error"));
- assertEquals("Count for '500 - Internal Server Error' error ", 1, metric.getErrors().get(error), 0.0);
+ assertEquals(1, metric.getErrors().get(error), 0.0, "Count for '500 - Internal Server Error' error ");
}
private SampleResult createSampleResult(boolean success) {
@@ -127,43 +127,41 @@
public void checkAddCumulatedOk() throws Exception {
SamplerMetric metric = new SamplerMetric();
SampleResult sample = createSampleResultWithSubresults(true);
- assertEquals("We are recognized as a TransactionController made sample", Boolean.TRUE,
- Boolean.valueOf(TransactionController.isFromTransactionController(sample)));
+ assertEquals(Boolean.TRUE, TransactionController.isFromTransactionController(sample), "We are recognized as a TransactionController made sample");
metric.addCumulated(sample);
- assertEquals("Before reset ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset hits", 2, metric.getHits(), 0.0);
- assertEquals("Before reset sent bytes", 2000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 4000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), ALLOWED_DELTA, "Before reset ok.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA, "Before reset all.max");
+ assertEquals(2, metric.getHits(), 0.0, "Before reset hits");
+ assertEquals(2000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(4000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
metric.resetForTimeInterval();
- assertEquals("After reset in TIMED mode ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), ALLOWED_DELTA);
- assertEquals("After reset in TIMED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA);
- assertEquals("After reset hits", 0, metric.getHits(), 0.0);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), ALLOWED_DELTA, "After reset in TIMED mode ok.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA, "After reset in TIMED mode all.max");
+ assertEquals(0, metric.getHits(), 0.0, "After reset hits");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
@Test
public void checkAddCumulatedKo() throws Exception {
SamplerMetric metric = new SamplerMetric();
SampleResult sample = createSampleResultWithSubresults(false);
- assertEquals("We are recognized as a TransactionController made sample", Boolean.TRUE,
- Boolean.valueOf(TransactionController.isFromTransactionController(sample)));
+ assertEquals(Boolean.TRUE, TransactionController.isFromTransactionController(sample), "We are recognized as a TransactionController made sample");
metric.addCumulated(sample);
- assertEquals("Before reset ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset failures", 1, metric.getFailures(), 0.0);
- assertEquals("Before reset sent bytes", 2000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 4000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), ALLOWED_DELTA, "Before reset ko.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA, "Before reset all.max");
+ assertEquals(1, metric.getFailures(), 0.0, "Before reset failures");
+ assertEquals(2000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(4000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
metric.resetForTimeInterval();
- assertEquals("After reset in TIMED mode ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), ALLOWED_DELTA);
- assertEquals("After reset in TIMED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA);
- assertEquals("After reset failures", 0, metric.getFailures(), 0.0);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), ALLOWED_DELTA, "After reset in TIMED mode ko.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA, "After reset in TIMED mode all.max");
+ assertEquals(0, metric.getFailures(), 0.0, "After reset failures");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
index ba9fa7f..42c3835 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.visualizers.backend;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
@@ -43,19 +43,19 @@
SamplerMetric metric = new SamplerMetric();
metric.add(createSampleResult(true));
- assertEquals("Before reset ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
- assertEquals("Before reset hits", 1, metric.getHits(), 0.0);
- assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001, "Before reset ok.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001, "Before reset all.max");
+ assertEquals(1, metric.getHits(), 0.0, "Before reset hits");
+ assertEquals(1000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(2000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
metric.resetForTimeInterval();
- assertEquals("After reset in TIMED mode ok.max", Double.NaN, metric.getOkMaxTime(), 0.0);
- assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
- assertEquals("After reset hits", 0, metric.getHits(), 0.0);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(Double.NaN, metric.getOkMaxTime(), 0.0, "After reset in TIMED mode ok.max");
+ assertEquals(Double.NaN, metric.getAllMaxTime(), 0.0, "After reset in TIMED mode all.max");
+ assertEquals(0, metric.getHits(), 0.0, "After reset hits");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
@Test
@@ -63,19 +63,19 @@
SamplerMetric metric = new SamplerMetric();
metric.add(createSampleResult(false));
- assertEquals("Before reset ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
- assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
- assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001, "Before reset ko.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001, "Before reset all.max");
+ assertEquals(1, metric.getFailures(), 0.0, "Before reset failure");
+ assertEquals(1000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(2000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
metric.resetForTimeInterval();
- assertEquals("After reset in TIMED mode ko.max", Double.NaN, metric.getKoMaxTime(), 0.0);
- assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
- assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(Double.NaN, metric.getKoMaxTime(), 0.0, "After reset in TIMED mode ko.max");
+ assertEquals(Double.NaN, metric.getAllMaxTime(), 0.0, "After reset in TIMED mode all.max");
+ assertEquals(0, metric.getFailures(), 0.001, "After reset failure");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
private SampleResult createSampleResult(boolean success) {
@@ -109,44 +109,42 @@
public void checkAddCumulatedOk() throws Exception {
SamplerMetric metric = new SamplerMetric();
SampleResult sample = createSampleResultWithSubresults(true);
- assertEquals("We are recognized as a TransactionController made sample", Boolean.TRUE,
- Boolean.valueOf(TransactionController.isFromTransactionController(sample)));
+ assertEquals(Boolean.TRUE, TransactionController.isFromTransactionController(sample), "We are recognized as a TransactionController made sample");
metric.addCumulated(sample);
- assertEquals("Before reset ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset hits", 2, metric.getHits(), 0.0);
- assertEquals("Before reset sent bytes", 2000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 4000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), ALLOWED_DELTA, "Before reset ok.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA, "Before reset all.max");
+ assertEquals(2, metric.getHits(), 0.0, "Before reset hits");
+ assertEquals(2000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(4000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
metric.resetForTimeInterval();
- assertEquals("After reset in TIMED mode ok.max", Double.NaN, metric.getOkMaxTime(), 0.0);
- assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
- assertEquals("After reset hits", 0, metric.getHits(), 0.0);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(Double.NaN, metric.getOkMaxTime(), 0.0, "After reset in TIMED mode ok.max");
+ assertEquals(Double.NaN, metric.getAllMaxTime(), 0.0, "After reset in TIMED mode all.max");
+ assertEquals(0, metric.getHits(), 0.0, "After reset hits");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
@Test
public void checkAddCumulatedKo() throws Exception {
SamplerMetric metric = new SamplerMetric();
SampleResult sample = createSampleResultWithSubresults(false);
- assertEquals("We are recognized as a TransactionController made sample", Boolean.TRUE,
- Boolean.valueOf(TransactionController.isFromTransactionController(sample)));
+ assertEquals(Boolean.TRUE, TransactionController.isFromTransactionController(sample), "We are recognized as a TransactionController made sample");
metric.addCumulated(sample);
- assertEquals("Before reset ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA);
- assertEquals("Before reset failures", 1, metric.getFailures(), 0.0);
- assertEquals("Before reset sent bytes", 2000, metric.getSentBytes(), 0.0);
- assertEquals("Before reset received bytes", 4000, metric.getReceivedBytes(), 0.0);
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), ALLOWED_DELTA, "Before reset ko.max");
+ assertEquals(DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), ALLOWED_DELTA, "Before reset all.max");
+ assertEquals(1, metric.getFailures(), 0.0, "Before reset failures");
+ assertEquals(2000, metric.getSentBytes(), 0.0, "Before reset sent bytes");
+ assertEquals(4000, metric.getReceivedBytes(), 0.0, "Before reset received bytes");
metric.resetForTimeInterval();
- assertEquals("After reset in TIMED mode ko.max", Double.NaN, metric.getKoMaxTime(), 0.0);
- assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
- assertEquals("After reset failures", 0, metric.getFailures(), 0.0);
- assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
- assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
+ assertEquals(Double.NaN, metric.getKoMaxTime(), 0.0, "After reset in TIMED mode ko.max");
+ assertEquals(Double.NaN, metric.getAllMaxTime(), 0.0, "After reset in TIMED mode all.max");
+ assertEquals(0, metric.getFailures(), 0.0, "After reset failures");
+ assertEquals(0, metric.getSentBytes(), 0.0, "After reset sent bytes");
+ assertEquals(0, metric.getReceivedBytes(), 0.0, "After reset received bytes");
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/engine/LocalHostTest.java b/src/core/src/test/java/org/apache/jmeter/engine/LocalHostTest.java
index 8c024cf..9d27c75 100644
--- a/src/core/src/test/java/org/apache/jmeter/engine/LocalHostTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/engine/LocalHostTest.java
@@ -17,6 +17,8 @@
package org.apache.jmeter.engine;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
@@ -28,7 +30,6 @@
import org.apache.commons.net.util.SubnetUtils;
import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -52,9 +53,7 @@
.filter(iface -> iface.getAddress().getAddress().length == 4) // hack to prevent checking IPv6
.map(this::toSubnetInfo)
.anyMatch(subnetInfo -> subnetInfo.isInRange(localHost));
- Assert.assertTrue(
- "localHost: " + localHost + " is bound to an interface",
- localHostIsBound);
+ assertTrue(localHostIsBound, () -> "localHost: " + localHost + " is bound to an interface");
}
private String guessExternalIPv4Interface() throws SocketException {
diff --git a/src/core/src/test/java/org/apache/jmeter/engine/TestTreeCloner.java b/src/core/src/test/java/org/apache/jmeter/engine/TestTreeCloner.java
index 143f569..ed5664c 100644
--- a/src/core/src/test/java/org/apache/jmeter/engine/TestTreeCloner.java
+++ b/src/core/src/test/java/org/apache/jmeter/engine/TestTreeCloner.java
@@ -17,9 +17,12 @@
package org.apache.jmeter.engine;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
@@ -53,10 +56,10 @@
TreeCloner cloner = new TreeCloner();
original.traverse(cloner);
ListedHashTree newTree = cloner.getClonedTree();
- assertTrue(original != newTree);
+ assertNotSame(original, newTree);
assertEquals(original.size(), newTree.size());
assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
- assertTrue(original.getArray()[0] != newTree.getArray()[0]);
+ assertNotSame(original.getArray()[0], newTree.getArray()[0]);
assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree
.getArray()[0]).getName());
assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0])
@@ -64,14 +67,14 @@
TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
clonedTestPlan.setRunningVersion(true);
clonedTestPlan.recoverRunningVersion();
- assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
+ assertFalse(plan.getUserDefinedVariablesAsProperty().isRunningVersion());
assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
while (iter.hasNext()) {
JMeterProperty argProp = iter.next();
- assertTrue(!argProp.isRunningVersion());
- assertTrue(argProp.getObjectValue() instanceof Argument);
+ assertFalse(argProp.isRunningVersion());
+ assertInstanceOf(Argument.class, argProp.getObjectValue());
Argument arg = (Argument) argProp.getObjectValue();
arg.setValue("yahoo");
assertEquals("yahoo", arg.getValue());
diff --git a/src/core/src/test/java/org/apache/jmeter/engine/util/TestValueReplacer.java b/src/core/src/test/java/org/apache/jmeter/engine/util/TestValueReplacer.java
index 026f95f..4a54e69 100644
--- a/src/core/src/test/java/org/apache/jmeter/engine/util/TestValueReplacer.java
+++ b/src/core/src/test/java/org/apache/jmeter/engine/util/TestValueReplacer.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.engine.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/core/src/test/java/org/apache/jmeter/gui/logging/TestGuiLogEventAppender.java b/src/core/src/test/java/org/apache/jmeter/gui/logging/TestGuiLogEventAppender.java
index e59184d..246c44a 100644
--- a/src/core/src/test/java/org/apache/jmeter/gui/logging/TestGuiLogEventAppender.java
+++ b/src/core/src/test/java/org/apache/jmeter/gui/logging/TestGuiLogEventAppender.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.gui.logging;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
@@ -107,6 +107,6 @@
public void testSimpleLogging() throws Exception {
final Logger log = LoggerFactory.getLogger(TestGuiLogEventAppender.class);
log.info("logger created.");
- assertTrue("Logging appender error: " + log4j2LevelErrorMessages, log4j2LevelErrorMessages.isEmpty());
+ assertTrue(log4j2LevelErrorMessages.isEmpty(), "Logging appender error: " + log4j2LevelErrorMessages);
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/listeners/TestResultAction.java b/src/core/src/test/java/org/apache/jmeter/listeners/TestResultAction.java
index 72b6cbc..a96eed1 100644
--- a/src/core/src/test/java/org/apache/jmeter/listeners/TestResultAction.java
+++ b/src/core/src/test/java/org/apache/jmeter/listeners/TestResultAction.java
@@ -17,6 +17,9 @@
package org.apache.jmeter.listeners;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.reporters.ResultAction;
import org.apache.jmeter.samplers.SampleEvent;
@@ -24,7 +27,6 @@
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -49,7 +51,7 @@
sampleResult.setSuccessful(true);
resultAction.setErrorAction(ResultAction.ON_ERROR_STOPTEST);
resultAction.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
- Assert.assertFalse(sampleResult.isStopTest());
+ assertFalse(sampleResult.isStopTest());
}
@Test
@@ -58,10 +60,10 @@
sampleResult.setSuccessful(false);
resultAction.setErrorAction(ResultAction.ON_ERROR_STOPTEST);
resultAction.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
- Assert.assertTrue(sampleResult.isStopTest());
- Assert.assertFalse(sampleResult.isStopTestNow());
- Assert.assertFalse(sampleResult.isStopThread());
- Assert.assertFalse(sampleResult.isStartNextThreadLoop());
+ assertTrue(sampleResult.isStopTest());
+ assertFalse(sampleResult.isStopTestNow());
+ assertFalse(sampleResult.isStopThread());
+ assertFalse(sampleResult.isStartNextThreadLoop());
}
@Test
@@ -70,10 +72,10 @@
sampleResult.setSuccessful(false);
resultAction.setErrorAction(ResultAction.ON_ERROR_STOPTEST_NOW);
resultAction.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
- Assert.assertFalse(sampleResult.isStopTest());
- Assert.assertTrue(sampleResult.isStopTestNow());
- Assert.assertFalse(sampleResult.isStopThread());
- Assert.assertFalse(sampleResult.isStartNextThreadLoop());
+ assertFalse(sampleResult.isStopTest());
+ assertTrue(sampleResult.isStopTestNow());
+ assertFalse(sampleResult.isStopThread());
+ assertFalse(sampleResult.isStartNextThreadLoop());
}
@Test
@@ -82,10 +84,10 @@
sampleResult.setSuccessful(false);
resultAction.setErrorAction(ResultAction.ON_ERROR_STOPTHREAD);
resultAction.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
- Assert.assertFalse(sampleResult.isStopTest());
- Assert.assertFalse(sampleResult.isStopTestNow());
- Assert.assertTrue(sampleResult.isStopThread());
- Assert.assertFalse(sampleResult.isStartNextThreadLoop());
+ assertFalse(sampleResult.isStopTest());
+ assertFalse(sampleResult.isStopTestNow());
+ assertTrue(sampleResult.isStopThread());
+ assertFalse(sampleResult.isStartNextThreadLoop());
}
@Test
@@ -94,9 +96,9 @@
sampleResult.setSuccessful(false);
resultAction.setErrorAction(ResultAction.ON_ERROR_START_NEXT_THREAD_LOOP);
resultAction.sampleOccurred(new SampleEvent(sampleResult, "JUnit-TG"));
- Assert.assertFalse(sampleResult.isStopTest());
- Assert.assertFalse(sampleResult.isStopTestNow());
- Assert.assertFalse(sampleResult.isStopThread());
- Assert.assertTrue(sampleResult.isStartNextThreadLoop());
+ assertFalse(sampleResult.isStopTest());
+ assertFalse(sampleResult.isStopTestNow());
+ assertFalse(sampleResult.isStopThread());
+ assertTrue(sampleResult.isStartNextThreadLoop());
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/report/core/CsvSampleReaderTest.java b/src/core/src/test/java/org/apache/jmeter/report/core/CsvSampleReaderTest.java
index f1bf97b..1df86af 100644
--- a/src/core/src/test/java/org/apache/jmeter/report/core/CsvSampleReaderTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/report/core/CsvSampleReaderTest.java
@@ -18,15 +18,17 @@
package org.apache.jmeter.report.core;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.IOException;
import org.apache.jmeter.junit.JMeterTestCase;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -54,7 +56,7 @@
@Test
public void testConstructorWithInvalidFile() {
- Assertions.assertThrows(
+ assertThrows(
IllegalArgumentException.class,
() -> new CsvSampleReader(new File("/not/available.csv"), metadata)
);
@@ -97,11 +99,11 @@
public void testHasNextAndReadSample() {
try (CsvSampleReader reader = new CsvSampleReader(tempCsv, metadata)) {
for (long i = 0; i < NR_ROWS; i++) {
- Assert.assertTrue(reader.hasNext());
+ assertTrue(reader.hasNext());
final Sample sample = reader.readSample();
- Assert.assertEquals(i, sample.getSampleRow());
+ assertEquals(i, sample.getSampleRow());
}
- Assert.assertFalse(reader.hasNext());
+ assertFalse(reader.hasNext());
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/report/core/SampleMetadataTest.java b/src/core/src/test/java/org/apache/jmeter/report/core/SampleMetadataTest.java
index dc34d57..fc6fb1c 100644
--- a/src/core/src/test/java/org/apache/jmeter/report/core/SampleMetadataTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/report/core/SampleMetadataTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.report.core;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
diff --git a/src/core/src/test/java/org/apache/jmeter/report/core/TestCsvSampleWriter.java b/src/core/src/test/java/org/apache/jmeter/report/core/TestCsvSampleWriter.java
index 5691f80..d0bd7db 100644
--- a/src/core/src/test/java/org/apache/jmeter/report/core/TestCsvSampleWriter.java
+++ b/src/core/src/test/java/org/apache/jmeter/report/core/TestCsvSampleWriter.java
@@ -17,15 +17,15 @@
package org.apache.jmeter.report.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.StringWriter;
import java.io.Writer;
import org.apache.jmeter.junit.JMeterTestUtils;
import org.apache.jmeter.util.JMeterUtils;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -44,7 +44,7 @@
@Test
public void testCsvSampleWriterConstructorWithNull() throws Exception {
- Assertions.assertThrows(
+ assertThrows(
NullPointerException.class,
() -> new CsvSampleWriter(null)
);
diff --git a/src/core/src/test/java/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java b/src/core/src/test/java/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java
index 2818ed5..b208ce0 100644
--- a/src/core/src/test/java/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java
+++ b/src/core/src/test/java/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java
@@ -17,11 +17,11 @@
package org.apache.jmeter.samplers;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -105,55 +105,55 @@
public void testFalse() throws Exception {
SampleSaveConfiguration a = new SampleSaveConfiguration(false);
SampleSaveConfiguration b = new SampleSaveConfiguration(false);
- assertEquals("Hash codes should be equal",a.hashCode(), b.hashCode());
- assertTrue("Objects should be equal",a.equals(b));
- assertTrue("Objects should be equal",b.equals(a));
+ assertEquals(a.hashCode(), b.hashCode(), "Hash codes should be equal");
+ assertTrue(a.equals(b), "Objects should be equal");
+ assertTrue(b.equals(a), "Objects should be equal");
}
@Test
public void testTrue() throws Exception {
SampleSaveConfiguration a = new SampleSaveConfiguration(true);
SampleSaveConfiguration b = new SampleSaveConfiguration(true);
- assertEquals("Hash codes should be equal",a.hashCode(), b.hashCode());
- assertTrue("Objects should be equal",a.equals(b));
- assertTrue("Objects should be equal",b.equals(a));
+ assertEquals(a.hashCode(), b.hashCode(), "Hash codes should be equal");
+ assertTrue(a.equals(b), "Objects should be equal");
+ assertTrue(b.equals(a), "Objects should be equal");
}
@Test
public void testFalseTrue() throws Exception {
SampleSaveConfiguration a = new SampleSaveConfiguration(false);
SampleSaveConfiguration b = new SampleSaveConfiguration(true);
- assertFalse("Hash codes should not be equal",a.hashCode() == b.hashCode());
- assertFalse("Objects should not be equal",a.equals(b));
- assertFalse("Objects should not be equal",b.equals(a));
+ assertFalse(a.hashCode() == b.hashCode(), "Hash codes should not be equal");
+ assertFalse(a.equals(b), "Objects should not be equal");
+ assertFalse(b.equals(a), "Objects should not be equal");
}
@Test
public void testFormatter() throws Exception {
SampleSaveConfiguration a = new SampleSaveConfiguration(false);
SampleSaveConfiguration b = new SampleSaveConfiguration(false);
- assertEquals("Hash codes should be equal",a.hashCode(), b.hashCode());
- assertTrue("Objects should be equal",a.equals(b));
- assertTrue("Objects should be equal",b.equals(a));
+ assertEquals(a.hashCode(), b.hashCode(), "Hash codes should be equal");
+ assertTrue(a.equals(b), "Objects should be equal");
+ assertTrue(b.equals(a), "Objects should be equal");
assertTrue(a.strictDateFormatter() == null);
assertTrue(b.strictDateFormatter() == null);
assertTrue(a.threadSafeLenientFormatter() == null);
assertTrue(b.threadSafeLenientFormatter() == null);
a.setDateFormat(null);
b.setDateFormat(null);
- assertEquals("Hash codes should be equal",a.hashCode(), b.hashCode());
- assertTrue("Objects should be equal",a.equals(b));
- assertTrue("Objects should be equal",b.equals(a));
+ assertEquals(a.hashCode(), b.hashCode(), "Hash codes should be equal");
+ assertTrue(a.equals(b), "Objects should be equal");
+ assertTrue(b.equals(a), "Objects should be equal");
assertTrue(a.strictDateFormatter() == null);
assertTrue(b.strictDateFormatter() == null);
assertTrue(a.threadSafeLenientFormatter() == null);
assertTrue(b.threadSafeLenientFormatter() == null);
a.setDateFormat("dd/MM/yyyy");
b.setDateFormat("dd/MM/yyyy");
- assertEquals("Hash codes should be equal",a.hashCode(), b.hashCode());
- assertTrue("Objects should be equal",a.equals(b));
- assertTrue("Objects should be equal",b.equals(a));
- assertTrue("Objects should be equal",a.strictDateFormatter().equals(b.strictDateFormatter()));
- assertTrue("Objects should be equal",a.threadSafeLenientFormatter().equals(b.threadSafeLenientFormatter()));
+ assertEquals(a.hashCode(), b.hashCode(), "Hash codes should be equal");
+ assertTrue(a.equals(b), "Objects should be equal");
+ assertTrue(b.equals(a), "Objects should be equal");
+ assertTrue(a.strictDateFormatter().equals(b.strictDateFormatter()), "Objects should be equal");
+ assertTrue(a.threadSafeLenientFormatter().equals(b.threadSafeLenientFormatter()), "Objects should be equal");
}
@Test
@@ -167,7 +167,7 @@
if (name.startsWith(SampleSaveConfiguration.CONFIG_GETTER_PREFIX) && method.getParameterTypes().length == 0) {
name = name.substring(SampleSaveConfiguration.CONFIG_GETTER_PREFIX.length());
getMethodNames.add(name);
- assertTrue("SAVE_CONFIG_NAMES should contain save" + name, SampleSaveConfiguration.SAVE_CONFIG_NAMES.contains(name));
+ assertTrue(SampleSaveConfiguration.SAVE_CONFIG_NAMES.contains(name), "SAVE_CONFIG_NAMES should contain save" + name);
}
if (name.startsWith(SampleSaveConfiguration.CONFIG_SETTER_PREFIX)
&& method.getParameterTypes().length == 1
@@ -175,14 +175,13 @@
name = name.substring(
SampleSaveConfiguration.CONFIG_SETTER_PREFIX.length());
setMethodNames.add(name);
- assertTrue("SAVE_CONFIG_NAMES should contain set" + name,
- SampleSaveConfiguration.SAVE_CONFIG_NAMES
- .contains(name));
+ assertTrue(SampleSaveConfiguration.SAVE_CONFIG_NAMES
+ .contains(name), "SAVE_CONFIG_NAMES should contain set" + name);
}
}
for (String name : SampleSaveConfiguration.SAVE_CONFIG_NAMES) {
- assertTrue("SAVE_CONFIG_NAMES should NOT contain save" + name, getMethodNames.contains(name));
- assertTrue("SAVE_CONFIG_NAMES should NOT contain set" + name, setMethodNames.contains(name));
+ assertTrue(getMethodNames.contains(name), "SAVE_CONFIG_NAMES should NOT contain save" + name);
+ assertTrue(setMethodNames.contains(name), "SAVE_CONFIG_NAMES should NOT contain set" + name);
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/save/TestCSVSaveService.java b/src/core/src/test/java/org/apache/jmeter/save/TestCSVSaveService.java
index cc7a6c8..cb9d959 100644
--- a/src/core/src/test/java/org/apache/jmeter/save/TestCSVSaveService.java
+++ b/src/core/src/test/java/org/apache/jmeter/save/TestCSVSaveService.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.save;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.BufferedReader;
@@ -40,9 +40,9 @@
}
private void checkStrings(String[] expected, String[] out) {
- assertEquals("Incorrect number of strings returned",expected.length, out.length);
+ assertEquals(expected.length, out.length, "Incorrect number of strings returned");
for(int i = 0; i < out.length; i++){
- assertEquals("Incorrect entry returned",expected[i], out[i]);
+ assertEquals(expected[i], out[i], "Incorrect entry returned");
}
}
@@ -108,7 +108,7 @@
checkStrings(new String[]{"","","f","g",""}, out);
out = CSVSaveService.csvReadFile(br, ',');
checkStrings(new String[]{""}, out); // Blank line
- assertEquals("Expected to be at EOF",-1,br.read());
+ assertEquals(-1, br.read(), "Expected to be at EOF");
// Empty strings at EOF
out = CSVSaveService.csvReadFile(br, ',');
checkStrings(new String[]{}, out);
@@ -121,7 +121,7 @@
BufferedReader br = new BufferedReader(new StringReader("\n"));
String[] out = CSVSaveService.csvReadFile(br, ',');
checkStrings(new String[]{""}, out);
- assertEquals("Expected to be at EOF",-1,br.read());
+ assertEquals(-1, br.read(), "Expected to be at EOF");
}
@Test
@@ -129,7 +129,7 @@
BufferedReader br = new BufferedReader(new StringReader("\"\"\n"));
String[] out = CSVSaveService.csvReadFile(br, ',');
checkStrings(new String[]{""}, out);
- assertEquals("Expected to be at EOF",-1,br.read());
+ assertEquals(-1, br.read(), "Expected to be at EOF");
}
@Test
@@ -137,7 +137,7 @@
BufferedReader br = new BufferedReader(new StringReader(""));
String[] out = CSVSaveService.csvReadFile(br, ',');
checkStrings(new String[]{}, out);
- assertEquals("Expected to be at EOF",-1,br.read());
+ assertEquals(-1, br.read(), "Expected to be at EOF");
}
@Test
@@ -145,7 +145,7 @@
BufferedReader br = new BufferedReader(new StringReader("a"));
String[] out = CSVSaveService.csvReadFile(br, ',');
checkStrings(new String[]{"a"}, out);
- assertEquals("Expected to be at EOF",-1,br.read());
+ assertEquals(-1, br.read(), "Expected to be at EOF");
}
@Test
@@ -154,7 +154,7 @@
public void testHeader() {
final String HDR = "timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,"
+ "failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect";
- assertEquals("Header text has changed", HDR, CSVSaveService.printableFieldNamesToString());
+ assertEquals(HDR, CSVSaveService.printableFieldNamesToString(), "Header text has changed");
}
@Test
@@ -180,6 +180,6 @@
result.setIdleTime(13);
result.setConnectTime(14);
- assertEquals("Result text has changed", RESULT, CSVSaveService.resultToDelimitedString(new SampleEvent(result,"")));
+ assertEquals(RESULT, CSVSaveService.resultToDelimitedString(new SampleEvent(result,"")), "Result text has changed");
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java b/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java
index 1a8f191..ed4a10f 100644
--- a/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java
+++ b/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.testbeans.gui;
-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.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
@@ -52,32 +52,32 @@
}
private void testBooleanEditor(PropertyEditor propertyEditor) {
- assertNotNull("Expected to find property editor", propertyEditor);
+ assertNotNull(propertyEditor, "Expected to find property editor");
String[] tags = propertyEditor.getTags();
- assertEquals(2,tags.length);
- assertEquals(TRUE,tags[0]);
- assertEquals(FALSE,tags[1]);
+ assertEquals(2, tags.length);
+ assertEquals(TRUE, tags[0]);
+ assertEquals(FALSE, tags[1]);
propertyEditor.setValue(Boolean.FALSE);
- assertEquals(FALSE,propertyEditor.getAsText());
+ assertEquals(FALSE, propertyEditor.getAsText());
propertyEditor.setAsText(FALSE);
- assertEquals(FALSE,propertyEditor.getAsText());
+ assertEquals(FALSE, propertyEditor.getAsText());
propertyEditor.setAsText("false");
- assertEquals(FALSE,propertyEditor.getAsText());
+ assertEquals(FALSE, propertyEditor.getAsText());
propertyEditor.setAsText("False");
- assertEquals(FALSE,propertyEditor.getAsText());
+ assertEquals(FALSE, propertyEditor.getAsText());
propertyEditor.setAsText("FALSE");
- assertEquals(FALSE,propertyEditor.getAsText());
+ assertEquals(FALSE, propertyEditor.getAsText());
propertyEditor.setValue(Boolean.TRUE);
- assertEquals(TRUE,propertyEditor.getAsText());
+ assertEquals(TRUE, propertyEditor.getAsText());
propertyEditor.setAsText(TRUE);
- assertEquals(TRUE,propertyEditor.getAsText());
+ assertEquals(TRUE, propertyEditor.getAsText());
propertyEditor.setAsText("true");
- assertEquals(TRUE,propertyEditor.getAsText());
+ assertEquals(TRUE, propertyEditor.getAsText());
propertyEditor.setAsText("True");
- assertEquals(TRUE,propertyEditor.getAsText());
+ assertEquals(TRUE, propertyEditor.getAsText());
propertyEditor.setAsText("TRUE");
- assertEquals(TRUE,propertyEditor.getAsText());
+ assertEquals(TRUE, propertyEditor.getAsText());
}
}
diff --git a/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java b/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java
index 69433ea..c0aae9b 100644
--- a/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java
+++ b/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestComboStringEditor.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.testbeans.gui;
-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 org.junit.jupiter.api.Test;
diff --git a/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestFieldStringEditor.java b/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestFieldStringEditor.java
index b3732ce..573de5b 100644
--- a/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestFieldStringEditor.java
+++ b/src/core/src/test/java/org/apache/jmeter/testbeans/gui/TestFieldStringEditor.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.testbeans.gui;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
diff --git a/src/core/src/test/java/org/apache/jmeter/testelement/PackageTest.java b/src/core/src/test/java/org/apache/jmeter/testelement/PackageTest.java
index 1c5d6c8..5be8b41 100644
--- a/src/core/src/test/java/org/apache/jmeter/testelement/PackageTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/testelement/PackageTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.testelement;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.config.ConfigTestElement;
@@ -38,13 +38,13 @@
LoginConfig loginConfig = new LoginConfig();
loginConfig.setUsername("user1");
loginConfig.setPassword("pass1");
- assertTrue(config.getProperty("login") instanceof NullProperty);
+ assertInstanceOf(NullProperty.class, config.getProperty("login"));
// This test should work whether or not all Nulls are equal
assertEquals(new NullProperty("login"), config.getProperty("login"));
config.addProperty(new TestElementProperty("login", loginConfig));
assertEquals(loginConfig.toString(), config.getPropertyAsString("login"));
config.recoverRunningVersion();
- assertTrue(config.getProperty("login") instanceof NullProperty);
+ assertInstanceOf(NullProperty.class, config.getProperty("login"));
assertEquals(new NullProperty("login"), config.getProperty("login"));
}
diff --git a/src/core/src/test/java/org/apache/jmeter/testelement/TestNumberProperty.java b/src/core/src/test/java/org/apache/jmeter/testelement/TestNumberProperty.java
index b30f0e2..5e74a08 100644
--- a/src/core/src/test/java/org/apache/jmeter/testelement/TestNumberProperty.java
+++ b/src/core/src/test/java/org/apache/jmeter/testelement/TestNumberProperty.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.testelement;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.testelement.property.DoubleProperty;
import org.apache.jmeter.testelement.property.IntegerProperty;
diff --git a/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java b/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java
index a114203..fcd3a5f 100644
--- a/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java
+++ b/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java
@@ -17,6 +17,10 @@
package org.apache.jmeter.threads;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.time.Instant;
import org.apache.jmeter.control.LoopController;
@@ -27,7 +31,6 @@
import org.apache.jmeter.testelement.ThreadListener;
import org.apache.jmeter.timers.Timer;
import org.apache.jorphan.collections.HashTree;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class TestJMeterThread {
@@ -117,7 +120,7 @@
hashTree.add("Test", new ThrowingThreadListener(true));
JMeterThread.ThreadListenerTraverser traverser =
new JMeterThread.ThreadListenerTraverser(true);
- Assertions.assertThrows(
+ assertThrows(
NoClassDefFoundError.class,
() -> hashTree.traverse(traverser));
}
@@ -158,11 +161,11 @@
jMeterThread.run();
long duration = Instant.now().toEpochMilli() - startTime.toEpochMilli();
- Assertions.assertFalse(dummySampler.isCalled(), "Sampler should not be called");
+ assertFalse(dummySampler.isCalled(), "Sampler should not be called");
// the duration of this test plan should currently be around zero seconds,
// but it is allowed to take up to maxDuration amount of time
- Assertions.assertTrue(duration <= maxDuration, "Test plan should not run for longer than duration");
+ assertTrue(duration <= maxDuration, "Test plan should not run for longer than duration");
}
private LoopController createLoopController() {
diff --git a/src/core/src/test/java/org/apache/jmeter/threads/TestTestCompiler.java b/src/core/src/test/java/org/apache/jmeter/threads/TestTestCompiler.java
index 17ffcd4..cbc368b 100644
--- a/src/core/src/test/java/org/apache/jmeter/threads/TestTestCompiler.java
+++ b/src/core/src/test/java/org/apache/jmeter/threads/TestTestCompiler.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.threads;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.control.GenericController;
diff --git a/src/core/src/test/java/org/apache/jmeter/threads/TestUnmodifiableJMeterVariables.java b/src/core/src/test/java/org/apache/jmeter/threads/TestUnmodifiableJMeterVariables.java
index fef4df0..3a6b68b 100644
--- a/src/core/src/test/java/org/apache/jmeter/threads/TestUnmodifiableJMeterVariables.java
+++ b/src/core/src/test/java/org/apache/jmeter/threads/TestUnmodifiableJMeterVariables.java
@@ -18,6 +18,7 @@
package org.apache.jmeter.threads;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collections;
import java.util.HashMap;
@@ -25,7 +26,6 @@
import java.util.Map;
import org.hamcrest.CoreMatchers;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
@@ -109,7 +109,7 @@
}
private void assertThrowsUnsupportedOperation(Executable executable) {
- Assertions.assertThrows(
+ assertThrows(
UnsupportedOperationException.class,
executable
);
diff --git a/src/core/src/test/java/org/apache/jmeter/util/PackageTest.java b/src/core/src/test/java/org/apache/jmeter/util/PackageTest.java
index ada7aaa..9bfc457 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/PackageTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/PackageTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.util;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
diff --git a/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java b/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
index a87999e..aef5a00 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
@@ -17,6 +17,10 @@
package org.apache.jmeter.util;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.security.Provider;
@@ -24,7 +28,6 @@
import java.util.Arrays;
import java.util.Properties;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -37,8 +40,8 @@
void removeAllDummyProviders() {
Security.removeProvider(DummyProvider.PROVIDER_NAME);
Security.removeProvider(DummyProviderWithConfig.PROVIDER_NAME);
- Assert.assertNull(Security.getProvider(DummyProvider.PROVIDER_NAME));
- Assert.assertNull(Security.getProvider(DummyProviderWithConfig.PROVIDER_NAME));
+ assertNull(Security.getProvider(DummyProvider.PROVIDER_NAME));
+ assertNull(Security.getProvider(DummyProviderWithConfig.PROVIDER_NAME));
}
@Test
@@ -48,7 +51,7 @@
try {
privateConstructor.newInstance();
} catch (InvocationTargetException e) {
- Assert.assertEquals(IllegalStateException.class, e.getCause().getClass());
+ assertEquals(IllegalStateException.class, e.getCause().getClass());
}
}
@@ -63,10 +66,10 @@
Provider[] providersAfter = Security.getProviders();
Provider provider = Security.getProvider(DummyProvider.PROVIDER_NAME);
try {
- Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
- Assert.assertNotNull("Provider not installed.", provider);
- Assert.assertEquals(DummyProvider.class, provider.getClass());
- Assert.assertEquals(provider, providersAfter[providersAfter.length - 1]);
+ assertEquals(providersCountBefore + 1, providersAfter.length);
+ assertNotNull(provider, "Provider not installed.");
+ assertEquals(DummyProvider.class, provider.getClass());
+ assertEquals(provider, providersAfter[providersAfter.length - 1]);
} catch (AssertionError e){
Arrays.stream(providers).forEach(pro -> System.err.println(pro.getName()));
throw e;
@@ -83,10 +86,10 @@
Provider[] providersAfter = Security.getProviders();
Provider provider = Security.getProvider(DummyProvider.PROVIDER_NAME);
- Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
- Assert.assertNotNull("Provider not installed.", provider);
- Assert.assertEquals(DummyProvider.class, provider.getClass());
- Assert.assertEquals(provider, providersAfter[providersAfter.length - 1]);
+ assertEquals(providersCountBefore + 1, providersAfter.length);
+ assertNotNull(provider, "Provider not installed.");
+ assertEquals(DummyProvider.class, provider.getClass());
+ assertEquals(provider, providersAfter[providersAfter.length - 1]);
}
@ParameterizedTest
@@ -99,7 +102,7 @@
int providersCountAfter = Security.getProviders().length;
- Assert.assertEquals(providersCountBefore, providersCountAfter);
+ assertEquals(providersCountBefore, providersCountAfter);
}
@ParameterizedTest
@@ -113,10 +116,10 @@
Provider[] providersAfter = Security.getProviders();
Provider provider = Security.getProvider(DummyProvider.PROVIDER_NAME);
- Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
- Assert.assertNotNull(provider);
- Assert.assertEquals(DummyProvider.class, provider.getClass());
- Assert.assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
+ assertEquals(providersCountBefore + 1, providersAfter.length);
+ assertNotNull(provider);
+ assertEquals(DummyProvider.class, provider.getClass());
+ assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
}
private int expectedInsertPosition(int position, Provider[] providersAfter) {
@@ -137,11 +140,11 @@
Provider[] providersAfter = Security.getProviders();
Provider provider = Security.getProvider(DummyProviderWithConfig.PROVIDER_NAME);
- Assert.assertNotNull("Provider not installed.", provider);
- Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
- Assert.assertEquals(DummyProviderWithConfig.class, provider.getClass());
- Assert.assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
- Assert.assertEquals(config.substring(config.lastIndexOf(":") + 1), ((DummyProviderWithConfig) provider).getConfig());
+ assertNotNull(provider, "Provider not installed.");
+ assertEquals(providersCountBefore + 1, providersAfter.length);
+ assertEquals(DummyProviderWithConfig.class, provider.getClass());
+ assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
+ assertEquals(config.substring(config.lastIndexOf(":") + 1), ((DummyProviderWithConfig) provider).getConfig());
}
@Test
@@ -156,19 +159,19 @@
SecurityProviderLoader.addSecurityProvider(properties);
Provider[] providersAfter = Security.getProviders();
- Assert.assertEquals(providersCountBefore + 2, providersAfter.length);
+ assertEquals(providersCountBefore + 2, providersAfter.length);
Provider provider = Security.getProvider(DummyProvider.PROVIDER_NAME);
Provider providerWithConfig = Security.getProvider(DummyProviderWithConfig.PROVIDER_NAME);
- Assert.assertNotNull("Provider not installed.", provider);
- Assert.assertEquals(DummyProvider.class, provider.getClass());
- Assert.assertEquals(provider, providersAfter[0]);
+ assertNotNull(provider, "Provider not installed.");
+ assertEquals(DummyProvider.class, provider.getClass());
+ assertEquals(provider, providersAfter[0]);
- Assert.assertNotNull("Provider not installed.", providerWithConfig);
- Assert.assertEquals(DummyProviderWithConfig.class, providerWithConfig.getClass());
- Assert.assertEquals(providerWithConfig, providersAfter[1]);
- Assert.assertEquals("CONFIG", ((DummyProviderWithConfig) providerWithConfig).getConfig());
+ assertNotNull(providerWithConfig, "Provider not installed.");
+ assertEquals(DummyProviderWithConfig.class, providerWithConfig.getClass());
+ assertEquals(providerWithConfig, providersAfter[1]);
+ assertEquals("CONFIG", ((DummyProviderWithConfig) providerWithConfig).getConfig());
}
static class DummyProvider extends Provider {
diff --git a/src/core/src/test/java/org/apache/jmeter/util/StringUtilitiesTest.java b/src/core/src/test/java/org/apache/jmeter/util/StringUtilitiesTest.java
index 3fcfaaf..eeb1558 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/StringUtilitiesTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/StringUtilitiesTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.util;
-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 org.junit.jupiter.api.Test;
diff --git a/src/core/src/test/java/org/apache/jmeter/util/TestJMeterUtils.java b/src/core/src/test/java/org/apache/jmeter/util/TestJMeterUtils.java
index 4abbe45..03c72ef 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/TestJMeterUtils.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/TestJMeterUtils.java
@@ -17,14 +17,16 @@
package org.apache.jmeter.util;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TestJMeterUtils {
@@ -32,18 +34,18 @@
@Test
public void testGetResourceFileAsText() throws Exception{
String sep = System.getProperty("line.separator");
- Assertions.assertEquals("line one" + sep + "line two" + sep,
+ assertEquals("line one" + sep + "line two" + sep,
JMeterUtils.getResourceFileAsText("resourcefile.txt"));
}
@Test
public void testGetResourceFileAsTextWithMisingResource() throws Exception{
- Assertions.assertEquals("", JMeterUtils.getResourceFileAsText("not_existant_resourcefile.txt"));
+ assertEquals("", JMeterUtils.getResourceFileAsText("not_existant_resourcefile.txt"));
}
@Test
public void testGesResStringDefaultWithNonExistantKey() throws Exception {
- Assertions.assertEquals("[res_key=noValidKey]", JMeterUtils.getResString("noValidKey"));
+ assertEquals("[res_key=noValidKey]", JMeterUtils.getResString("noValidKey"));
}
@Test
@@ -53,25 +55,25 @@
JMeterUtils.getJMeterProperties().setProperty("testGetArrayPropDefaultEmpty", " ");
JMeterUtils.getJMeterProperties().setProperty("testGetArrayPropDefault",
" Tolstoi Dostoievski Pouchkine Gorki ");
- Assertions.assertArrayEquals(new String[]{"Tolstoi", "Dostoievski", "Pouchkine", "Gorki"},
+ assertArrayEquals(new String[]{"Tolstoi", "Dostoievski", "Pouchkine", "Gorki"},
JMeterUtils.getArrayPropDefault("testGetArrayPropDefault", null));
- Assertions.assertArrayEquals(new String[]{"Gilels", "Richter"},
+ assertArrayEquals(new String[]{"Gilels", "Richter"},
JMeterUtils.getArrayPropDefault("testGetArrayPropDefaultMissing",
new String[]{"Gilels", "Richter"}));
- Assertions.assertArrayEquals(null,
+ assertArrayEquals(null,
JMeterUtils.getArrayPropDefault("testGetArrayPropDefaultEmpty", null));
}
@Test
void testCompilePatternOK() {
Pattern pattern = JMeterUtils.compilePattern("some.*");
- Assertions.assertTrue(pattern.matcher("something").matches());
+ assertTrue(pattern.matcher("something").matches());
}
@Test
void testCompilePatternMultilineCaseIgnoreOK() {
Pattern pattern = JMeterUtils.compilePattern("^some.*g$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
- Assertions.assertTrue(pattern.matcher("abc\nsome good thing").find());
+ assertTrue(pattern.matcher("abc\nsome good thing").find());
}
@Test
diff --git a/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java b/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
index 5a719c8..3ebf8c2 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
@@ -18,8 +18,8 @@
package org.apache.jmeter.util;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
@@ -74,7 +74,7 @@
selector.setContextItem(p.newDocumentBuilder().build(new StreamSource(new StringReader(xmlDoc))));
XdmValue nodes = selector.evaluate();
XdmItem item = nodes.itemAt(0);
- assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>",item.toString());
+ assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>", item.toString());
}
@Test
@@ -86,41 +86,41 @@
int matchNumber = 3;
XPathUtil.putValuesForXPathInListUsingSaxon(xmlDoc, xPathQuery, matchStrings, fragment, matchNumber, namespaces);
- assertEquals("Manager",matchStrings.get(0));
+ assertEquals("Manager", matchStrings.get(0));
matchNumber = 0;
xPathQuery="//Employees/Employee[1]/age:ag";
fragment = true;
matchStrings.clear();
XPathUtil.putValuesForXPathInListUsingSaxon(xmlDoc, xPathQuery, matchStrings, fragment, matchNumber, namespaces);
- assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>",matchStrings.get(0));
- assertEquals(1,matchStrings.size());
+ assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>", matchStrings.get(0));
+ assertEquals(1, matchStrings.size());
matchNumber = -1;
xPathQuery="//Employees/Employee/age:ag";
matchStrings.clear();
XPathUtil.putValuesForXPathInListUsingSaxon(xmlDoc, xPathQuery, matchStrings, fragment, matchNumber, namespaces);
- assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>",matchStrings.get(0));
- assertEquals(4,matchStrings.size());
+ assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>", matchStrings.get(0));
+ assertEquals(4, matchStrings.size());
fragment = false;
matchStrings.clear();
XPathUtil.putValuesForXPathInListUsingSaxon(xmlDoc, xPathQuery, matchStrings, fragment, matchNumber, namespaces);
- assertEquals("29",matchStrings.get(0));
- assertEquals(4,matchStrings.size());
+ assertEquals("29", matchStrings.get(0));
+ assertEquals(4, matchStrings.size());
matchStrings.clear();
xPathQuery="regtsgwsdfstgsdf";
XPathUtil.putValuesForXPathInListUsingSaxon(xmlDoc, xPathQuery, matchStrings, fragment, matchNumber, namespaces);
- assertEquals(new ArrayList<String>(),matchStrings);
- assertEquals(0,matchStrings.size());
+ assertEquals(new ArrayList<String>(), matchStrings);
+ assertEquals(0, matchStrings.size());
matchStrings.clear();
xPathQuery="//Employees/Employee[1]/age:ag";
matchNumber = 555;
XPathUtil.putValuesForXPathInListUsingSaxon(xmlDoc, xPathQuery, matchStrings, fragment, matchNumber, namespaces);
- assertEquals(new ArrayList<String>(),matchStrings);
- assertEquals(0,matchStrings.size());
+ assertEquals(new ArrayList<String>(), matchStrings);
+ assertEquals(0, matchStrings.size());
}
static Stream<Arguments> namespaceData() {
@@ -140,7 +140,7 @@
@MethodSource("namespaceData")
public void testnamespacesParse(String namespaces, String key, String value, int position) {
List<String[]> test = XPathUtil.namespacesParse(namespaces);
- assertEquals(key,test.get(position)[0]);
+ assertEquals(key, test.get(position)[0]);
assertEquals(value, test.get(position)[1]);
}
@@ -203,8 +203,8 @@
false, false, false, false, false);
AssertionResult res = new AssertionResult("test");
XPathUtil.computeAssertionResult(res, testDoc, xpathquery, isNegated);
- assertEquals("test isError", isError, res.isError());
- assertEquals("test isFailure", isFailure, res.isFailure());
+ assertEquals(isError, res.isError(), "test isError");
+ assertEquals(isFailure, res.isFailure(), "test isFailure");
}
@Test
diff --git a/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java b/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java
index aa47eed..799568a 100644
--- a/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java
+++ b/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java
@@ -17,7 +17,8 @@
package org.apache.jorphan.reflect;
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Map;
@@ -100,13 +101,13 @@
Test1 t1 = new Test1("t1");
Test2 t2 = new Test2("t2");
Test1a t1a = new Test1a("aa");
- assertEquals("t1",f1.invoke(t1));
+ assertEquals("t1", f1.invoke(t1));
assertThrows(JMeterError.class, () -> f1.invoke(t2));
- assertEquals("t2",f2.invoke(t2));
- assertEquals("1a:aa.",f1a.invoke(t1a));
+ assertEquals("t2", f2.invoke(t2));
+ assertEquals("1a:aa.", f1a.invoke(t1a));
assertThrows(JMeterError.class, () -> f1a.invoke(t1));
// OK (currently) to invoke using sub-class
- assertEquals("1a:aa.",f1.invoke(t1a));
+ assertEquals("1a:aa.", f1.invoke(t1a));
}
@Test
@@ -114,9 +115,9 @@
Functor f = new Functor("getString",new Class[]{String.class});
Functor f2 = new Functor("getString");// Args will be provided later
Test1 t1 = new Test1("t1");
- assertEquals("x1",f.invoke(t1,new String[]{"x1"}));
+ assertEquals("x1", f.invoke(t1,new String[]{"x1"}));
assertThrows(JMeterError.class, () -> f.invoke(t1));
- assertEquals("x2",f2.invoke(t1,new String[]{"x2"}));
+ assertEquals("x2", f2.invoke(t1,new String[]{"x2"}));
assertThrows(JMeterError.class, () -> f2.invoke(t1));
}
@@ -125,8 +126,8 @@
Test1 t1 = new Test1("t1");
Test2 t2 = new Test2("t2");
Functor f1 = new Functor(t1,"getName");
- assertEquals("t1",f1.invoke(t1));
- assertEquals("t1",f1.invoke(t2)); // should use original object
+ assertEquals("t1", f1.invoke(t1));
+ assertEquals("t1", f1.invoke(t2)); // should use original object
}
// Check how Class definition behaves
@@ -136,23 +137,23 @@
Test1 t1a = new Test1a("t1a");
Test2 t2 = new Test2("t2");
Functor f1 = new Functor(HasName.class,"getName");
- assertEquals("t1",f1.invoke(t1));
- assertEquals("1a:t1a.",f1.invoke(t1a));
- assertEquals("t2",f1.invoke(t2));
+ assertEquals("t1", f1.invoke(t1));
+ assertEquals("1a:t1a.", f1.invoke(t1a));
+ assertEquals("t2", f1.invoke(t2));
assertThrows(IllegalStateException.class, () -> f1.invoke());
Functor f2 = new Functor(HasString.class,"getString");
- assertEquals("xyz",f2.invoke(t2,new String[]{"xyz"}));
+ assertEquals("xyz", f2.invoke(t2,new String[]{"xyz"}));
assertThrows(JMeterError.class, () -> f2.invoke(t1,new String[]{"xyz"}));
Functor f3 = new Functor(t2,"getString");
- assertEquals("xyz",f3.invoke(t2,new Object[]{"xyz"}));
+ assertEquals("xyz", f3.invoke(t2,new Object[]{"xyz"}));
Properties p = new Properties();
p.put("Name","Value");
Functor fk = new Functor(Map.Entry.class,"getKey");
Functor fv = new Functor(Map.Entry.class,"getValue");
Object o = p.entrySet().iterator().next();
- assertEquals("Name",fk.invoke(o));
- assertEquals("Value",fv.invoke(o));
+ assertEquals("Name", fk.invoke(o));
+ assertEquals("Value", fv.invoke(o));
}
@Test
diff --git a/src/core/src/testFixtures/java/org/apache/jmeter/junit/JMeterTestCase.java b/src/core/src/testFixtures/java/org/apache/jmeter/junit/JMeterTestCase.java
index ebf7ade..475b012 100644
--- a/src/core/src/testFixtures/java/org/apache/jmeter/junit/JMeterTestCase.java
+++ b/src/core/src/testFixtures/java/org/apache/jmeter/junit/JMeterTestCase.java
@@ -17,6 +17,7 @@
package org.apache.jmeter.junit;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
@@ -144,7 +145,7 @@
}
public static void assertPrimitiveEquals(boolean expected, boolean actual) {
- org.junit.Assert.assertEquals(expected, actual);
+ assertEquals(expected, actual);
}
/**
diff --git a/src/core/src/testFixtures/java/org/apache/jmeter/resources/ResourceKeyUsageTest.java b/src/core/src/testFixtures/java/org/apache/jmeter/resources/ResourceKeyUsageTest.java
index 92308c1..c8b4b63 100644
--- a/src/core/src/testFixtures/java/org/apache/jmeter/resources/ResourceKeyUsageTest.java
+++ b/src/core/src/testFixtures/java/org/apache/jmeter/resources/ResourceKeyUsageTest.java
@@ -17,6 +17,10 @@
package org.apache.jmeter.resources;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -31,7 +35,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ResourceKeyUsageTest {
@@ -52,7 +55,7 @@
void checkResourceReferences() throws Exception {
String resourceName = "/org/apache/jmeter/resources/messages.properties";
PropertyResourceBundle messagePRB = getRAS(resourceName);
- Assertions.assertNotNull(resourceName, () -> "Resource bundle " + resourceName + " was not found");
+ assertNotNull(resourceName, () -> "Resource bundle " + resourceName + " was not found");
List<String> failures = new ArrayList<>();
final List<Exception> exceptions = new ArrayList<>();
@@ -91,10 +94,10 @@
}
return file.isDirectory();
});
- Assertions.assertTrue(exceptions.isEmpty());
+ assertTrue(exceptions.isEmpty());
if (failures.isEmpty()) {
return;
}
- Assertions.fail(() -> String.join("\n", failures));
+ fail(String.join("\n", failures));
}
}
diff --git a/src/core/src/testFixtures/java/org/apache/jmeter/threads/TestJMeterContextService.java b/src/core/src/testFixtures/java/org/apache/jmeter/threads/TestJMeterContextService.java
index 173bfc9..019eafe 100644
--- a/src/core/src/testFixtures/java/org/apache/jmeter/threads/TestJMeterContextService.java
+++ b/src/core/src/testFixtures/java/org/apache/jmeter/threads/TestJMeterContextService.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.threads;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
diff --git a/src/dist-check/src/test/java/org/apache/jmeter/control/TestSwitchController.java b/src/dist-check/src/test/java/org/apache/jmeter/control/TestSwitchController.java
index dfc9b63..246c803 100644
--- a/src/dist-check/src/test/java/org/apache/jmeter/control/TestSwitchController.java
+++ b/src/dist-check/src/test/java/org/apache/jmeter/control/TestSwitchController.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.control;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.HashMap;
import java.util.Map;
@@ -124,11 +124,11 @@
controller.initialize();
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop " + i, "before", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop " + i);
if (exp != null) {
- assertEquals("Loop " + i, exp, nextName(controller));
+ assertEquals(exp, nextName(controller), "Loop " + i);
}
- assertEquals("Loop " + i, "after", nextName(controller));
+ assertEquals("after", nextName(controller), "Loop " + i);
assertNull(nextName(controller));
}
}
@@ -171,12 +171,12 @@
controller.addTestElement(new TestSampler("after"));
controller.initialize();
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop=" + i, "before", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop=" + i);
if (exp != null) {
- assertEquals("Loop=" + i, exp, nextName(controller));
+ assertEquals(exp, nextName(controller), "Loop=" + i);
}
- assertEquals("Loop=" + i, "after", nextName(controller));
- assertNull("Loop=" + i, nextName(controller));
+ assertEquals("after", nextName(controller), "Loop=" + i);
+ assertNull(nextName(controller), "Loop=" + i);
}
}
@@ -243,13 +243,13 @@
switch_cont.setRunningVersion(true);
controller.initialize();
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop:" + i, "before", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop:" + i);
for (String anExp : exp) {
- assertEquals("Loop:" + i, anExp, nextName(controller));
+ assertEquals(anExp, nextName(controller), "Loop:" + i);
}
- assertEquals("Loop:" + i, "after", nextName(controller));
+ assertEquals("after", nextName(controller), "Loop:" + i);
}
- assertNull("Loops:" + loops, nextName(controller));
+ assertNull(nextName(controller), "Loops:" + loops);
}
/*
@@ -288,17 +288,17 @@
assertEquals("100", jmvars.get("VAR"));
for (int i = 1; i <= 3; i++) {
- assertEquals("Loop " + i, "before", nextName(controller));
- assertEquals("Loop " + i, "" + i, nextName(controller));
- assertEquals("Loop " + i, "" + i, jmvars.get("VAR"));
- assertEquals("Loop " + i, "after", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop " + i);
+ assertEquals("" + i, nextName(controller), "Loop " + i);
+ assertEquals("" + i, jmvars.get("VAR"), "Loop " + i);
+ assertEquals("after", nextName(controller), "Loop " + i);
assertNull(nextName(controller));
}
int i = 4;
- assertEquals("Loop " + i, "before", nextName(controller));
- assertEquals("Loop " + i, "0", nextName(controller));
- assertEquals("Loop " + i, "" + i, jmvars.get("VAR"));
- assertEquals("Loop " + i, "after", nextName(controller));
+ assertEquals("before", nextName(controller), "Loop " + i);
+ assertEquals("0", nextName(controller), "Loop " + i);
+ assertEquals("" + i, jmvars.get("VAR"), "Loop " + i);
+ assertEquals("after", nextName(controller), "Loop " + i);
assertNull(nextName(controller));
assertEquals("4", jmvars.get("VAR"));
}
diff --git a/src/dist-check/src/test/java/org/apache/jmeter/resources/TestPropertiesFiles.java b/src/dist-check/src/test/java/org/apache/jmeter/resources/TestPropertiesFiles.java
index bcae474..db4487b 100644
--- a/src/dist-check/src/test/java/org/apache/jmeter/resources/TestPropertiesFiles.java
+++ b/src/dist-check/src/test/java/org/apache/jmeter/resources/TestPropertiesFiles.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.resources;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileInputStream;
@@ -34,7 +34,7 @@
@Test
public void testUserProperties() throws Exception {
Properties props = loadProps(new File(JMeterUtils.getJMeterBinDir(), "user.properties"));
- assertTrue("user.properties should not contain any enabled properties", props.isEmpty());
+ assertTrue(props.isEmpty(), "user.properties should not contain any enabled properties");
}
// The keys in jmeter.properties and reportgenerator.properties should be distinct
@@ -45,12 +45,12 @@
Enumeration<?> jmeterNames = jmeter.propertyNames();
while (jmeterNames.hasMoreElements()) {
final Object key = jmeterNames.nextElement();
- assertFalse("reportgenerator should not contain the jmeter key " + key, report.containsKey(key));
+ assertFalse(report.containsKey(key), "reportgenerator should not contain the jmeter key " + key);
}
Enumeration<?> reportNames = report.propertyNames();
while (reportNames.hasMoreElements()) {
final Object key = reportNames.nextElement();
- assertFalse("jmeter should not contain the reportgenerator key " + key, jmeter.containsKey(key));
+ assertFalse(jmeter.containsKey(key), "jmeter should not contain the reportgenerator key " + key);
}
}
diff --git a/src/dist-check/src/test/java/org/apache/jmeter/save/TestSaveService.java b/src/dist-check/src/test/java/org/apache/jmeter/save/TestSaveService.java
index 6a64173..0f08f23 100644
--- a/src/dist-check/src/test/java/org/apache/jmeter/save/TestSaveService.java
+++ b/src/dist-check/src/test/java/org/apache/jmeter/save/TestSaveService.java
@@ -17,9 +17,10 @@
package org.apache.jmeter.save;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -86,8 +87,10 @@
@Test
public void testPROPVERSION() {
assertEquals(
- "Property Version mismatch, ensure you update SaveService#PROPVERSION field with _version property value from saveservice.properties",
- SaveService.PROPVERSION, SaveService.getPropertyVersion());
+ SaveService.PROPVERSION,
+ SaveService.getPropertyVersion(),
+ "Property Version mismatch, ensure you update SaveService#PROPVERSION field with _version property value from saveservice.properties"
+ );
}
@Test
diff --git a/src/dist-check/src/test/java/org/apache/jorphan/TestFunctorUsers.java b/src/dist-check/src/test/java/org/apache/jorphan/TestFunctorUsers.java
index 458f77d..4d0394d 100644
--- a/src/dist-check/src/test/java/org/apache/jorphan/TestFunctorUsers.java
+++ b/src/dist-check/src/test/java/org/apache/jorphan/TestFunctorUsers.java
@@ -17,7 +17,7 @@
package org.apache.jorphan;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.config.gui.ArgumentsPanel;
import org.apache.jmeter.junit.JMeterTestCase;
@@ -35,37 +35,37 @@
@Test
@SuppressWarnings("deprecation")
public void testSummaryReport() throws Exception {
- assertTrue("SummaryReport Functor", SummaryReport.testFunctors());
+ assertTrue(SummaryReport.testFunctors(), "SummaryReport Functor");
}
@Test
public void testTableVisualizer() throws Exception {
- assertTrue("TableVisualizer Functor", TableVisualizer.testFunctors());
+ assertTrue(TableVisualizer.testFunctors(), "TableVisualizer Functor");
}
@Test
public void testStatGraphVisualizer() throws Exception {
- assertTrue("StatGraphVisualizer Functor", StatGraphVisualizer.testFunctors());
+ assertTrue(StatGraphVisualizer.testFunctors(), "StatGraphVisualizer Functor");
}
@Test
@SuppressWarnings("deprecation")
public void testStatVisualizer() throws Exception {
- assertTrue("StatVisualizer Functor", StatVisualizer.testFunctors());
+ assertTrue(StatVisualizer.testFunctors(), "StatVisualizer Functor");
}
@Test
public void testArgumentsPanel() throws Exception {
- assertTrue("ArgumentsPanel Functor", ArgumentsPanel.testFunctors());
+ assertTrue(ArgumentsPanel.testFunctors(), "ArgumentsPanel Functor");
}
@Test
public void testHTTPArgumentsPanel() throws Exception {
- assertTrue("HTTPArgumentsPanel Functor", HTTPArgumentsPanel.testFunctors());
+ assertTrue(HTTPArgumentsPanel.testFunctors(), "HTTPArgumentsPanel Functor");
}
@Test
public void testLDAPArgumentsPanel() throws Exception {
- assertTrue("LDAPArgumentsPanel Functor", LDAPArgumentsPanel.testFunctors());
+ assertTrue(LDAPArgumentsPanel.testFunctors(), "LDAPArgumentsPanel Functor");
}
}
diff --git a/src/dist-check/src/test/java/org/apache/jorphan/reflect/TestClassFinder.java b/src/dist-check/src/test/java/org/apache/jorphan/reflect/TestClassFinder.java
index a035d32..182bfd1 100644
--- a/src/dist-check/src/test/java/org/apache/jorphan/reflect/TestClassFinder.java
+++ b/src/dist-check/src/test/java/org/apache/jorphan/reflect/TestClassFinder.java
@@ -17,17 +17,18 @@
package org.apache.jorphan.reflect;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;
-import java.util.stream.Collectors;
import org.apache.jmeter.junit.JMeterTestUtils;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.logging.log4j.LoggingException;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -62,8 +63,7 @@
libDirs,
new Class<?>[] { Object.class },
true);
- Assert.assertFalse(
- findClassesThatExtend.stream().filter(s -> s.contains("$")).collect(Collectors.toList()).isEmpty());
+ assertFalse(findClassesThatExtend.stream().noneMatch(s -> s.contains("$")));
}
@Test
@@ -73,8 +73,7 @@
libDirs,
new Class<?>[] { Exception.class },
false);
- Assert.assertTrue(
- findClassesThatExtend.stream().filter(s -> s.contains("$")).collect(Collectors.toList()).isEmpty());
+ assertTrue(findClassesThatExtend.stream().noneMatch(s -> s.contains("$")));
MatcherAssert.assertThat(findClassesThatExtend, CoreMatchers.hasItem(LoggingException.class.getName()));
}
@@ -87,9 +86,8 @@
false,
"org.apache.log",
"core");
- Assert.assertTrue(
- findClassesThatExtend.stream().filter(s -> s.contains("core")).collect(Collectors.toList()).isEmpty());
- Assert.assertFalse(findClassesThatExtend.isEmpty());
+ assertTrue(findClassesThatExtend.stream().noneMatch(s -> s.contains("core")));
+ assertFalse(findClassesThatExtend.isEmpty());
}
@Test
@@ -102,7 +100,7 @@
null,
null,
true);
- Assert.assertFalse(annotatedClasses.isEmpty());
+ assertFalse(annotatedClasses.isEmpty());
}
@Test
@@ -111,7 +109,7 @@
List<String> annotatedClasses = ClassFinder.findAnnotatedClasses(
libDirs,
new Class[] { java.beans.Transient.class});
- Assert.assertFalse(annotatedClasses.isEmpty());
+ assertFalse(annotatedClasses.isEmpty());
}
@Test
@@ -119,21 +117,21 @@
@SuppressWarnings({"deprecation", "unchecked"})
List<String> annotatedClasses = ClassFinder.findAnnotatedClasses(libDirs,
new Class[] { java.lang.Deprecated.class}, true);
- Assert.assertTrue(annotatedClasses.stream().anyMatch(s->s.contains("$")));
+ assertTrue(annotatedClasses.stream().anyMatch(s->s.contains("$")));
}
@Test
public void testFindClasses() throws IOException {
@SuppressWarnings("deprecation")
List<String> classes = ClassFinder.findClasses(libDirs, className -> true);
- Assert.assertFalse(classes.isEmpty());
+ assertFalse(classes.isEmpty());
}
@Test
public void testFindClassesNone() throws IOException {
@SuppressWarnings("deprecation")
List<String> classes = ClassFinder.findClasses(libDirs, className -> false);
- Assert.assertTrue(classes.isEmpty());
+ assertTrue(classes.isEmpty());
}
}
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/EvalFunctionTest.java b/src/functions/src/test/java/org/apache/jmeter/functions/EvalFunctionTest.java
index 3b4eba6..85c1bf4 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/EvalFunctionTest.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/EvalFunctionTest.java
@@ -18,7 +18,7 @@
package org.apache.jmeter.functions;
import static org.apache.jmeter.functions.FunctionTestHelper.makeParams;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collection;
@@ -54,7 +54,7 @@
parms = makeParams("${query}",null,null);
eval.setParameters(parms);
s = eval.execute(null,null);
- assertEquals("select name from customers",s);
+ assertEquals("select name from customers", s);
}
@Test
@@ -69,6 +69,6 @@
parms = makeParams("query",null,null);
evalVar.setParameters(parms);
s = evalVar.execute(null,null);
- assertEquals("select name from customers",s);
+ assertEquals("select name from customers", s);
}
}
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/RandomFunctionTest.java b/src/functions/src/test/java/org/apache/jmeter/functions/RandomFunctionTest.java
index ba9dd23..31178e1 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/RandomFunctionTest.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/RandomFunctionTest.java
@@ -18,8 +18,9 @@
package org.apache.jmeter.functions;
import static org.apache.jmeter.functions.FunctionTestHelper.makeParams;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collection;
import java.util.HashSet;
@@ -30,7 +31,6 @@
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -70,9 +70,9 @@
Collection<CompoundVariable> parms = makeParams("10","abcdefghijklmnopqrstuvwxyz","VAR");
r.setParameters(parms);
String s = r.execute(null,null);
- Assert.assertNotNull(s);
+ assertNotNull(s);
assertEquals(10, s.length());
- assertTrue("Random String contains unexpected character", stringOnlyContainsChars(s, "abcdefghijklmnopqrstuvwxyz"));
+ assertTrue(stringOnlyContainsChars(s, "abcdefghijklmnopqrstuvwxyz"), "Random String contains unexpected character");
String varValue = JMeterContextService.getContext().getVariables().get("VAR");
assertEquals(s, varValue);
@@ -80,7 +80,7 @@
parms = makeParams("5","", "VAR2");
r.setParameters(parms);
s = r.execute(null,null);
- Assert.assertNotNull(s);
+ assertNotNull(s);
assertEquals(5, s.length());
varValue = JMeterContextService.getContext().getVariables().get("VAR2");
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestFileRowColContainer.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestFileRowColContainer.java
index 07fbfe8..fb4663e 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestFileRowColContainer.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestFileRowColContainer.java
@@ -17,10 +17,8 @@
package org.apache.jmeter.functions;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
@@ -31,6 +29,7 @@
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.test.JMeterSerialTest;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -60,7 +59,7 @@
public void testrowNum() throws Exception {
FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/unit/TestFileRowColContainer.csv"));
assertNotNull(f);
- assertEquals("Expected 4 lines", 4, f.getSize());
+ assertEquals(4, f.getSize(), "Expected 4 lines");
assertEquals(0, f.nextRow());
assertEquals(1, f.nextRow());
@@ -73,7 +72,7 @@
public void testRowNumRelative() throws Exception {
FileRowColContainer f = new FileRowColContainer("testfiles/unit/TestFileRowColContainer.csv");
assertNotNull(f);
- assertEquals("Expected 4 lines", 4, f.getSize());
+ assertEquals(4, f.getSize(), "Expected 4 lines");
assertEquals(0, f.nextRow());
assertEquals(1, f.nextRow());
@@ -86,7 +85,7 @@
public void testColumns() throws Exception {
FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/unit/TestFileRowColContainer.csv"));
assertNotNull(f);
- assertTrue("Not empty", f.getSize() > 0);
+ Assertions.assertTrue(f.getSize() > 0, "Not empty");
int myRow = f.nextRow();
assertEquals(0, myRow);
@@ -95,7 +94,7 @@
try {
f.getColumn(myRow, 4);
- fail("Expected out of bounds");
+ Assertions.fail("Expected out of bounds");
} catch (IndexOutOfBoundsException e) {
}
myRow = f.nextRow();
@@ -108,7 +107,7 @@
public void testColumnsComma() throws Exception {
FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/unit/TestFileRowColContainer.csv"), ",");
assertNotNull(f);
- assertTrue("Not empty", f.getSize() > 0);
+ Assertions.assertTrue(f.getSize() > 0, "Not empty");
int myRow = f.nextRow();
assertEquals(0, myRow);
@@ -117,7 +116,7 @@
try {
f.getColumn(myRow, 4);
- fail("Expected out of bounds");
+ Assertions.fail("Expected out of bounds");
} catch (IndexOutOfBoundsException e) {
}
myRow = f.nextRow();
@@ -130,7 +129,7 @@
public void testColumnsTab() throws Exception {
FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/test.tsv"), "\t");
assertNotNull(f);
- assertTrue("Not empty", f.getSize() > 0);
+ Assertions.assertTrue(f.getSize() > 0, "Not empty");
int myRow = f.nextRow();
assertEquals(0, myRow);
@@ -139,7 +138,7 @@
try {
f.getColumn(myRow, 4);
- fail("Expected out of bounds");
+ Assertions.fail("Expected out of bounds");
} catch (IndexOutOfBoundsException e) {
}
myRow = f.nextRow();
@@ -152,7 +151,7 @@
public void testEmptyCols() throws Exception {
FileRowColContainer f = new FileRowColContainer(findTestPath("testfiles/testempty.csv"));
assertNotNull(f);
- assertEquals("Expected 4 lines", 4, f.getSize());
+ assertEquals(4, f.getSize(), "Expected 4 lines");
int myRow = f.nextRow();
assertEquals(0, myRow);
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestFileToString.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestFileToString.java
index 634482c..cd28738 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestFileToString.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestFileToString.java
@@ -17,7 +17,8 @@
package org.apache.jmeter.functions;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.util.ArrayList;
@@ -30,7 +31,6 @@
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -74,7 +74,7 @@
params.add(new CompoundVariable(file.getAbsolutePath()));
function.setParameters(params);
String returnValue = function.execute(result, null);
- Assert.assertTrue(returnValue.indexOf("language=")>0);
+ assertTrue(returnValue.indexOf("language=")>0);
}
@Test
@@ -84,7 +84,7 @@
params.add(new CompoundVariable("UTF-8"));
function.setParameters(params);
String returnValue = function.execute(result, null);
- Assert.assertTrue(returnValue.indexOf("language=")>0);
+ assertTrue(returnValue.indexOf("language=")>0);
}
@Test
@@ -95,7 +95,7 @@
params.add(new CompoundVariable("MY_FILE_AS_TEXT"));
function.setParameters(params);
String returnValue = function.execute(result, null);
- Assert.assertTrue(returnValue.indexOf("language=")>0);
- Assert.assertTrue(vars.get("MY_FILE_AS_TEXT").indexOf("language=")>0);
+ assertTrue(returnValue.indexOf("language=")>0);
+ assertTrue(vars.get("MY_FILE_AS_TEXT").indexOf("language=")>0);
}
}
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestGroovyFunction.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestGroovyFunction.java
index a8e5a28..cca2e07 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestGroovyFunction.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestGroovyFunction.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.functions;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestIsPropDefined.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestIsPropDefined.java
index 297fc90..ffc8a2a 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestIsPropDefined.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestIsPropDefined.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.functions;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestRegexFunction.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestRegexFunction.java
index 4fd7f19..0713711 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestRegexFunction.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestRegexFunction.java
@@ -17,8 +17,9 @@
package org.apache.jmeter.functions;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collection;
import java.util.stream.Collectors;
@@ -30,7 +31,6 @@
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -389,7 +389,7 @@
"",
"No Value Found");
variable.setParameters(params);
- Assertions.assertThrows(
+ assertThrows(
Exception.class,
() -> variable.execute(result, null));
}
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestSetProperty.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestSetProperty.java
index 7a1e714..40f4200 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestSetProperty.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestSetProperty.java
@@ -17,7 +17,8 @@
package org.apache.jmeter.functions;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.ArrayList;
import java.util.Collection;
@@ -30,7 +31,6 @@
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.test.JMeterSerialTest;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -78,7 +78,7 @@
function.setParameters(params);
String returnValue = function.execute(result, null);
assertEquals("value1", JMeterUtils.getProperty("prop1"));
- Assert.assertNull(returnValue);
+ assertNull(returnValue);
params.clear();
params.add(new CompoundVariable("prop1"));
diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/VariableTest.java b/src/functions/src/test/java/org/apache/jmeter/functions/VariableTest.java
index 1fc4541..9dfd907 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/VariableTest.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/VariableTest.java
@@ -18,7 +18,7 @@
package org.apache.jmeter.functions;
import static org.apache.jmeter.functions.FunctionTestHelper.makeParams;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collection;
@@ -56,46 +56,46 @@
parms = makeParams("V",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("A",s);
+ assertEquals("A", s);
parms = makeParams("V","DEFAULT",null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("A",s);
+ assertEquals("A", s);
parms = makeParams("EMPTY","DEFAULT",null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("DEFAULT",s);
+ assertEquals("DEFAULT", s);
parms = makeParams("X",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("X",s);
+ assertEquals("X", s);
parms = makeParams("A${X}",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("A${X}",s);
+ assertEquals("A${X}", s);
parms = makeParams("A_1",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("a1",s);
+ assertEquals("a1", s);
parms = makeParams("A_2",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("a2",s);
+ assertEquals("a2", s);
parms = makeParams("A_${two}",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("a2",s);
+ assertEquals("a2", s);
parms = makeParams("${V}_${one}",null,null);
r.setParameters(parms);
s = r.execute(null,null);
- assertEquals("a1",s);
+ assertEquals("a1", s);
}
}
diff --git a/src/jorphan/src/test/java/org/apache/commons/cli/avalon/ClutilTestCase.java b/src/jorphan/src/test/java/org/apache/commons/cli/avalon/ClutilTestCase.java
index a2a7548..3720bf1 100644
--- a/src/jorphan/src/test/java/org/apache/commons/cli/avalon/ClutilTestCase.java
+++ b/src/jorphan/src/test/java/org/apache/commons/cli/avalon/ClutilTestCase.java
@@ -17,9 +17,9 @@
package org.apache.commons.cli.avalon;
-import static org.junit.Assert.assertEquals;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.List;
@@ -120,11 +120,11 @@
final List<CLOption> clOptions = parser.getArguments();
final int size = clOptions.size();
- assertEquals("Option count", 3, size);
+ assertEquals(3, size, "Option count");
final CLOption option0 = clOptions.get(0);
- assertEquals("Option Code: " + option0.getDescriptor().getId(), TAINT_OPT, option0.getDescriptor().getId());
- assertEquals("Option Arg: " + option0.getArgument(0), null, option0.getArgument(0));
+ assertEquals(TAINT_OPT, option0.getDescriptor().getId(), "Option Code: " + option0.getDescriptor().getId());
+ assertNull(option0.getArgument(0), "Option Arg: " + option0.getArgument(0));
final CLOption option1 = clOptions.get(1);
assertEquals(option1.getDescriptor().getId(), CLOption.TEXT_ARGUMENT);
@@ -132,7 +132,7 @@
final CLOption option2 = clOptions.get(2);
assertEquals(option2.getDescriptor().getId(), ALL_OPT);
- assertEquals(option2.getArgument(0), null);
+ assertNull(option2.getArgument(0));
}
@Test
@@ -149,11 +149,11 @@
final List<CLOption> clOptions = parser.getArguments();
final int size = clOptions.size();
- assertEquals("Option count", 3, size);
+ assertEquals(3, size, "Option count");
final CLOption option0 = clOptions.get(0);
- assertEquals("Option Code: " + option0.getDescriptor().getId(), TAINT_OPT, option0.getDescriptor().getId());
- assertEquals("Option Arg: " + option0.getArgument(0), null, option0.getArgument(0));
+ assertEquals(TAINT_OPT, option0.getDescriptor().getId(), "Option Code: " + option0.getDescriptor().getId());
+ assertNull(option0.getArgument(0), "Option Arg: " + option0.getArgument(0));
final CLOption option1 = clOptions.get(1);
assertEquals(CLOption.TEXT_ARGUMENT, option1.getDescriptor().getId());
@@ -161,7 +161,7 @@
final CLOption option2 = clOptions.get(2);
assertEquals(option2.getDescriptor().getId(), ALL_OPT);
- assertEquals(option2.getArgument(0), null);
+ assertNull(option2.getArgument(0));
}
@Test
@@ -178,15 +178,15 @@
final List<CLOption> clOptions = parser.getArguments();
final int size = clOptions.size();
- assertEquals("Option count", 2, size);
+ assertEquals(2, size, "Option count");
final CLOption option0 = clOptions.get(0);
- assertEquals("Option Code: " + option0.getDescriptor().getId(), TAINT_OPT, option0.getDescriptor().getId());
- assertEquals("Option Arg: " + option0.getArgument(0), "param", option0.getArgument(0));
+ assertEquals(TAINT_OPT, option0.getDescriptor().getId(), "Option Code: " + option0.getDescriptor().getId());
+ assertEquals("param", option0.getArgument(0), "Option Arg: " + option0.getArgument(0));
final CLOption option2 = clOptions.get(1);
assertEquals(option2.getDescriptor().getId(), ALL_OPT);
- assertEquals(option2.getArgument(0), null);
+ assertNull(option2.getArgument(0));
}
@Test
@@ -202,15 +202,15 @@
final List<CLOption> clOptions = parser.getArguments();
final int size = clOptions.size();
- assertEquals("Option count", 2, size);
+ assertEquals(2, size, "Option count");
final CLOption option0 = clOptions.get(0);
- assertEquals("Option Code: " + option0.getDescriptor().getId(), TAINT_OPT, option0.getDescriptor().getId());
- assertEquals("Option Arg: " + option0.getArgument(0), null, option0.getArgument(0));
+ assertEquals(TAINT_OPT, option0.getDescriptor().getId(), "Option Code: " + option0.getDescriptor().getId());
+ assertNull(option0.getArgument(0), "Option Arg: " + option0.getArgument(0));
final CLOption option1 = clOptions.get(1);
assertEquals(option1.getDescriptor().getId(), ALL_OPT);
- assertEquals(option1.getArgument(0), null);
+ assertNull(option1.getArgument(0));
}
@Test
@@ -234,7 +234,7 @@
final CLOption option1 = clOptions.get(1);
assertEquals(ALL_OPT, option1.getDescriptor().getId());
- assertEquals(null, option1.getArgument(0));
+ assertNull(option1.getArgument(0));
}
@Test
@@ -258,7 +258,7 @@
final CLOption option1 = clOptions.get(1);
assertEquals(ALL_OPT, option1.getDescriptor().getId());
- assertEquals(null, option1.getArgument(0));
+ assertNull(option1.getArgument(0));
}
@Test
@@ -278,11 +278,11 @@
assertEquals(size, 2);
final CLOption option0 = clOptions.get(0);
assertEquals(TAINT_OPT, option0.getDescriptor().getId());
- assertEquals(null, option0.getArgument(0));
+ assertNull(option0.getArgument(0));
final CLOption option1 = clOptions.get(1);
assertEquals(ALL_OPT, option1.getDescriptor().getId());
- assertEquals(null, option1.getArgument(0));
+ assertNull(option1.getArgument(0));
}
@Test
@@ -734,7 +734,7 @@
assertEquals(clOptions1.get(2).getDescriptor().getId(), ALL_OPT);
assertEquals(clOptions1.get(3).getDescriptor().getId(), CLEAR1_OPT);
- assertEquals("ler",parser1.getUnparsedArgs()[0]);
+ assertEquals("ler", parser1.getUnparsedArgs()[0]);
final CLArgsParser parser2 = new CLArgsParser(parser1.getUnparsedArgs(), options2);
@@ -861,7 +861,7 @@
assertEquals('n', optionByID.getDescriptor().getId());
final CLOption optionByName = parser.getArgumentByName(FILE.getName());
- assertNull("Looking for non-existent option by name", optionByName);
+ assertNull(optionByName, "Looking for non-existent option by name");
}
/**
@@ -884,7 +884,7 @@
final StringBuilder sb = CLUtil.describeOptions(options);
final String lineSeparator = System.getProperty("line.separator");
- assertEquals("Testing display of null description", "\t-n, --nulltest" + lineSeparator, sb.toString());
+ assertEquals("\t-n, --nulltest" + lineSeparator, sb.toString(), "Testing display of null description");
}
@Test
@@ -927,7 +927,7 @@
private void check(String[] args, String canon){
final CLArgsParser parser = new CLArgsParser(args, OPTIONS);
- assertNull(parser.getErrorString(),parser.getErrorString());
+ assertNull(parser.getErrorString(), parser.getErrorString());
final List<CLOption> clOptions = parser.getArguments();
final int size = clOptions.size();
@@ -938,7 +938,7 @@
}
sb.append(clOptions.get(i).toShortString());
}
- assertEquals("Canonical form ("+size+")",canon,sb.toString());
+ assertEquals(canon, sb.toString(), "Canonical form ("+size+")");
}
/*
* TODO add tests to check for: - name clash - long option abbreviations
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/collections/PackageTest.java b/src/jorphan/src/test/java/org/apache/jorphan/collections/PackageTest.java
index 61e6daf..fec95bc 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/collections/PackageTest.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/collections/PackageTest.java
@@ -17,11 +17,11 @@
package org.apache.jorphan.collections;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collection;
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/exec/TestKeyToolUtils.java b/src/jorphan/src/test/java/org/apache/jorphan/exec/TestKeyToolUtils.java
index 5edb729..22fb3d1 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/exec/TestKeyToolUtils.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/exec/TestKeyToolUtils.java
@@ -17,7 +17,7 @@
package org.apache.jorphan.exec;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.IOException;
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java b/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java
index 051f414..cd9082f 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java
@@ -18,8 +18,8 @@
package org.apache.jorphan.gui;
import static java.lang.String.format;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.ArrayDeque;
import java.util.ArrayList;
@@ -60,7 +60,7 @@
* @return <code>this</code>
*/
public EventAssertion addInt(String name, int expected, ToIntFunction<TableModelEvent> f) {
- return add((e,i) -> assertEquals(format("%s[%d]", name, i), expected, f.applyAsInt(e)));
+ return add((e,i) -> assertEquals(expected, f.applyAsInt(e), () -> format("%s[%d]", name, i)));
}
/**
@@ -69,7 +69,7 @@
* @return <code>this</code>
*/
public EventAssertion source(Object expected) {
- return add((e,i) -> assertSame(format("source[%d]",i), expected, e.getSource()));
+ return add((e,i) -> assertSame(expected, e.getSource(), () -> format("source[%d]",i)));
}
/**
@@ -149,12 +149,12 @@
*/
public void assertEvents(EventAssertion... assertions) {
try {
- assertEquals("event count", assertions.length, events.size());
-
int i = 0;
for (TableModelEvent event : events) {
assertions[i].assertEvent(event, i++);
}
+
+ assertEquals(assertions.length, events.size(), "event count");
} finally {
events.clear();
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java
index e31cebe..16f8e25 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.config;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/UrlConfigTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/UrlConfigTest.java
index 39f8eb1..2ac1c81 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/UrlConfigTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/config/UrlConfigTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.junit.JMeterTestCase;
@@ -66,7 +66,7 @@
@Test
public void testOverRide() {
JMeterProperty jmp = partialConfig.getProperty(HTTPSamplerBase.DOMAIN);
- assertTrue(jmp instanceof NullProperty);
+ assertInstanceOf(NullProperty.class, jmp);
assertEquals(jmp, new NullProperty(HTTPSamplerBase.DOMAIN));
partialConfig.addTestElement(defaultConfig);
assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.DOMAIN), "www.xerox.com");
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManager.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManager.java
index eee4a21..6df391e 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManager.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManager.java
@@ -17,9 +17,8 @@
package org.apache.jmeter.protocol.http.control;
-import static org.junit.Assert.assertEquals;
-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.assertNull;
import java.io.File;
import java.io.IOException;
@@ -29,18 +28,19 @@
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TestAuthManager extends JMeterTestCase {
@Test
public void testHttp() throws Exception {
- assertTrue(AuthManager.isSupportedProtocol(new URL("http:")));
+ Assertions.assertTrue(AuthManager.isSupportedProtocol(new URL("http:")));
}
@Test
public void testHttps() throws Exception {
- assertTrue(AuthManager.isSupportedProtocol(new URL("https:")));
+ Assertions.assertTrue(AuthManager.isSupportedProtocol(new URL("https:")));
}
@Test
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManagerThreadIteration.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManagerThreadIteration.java
index 419fc83..10e0918 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManagerThreadIteration.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestAuthManagerThreadIteration.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.control;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.lang.reflect.Field;
import java.util.concurrent.ConcurrentHashMap;
@@ -65,22 +65,22 @@
Field authPrivateField = authManager.getClass().getDeclaredField("kerberosManager");
authPrivateField.setAccessible(true);
authPrivateField.set(authManager, kerberosManager);
- assertNotNull("Before the iteration, the AuthManager shouldn't be cleared",subjects.get("test"));
+ assertNotNull(subjects.get("test"), "Before the iteration, the AuthManager shouldn't be cleared");
authManager.setControlledByThread(false);
authManager.setClearEachIteration(true);
authManager.testIterationStart(null);
- assertNull("After the iteration, the AuthManager should be cleared",subjects.get("test"));
+ assertNull(subjects.get("test"), "After the iteration, the AuthManager should be cleared");
//Test button controlled by Thread
kerberosManager=initKerberosManager();
jmvars.putObject(SAME_USER, false);
jmctx.setVariables(jmvars);
authManager.setThreadContext(jmctx);
authPrivateField.set(authManager, kerberosManager);
- assertNotNull("Before the iteration, the AuthManager shouldn't be cleared",subjects.get("test"));
+ assertNotNull(subjects.get("test"), "Before the iteration, the AuthManager shouldn't be cleared");
authManager.setControlledByThread(true);
authManager.setClearEachIteration(false);
authManager.testIterationStart(null);
- assertNull("After the iteration, the AuthManager should be cleared",subjects.get("test"));
+ assertNull(subjects.get("test"), "After the iteration, the AuthManager should be cleared");
}
@Test
@@ -92,21 +92,21 @@
Field authPrivateField = authManager.getClass().getDeclaredField("kerberosManager");
authPrivateField.setAccessible(true);
authPrivateField.set(authManager, kerberosManager);
- assertNotNull("Before the iteration, the AuthManager shouldn't be cleared", subjects.get("test"));
+ assertNotNull(subjects.get("test"), "Before the iteration, the AuthManager shouldn't be cleared");
authManager.setControlledByThread(false);
authManager.setClearEachIteration(false);
authManager.testIterationStart(null);
- assertNotNull("After the iteration, the AuthManager shouldn't be cleared", subjects.get("test"));
+ assertNotNull(subjects.get("test"), "After the iteration, the AuthManager shouldn't be cleared");
// Test button controlled by Thread
kerberosManager = initKerberosManager();
jmvars.putObject(SAME_USER, true);
jmctx.setVariables(jmvars);
authManager.setThreadContext(jmctx);
authPrivateField.set(authManager, kerberosManager);
- assertNotNull("Before the iteration, the AuthManager shouldn't be cleared", subjects.get("test"));
+ assertNotNull(subjects.get("test"), "Before the iteration, the AuthManager shouldn't be cleared");
authManager.setControlledByThread(true);
authManager.setClearEachIteration(false);
authManager.testIterationStart(null);
- assertNotNull("After the iteration, the AuthManager shouldn't be cleared", subjects.get("test"));
+ assertNotNull(subjects.get("test"), "After the iteration, the AuthManager shouldn't be cleared");
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java
index f8ca9a1..d2909b8 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java
@@ -17,10 +17,10 @@
package org.apache.jmeter.protocol.http.control;
-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.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.URISyntaxException;
@@ -309,19 +309,19 @@
public void testCacheControlCleared() throws Exception {
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
Header[] headers = new Header[1];
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url, headers));
+ assertFalse(this.cacheManager.inCache(url, headers), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(Instant.ofEpochMilli(start)));
setCacheControl("public, max-age=1");
cacheResult(sampleResultOK);
- assertNotNull("Before iternation, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Before iternation, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Before iternation, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "Before iternation, should find valid entry");
this.cacheManager.setClearEachIteration(true);
this.cacheManager.testIterationStart(null);
- assertNull("After iterantion, should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("After iterantion, should not find valid entry", this.cacheManager.inCache(url, headers));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "After iterantion, should not find entry");
+ assertFalse(this.cacheManager.inCache(url, headers), "After iterantion, should not find valid entry");
}
@Test
@@ -333,7 +333,7 @@
sampler.setCacheManager(cacheManager);
sampler.setThreadContext(jmctx);
boolean res = (boolean) cacheManager.getThreadContext().getVariables().getObject(SAME_USER);
- assertTrue("When test different user on the different iternation, the cache should be cleared", res);
+ assertTrue(res, "When test different user on the different iternation, the cache should be cleared");
}
@Test
@@ -345,7 +345,7 @@
sampler.setCacheManager(cacheManager);
sampler.setThreadContext(jmctx);
boolean res = (boolean) cacheManager.getThreadContext().getVariables().getObject(SAME_USER);
- assertFalse("When test different user on the different iternation, the cache shouldn't be cleared", res);
+ assertFalse(res, "When test different user on the different iternation, the cache shouldn't be cleared");
}
@Test
@@ -355,20 +355,20 @@
jmctx.setVariables(jmvars);
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
Header[] headers = new Header[1];
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url, headers));
+ assertFalse(this.cacheManager.inCache(url, headers), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(Instant.ofEpochMilli(start)));
setCacheControl("public, max-age=1");
cacheResult(sampleResultOK);
this.cacheManager.setThreadContext(jmctx);
this.cacheManager.setControlledByThread(true);
- assertNotNull("Before iternation, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Before iternation, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Before iternation, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "Before iternation, should find valid entry");
this.cacheManager.testIterationStart(null);
- assertNull("After iterantion, should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("After iterantion, should not find valid entry", this.cacheManager.inCache(url, headers));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "After iterantion, should not find entry");
+ assertFalse(this.cacheManager.inCache(url, headers), "After iterantion, should not find valid entry");
//Controlled by cacheManager
jmvars.putObject(SAME_USER, true);
@@ -378,13 +378,13 @@
setExpires(makeDate(Instant.ofEpochMilli(start)));
setCacheControl("public, max-age=1");
cacheResult(sampleResultOK);
- assertNotNull("Before iternation, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Before iternation, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Before iternation, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "Before iternation, should find valid entry");
this.cacheManager.setControlledByThread(false);
this.cacheManager.setClearEachIteration(true);
this.cacheManager.testIterationStart(null);
- assertNull("After iterantion, should not find entry", getThreadCacheEntry(LOCAL_HOST));
- assertFalse("After iterantion, should not find valid entry", this.cacheManager.inCache(url, headers));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "After iterantion, should not find entry");
+ assertFalse(this.cacheManager.inCache(url, headers), "After iterantion, should not find valid entry");
}
@Test
@@ -394,20 +394,20 @@
jmctx.setVariables(jmvars);
this.cacheManager.setUseExpires(true);
this.cacheManager.testIterationStart(null);
- assertNull("Should not find entry", getThreadCacheEntry(LOCAL_HOST));
+ assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry");
Header[] headers = new Header[1];
- assertFalse("Should not find valid entry", this.cacheManager.inCache(url, headers));
+ assertFalse(this.cacheManager.inCache(url, headers), "Should not find valid entry");
long start = System.currentTimeMillis();
setExpires(makeDate(Instant.ofEpochMilli(start)));
setCacheControl("public, max-age=1");
cacheResult(sampleResultOK);
this.cacheManager.setThreadContext(jmctx);
this.cacheManager.setControlledByThread(true);
- assertNotNull("Before iteration, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Before iteration, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Before iteration, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "Before iteration, should find valid entry");
this.cacheManager.testIterationStart(null);
- assertNotNull("After iteration, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("After iteration, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "After iteration, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "After iteration, should find valid entry");
// Controlled by cacheManager
jmvars.putObject(SAME_USER, false);
jmctx.setVariables(jmvars);
@@ -416,13 +416,13 @@
setExpires(makeDate(Instant.ofEpochMilli(start)));
setCacheControl("public, max-age=1");
cacheResult(sampleResultOK);
- assertNotNull("Before iteration, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("Before iteration, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Before iteration, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "Before iteration, should find valid entry");
this.cacheManager.setControlledByThread(false);
this.cacheManager.setClearEachIteration(false);
this.cacheManager.testIterationStart(null);
- assertNotNull("After iteration, should find entry", getThreadCacheEntry(LOCAL_HOST));
- assertTrue("After iteration, should find valid entry", this.cacheManager.inCache(url, headers));
+ assertNotNull(getThreadCacheEntry(LOCAL_HOST), "After iteration, should find entry");
+ assertTrue(this.cacheManager.inCache(url, headers), "After iteration, should find valid entry");
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCookieManagerThreadIteration.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCookieManagerThreadIteration.java
index 3fd04d3..e92b707 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCookieManagerThreadIteration.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCookieManagerThreadIteration.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.protocol.http.control;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import java.lang.reflect.Field;
@@ -55,7 +55,7 @@
sampler.setCookieManager(cookieManager);
sampler.setThreadContext(jmctx);
boolean res = (boolean) cookieManager.getThreadContext().getVariables().getObject(SAME_USER);
- assertTrue("When test different users on the different iternations, the cookie should be cleared", res);
+ assertTrue(res, "When test different users on the different iternations, the cookie should be cleared");
}
@Test
@@ -68,7 +68,7 @@
sampler.setCookieManager(cookieManager);
sampler.setThreadContext(jmctx);
boolean res = (boolean) cookieManager.getThreadContext().getVariables().getObject(SAME_USER);
- assertFalse("When test same user on the different iternations, the cookie shouldn't be cleared", res);
+ assertFalse(res, "When test same user on the different iternations, the cookie shouldn't be cleared");
}
@Test
@@ -92,15 +92,23 @@
cookieManagerStatic.getCookies().addItem(cookieStatic);
CollectionProperty initialCookies = cookieManagerStatic.getCookies();
privateStringField.set(cookieManagerDynamic, initialCookies);
- assertTrue("Before the iteration,the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
- assertEquals("Before the iteration, the value of cookie should be what user have set", DYNAMIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "Before the iteration,the quantity of cookies should be 1");
+ assertEquals(
+ DYNAMIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "Before the iteration, the value of cookie should be what user have set");
cookieManagerDynamic.testIterationStart(null);
- assertEquals("After the iteration, the value of cookie should be the initial cookies", STATIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
- assertTrue("After the iteration, the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
+ assertEquals(
+ STATIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "After the iteration, the value of cookie should be the initial cookies");
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "After the iteration, the quantity of cookies should be 1");
// Controlled by CookieManager
jmvars.putObject(SAME_USER, true);
jmctx.setVariables(jmvars);
@@ -115,15 +123,23 @@
cookieManagerStatic.getCookies().addItem(cookieStatic);
initialCookies = cookieManagerStatic.getCookies();
privateStringField.set(cookieManagerDynamic, initialCookies);
- assertEquals("Before the iteration, the value of cookie should be what user have set", DYNAMIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
- assertTrue("Before the iteration,the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
+ assertEquals(
+ DYNAMIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "Before the iteration, the value of cookie should be what user have set");
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "Before the iteration,the quantity of cookies should be 1");
cookieManagerDynamic.testIterationStart(null);
- assertEquals("After the iteration, the value of cookie should be the initial cookies", STATIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
- assertTrue("After the iteration, the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
+ assertEquals(
+ STATIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "After the iteration, the value of cookie should be the initial cookies");
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "After the iteration, the quantity of cookies should be 1");
}
@Test
@@ -147,15 +163,23 @@
cookieManagerStatic.getCookies().addItem(cookieStatic);
CollectionProperty initialCookies = cookieManagerStatic.getCookies();
privateStringField.set(cookieManagerDynamic, initialCookies);
- assertTrue("Before the iteration,the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
- assertEquals("Before the iteration, the value of cookie should be what user have set", DYNAMIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "Before the iteration,the quantity of cookies should be 1");
+ assertEquals(
+ DYNAMIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "Before the iteration, the value of cookie should be what user have set");
cookieManagerDynamic.testIterationStart(null);
- assertEquals("After the iteration, the value of cookie should be what user have set", DYNAMIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
- assertTrue("After the iteration, the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
+ assertEquals(
+ DYNAMIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "After the iteration, the value of cookie should be what user have set");
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "After the iteration, the quantity of cookies should be 1");
// Controlled by CookieManager
jmvars.putObject(SAME_USER, false);
@@ -169,14 +193,19 @@
cookieManagerStatic.getCookies().clear();
cookieStatic.setName(STATIC_COOKIE);
privateStringField.set(cookieManagerDynamic, initialCookies);
- assertEquals("Before the iteration, the value of cookie should be what user have set", DYNAMIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
- assertTrue("Before the iteration,the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
+ assertEquals(
+ DYNAMIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "Before the iteration, the value of cookie should be what user have set");
+ assertEquals(
+ 1,
+ cookieManagerDynamic.getCookies().size(),
+ "Before the iteration,the quantity of cookies should be 1");
cookieManagerDynamic.testIterationStart(null);
- assertEquals("After the iteration, the value of cookie should be what user have set", DYNAMIC_COOKIE,
- cookieManagerDynamic.getCookies().get(0).getName());
- assertTrue("After the iteration, the quantity of cookies should be 1",
- cookieManagerDynamic.getCookies().size() == 1);
+ assertEquals(
+ DYNAMIC_COOKIE,
+ cookieManagerDynamic.getCookies().get(0).getName(),
+ "After the iteration, the value of cookie should be what user have set");
+ assertEquals(1, cookieManagerDynamic.getCookies().size(), "After the iteration, the quantity of cookies should be 1");
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java
index 0d445cf..8b24254 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java
@@ -17,11 +17,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.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+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.net.URL;
import java.util.List;
@@ -113,7 +112,7 @@
URL url = new URL("https://subdomain.bt.com/page");
String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
man.addCookieFromHeader(headerLine, url);
- Assertions.assertEquals(1, man.getCookieCount());
+ assertEquals(1, man.getCookieCount());
HC4CookieHandler cookieHandler = (HC4CookieHandler) man.getCookieHandler();
List<org.apache.http.cookie.Cookie> cookies =
cookieHandler.getCookiesForUrl(man.getCookies(), url,
@@ -121,8 +120,8 @@
for (org.apache.http.cookie.Cookie cookie : cookies) {
// See http://tools.ietf.org/html/rfc6265#section-5.2.3
- Assertions.assertEquals("bt.com", cookie.getDomain());
- Assertions.assertTrue(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+ assertEquals("bt.com", cookie.getDomain());
+ assertTrue(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
}
// we check that CookieManager returns the cookies for the main domain
@@ -130,11 +129,11 @@
cookies =
cookieHandler.getCookiesForUrl(man.getCookies(), urlMainDomain,
CookieManager.ALLOW_VARIABLE_COOKIES);
- Assertions.assertEquals(1, cookies.size());
+ assertEquals(1, cookies.size());
for (org.apache.http.cookie.Cookie cookie : cookies) {
// See http://tools.ietf.org/html/rfc6265#section-5.2.3
- Assertions.assertEquals("bt.com", cookie.getDomain());
- Assertions.assertTrue(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+ assertEquals("bt.com", cookie.getDomain());
+ assertTrue(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
}
}
@@ -143,15 +142,15 @@
URL url = new URL("https://subdomain.bt.com/page");
String headerLine = "SMTRYNO=1; path=/";
man.addCookieFromHeader(headerLine, url);
- Assertions.assertEquals(1, man.getCookieCount());
+ assertEquals(1, man.getCookieCount());
HC4CookieHandler cookieHandler = (HC4CookieHandler) man.getCookieHandler();
List<org.apache.http.cookie.Cookie> cookies =
cookieHandler.getCookiesForUrl(man.getCookies(), url,
CookieManager.ALLOW_VARIABLE_COOKIES);
- Assertions.assertEquals(1, cookies.size());
+ assertEquals(1, cookies.size());
for (org.apache.http.cookie.Cookie cookie : cookies) {
// See http://tools.ietf.org/html/rfc6265#section-5.2.3
- Assertions.assertEquals("subdomain.bt.com", cookie.getDomain());
+ assertEquals("subdomain.bt.com", cookie.getDomain());
Assertions.assertFalse(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
}
@@ -160,7 +159,7 @@
cookies =
cookieHandler.getCookiesForUrl(man.getCookies(), urlMainDomain,
CookieManager.ALLOW_VARIABLE_COOKIES);
- Assertions.assertEquals(0, cookies.size());
+ assertEquals(0, cookies.size());
}
@Test
@@ -169,18 +168,18 @@
String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
man.addCookieFromHeader(headerLine, url);
- Assertions.assertEquals(1, man.getCookieCount());
+ assertEquals(1, man.getCookieCount());
HC4CookieHandler cookieHandler = (HC4CookieHandler) man.getCookieHandler();
URL urlSubDomain = new URL("https://subdomain.bt.com/page");
List<org.apache.http.cookie.Cookie> cookies =
cookieHandler.getCookiesForUrl(man.getCookies(), urlSubDomain,
CookieManager.ALLOW_VARIABLE_COOKIES);
- Assertions.assertEquals(1, cookies.size());
+ assertEquals(1, cookies.size());
for (org.apache.http.cookie.Cookie cookie : cookies) {
// See http://tools.ietf.org/html/rfc6265#section-5.2.3
- Assertions.assertEquals("bt.com", cookie.getDomain());
- Assertions.assertTrue(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+ assertEquals("bt.com", cookie.getDomain());
+ assertTrue(((BasicClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
}
}
@@ -191,18 +190,18 @@
man.setCookiePolicy(CookieSpecs.STANDARD);
man.addCookieFromHeader(headerLine, url);
- Assertions.assertEquals(1, man.getCookieCount());
+ assertEquals(1, man.getCookieCount());
HC4CookieHandler cookieHandler = (HC4CookieHandler) man.getCookieHandler();
URL urlSameDomainDifferentPort = new URL("http://remote.com:10001/test/me");
List<org.apache.http.cookie.Cookie> cookies =
cookieHandler.getCookiesForUrl(man.getCookies(), urlSameDomainDifferentPort,
CookieManager.ALLOW_VARIABLE_COOKIES);
- Assertions.assertEquals(1, cookies.size());
+ assertEquals(1, cookies.size());
for (org.apache.http.cookie.Cookie cookie : cookies) {
// See http://tools.ietf.org/html/rfc6265#section-5.2.3
- Assertions.assertEquals("remote.com", cookie.getDomain());
- Assertions.assertEquals("test", cookie.getName());
+ assertEquals("remote.com", cookie.getDomain());
+ assertEquals("test", cookie.getName());
}
}
@@ -493,7 +492,7 @@
cookieHandler.getCookiesForUrl(man.getCookies(), url,
CookieManager.ALLOW_VARIABLE_COOKIES);
assertEquals("/sub1", c.get(0).getPath());
- assertFalse(((BasicClientCookie) c.get(0)).containsAttribute(ClientCookie.PATH_ATTR));
+ Assertions.assertFalse(((BasicClientCookie) c.get(0)).containsAttribute(ClientCookie.PATH_ATTR));
assertEquals("/sub1", c.get(1).getPath());
assertTrue(((BasicClientCookie) c.get(1)).containsAttribute(ClientCookie.PATH_ATTR));
assertEquals("/", c.get(2).getPath());
@@ -520,7 +519,7 @@
cookieHandler.getCookiesForUrl(man.getCookies(), url,
CookieManager.ALLOW_VARIABLE_COOKIES);
assertEquals("/sub1", c.get(0).getPath());
- assertFalse(((BasicClientCookie) c.get(0)).containsAttribute(ClientCookie.PATH_ATTR));
+ Assertions.assertFalse(((BasicClientCookie) c.get(0)).containsAttribute(ClientCookie.PATH_ATTR));
assertEquals("/sub1", c.get(1).getPath());
assertTrue(((BasicClientCookie) c.get(1)).containsAttribute(ClientCookie.PATH_ATTR));
assertEquals("/", c.get(2).getPath());
@@ -548,7 +547,7 @@
cookieHandler.getCookiesForUrl(man.getCookies(), url,
CookieManager.ALLOW_VARIABLE_COOKIES);
assertEquals("/sub1", c.get(0).getPath());
- assertFalse(((BasicClientCookie) c.get(0)).containsAttribute(ClientCookie.PATH_ATTR));
+ Assertions.assertFalse(((BasicClientCookie) c.get(0)).containsAttribute(ClientCookie.PATH_ATTR));
assertEquals("/sub1", c.get(1).getPath());
assertTrue(((BasicClientCookie) c.get(1)).containsAttribute(ClientCookie.PATH_ATTR));
assertEquals("/", c.get(2).getPath());
@@ -610,7 +609,7 @@
assertEquals("value2", man.get(num).getValue());
assertEquals("/", man.get(num).getPath());
assertEquals("", man.get(num).getDomain());
- assertFalse(man.get(num).getSecure());
+ Assertions.assertFalse(man.get(num).getSecure());
assertEquals(0, man.get(num).getExpires());
num++;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
index c5489bf..513bf0d 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
@@ -17,11 +17,10 @@
package org.apache.jmeter.protocol.http.control.gui;
-import static org.junit.Assert.assertEquals;
-
import org.apache.jmeter.junit.categories.NeedGuiTests;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -42,8 +41,6 @@
HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
clonedSampler.setRunningVersion(true);
sampler.getArguments().getArgument(0).setValue("new value");
- assertEquals("Sampler didn't clone correctly",
- "new value",
- sampler.getArguments().getArgument(0).getValue());
+ Assertions.assertEquals("new value", sampler.getArguments().getArgument(0).getValue(), "Sampler didn't clone correctly");
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
index 5221b78..d16801b 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
@@ -17,9 +17,7 @@
package org.apache.jmeter.protocol.http.modifier;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.net.MalformedURLException;
@@ -37,6 +35,7 @@
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jorphan.io.TextFile;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -179,7 +178,7 @@
jmctx.setPreviousResult(result);
parser.process();
String newUrl = config.getUrl().toString();
- assertTrue("http://www.apache.org/index.html".equals(newUrl)
+ Assertions.assertTrue("http://www.apache.org/index.html".equals(newUrl)
|| "http://www.apache.org/subdir/lowerdir/index.html".equals(newUrl));
}
@@ -288,7 +287,7 @@
jmctx.setPreviousResult(result);
parser.process();
String newUrl = config.getUrl().toString();
- assertNotEquals("http://www.apache.org/home/index.html?param1=value1", newUrl);
+ Assertions.assertNotEquals("http://www.apache.org/home/index.html?param1=value1", newUrl);
assertEquals(config.getUrl().toString(), newUrl);
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
index 0ae4171..3b29a07 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.modifier;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
@@ -274,8 +274,7 @@
context.setPreviousResult(response);
newMod.process();
Arguments args = sampler.getArguments();
- assertEquals("For case i=" + i, "myId",
- ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+ assertEquals("myId", ((Argument) args.getArguments().get(0).getObjectValue()).getValue(), "For case i=" + i);
}
}
@@ -315,8 +314,7 @@
context.setPreviousResult(response);
newMod.process();
Arguments args = sampler.getArguments();
- assertEquals("For case i=" + i, "myId",
- ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+ assertEquals("myId", ((Argument) args.getArguments().get(0).getObjectValue()).getValue(), "For case i=" + i);
}
}
@@ -339,8 +337,7 @@
context.setPreviousResult(response);
newMod.process();
Arguments args = sampler.getArguments();
- assertEquals("For case i=" + i, html[i * 2 + 1],
- ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
+ assertEquals(html[i * 2 + 1], ((Argument) args.getArguments().get(0).getObjectValue()).getValue(), "For case i=" + i);
}
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBaseParser.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBaseParser.java
index e6ec9cd..e0df527 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBaseParser.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBaseParser.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.parser;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
import org.junit.jupiter.api.Test;
@@ -26,16 +26,12 @@
@Test
public void testReusableCache() throws Exception {
- assertSame(
- BaseParser.getParser(ReusableParser.class.getCanonicalName()),
- BaseParser.getParser(ReusableParser.class.getCanonicalName()));
+ assertSame(BaseParser.getParser(ReusableParser.class.getCanonicalName()), BaseParser.getParser(ReusableParser.class.getCanonicalName()));
}
@Test
public void testNotReusableCache() throws Exception {
- assertNotSame(
- BaseParser.getParser(NotReusableParser.class.getCanonicalName()),
- BaseParser.getParser(NotReusableParser.class.getCanonicalName()));
+ assertNotSame(BaseParser.getParser(NotReusableParser.class.getCanonicalName()), BaseParser.getParser(NotReusableParser.class.getCanonicalName()));
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
index 2a5e85e..3867046 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHtmlParsingUtils.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.parser;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.junit.JMeterTestCase;
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 c0b1326..3c5a685 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
@@ -17,9 +17,9 @@
package org.apache.jmeter.protocol.http.proxy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -219,11 +219,8 @@
String actualQueryString = s.getQueryString();
String alternativeExpectedQueryString = queryString.replaceAll("%20", "+");
if (!queryString.equals(actualQueryString) && !alternativeExpectedQueryString.equals(actualQueryString)) {
- assertEquals(
- "%20 is the same as +, so expecting either " +
- queryString + " or " + alternativeExpectedQueryString,
- queryString,
- actualQueryString);
+ assertEquals(queryString, actualQueryString, "%20 is the same as +, so expecting either " +
+ queryString + " or " + alternativeExpectedQueryString);
}
assertEquals("UTF-8", s.getContentEncoding());
@@ -269,11 +266,8 @@
assertEquals(HTTPConstants.POST, s.getMethod());
alternativeExpectedQueryString = expectedQueryString.replaceAll("%20", "+");
if (!queryString.equals(actualQueryString) && !alternativeExpectedQueryString.equals(actualQueryString)) {
- assertEquals(
- "%20 is the same as +, so expecting either " +
- queryString + " or " + alternativeExpectedQueryString,
- queryString,
- actualQueryString);
+ assertEquals(queryString, actualQueryString, "%20 is the same as +, so expecting either " +
+ queryString + " or " + alternativeExpectedQueryString);
}
assertEquals("UTF-8", s.getContentEncoding());
assertFalse(s.getDoMultipart());
@@ -334,7 +328,7 @@
// know the encoding for the page
HTTPSamplerBase s = getSamplerForRequest(null, testGetRequest, null);
assertEquals(HTTPConstants.GET, s.getMethod());
- assertEquals("Default content encoding is UTF-8", "UTF-8", s.getContentEncoding());
+ assertEquals("UTF-8", s.getContentEncoding(), "Default content encoding is UTF-8");
// Check arguments
Arguments arguments = s.getArguments();
assertEquals(2, arguments.getArgumentCount());
@@ -400,7 +394,7 @@
// know the encoding for the page
HTTPSamplerBase s = getSamplerForRequest(null, testPostRequest, null);
assertEquals(HTTPConstants.POST, s.getMethod());
- assertEquals("Default content encoding is UTF-8", "UTF-8", s.getContentEncoding());
+ assertEquals("UTF-8", s.getContentEncoding(), "Default content encoding is UTF-8");
// Check arguments
Arguments arguments = s.getArguments();
assertEquals(2, arguments.getArgumentCount());
@@ -549,8 +543,8 @@
Header header;
mgr.getHeaders();
header = mgr.getHeader(0);
- assertEquals("name",header.getName());
- assertEquals("value",header.getValue());
+ assertEquals("name", header.getName());
+ assertEquals("value", header.getValue());
}
@@ -564,8 +558,8 @@
Header header;
mgr.getHeaders();
header = mgr.getHeader(0);
- assertEquals("name",header.getName());
- assertEquals("value",header.getValue());
+ assertEquals("name", header.getName());
+ assertEquals("value", header.getValue());
}
@Test
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
index 586455b..f946892 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.proxy;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
@@ -43,21 +43,21 @@
public void testFilter1() throws Exception {
sampler.setDomain("jakarta.org");
sampler.setPath("index.jsp");
- assertTrue("Should find jakarta.org/index.jsp", control.filterUrl(sampler));
+ assertTrue(control.filterUrl(sampler), "Should find jakarta.org/index.jsp");
}
@Test
public void testFilter2() throws Exception {
sampler.setPath("index.jsp");
sampler.setDomain("www.apache.org");
- assertFalse("Should not match www.apache.org", control.filterUrl(sampler));
+ assertFalse(control.filterUrl(sampler), "Should not match www.apache.org");
}
@Test
public void testFilter3() throws Exception {
sampler.setPath("header.gif");
sampler.setDomain("jakarta.org");
- assertFalse("Should not match header.gif", control.filterUrl(sampler));
+ assertFalse(control.filterUrl(sampler), "Should not match header.gif");
}
@Test
@@ -68,33 +68,33 @@
control.setContentTypeExclude(null);
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertTrue("Should allow text/html", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/html");
result.setContentType("image/png");
- assertTrue("Should allow image/png", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow image/png");
// Empty filters
control.setContentTypeInclude("");
control.setContentTypeExclude("");
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertTrue("Should allow text/html", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/html");
result.setContentType("image/png");
- assertTrue("Should allow image/png", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow image/png");
// Non empty filters
control.setContentTypeInclude(" ");
control.setContentTypeExclude(" ");
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertFalse("Should not allow text/html", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow text/html");
result.setContentType("image/png");
- assertFalse("Should not allow image/png", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow image/png");
}
@Test
@@ -103,11 +103,11 @@
control.setContentTypeInclude("text/html|text/ascii");
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertTrue("Should allow text/html", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/html");
result.setContentType("text/css");
- assertFalse("Should not allow text/css", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow text/css");
}
@Test
@@ -116,11 +116,11 @@
control.setContentTypeExclude("text/css");
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertTrue("Should allow text/html", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/html");
result.setContentType("text/css");
- assertFalse("Should not allow text/css", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow text/css");
}
@Test
@@ -131,25 +131,25 @@
control.setContentTypeExclude("text/css");
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertTrue("Should allow text/html", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/html");
result.setContentType("text/css");
- assertFalse("Should not allow text/css", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow text/css");
result.setContentType("image/png");
- assertFalse("Should not allow image/png", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow image/png");
// Allow all but images
control.setContentTypeInclude(null);
control.setContentTypeExclude("image/.*");
result.setContentType(null);
- assertTrue("Should allow if no content-type present", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow if no content-type present");
result.setContentType("text/html; charset=utf-8");
- assertTrue("Should allow text/html", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/html");
result.setContentType("text/css");
- assertTrue("Should allow text/css", control.filterContentType(result));
+ assertTrue(control.filterContentType(result), "Should allow text/css");
result.setContentType("image/png");
- assertFalse("Should not allow image/png", control.filterContentType(result));
+ assertFalse(control.filterContentType(result), "Should not allow image/png");
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PackageTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PackageTest.java
index c13a590..45f7cec 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PackageTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PackageTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.sampler;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.junit.categories.NeedGuiTests;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
index cae9635..bd5b36b 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
@@ -17,9 +17,9 @@
package org.apache.jmeter.protocol.http.sampler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
import java.io.File;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java
index 1c948c1..207c1a3 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.sampler;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.net.URLConnection;
@@ -37,8 +37,7 @@
"mime1") });
PutWriter pw = new PutWriter();
pw.setHeaders(uc, sampler);
- assertEquals("mime1",
- uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
+ assertEquals("mime1", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
}
@Test
@@ -52,7 +51,6 @@
sampler.setArguments(arguments);
PutWriter pw = new PutWriter();
pw.setHeaders(uc, sampler);
- assertEquals("mime2",
- uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
+ assertEquals("mime2", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
index 26d5916..5d0fb9f 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
@@ -17,7 +17,8 @@
package org.apache.jmeter.protocol.http.sampler;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.stream.Stream;
@@ -26,7 +27,6 @@
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jorphan.test.JMeterSerialTest;
import org.junit.Ignore;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@@ -47,18 +47,17 @@
void testBug63364(String implementation) {
TestPlan plan = new TestPlan();
SampleResult[] subResults = doSample(implementation);
- Assertions.assertTrue(subResults.length > 0, "We should have at least one sample result, we had none");
+ assertTrue(subResults.length > 0, "We should have at least one sample result, we had none");
for (int i = 0; i < subResults.length; i++) {
- assertEquals("Expected sample label to be " + LABEL + "-" + i, LABEL + "-" + i,
- subResults[i].getSampleLabel());
+ assertEquals(LABEL + "-" + i, subResults[i].getSampleLabel(), "Expected sample label to be " + LABEL + "-" + i);
}
final boolean prevValue = TestPlan.getFunctionalMode();
plan.setFunctionalMode(true);
try {
subResults = doSample(implementation);
- Assertions.assertTrue(subResults.length > 0, "We should have at least one sample result, we had none");
+ assertTrue(subResults.length > 0, "We should have at least one sample result, we had none");
for (SampleResult subResult : subResults) {
- Assertions.assertTrue(subResult.getSampleLabel().startsWith(JMETER_HOME_PAGE), "Expected sample label to start with " + JMETER_HOME_PAGE);
+ assertTrue(subResult.getSampleLabel().startsWith(JMETER_HOME_PAGE), "Expected sample label to start with " + JMETER_HOME_PAGE);
}
} finally {
plan.setFunctionalMode(prevValue);
@@ -80,7 +79,7 @@
// We intentionally keep only resources which start with JMETER_HOME_PAGE
httpSamplerProxy.setEmbeddedUrlRE(JMETER_HOME_PAGE + ".*");
SampleResult result = httpSamplerProxy.sample();
- assertEquals("Expected sample label to be " + LABEL, LABEL, result.getSampleLabel());
+ assertEquals(LABEL, result.getSampleLabel(), "Expected sample label to be " + LABEL);
return result.getSubResults();
}
}
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 5194852..315806d 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
@@ -17,8 +17,6 @@
package org.apache.jmeter.protocol.http.sampler;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
@@ -33,6 +31,7 @@
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
@@ -61,7 +60,7 @@
sampler.getArguments().addArgument(argument);
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
String requestData = hc.setupHttpEntityEnclosingRequestData(post);
- assertTrue(requestData.contains("charset=utf-8"));
+ Assertions.assertTrue(requestData.contains("charset=utf-8"));
}
@Test
@@ -76,7 +75,7 @@
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
String requestData = hc.setupHttpEntityEnclosingRequestData(post);
assertEquals(0, post.getHeaders(HTTPConstants.HEADER_CONTENT_TYPE).length);
- assertTrue(requestData.contains("charset=utf-8"));
+ Assertions.assertTrue(requestData.contains("charset=utf-8"));
}
@Test
@@ -95,7 +94,7 @@
sampler.setHTTPFiles(Collections.singletonList(fileArg).toArray(new HTTPFileArg[1]));
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
String requestData = hc.setupHttpEntityEnclosingRequestData(post);
- assertTrue(requestData.contains("charset=utf-8"));
+ Assertions.assertTrue(requestData.contains("charset=utf-8"));
}
@Test
@@ -106,7 +105,7 @@
sampler.setThreadContext(jmctx);
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
hc.notifyFirstSampleAfterLoopRestart();
- assertFalse("User is the same, the state shouldn't be reset", HTTPHC4Impl.resetStateOnThreadGroupIteration.get());
+ Assertions.assertFalse(HTTPHC4Impl.resetStateOnThreadGroupIteration.get(), "User is the same, the state shouldn't be reset");
}
@Test
@@ -117,6 +116,6 @@
sampler.setThreadContext(jmctx);
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
hc.notifyFirstSampleAfterLoopRestart();
- assertTrue("Users are different, the state should be reset", HTTPHC4Impl.resetStateOnThreadGroupIteration.get());
+ Assertions.assertTrue(HTTPHC4Impl.resetStateOnThreadGroupIteration.get(), "Users are different, the state should be reset");
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java
index 1caacb7..482b245 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplers.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.sampler;
-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 org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpWebdav.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpWebdav.java
index 7dfde4c..113132f 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpWebdav.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpWebdav.java
@@ -17,10 +17,6 @@
package org.apache.jmeter.protocol.http.sampler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
@@ -28,6 +24,7 @@
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TestHttpWebdav {
@@ -41,12 +38,10 @@
@Test
public void testIsWebdavMethod() {
for (String method : VALID_METHODS) {
- assertTrue(method + " is a HttpWebdav method",
- HttpWebdav.isWebdavMethod(method));
+ Assertions.assertTrue(HttpWebdav.isWebdavMethod(method), method + " is a HttpWebdav method");
}
for (String method : INVALID_METHODS) {
- assertFalse(method + " is not a HttpWebdav method",
- HttpWebdav.isWebdavMethod(method));
+ Assertions.assertFalse(HttpWebdav.isWebdavMethod(method), method + " is not a HttpWebdav method");
}
}
@@ -55,7 +50,7 @@
for (String method : VALID_METHODS) {
HttpRequestBase request = new HttpWebdav(method, new URI(
"http://example.com"));
- assertEquals(method, request.getMethod());
+ Assertions.assertEquals(method, request.getMethod());
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
index 1e50369..1c944e8 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPArgument.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.util;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.testelement.property.CollectionProperty;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java
index 8499266..9b535b3 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArg.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.util;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
@@ -26,21 +26,21 @@
@Test
public void testConstructors() throws Exception {
HTTPFileArg file = new HTTPFileArg();
- assertEquals("no parameter failure", "", file.getPath());
- assertEquals("no parameter failure", "", file.getParamName());
- assertEquals("no parameter failure", "", file.getMimeType());
+ assertEquals("", file.getPath(), "no parameter failure");
+ assertEquals("", file.getParamName(), "no parameter failure");
+ assertEquals("", file.getMimeType(), "no parameter failure");
file = new HTTPFileArg("path");
- assertEquals("single parameter failure", "path", file.getPath());
- assertEquals("single parameter failure", "", file.getParamName());
- assertEquals("single parameter failure", "application/octet-stream", file.getMimeType());
+ assertEquals("path", file.getPath(), "single parameter failure");
+ assertEquals("", file.getParamName(), "single parameter failure");
+ assertEquals("application/octet-stream", file.getMimeType(), "single parameter failure");
file = new HTTPFileArg("path", "param", "mimetype");
- assertEquals("three parameter failure", "path", file.getPath());
- assertEquals("three parameter failure", "param", file.getParamName());
- assertEquals("three parameter failure", "mimetype", file.getMimeType());
+ assertEquals("path", file.getPath(), "three parameter failure");
+ assertEquals("param", file.getParamName(), "three parameter failure");
+ assertEquals("mimetype", file.getMimeType(), "three parameter failure");
HTTPFileArg file2 = new HTTPFileArg(file);
- assertEquals("copy constructor failure", "path", file2.getPath());
- assertEquals("copy constructor failure", "param", file2.getParamName());
- assertEquals("copy constructor failure", "mimetype", file2.getMimeType());
+ assertEquals("path", file2.getPath(), "copy constructor failure");
+ assertEquals("param", file2.getParamName(), "copy constructor failure");
+ assertEquals("mimetype", file2.getMimeType(), "copy constructor failure");
}
@Test
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java
index fb8c4ec..c2b9186 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.http.util;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
@@ -118,7 +118,6 @@
files.addHTTPFileArg("file3.jar");
assertEquals("path:'file1'|param:''|mimetype:'application/octet-stream'\n"
+"path:'file2.jpg'|param:''|mimetype:'image/jpeg'\n"
- +"path:'file3.jar'|param:''|mimetype:'application/java-archive'",
- files.toString());
+ +"path:'file3.jar'|param:''|mimetype:'application/java-archive'", files.toString());
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
index bd7c52a..30f6334 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestLogFilter.java
@@ -17,11 +17,11 @@
package org.apache.jmeter.protocol.http.util.accesslog;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.junit.JMeterTestCase;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -86,7 +86,7 @@
public void testReplaceExtension() {
testf.setReplaceExtension("html", "jsp");
testf.isFiltered(TESTSTR, null);// set the required variables
- assertEquals(TESTSTROUT, testf.filter(TESTSTR));
+ Assertions.assertEquals(TESTSTROUT, testf.filter(TESTSTR));
}
@Test
@@ -99,9 +99,9 @@
testf.isFiltered(theFile, null);
String line = testf.filter(theFile);
if (line != null) {
- assertTrue("Expect to accept " + theFile, expect);
+ assertTrue(expect, "Expect to accept " + theFile);
} else {
- assertFalse("Expect to reject " + theFile, expect);
+ assertFalse(expect, "Expect to reject " + theFile);
}
}
}
@@ -116,9 +116,9 @@
testf.isFiltered(theFile, null);
String line = testf.filter(theFile);
if (line != null) {
- assertTrue("Expect to accept " + theFile, expect);
+ assertTrue(expect, "Expect to accept " + theFile);
} else {
- assertFalse("Expect to reject " + theFile, expect);
+ assertFalse(expect, "Expect to reject " + theFile);
}
}
}
@@ -133,9 +133,9 @@
assertPrimitiveEquals(!expect, testf.isFiltered(theFile, null));
String line = testf.filter(theFile);
if (line != null) {
- assertTrue("Expect to accept " + theFile, expect);
+ assertTrue(expect, "Expect to accept " + theFile);
} else {
- assertFalse("Expect to reject " + theFile, expect);
+ assertFalse(expect, "Expect to reject " + theFile);
}
}
}
@@ -150,9 +150,9 @@
assertPrimitiveEquals(!expect, testf.isFiltered(theFile, null));
String line = testf.filter(theFile);
if (line != null) {
- assertTrue("Expect to accept " + theFile, expect);
+ assertTrue(expect, "Expect to accept " + theFile);
} else {
- assertFalse("Expect to reject " + theFile, expect);
+ assertFalse(expect, "Expect to reject " + theFile);
}
}
}
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestSessionFilter.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestSessionFilter.java
index 48b3849..15a9da3 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestSessionFilter.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestSessionFilter.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.http.util.accesslog;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.IdentityHashMap;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
index a682476..a7bf587 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/accesslog/TestTCLogParser.java
@@ -17,10 +17,10 @@
package org.apache.jmeter.protocol.http.util.accesslog;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
@@ -37,11 +37,11 @@
public void testConstruct() throws Exception {
TCLogParser tcp;
tcp = new TCLogParser();
- assertNull("Should not have set the filename", tcp.FILENAME);
+ assertNull(tcp.FILENAME, "Should not have set the filename");
String file = "testfiles/access.log";
tcp = new TCLogParser(file);
- assertEquals("Filename should have been saved", file, tcp.FILENAME);
+ assertEquals(file, tcp.FILENAME, "Filename should have been saved");
}
@Test
@@ -53,8 +53,8 @@
@Test
public void testcheckURL() throws Exception {
- assertFalse("URL does not have a query", tclp.checkURL(URL1));
- assertTrue("URL is a query", tclp.checkURL(URL2));
+ assertFalse(tclp.checkURL(URL1), "URL does not have a query");
+ assertTrue(tclp.checkURL(URL2), "URL is a query");
}
@Test
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/testelement/TestHeaderManager.java b/src/protocol/http/src/test/java/org/apache/jmeter/testelement/TestHeaderManager.java
index eaaccb5..a508a73 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/testelement/TestHeaderManager.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/testelement/TestHeaderManager.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.testelement;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.protocol.http.control.Header;
diff --git a/src/protocol/jms/src/test/java/org/apache/jmeter/protocol/jms/sampler/PublisherSamplerTest.java b/src/protocol/jms/src/test/java/org/apache/jmeter/protocol/jms/sampler/PublisherSamplerTest.java
index 100d4ab..c60afc0 100644
--- a/src/protocol/jms/src/test/java/org/apache/jmeter/protocol/jms/sampler/PublisherSamplerTest.java
+++ b/src/protocol/jms/src/test/java/org/apache/jmeter/protocol/jms/sampler/PublisherSamplerTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.jms.sampler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Locale;
diff --git a/src/protocol/ldap/src/test/java/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java b/src/protocol/ldap/src/test/java/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java
index 8e30145..6c9f3cb 100644
--- a/src/protocol/ldap/src/test/java/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java
+++ b/src/protocol/ldap/src/test/java/org/apache/jmeter/protocol/ldap/config/gui/PackageTest.java
@@ -17,7 +17,7 @@
package org.apache.jmeter.protocol.ldap.config.gui;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
diff --git a/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/BinaryTCPClientImplTest.java b/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/BinaryTCPClientImplTest.java
index ae0f161..ac0297a 100644
--- a/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/BinaryTCPClientImplTest.java
+++ b/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/BinaryTCPClientImplTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.tcp.sampler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -42,12 +42,12 @@
ba = BinaryTCPClientImpl.hexStringToByteArray("0f107F8081ff");
assertEquals(6, ba.length);
- assertEquals(15, ba[0]);
- assertEquals(16, ba[1]);
- assertEquals(127, ba[2]);
+ assertEquals(15, ba[0]);
+ assertEquals(16, ba[1]);
+ assertEquals(127, ba[2]);
assertEquals(-128, ba[3]);
assertEquals(-127, ba[4]);
- assertEquals(-1, ba[5]);
+ assertEquals(-1, ba[5]);
try {
ba = BinaryTCPClientImpl.hexStringToByteArray("0f107f8081ff1");// odd chars
fail("Expected IllegalArgumentException");
@@ -80,8 +80,8 @@
ByteArrayOutputStream os = new ByteArrayOutputStream();
bi.write(os, "3132333435"); // '12345'
os.close();
- assertEquals("12345",os.toString("ISO-8859-1"));
+ assertEquals("12345", os.toString("ISO-8859-1"));
ByteArrayInputStream bis = new ByteArrayInputStream(os.toByteArray());
- assertEquals("3132333435",bi.read(bis, new SampleResult()));
+ assertEquals("3132333435", bi.read(bis, new SampleResult()));
}
}
diff --git a/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImplTest.java b/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImplTest.java
index cccadda..256f20e 100644
--- a/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImplTest.java
+++ b/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImplTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.tcp.sampler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
diff --git a/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java b/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java
index c18ad04..e0609e9 100644
--- a/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java
+++ b/src/protocol/tcp/src/test/java/org/apache/jmeter/protocol/tcp/sampler/TCPClientDecoratorTest.java
@@ -17,8 +17,8 @@
package org.apache.jmeter.protocol.tcp.sampler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;