You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2021/02/21 10:01:15 UTC
[jmeter] branch master updated (eb8c962 -> d7e745e)
This is an automated email from the ASF dual-hosted git repository.
fschumacher pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git.
from eb8c962 Save sub-results in correct order
new 953b394 Java floats are not that precise. Silence ErrorProne waring
new f475f17 Silence warnings of ErrorProne about usage of Date in test methods
new 341977d Silence ErrorProne in test class
new 47ecfcc Add missing Override to silence ErrorProne
new 3359589 Silence ErrorProne in test class
new 8e7a4aa Make inner class static, because we can. Silence ErrorProne
new d7e745e Get rid of cast (and silence ErrorProne)
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/jmeter/junit/JMeterTestCase.java | 32 +++++++---------------
.../org/apache/jorphan/reflect/TestFunctor.java | 4 +--
.../java/org/apache/jorphan/test/AllTests.java | 3 +-
.../apache/jorphan/gui/TableModelEventBacker.java | 10 ++++---
.../apache/jorphan/math/TestStatCalculator.java | 2 +-
.../org/apache/jorphan/util/TestConverter.java | 3 ++
.../protocol/http/curl/StringArgumentHolder.java | 1 +
7 files changed, 25 insertions(+), 30 deletions(-)
[jmeter] 07/07: Get rid of cast (and silence ErrorProne)
Posted by fs...@apache.org.
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 d7e745e8179d1994b6688101ce66d08f5c7810ca
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:53:42 2021 +0100
Get rid of cast (and silence ErrorProne)
With newer APIs we can make sure, that we get a subclass of UnitTestManager and
don't need the cast anymore.
---
src/core/src/test/java/org/apache/jorphan/test/AllTests.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/core/src/test/java/org/apache/jorphan/test/AllTests.java b/src/core/src/test/java/org/apache/jorphan/test/AllTests.java
index 8737c9b..bbbeefa 100644
--- a/src/core/src/test/java/org/apache/jorphan/test/AllTests.java
+++ b/src/core/src/test/java/org/apache/jorphan/test/AllTests.java
@@ -310,7 +310,8 @@ public final class AllTests {
if (args.length >= 3) {
try {
System.out.println("Using initializeProperties() from " + args[2]);
- UnitTestManager um = (UnitTestManager) Class.forName(args[2]).getDeclaredConstructor().newInstance();
+ UnitTestManager um = Class.forName(args[2]).asSubclass(UnitTestManager.class).getDeclaredConstructor()
+ .newInstance();
System.out.println("Setting up initial properties using: " + args[1]);
um.initializeProperties(args[1]);
} catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
[jmeter] 03/07: Silence ErrorProne in test class
Posted by fs...@apache.org.
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 341977d2464d2c9682137689f45b44a8de814904
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:33:43 2021 +0100
Silence ErrorProne in test class
Use ArrayDeque instead of LinkedList and make sure it is guarded
against null elements.
Make inner class static, because we can.
---
.../java/org/apache/jorphan/gui/TableModelEventBacker.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java b/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java
index 9842649..051f414 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/gui/TableModelEventBacker.java
@@ -21,9 +21,9 @@ import static java.lang.String.format;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
-import java.util.LinkedList;
import java.util.List;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@@ -39,7 +39,7 @@ public class TableModelEventBacker implements TableModelListener {
/**
* Makes assertions for a single {@link TableModelEvent}.
*/
- public class EventAssertion {
+ public static class EventAssertion {
private List<ObjIntConsumer<TableModelEvent>> assertions = new ArrayList<>();
/**
@@ -118,14 +118,16 @@ public class TableModelEventBacker implements TableModelListener {
}
}
- private Deque<TableModelEvent> events = new LinkedList<>();
+ private Deque<TableModelEvent> events = new ArrayDeque<>();
/**
* Stores event.
*/
@Override
public void tableChanged(TableModelEvent e) {
- events.add(e);
+ if (e != null) {
+ events.add(e);
+ }
}
public Deque<TableModelEvent> getEvents() {
[jmeter] 05/07: Silence ErrorProne in test class
Posted by fs...@apache.org.
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 335958967f655e8849532851a3f8d870f674db08
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:45:27 2021 +0100
Silence ErrorProne in test class
Use ArrayDeque instead of LinkedList, even if it doesn't matter here (performance wise).
Use assertThrows instead of fail together with a try-catch block, as it should make
the intent clearer.
---
.../org/apache/jmeter/junit/JMeterTestCase.java | 32 +++++++---------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/src/core/src/test/java/org/apache/jmeter/junit/JMeterTestCase.java b/src/core/src/test/java/org/apache/jmeter/junit/JMeterTestCase.java
index 8696d22..1296969 100644
--- a/src/core/src/test/java/org/apache/jmeter/junit/JMeterTestCase.java
+++ b/src/core/src/test/java/org/apache/jmeter/junit/JMeterTestCase.java
@@ -17,12 +17,12 @@
package org.apache.jmeter.junit;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
import java.nio.charset.Charset;
+import java.util.ArrayDeque;
import java.util.Collection;
-import java.util.LinkedList;
import java.util.Locale;
import java.util.MissingResourceException;
@@ -113,14 +113,10 @@ public abstract class JMeterTestCase {
protected void checkInvalidParameterCounts(AbstractFunction func, int minimum)
throws Exception {
- Collection<CompoundVariable> parms = new LinkedList<>();
+ Collection<CompoundVariable> parms = new ArrayDeque<>();
for (int c = 0; c < minimum; c++) {
- try {
- func.setParameters(parms);
- fail("Should have generated InvalidVariableException for " + parms.size()
- + " parameters");
- } catch (InvalidVariableException ignored) {
- }
+ assertThrows(InvalidVariableException.class, () -> func.setParameters(parms),
+ "parms.size() = " + parms.size() + " is too small");
parms.add(new CompoundVariable());
}
func.setParameters(parms);
@@ -128,14 +124,10 @@ public abstract class JMeterTestCase {
protected void checkInvalidParameterCounts(AbstractFunction func, int min,
int max) throws Exception {
- Collection<CompoundVariable> parms = new LinkedList<>();
+ Collection<CompoundVariable> parms = new ArrayDeque<>();
for (int count = 0; count < min; count++) {
- try {
- func.setParameters(parms);
- fail("Should have generated InvalidVariableException for " + parms.size()
- + " parameters");
- } catch (InvalidVariableException ignored) {
- }
+ assertThrows(InvalidVariableException.class, () -> func.setParameters(parms),
+ "parms.size() = " + parms.size() + " is too small");
parms.add(new CompoundVariable());
}
for (int count = min; count <= max; count++) {
@@ -143,12 +135,8 @@ public abstract class JMeterTestCase {
parms.add(new CompoundVariable());
}
parms.add(new CompoundVariable());
- try {
- func.setParameters(parms);
- fail("Should have generated InvalidVariableException for " + parms.size()
- + " parameters");
- } catch (InvalidVariableException ignored) {
- }
+ assertThrows(InvalidVariableException.class, () -> func.setParameters(parms),
+ "parms.size() = " + parms.size() + " is too big");
}
public static void assertPrimitiveEquals(boolean expected, boolean actual) {
[jmeter] 01/07: Java floats are not that precise. Silence
ErrorProne waring
Posted by fs...@apache.org.
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 953b394d6ae455269147e4e316afbb137ec93aa0
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:17:22 2021 +0100
Java floats are not that precise. Silence ErrorProne waring
---
.../src/test/java/org/apache/jorphan/math/TestStatCalculator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/math/TestStatCalculator.java b/src/jorphan/src/test/java/org/apache/jorphan/math/TestStatCalculator.java
index c9de55a..c0cc5d6 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/math/TestStatCalculator.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/math/TestStatCalculator.java
@@ -80,7 +80,7 @@ public class TestStatCalculator {
calc.addValue(15);
calc.addValue(21);
assertEquals(16, (int) calc.getMean());
- assertEquals(8.0622577F, (float) calc.getStandardDeviation(), 0F);
+ assertEquals(8.062258F, (float) calc.getStandardDeviation(), 0F);
assertEquals(30, calc.getMax().intValue());
assertEquals(3, calc.getMin().intValue());
assertEquals(15, calc.getMedian().intValue());
[jmeter] 04/07: Add missing Override to silence ErrorProne
Posted by fs...@apache.org.
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 47ecfcc9825a44775bd196b81674b6d48d6c93ae
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:36:27 2021 +0100
Add missing Override to silence ErrorProne
---
.../java/org/apache/jmeter/protocol/http/curl/StringArgumentHolder.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/StringArgumentHolder.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/StringArgumentHolder.java
index 3c1db0e..2a72c02 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/StringArgumentHolder.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/StringArgumentHolder.java
@@ -63,6 +63,7 @@ public class StringArgumentHolder implements ArgumentHolder {
return this.name;
}
+ @Override
public Map<String, String> getMetadata() {
return Collections.unmodifiableMap(metadata);
}
[jmeter] 02/07: Silence warnings of ErrorProne about usage of Date
in test methods
Posted by fs...@apache.org.
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 f475f17c909500995e91bb64191468d6d04c18b0
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:24:47 2021 +0100
Silence warnings of ErrorProne about usage of Date in test methods
We know Date is obsolete, but those types are part of the API and
can't be removed easily. Comparison with equals should be safe
in these test methods, too. We are comparing *real* Dates.
---
src/jorphan/src/test/java/org/apache/jorphan/util/TestConverter.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/util/TestConverter.java b/src/jorphan/src/test/java/org/apache/jorphan/util/TestConverter.java
index 53f923f..4d81209 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/util/TestConverter.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/util/TestConverter.java
@@ -65,18 +65,21 @@ public class TestConverter {
}
@Test
+ @SuppressWarnings({ "UndefinedEquals", "JdkObsolete" })
public void testGetDateObjectDateWithTimeAndNullDefault() {
Date time = new Date();
assertEquals(time, Converter.getDate(time, null));
}
@Test
+ @SuppressWarnings({ "UndefinedEquals", "JdkObsolete" })
public void testGetDateObjectDateWithNullAndDateAsDefault() {
Date date = new Date();
assertEquals(date, Converter.getDate(null, date));
}
@Test
+ @SuppressWarnings("UndefinedEquals")
public void testGetDateObjectDateWithValidStringAndNullDefault() {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.HOUR_OF_DAY, 0);
[jmeter] 06/07: Make inner class static,
because we can. Silence ErrorProne
Posted by fs...@apache.org.
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 8e7a4aac89bc83b5a6e9af8ee669e49ef038c292
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Feb 21 10:50:23 2021 +0100
Make inner class static, because we can. Silence ErrorProne
---
src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java b/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java
index 94d0a0d..83ca1fe 100644
--- a/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java
+++ b/src/core/src/test/java/org/apache/jorphan/reflect/TestFunctor.java
@@ -41,7 +41,7 @@ public class TestFunctor extends JMeterTestCase {
String getString(String s);
}
- class Test1 implements HasName {
+ static class Test1 implements HasName {
private final String name;
public Test1(){
this("");
@@ -57,7 +57,7 @@ public class TestFunctor extends JMeterTestCase {
return s;
}
}
- class Test1a extends Test1{
+ static class Test1a extends Test1{
Test1a(){
super("1a");
}