jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1844031 - in /jmeter/trunk: src/components/org/apache/jmeter/visualizers/SummaryReport.java src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java xdocs/changes.xml
Date Tue, 16 Oct 2018 17:33:44 GMT
Author: fschumacher
Date: Tue Oct 16 17:33:44 2018
New Revision: 1844031

URL: http://svn.apache.org/viewvc?rev=1844031&view=rev
Log:
Render uninitialized min and max values in Summary Report as `#N/A`

In the Summary Report min and max values are initialized with
`Long#MAX_VALUE` and `Long#MIN_VALUE` to work easily with them.

Those initial values are looking weird in the rendered view.
Hide them by replacing the extrema by the text `#N/A`.

Closes #407 on github
Bugzilla Id: 62822


Added:
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java   (with props)
    jmeter/trunk/test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java   (with props)
Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java?rev=1844031&r1=1844030&r2=1844031&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/SummaryReport.java Tue Oct 16
17:33:44 2018
@@ -44,6 +44,7 @@ import javax.swing.Timer;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.TableCellRenderer;
+import javax.swing.text.NumberFormatter;
 
 import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.gui.util.FileDialoger;
@@ -55,6 +56,7 @@ import org.apache.jmeter.testelement.Tes
 import org.apache.jmeter.util.Calculator;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
+import org.apache.jorphan.gui.MinMaxLongRenderer;
 import org.apache.jorphan.gui.NumberRenderer;
 import org.apache.jorphan.gui.ObjectTableModel;
 import org.apache.jorphan.gui.ObjectTableSorter;
@@ -126,8 +128,8 @@ public class SummaryReport extends Abstr
             null, // Label
             null, // count
             null, // Mean
-            null, // Min
-            null, // Max
+            new MinMaxLongRenderer("#0"), // Min //$NON-NLS-1$
+            new MinMaxLongRenderer("#0"), // Max //$NON-NLS-1$
             new NumberRenderer("#0.00"), // Std Dev. //$NON-NLS-1$
             new NumberRenderer("#0.00%"), // Error %age //$NON-NLS-1$
             new RateRenderer("#.0"),      // Throughput //$NON-NLS-1$
@@ -142,8 +144,8 @@ public class SummaryReport extends Abstr
             null, // Label
             null, // count
             null, // Mean
-            null, // Min
-            null, // Max
+            new DecimalFormat("#0"), // Min //$NON-NLS-1$
+            new DecimalFormat("#0"), // Max //$NON-NLS-1$
             new DecimalFormat("#0.00"), // Std Dev. //$NON-NLS-1$
             new DecimalFormat("#0.000%"), // Error %age //$NON-NLS-1$
             new DecimalFormat("#.00000"),      // Throughput //$NON-NLS-1$

Added: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java?rev=1844031&view=auto
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java (added)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java Tue Oct 16 17:33:44
2018
@@ -0,0 +1,31 @@
+package org.apache.jorphan.gui;
+
+/**
+ * Renders a min or max value and hides the extrema as they
+ * are used for initialization of the values and will likely be interpreted as
+ * random values.
+ * <p>
+ * {@link Long#MIN_VALUE} and {@link Long#MAX_VALUE} will be displayed as
+ * {@code #N/A}.
+ *
+ */
+public class MinMaxLongRenderer extends NumberRenderer { // NOSONAR
+
+    private static final long serialVersionUID = 1L;
+
+    public MinMaxLongRenderer(String format) {
+        super(format);
+    }
+
+    @Override
+    public void setValue(Object value) {
+        if (value instanceof Long) {
+            long longValue = ((Long) value).longValue();
+            if (!(longValue == Long.MAX_VALUE || longValue == Long.MIN_VALUE)) {
+                setText(formatter.format(longValue));
+                return;
+            }
+        }
+        setText("#N/A");
+    }
+}

Propchange: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MinMaxLongRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jmeter/trunk/test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java?rev=1844031&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java (added)
+++ jmeter/trunk/test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java Tue Oct 16 17:33:44
2018
@@ -0,0 +1,71 @@
+/*
+ * 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.jorphan.gui;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class MinMaxLongRendererTest {
+
+    @Parameters
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+            { Long.valueOf(Long.MAX_VALUE), "#N/A" },
+            { Long.valueOf(Long.MIN_VALUE), "#N/A" },
+            { Long.valueOf(0), "0" },
+            { null, "#N/A" },
+            { "invalid", "#N/A" },
+            });
+    }
+
+    private final Object value;
+    private final String expected;
+
+    public MinMaxLongRendererTest(Object value, String expected) {
+        this.value = value;
+        this.expected = expected;
+    }
+
+    @Test
+    public void testRendering() {
+        final AtomicBoolean afterInit = new AtomicBoolean(false);
+        MinMaxLongRenderer renderer = new MinMaxLongRenderer("#0") {
+            private static final long serialVersionUID = 2L;
+
+            @Override
+            public void setText(String text) {
+                if (afterInit.get()) {
+                    Assert.assertThat(text, CoreMatchers.is(expected));
+                }
+            }
+        };
+        afterInit.set(true);
+        renderer.setValue(value);
+    }
+
+}

Propchange: jmeter/trunk/test/src/org/apache/jorphan/gui/MinMaxLongRendererTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1844031&r1=1844030&r2=1844031&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Oct 16 17:33:44 2018
@@ -88,6 +88,7 @@ Summary
 
 <h3>Listeners</h3>
 <ul>
+  <li><bug>62822</bug><pr>407</pr>Render uninitialized min
and max values in Summary Report as <code>#N/A</code></li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>



Mime
View raw message