jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] 02/02: Extract conversion to bytes out of lambda
Date Sat, 10 Oct 2020 12:12:03 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

commit 235c4c39b0519ee0fcaa764228fc5ba9e7b3c034
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Oct 10 14:10:06 2020 +0200

    Extract conversion to bytes out of lambda
    
    We don't want to test the conversion of String to bytes[] for utf-8.
---
 .../http/util/TestGraphQLRequestParamUtils.java    | 31 ++++++++++++++--------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestGraphQLRequestParamUtils.java
b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestGraphQLRequestParamUtils.java
index 867b283..044b05e 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestGraphQLRequestParamUtils.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestGraphQLRequestParamUtils.java
@@ -132,30 +132,39 @@ class TestGraphQLRequestParamUtils {
 
     @ParameterizedTest
     @ValueSource(strings = { "", "{}"})
-    void testInvalidJsonData(String postData) throws JsonProcessingException, UnsupportedEncodingException
{
+    void testInvalidJsonData(String postDataAsString) throws JsonProcessingException, UnsupportedEncodingException
{
+        byte[] postData = postDataAsString.getBytes(StandardCharsets.UTF_8);
         assertThrows(IllegalArgumentException.class,
-                () -> GraphQLRequestParamUtils.toGraphQLRequestParams(postData.getBytes(StandardCharsets.UTF_8),
null));
+                () -> {
+                    GraphQLRequestParamUtils.toGraphQLRequestParams(postData, null);
+                });
     }
 
     @Test
     void testInvalidGraphQueryParam() throws JsonProcessingException, UnsupportedEncodingException
{
-        assertThrows(IllegalArgumentException.class, () -> GraphQLRequestParamUtils
-                .toGraphQLRequestParams("{\"query\":\"select * from emp\"}".getBytes(StandardCharsets.UTF_8),
null));
+        byte[] postData = "{\"query\":\"select * from emp\"}".getBytes(StandardCharsets.UTF_8);
+        assertThrows(IllegalArgumentException.class, () -> {
+            GraphQLRequestParamUtils
+                    .toGraphQLRequestParams(postData, null);
+        });
     }
 
     @Test
     void testIvalidGraphOperationName() throws JsonProcessingException, UnsupportedEncodingException
{
-        assertThrows(IllegalArgumentException.class, () -> GraphQLRequestParamUtils.toGraphQLRequestParams(
-                "{\"operationName\":{\"id\":123},\"query\":\"query { droid { id }}\"}".getBytes(StandardCharsets.UTF_8),
-                null));
+        byte[] postData = "{\"operationName\":{\"id\":123},\"query\":\"query { droid { id
}}\"}"
+                .getBytes(StandardCharsets.UTF_8);
+        assertThrows(IllegalArgumentException.class, () -> {
+            GraphQLRequestParamUtils.toGraphQLRequestParams(postData, null);
+        });
     }
 
     @Test
     void testInvalidGraphVariableType() {
-        assertThrows(IllegalArgumentException.class,
-                () -> GraphQLRequestParamUtils.toGraphQLRequestParams(
-                        "{\"variables\":\"r2d2\",\"query\":\"query { droid { id }}\"}".getBytes(StandardCharsets.UTF_8),
-                        null));
+        byte[] postData = "{\"variables\":\"r2d2\",\"query\":\"query { droid { id }}\"}"
+                .getBytes(StandardCharsets.UTF_8);
+        assertThrows(IllegalArgumentException.class, () -> {
+            GraphQLRequestParamUtils.toGraphQLRequestParams(postData, null);
+        });
     }
 
     @Test


Mime
View raw message