ham1 commented on code in PR #6872:
URL: https://github.com/apache/jmeter/pull/6872#discussion_r4731775246


##########
src/jorphan/src/test/java/org/apache/jorphan/collections/PackageTest.java:
##########
@@ -174,4 +177,41 @@ public void testSearch() throws Exception {
         tree.traverse(searcher);
         assertEquals(1, searcher.getSearchResults().size());
     }
+
+    @Test
+    public void testTraverseCallbackOrder() {
+        // a has children b (with child c) and d.
+        ListedHashTree tree = new ListedHashTree();
+        tree.add("a", "b");
+        tree.getTree("a").getTree("b").add("c");
+        tree.getTree("a").add("d");
+        List<String> events = new ArrayList<>();
+        tree.traverse(new HashTreeTraverser() {
+            @Override
+            public void addNode(Object node, HashTree subTree) {
+                events.add("+" + node);
+            }
+
+            @Override
+            public void subtractNode() {
+                events.add("-");
+            }
+
+            @Override
+            public void processPath() {
+                events.add("path");
+            }
+        });
+        assertEquals(
+                Arrays.asList("+a", "+b", "+c", "path", "-", "-", "+d", 
"path", "-", "-"),
+                events);
+    }
+
+    @Test
+    public void testHashCodeDiffersForDifferentTrees() {
+        HashTree leaf = new HashTree("abcde");
+        HashTree withChild = new HashTree("abcde");
+        withChild.add("abcde", "abcdef");
+        assertNotEquals(leaf.hashCode(), withChild.hashCode());

Review Comment:
   Added a comment in 3847f008c saying it guards against a degenerate hash, 
such as a constant.



##########
src/core/src/test/java/org/apache/jmeter/samplers/TestSampleResult.java:
##########
@@ -337,6 +338,90 @@ void testEncodingAndType() throws Exception {
         Assertions.assertEquals("text", res.getDataType());
     }
 
+    @Test
+    void testEncodingAndTypeEdgeCases() {
+        SampleResult res = new SampleResult();
+        res.setEncodingAndType("text/plain; charset=ISO-8859-1; 
format=flowed");
+        Assertions.assertEquals("ISO-8859-1", res.getDataEncodingNoDefault());
+        res.setEncodingAndType("text/plain; charset='utf-16'");
+        Assertions.assertEquals("utf-16", res.getDataEncodingNoDefault());
+        res.setEncodingAndType("image/png");
+        Assertions.assertEquals(SampleResult.BINARY, res.getDataType());
+        res.setEncodingAndType("image/svg+xml");
+        Assertions.assertEquals(SampleResult.TEXT, res.getDataType());
+    }
+
+    @Test
+    void testIsBinaryType() {
+        Assertions.assertTrue(SampleResult.isBinaryType("image/png"));
+        Assertions.assertTrue(SampleResult.isBinaryType("audio/mpeg"));
+        Assertions.assertTrue(SampleResult.isBinaryType("video/mp4"));
+        // Media manifests and SVG are text, although their prefix looks 
binary.
+        Assertions.assertFalse(SampleResult.isBinaryType("audio/mpegurl"));
+        Assertions.assertFalse(SampleResult.isBinaryType("audio/x-mpegurl"));
+        Assertions.assertFalse(SampleResult.isBinaryType("video/f4m"));
+        Assertions.assertFalse(SampleResult.isBinaryType("image/svg+xml"));
+        Assertions.assertFalse(SampleResult.isBinaryType("text/html"));
+    }
+
+    @Test
+    void testAddSubResultAddsSizesAndSharesThreadName() {

Review Comment:
   Split into four tests in 97942e302: size totals, thread name, bytes-only 
totals and the `null` sub result.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to