jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: Convert test to jupiter (JUnit 5)
Date Sat, 11 Sep 2021 16:00:11 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher 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 6b07256  Convert test to jupiter (JUnit 5)
6b07256 is described below

commit 6b07256c05b57146bdab61d2f3ff84acfa262d16
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Sep 11 17:56:33 2021 +0200

    Convert test to jupiter (JUnit 5)
    
    Try to get rid of all old junit 4 style tests by converting them.
---
 .../http/parser/TestBug60842HtmlParser.java        | 162 +++++++++------------
 1 file changed, 70 insertions(+), 92 deletions(-)

diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBug60842HtmlParser.java
b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBug60842HtmlParser.java
index 4007d77..45ba51f 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBug60842HtmlParser.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestBug60842HtmlParser.java
@@ -27,107 +27,85 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class TestBug60842HtmlParser {
 
-    private List<String> links;
-    private String html;
-    private HTMLParser parser;
-
-    public TestBug60842HtmlParser(HTMLParser parser, String html,
-            String links) {
-        this.parser = parser;
-        this.html = html;
-        if (links.isEmpty()) {
-            this.links = Collections.emptyList();
-        } else {
-            this.links = Arrays.asList(links.split(","));
-        }
-    }
-
-    @Parameters()
-    public static Collection<Object[]> params() {
-        List<Object[]> result = new ArrayList<>();
-        for (HTMLParser parserToTest : Arrays.asList(
-                new LagartoBasedHtmlParser(), new JsoupBasedHtmlParser())) {
-
-            for (Object[] data : Arrays.asList(
-                    new Object[] { parserToTest, "<body background='abc.png'/>",
-                            "http://example.org/abc.png" },
-                    new Object[] { parserToTest,
-                            "<link href='abc.css' rel='stylesheet'/>",
-                            "http://example.org/abc.css" },
-                    new Object[] { parserToTest, "<img src='abc.png'/>",
-                            "http://example.org/abc.png" },
-                    new Object[] { parserToTest,
-                            "<base href='http://another.org'/><img src='one.png'/>",
-                            "http://another.org/one.png" },
-                    new Object[] { parserToTest, "<applet code='abc.jar'/>",
-                            "http://example.org/abc.jar" },
-                    new Object[] { parserToTest,
-                            "<object codebase='abc.jar' data='something'/>",
-                            "http://example.org/abc.jar,http://example.org/something" },
-                    new Object[] { parserToTest, "<object data='something'/>",
-                            "http://example.org/something" },
-                    new Object[] { parserToTest, "<object codebase='abc.jar'/>",
-                            "http://example.org/abc.jar" },
-                    new Object[] { parserToTest,
-                            "<input type='image' src='foo'/>",
-                            "http://example.org/foo" },
-                    new Object[] { parserToTest,
-                            "<input type='text' src='foo'/>", "" },
-                    new Object[] { parserToTest,
-                            "<frameset><frame src='foo'/></frameset>",
-                            "http://example.org/foo" },
-                    new Object[] { parserToTest, "<iframe src='foo'/>",
-                            "http://example.org/foo" },
-                    new Object[] { parserToTest, "<embed src='foo'/>",
-                            "http://example.org/foo" },
-                    new Object[] { parserToTest, "<bgsound src='foo'/>",
-                            "http://example.org/foo" },
-                    new Object[] { parserToTest, "<anytag background='foo'/>",
-                            "http://example.org/foo" },
-                    new Object[] { parserToTest,
-                            "<anytag style='foo: url(\"bar\")'/>",
-                            "http://example.org/bar" },
-                    new Object[] { parserToTest,
-                            "<anytag style=\"foo: url('bar')'\"/>",
-                            "http://example.org/bar" },
-                    new Object[] { parserToTest,
-                            "<link href='  abc\n.css  ' rel='stylesheet'/>",
-                            "http://example.org/abc.css" },
-                    new Object[] { parserToTest,
-                            "<link href='  with spaces\n.css  ' rel='stylesheet'/>",
-                            "http://example.org/with spaces.css" },
-                    new Object[] { parserToTest,
-                            "<link href='favicon.ico' rel='shortcut icon' type='image/vnd.microsoft.icon'/>",
-                            "http://example.org/favicon.ico" },
-                    new Object[] { parserToTest,
-                            "<link href='favicon.ico' rel='icon' type='image/vnd.microsoft.icon'/>",
-                            "http://example.org/favicon.ico" },
-                    new Object[] { parserToTest,
-                            "<applet codebase='/some/path' code='Application.class' />",
-                            "http://example.org/some/path/Application.class" },
-                    new Object[] { parserToTest,
-                            "<applet codebase='/some/path' code='Application.class' archive='app.jar'
/>",
-                            "http://example.org/some/path/app.jar" },
-                    new Object[] { parserToTest, "<embed src=''/>", "" },
-                    new Object[] { parserToTest, "<embed src='  '/>", "" })) {
-                result.add(data);
+    private static Stream<Arguments> params() {
+        List<String[]> snippets = Arrays.asList(
+                        new String[] { "<body background='abc.png'/>",
+                                "http://example.org/abc.png" },
+                        new String[] { "<link href='abc.css' rel='stylesheet'/>",
+                                "http://example.org/abc.css" },
+                        new String[] { "<img src='abc.png'/>",
+                                "http://example.org/abc.png" },
+                        new String[] { "<base href='http://another.org'/><img src='one.png'/>",
+                                "http://another.org/one.png" },
+                        new String[] { "<applet code='abc.jar'/>",
+                                "http://example.org/abc.jar" },
+                        new String[] { "<object codebase='abc.jar' data='something'/>",
+                                "http://example.org/abc.jar,http://example.org/something"
},
+                        new String[] { "<object data='something'/>",
+                                "http://example.org/something" },
+                        new String[] { "<object codebase='abc.jar'/>",
+                                "http://example.org/abc.jar" },
+                        new String[] { "<input type='image' src='foo'/>",
+                                "http://example.org/foo" },
+                        new String[] { "<input type='text' src='foo'/>", "" },
+                        new String[] { "<frameset><frame src='foo'/></frameset>",
+                                "http://example.org/foo" },
+                        new String[] { "<iframe src='foo'/>",
+                                "http://example.org/foo" },
+                        new String[] { "<embed src='foo'/>",
+                                "http://example.org/foo" },
+                        new String[] { "<bgsound src='foo'/>",
+                                "http://example.org/foo" },
+                        new String[] { "<anytag background='foo'/>",
+                                "http://example.org/foo" },
+                        new String[] { "<anytag style='foo: url(\"bar\")'/>",
+                                "http://example.org/bar" },
+                        new String[] { "<anytag style=\"foo: url('bar')'\"/>",
+                                "http://example.org/bar" },
+                        new String[] { "<link href='  abc\n.css  ' rel='stylesheet'/>",
+                                "http://example.org/abc.css" },
+                        new String[] { "<link href='  with spaces\n.css  ' rel='stylesheet'/>",
+                                "http://example.org/with spaces.css" },
+                        new String[] { "<link href='favicon.ico' rel='shortcut icon' type='image/vnd.microsoft.icon'/>",
+                                "http://example.org/favicon.ico" },
+                        new String[] { "<link href='favicon.ico' rel='icon' type='image/vnd.microsoft.icon'/>",
+                                "http://example.org/favicon.ico" },
+                        new String[] { "<applet codebase='/some/path' code='Application.class'
/>",
+                                "http://example.org/some/path/Application.class" },
+                        new String[] { "<applet codebase='/some/path' code='Application.class'
archive='app.jar' />",
+                                "http://example.org/some/path/app.jar" },
+                        new String[] { "<embed src=''/>", "" },
+                        new String[] { "<embed src='  '/>", "" });
+        List<Arguments> result = new ArrayList<>();
+        for (HTMLParser parserToTest : Arrays.asList(new LagartoBasedHtmlParser(), new JsoupBasedHtmlParser()))
{
+            for (String[] data : snippets) {
+                String htmlData = data[0];
+                String linksData = data[1];
+                Collection<String> links;
+                if (linksData.isEmpty()) {
+                    links = Collections.emptyList();
+                } else {
+                    links = Arrays.asList(linksData.split(","));
+                }
+                result.add(Arguments.of(parserToTest, htmlData, links));
             }
         }
-        return result;
+        return result.stream();
     }
 
-    @Test
-    public void testGetEmbeddedResourceURLsStringByteArrayURLURLCollectionString()
+    @ParameterizedTest
+    @MethodSource("params")
+    void testGetEmbeddedResourceURLsStringByteArrayURLURLCollectionString(HTMLParser parser,
String html,
+            Collection<String> links)
             throws Exception {
         final ArrayList<URLString> c = new ArrayList<>();
         parser.getEmbeddedResourceURLs("Mozilla",

Mime
View raw message