This is an automated email from the ASF dual-hosted git repository.

milamber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new a2693893de Change from Assert. to Assertions. (#5813)
a2693893de is described below

commit a2693893de0eecd517bb10691fbb8564bc3aaf59
Author: Milamber <[email protected]>
AuthorDate: Sat Apr 22 12:19:35 2023 +0000

    Change from Assert. to Assertions. (#5813)
    
    * Change from Assert. to Assertions.
    
    * No need to extends TestCase
---
 .../http/control/TestHC4CookieManager.java         |  40 +++----
 .../protocol/http/sampler/SamplingNamingTest.java  |   9 +-
 .../http/visualizers/RequestViewHTTPTest.java      | 124 ++++++++++-----------
 3 files changed, 85 insertions(+), 88 deletions(-)

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 2468448ac8..0d445cf9b7 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
@@ -35,7 +35,7 @@ import 
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterContextService;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -113,7 +113,7 @@ public class TestHC4CookieManager extends JMeterTestCase {
         URL url = new URL("https://subdomain.bt.com/page";);
         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
         man.addCookieFromHeader(headerLine, url);
-        Assert.assertEquals(1, man.getCookieCount());
+        Assertions.assertEquals(1, man.getCookieCount());
         HC4CookieHandler cookieHandler = (HC4CookieHandler) 
man.getCookieHandler();
         List<org.apache.http.cookie.Cookie> cookies =
                 cookieHandler.getCookiesForUrl(man.getCookies(), url,
@@ -121,8 +121,8 @@ public class TestHC4CookieManager extends JMeterTestCase {
 
         for (org.apache.http.cookie.Cookie cookie : cookies) {
             // See http://tools.ietf.org/html/rfc6265#section-5.2.3
-            Assert.assertEquals("bt.com", cookie.getDomain());
-            Assert.assertTrue(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+            Assertions.assertEquals("bt.com", cookie.getDomain());
+            Assertions.assertTrue(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
         }
 
         // we check that CookieManager returns the cookies for the main domain
@@ -130,11 +130,11 @@ public class TestHC4CookieManager extends JMeterTestCase {
         cookies =
                 cookieHandler.getCookiesForUrl(man.getCookies(), urlMainDomain,
                         CookieManager.ALLOW_VARIABLE_COOKIES);
-        Assert.assertEquals(1, cookies.size());
+        Assertions.assertEquals(1, cookies.size());
         for (org.apache.http.cookie.Cookie cookie : cookies) {
             // See http://tools.ietf.org/html/rfc6265#section-5.2.3
-            Assert.assertEquals("bt.com", cookie.getDomain());
-            Assert.assertTrue(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+            Assertions.assertEquals("bt.com", cookie.getDomain());
+            Assertions.assertTrue(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
         }
     }
 
@@ -143,16 +143,16 @@ public class TestHC4CookieManager extends JMeterTestCase {
         URL url = new URL("https://subdomain.bt.com/page";);
         String headerLine = "SMTRYNO=1; path=/";
         man.addCookieFromHeader(headerLine, url);
-        Assert.assertEquals(1, man.getCookieCount());
+        Assertions.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);
-        Assert.assertEquals(1, cookies.size());
+        Assertions.assertEquals(1, cookies.size());
         for (org.apache.http.cookie.Cookie cookie : cookies) {
             // See http://tools.ietf.org/html/rfc6265#section-5.2.3
-            Assert.assertEquals("subdomain.bt.com", cookie.getDomain());
-            Assert.assertFalse(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+            Assertions.assertEquals("subdomain.bt.com", cookie.getDomain());
+            Assertions.assertFalse(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
         }
 
         // we check that CookieManager returns the cookies for the main domain
@@ -160,7 +160,7 @@ public class TestHC4CookieManager extends JMeterTestCase {
         cookies =
                 cookieHandler.getCookiesForUrl(man.getCookies(), urlMainDomain,
                         CookieManager.ALLOW_VARIABLE_COOKIES);
-        Assert.assertEquals(0, cookies.size());
+        Assertions.assertEquals(0, cookies.size());
     }
 
     @Test
@@ -169,18 +169,18 @@ public class TestHC4CookieManager extends JMeterTestCase {
         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
         man.addCookieFromHeader(headerLine, url);
 
-        Assert.assertEquals(1, man.getCookieCount());
+        Assertions.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);
-        Assert.assertEquals(1, cookies.size());
+        Assertions.assertEquals(1, cookies.size());
         for (org.apache.http.cookie.Cookie cookie : cookies) {
             // See http://tools.ietf.org/html/rfc6265#section-5.2.3
-            Assert.assertEquals("bt.com", cookie.getDomain());
-            Assert.assertTrue(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
+            Assertions.assertEquals("bt.com", cookie.getDomain());
+            Assertions.assertTrue(((BasicClientCookie) 
cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));
         }
     }
 
@@ -191,18 +191,18 @@ public class TestHC4CookieManager extends JMeterTestCase {
         man.setCookiePolicy(CookieSpecs.STANDARD);
         man.addCookieFromHeader(headerLine, url);
 
-        Assert.assertEquals(1, man.getCookieCount());
+        Assertions.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);
-        Assert.assertEquals(1, cookies.size());
+        Assertions.assertEquals(1, cookies.size());
         for (org.apache.http.cookie.Cookie cookie : cookies) {
             // See http://tools.ietf.org/html/rfc6265#section-5.2.3
-            Assert.assertEquals("remote.com", cookie.getDomain());
-            Assert.assertEquals("test", cookie.getName());
+            Assertions.assertEquals("remote.com", cookie.getDomain());
+            Assertions.assertEquals("test", cookie.getName());
         }
     }
 
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 f82da5a4c7..26d5916da5 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
@@ -25,8 +25,8 @@ import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.testelement.TestPlan;
 import org.apache.jorphan.test.JMeterSerialTest;
-import org.junit.Assert;
 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,7 +47,7 @@ class SamplingNamingTest extends JMeterTestCase implements 
JMeterSerialTest {
     void testBug63364(String implementation) {
         TestPlan plan = new TestPlan();
         SampleResult[] subResults = doSample(implementation);
-        Assert.assertTrue("We should have at least one sample result, we had 
none", subResults.length > 0);
+        Assertions.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());
@@ -56,10 +56,9 @@ class SamplingNamingTest extends JMeterTestCase implements 
JMeterSerialTest {
         plan.setFunctionalMode(true);
         try {
             subResults = doSample(implementation);
-            Assert.assertTrue("We should have at least one sample result, we 
had none", subResults.length > 0);
+            Assertions.assertTrue(subResults.length > 0, "We should have at 
least one sample result, we had none");
             for (SampleResult subResult : subResults) {
-                Assert.assertTrue("Expected sample label to start with " + 
JMETER_HOME_PAGE,
-                        
subResult.getSampleLabel().startsWith(JMETER_HOME_PAGE));
+                
Assertions.assertTrue(subResult.getSampleLabel().startsWith(JMETER_HOME_PAGE), 
"Expected sample label to start with " + JMETER_HOME_PAGE);
             }
         } finally {
             plan.setFunctionalMode(prevValue);
diff --git 
a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTPTest.java
 
b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTPTest.java
index 5066799ba2..28279d8287 100644
--- 
a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTPTest.java
+++ 
b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTPTest.java
@@ -20,12 +20,10 @@ package org.apache.jmeter.protocol.http.visualizers;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-import junit.framework.TestCase;
-
-public class RequestViewHTTPTest extends TestCase {
+public class RequestViewHTTPTest {
 
     @Test
     public void testGetQueryMapValueContainingAmpersand() {
@@ -33,18 +31,18 @@ public class RequestViewHTTPTest extends TestCase {
         String query = "login=toto1&pwd=Welcome%261";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(2, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(2, params.size());
 
         String[] param1 = params.get("login");
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.length);
-        Assert.assertEquals("toto1", param1[0]);
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.length);
+        Assertions.assertEquals("toto1", param1[0]);
 
         String[] param2 = params.get("pwd");
-        Assert.assertNotNull(param2);
-        Assert.assertEquals(1, param2.length);
-        Assert.assertEquals("Welcome&1", param2[0]);
+        Assertions.assertNotNull(param2);
+        Assertions.assertEquals(1, param2.length);
+        Assertions.assertEquals("Welcome&1", param2[0]);
     }
 
     //http://www.foo.com/test/json/getXXXX.jsp?postalCode=59115&qrcode=
@@ -53,18 +51,18 @@ public class RequestViewHTTPTest extends TestCase {
         String query = "postalCode=59115&qrcode=";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(2, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(2, params.size());
 
         String[] param1 = params.get("postalCode");
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.length);
-        Assert.assertEquals("59115", param1[0]);
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.length);
+        Assertions.assertEquals("59115", param1[0]);
 
         String[] param2 = params.get("qrcode");
-        Assert.assertNotNull(param2);
-        Assert.assertEquals(1, param2.length);
-        Assert.assertEquals("", param2[0]);
+        Assertions.assertNotNull(param2);
+        Assertions.assertEquals(1, param2.length);
+        Assertions.assertEquals("", param2[0]);
     }
 
     @Test
@@ -72,19 +70,19 @@ public class RequestViewHTTPTest extends TestCase {
         String query = "param2=15&param1=12&param2=baulpismuth";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(2, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(2, params.size());
 
         String[] param1 = params.get("param1");
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.length);
-        Assert.assertEquals("12", param1[0]);
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.length);
+        Assertions.assertEquals("12", param1[0]);
 
         String[] param2 = params.get("param2");
-        Assert.assertNotNull(param2);
-        Assert.assertEquals(2, param2.length);
-        Assert.assertEquals("15", param2[0]);
-        Assert.assertEquals("baulpismuth", param2[1]);
+        Assertions.assertNotNull(param2);
+        Assertions.assertEquals(2, param2.length);
+        Assertions.assertEquals("15", param2[0]);
+        Assertions.assertEquals("baulpismuth", param2[1]);
     }
 
     @Test
@@ -92,23 +90,23 @@ public class RequestViewHTTPTest extends TestCase {
         String query = "param2=15&param1=12&param3=baul%26Pismuth";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(3, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(3, params.size());
 
         String[] param1 = params.get("param1");
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.length);
-        Assert.assertEquals("12", param1[0]);
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.length);
+        Assertions.assertEquals("12", param1[0]);
 
         String[] param2 = params.get("param2");
-        Assert.assertNotNull(param2);
-        Assert.assertEquals(1, param2.length);
-        Assert.assertEquals("15", param2[0]);
+        Assertions.assertNotNull(param2);
+        Assertions.assertEquals(1, param2.length);
+        Assertions.assertEquals("15", param2[0]);
 
         String[] param3 = params.get("param3");
-        Assert.assertNotNull(param3);
-        Assert.assertEquals(1, param3.length);
-        Assert.assertEquals("baul&Pismuth", param3[0]);
+        Assertions.assertNotNull(param3);
+        Assertions.assertEquals(1, param3.length);
+        Assertions.assertEquals("baul&Pismuth", param3[0]);
     }
 
     @Test
@@ -116,23 +114,23 @@ public class RequestViewHTTPTest extends TestCase {
         String query = 
"param2=15&param1=12&param3=bu4m1KzFvsozCnR4lra0%2Be69YzpnRcF09nDjc3VJvl8%3D";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(3, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(3, params.size());
 
         String[] param1 = params.get("param1");
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.length);
-        Assert.assertEquals("12", param1[0]);
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.length);
+        Assertions.assertEquals("12", param1[0]);
 
         String[] param2 = params.get("param2");
-        Assert.assertNotNull(param2);
-        Assert.assertEquals(1, param2.length);
-        Assert.assertEquals("15", param2[0]);
+        Assertions.assertNotNull(param2);
+        Assertions.assertEquals(1, param2.length);
+        Assertions.assertEquals("15", param2[0]);
 
         String[] param3 = params.get("param3");
-        Assert.assertNotNull(param3);
-        Assert.assertEquals(1, param3.length);
-        Assert.assertEquals("bu4m1KzFvsozCnR4lra0+e69YzpnRcF09nDjc3VJvl8=", 
param3[0]);
+        Assertions.assertNotNull(param3);
+        Assertions.assertEquals(1, param3.length);
+        
Assertions.assertEquals("bu4m1KzFvsozCnR4lra0+e69YzpnRcF09nDjc3VJvl8=", 
param3[0]);
     }
 
     @Test
@@ -142,14 +140,14 @@ public class RequestViewHTTPTest extends TestCase {
                 + "<params></params><refs></refs></call></body></envelope>";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(1, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(1, params.size());
 
         Map.Entry<String, String[]> param1 = 
params.entrySet().iterator().next();
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.getValue().length);
-        Assert.assertEquals(query, param1.getValue()[0]);
-        Assert.assertTrue(StringUtils.isBlank(param1.getKey()));
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.getValue().length);
+        Assertions.assertEquals(query, param1.getValue()[0]);
+        Assertions.assertTrue(StringUtils.isBlank(param1.getKey()));
     }
 
     @Test
@@ -184,13 +182,13 @@ public class RequestViewHTTPTest extends TestCase {
                 "</SOAP-ENV:Envelope>";
         Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
 
-        Assert.assertNotNull(params);
-        Assert.assertEquals(1, params.size());
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(1, params.size());
 
         Map.Entry<String, String[]> param1 = 
params.entrySet().iterator().next();
-        Assert.assertNotNull(param1);
-        Assert.assertEquals(1, param1.getValue().length);
-        Assert.assertEquals(query, param1.getValue()[0]);
-        Assert.assertTrue(StringUtils.isBlank(param1.getKey()));
+        Assertions.assertNotNull(param1);
+        Assertions.assertEquals(1, param1.getValue().length);
+        Assertions.assertEquals(query, param1.getValue()[0]);
+        Assertions.assertTrue(StringUtils.isBlank(param1.getKey()));
     }
 }

Reply via email to