You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by "FSchumacher (via GitHub)" <gi...@apache.org> on 2023/04/22 11:54:52 UTC

[GitHub] [jmeter] FSchumacher commented on a diff in pull request #5812: Bug #5807 - Fix an ArrayIndexOutOfBoundsException on HTTP parameters …

FSchumacher commented on code in PR #5812:
URL: https://github.com/apache/jmeter/pull/5812#discussion_r1174398175


##########
src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTPQueryMapTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.protocol.http.visualizers;
+
+import java.util.Map;
+import java.util.stream.Stream;
+
+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;
+
+class RequestViewHTTPQueryMapTest {
+
+    private static Stream<Arguments> data() {
+        return Stream.of(
+                Arguments.of("k1=v1&=&k2=v2", 2),
+                Arguments.of("=", 0),
+                Arguments.of("k1=v1&=value&k2=v2", 3));
+    }
+
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testGetQueryMapWithEmptyKeyAndValue(String query, int numParamExpect) {
+        Map<String, String[]> params = RequestViewHTTP.getQueryMap(query);
+        Assertions.assertNotNull(params);
+        Assertions.assertEquals(numParamExpect, params.size());

Review Comment:
   But remember, that we are using Java 8 and not Kotlin (or change it accordingly) ;)
   Something equally nice could probably be achieved using Spock. But the important aspect for me, is that we have handled the values.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org