Commit Graph

5568 Commits

Author SHA1 Message Date
Allon Mureinik f7fae53aec Functions' interfaces modifiers
Remove the redundant public modifier from the inner interfaces in
Functions, as per the Checkstyle policy of the project.
2019-02-08 18:18:40 +02:00
Allon Mureinik 1c48eb0d8b Add license to FunctionsTest.java
Add a license header to FunctionsTest.java to make the rat maven task
pass.
2019-02-08 17:47:29 +02:00
Benedikt Ritter ef1480a505
Add missing Apache license header 2019-02-08 16:42:31 +01:00
Jochen Wiedmann (jwi) 2ebc17ba3f Added Functions.tryWithResources. 2019-01-29 11:42:07 +01:00
Jochen Wiedmann (jwi) 11d9eb47a4 Adding the Functions class as a helper for dealing with Java 8 Lambdas. 2019-01-23 14:59:25 +01:00
Bruno P. Kinoshita b00e65686e Fix checkstyle issues in new test code 2019-01-08 20:01:56 +13:00
Bruno P. Kinoshita 104cc28105 Merge branch 'pr-379'
This closes pr #379

Thanks to @apirom9
2019-01-08 19:48:34 +13:00
Apirom Na Nakorn bf77678673 add test use ImmutablePair class with java.util.HashMap and java.util.TreeMap 2019-01-08 19:48:22 +13:00
pascalschumacher f7c62b29c9 Update spotbugs-maven-plugin to version 3.1.10 2019-01-05 22:51:18 +01:00
pascalschumacher ef18f3ea26 Travis: "openjdk-ea" now means Java 13, so add Java 12 to JDKs to build on. (closes #396) 2019-01-05 22:13:24 +01:00
RahulNagekar cee7cc6b64 Refactoring junits of JsonToStringStyle 2018-12-21 01:05:50 +05:30
RahulNagekar 92e63fb3c8 Adding junits for JsonToStringStyle
Signed-off-by: RahulNagekar <rahul.nagekar1@gmail.com>
2018-12-21 00:42:34 +05:30
pascalschumacher e0a5a4b5b6 Update to JaCoCo 0.8.2 with works Java 11+. 2018-12-20 14:48:34 +01:00
pascalschumacher a48d045709 LANG-1427: Add SystemUtils.isJavaVersionAtMost(JavaVersion)
Fix checkstyle violations.
2018-12-20 14:26:28 +01:00
Gary Gregory e21cb463c0 Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-lang.git 2018-12-10 17:48:30 -07:00
Gary Gregory a410aab651 [LANG-1427] Add API
org.apache.commons.lang3.SystemUtils.isJavaVersionAtMost(JavaVersion)
2018-12-10 17:48:06 -07:00
RahulNagekar c368955343 Add additional tests for StandardToStringStyle (closes #390) 2018-12-02 19:59:59 +01:00
pascalschumacher 37ba8d3981 Update to JUnit version 5.3.2 2018-12-02 14:11:09 +01:00
pascalschumacher aae1a0a681 Travis: Stop building with Java 9 and 10, as these are superseded by Java 11 and not supported anymore. 2018-11-24 12:47:38 +01:00
pascalschumacher 60b8f18e46 Update Spotbugs Maven Plugin to version 3.1.8 2018-11-20 21:38:15 +01:00
pascalschumacher 5cdac9cfd5 Make whitespace use around generic tokens consistent and add a checkstyle rule to enforce it. 2018-11-19 22:05:18 +01:00
pascalschumacher 07f537120f Make whitespace use before tokens consistent and add a checkstyle rule to enforce it. 2018-11-19 22:05:11 +01:00
pascalschumacher 89cbfa54b0 Make whitespace use after tokens consistent and add a checkstyle rule to enforce it. 2018-11-19 22:04:35 +01:00
Bruno P. Kinoshita c4d0dbcb56 Merge branch 'pr-380'
This closes #380 thanks to @oorijsonar
2018-11-03 13:50:48 +13:00
Uri e1618fa232 fix javadoc typo 2018-11-02 16:48:04 -07:00
pascalschumacher a668a47981 Update JUnit Pioneer to version 0.3.0 2018-11-02 21:05:14 +01:00
pascalschumacher 5ccbfeb86f Update maven-spotbugs-plugin to version 3.1.7 2018-11-02 21:01:51 +01:00
Gary Gregory 0fcd4ce92a Update EasyMock from 3.6 to 4.0 to fix testing on Java 11. 2018-10-28 09:11:14 -06:00
pascalschumacher 97ade3f6e3 Use surefire plugin version from parent POM. 2018-10-26 19:51:07 +02:00
pascalschumacher b278ac8c39 Remove unused test code 2018-10-26 19:49:58 +02:00
pascalschumacher 5afe35c024 LANG-1422: Add null-safe StringUtils.valueOf(char[]) to delegate to String.valueOf(char[])
Fix checkstyle violations
2018-10-26 19:48:28 +02:00
Gary Gregory c70e05ae41 [LANG-1422] Add null-safe StringUtils.valueOf(char[]) to delegate to
String.valueOf(char[])
2018-10-25 08:52:48 -06:00
pascalschumacher b60ca26a23 Travis: Remove Oracle JDK 10 because it is no longer available 2018-10-17 08:55:05 +02:00
Allon Mureinik 3609993fb5 Clean up assertions (closes #376)
Use built-in assertion methods provides by
org.junit.jupiter.api.Assertions instead of reimplementing the same
logic with assertTrue and assertFalse.

Note that JUnit Jupiter 5.3.1 does not support deltas of 0 for
assertEquals(double, double, double) and
assertEquals(float, float, float), so these usages of assertTrue were
left untouched, and will be addressed when JUnit Jupiter 5.4, that
addresses this isssue, will be available (see
https://github.com/junit-team/junit5/pull/1613 for details).
2018-10-13 21:10:54 +02:00
Allon Mureinik b3d86ca08a Clean up redundant throws clauses 2018-10-13 21:09:37 +02:00
Allon Mureinik e00e871d1d Use assertTrue/assertFalse instead of reimplementing them
Use assertTrue and assertFalse instead of reimplemeting their logic by
having an if statement conditionalling call fail.
2018-10-13 21:09:37 +02:00
Allon Mureinik 3387734b4f Clean up testing of exceptions
Now that the entire project is ported to JUnit Jupiter, there are more
elegant ways to test for exceptions, which this patch applies
throughtout the code base.

If throwing an exception is supposed to fail a test, just throwing it
outside of the method cleans up the code and makes it more elegant,
instead of catching it and calling Assertions#fail.

If an exception is supposed to be thrown, calling
Assertions#assertThrows is a more elegant option than calling
Assertions#fail in the try block and then catching and ignoring the
expected exception.
Note that assertThrows uses a lambda block, so the variables inside it
should be final or effectively final. Reusing variables is a common
practice in the tests, so where needed new final variables were
introduced, or the variables used were inlined.
2018-10-13 21:09:36 +02:00
Allon Mureinik 0fa0bfd8bb Remove double stop() test in StopWatchTest
StopWatchTest#testBadStates has the same block of code testing
StopWatch#stop copy-pasted.
This patch cleans it up by removing one of those blocks.
2018-10-13 21:09:36 +02:00
Allon Mureinik fde19e79d5 Make LocaleUtilsTest#parseAllLocales parameterized
This patch converts testParseAllLocales to a @ParameterizedTest instead
of iterating over the locales inside the method's body.
This changes allows using standard asserts for each case individually
instead of having to count failures and print the problematic locales
to System.out.
2018-10-13 21:09:35 +02:00
Allon Mureinik 369d0616ce Remove ConversionTest#assertBinaryEquals
JUnit Jupiter's Assertions has an
assertArraysEuqals(boolean[], boolean[]) method, so there's no longer a
need for the assertBinaryEquals method.
2018-10-13 21:09:35 +02:00
pascalschumacher 46ea7e5e96 Update checkstyle to version 8.13 2018-10-13 20:22:23 +02:00
Allon Mureinik e99b0dde8e Update tests to JUnit Jupiter (closes #375)
This patch finalizes the upgrade of commons-lang's tests to use JUnit
Jupiter and remove the Vintage Engine dependency entirely.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Assert.assertEquals(double, double, double),
org.junit.jupiter.api.Assertions.assertEquals(double, double, double)
does not support deltas of zero, only strictly positive deltas.
This issue will be addressed in JUnit Jupiter 5.4 (see
https://github.com/junit-team/junit5/pull/1613 for details). In the
meanwhile, assertTrue(expected==actual) was used, and TODO comments were
placed in the code to refactor it to assertEquals once JUnit 5.4 is
available.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have a
"timeout" argument either. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertTimeoutPreemptively is used.

JUnit Jupiter also no longer has the concept of Rules. Usages of the
SystemDefaultsSwitch rule and its accompanying annotates were replaced
with the @DefaultLocale annotation that Benedikt Ritter contributed to
JUnit Pioneer, the semi-official JUnit extension project.
Following the removal of their usages, the SystemDefaults annotation,
the SystemDefaultsSwitch rule and the SystemDefaultsSwitchTest class
that tests them had no more use, and they were removed entirely.

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
more elegant with Jupiter's new features, but that work is left for
subsequent patches.
2018-10-11 22:28:38 +02:00
Allon Mureinik ca2e59c513 Update time tests to JUnit Jupiter
Upgrade the tests in the time package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

JUnit Jupiter no longer has a concept of runners. Tests previously run
with the org.junit.runners.Parameterized runner were rewritten to use
@ParameterizedTest and a @MethodSource.

JUnit Jupiter also no longer has the concept of Rules. Usages of the
SystemDefaultsSwitch rule and its accompanying annotates were replaced
with the @DefaultLocale and @DefaultTimezone annotations that
Benedikt Ritter contributed to JUnit Pioneer, the semi-official JUnit
extension project.

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
more elegant with Jupiter's new features, but that work is left for
subsequent patches.
2018-10-10 19:09:33 +03:00
Allon Mureinik 94beded839 Update mutable tests to JUnit Jupiter
Upgrade the tests in the mutable package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

Unlike org.junit.Assert.assertEquals(double, double, double),
org.junit.jupiter.api.Assertions.assertEquals(double, double, double)
does not support deltas of zero, only strictly positive deltas.
This issue will be addressed in JUnit Jupiter 5.4 (see
https://github.com/junit-team/junit5/pull/1613 for details). In the
meanwhile, assertTrue(expected==actual) was used, and TODO comments were
placed in the code to refactor it to assertEquals once JUnit 5.4 is
available.

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
more elegant with Jupiter's new features, but that work is left for
subsequent patches.
2018-10-09 19:39:13 +03:00
Allon Mureinik 47a9ea7c82 Update math tests to JUnit Jupiter
Upgrade the tests in the math package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

Unlike org.junit.Assert.assertEquals(double, double, double),
org.junit.jupiter.api.Assertions.assertEquals(double, double, double)
does not support deltas of zero, only strictly positive deltas.
This issue will be addressed in JUnit Jupiter 5.4 (see
https://github.com/junit-team/junit5/pull/1613 for details). In the
meanwhile, assertTrue(expected==actual) was used, and TODO comments were
placed in the code to refactor it to assertEquals once JUnit 5.4 is
available.

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
more elegant with Jupiter's new features, but that work is left for
subsequent patches.
2018-10-09 09:41:10 +03:00
Allon Mureinik f110da945a Update tuple tests to JUnit Jupiter
Upgrade the tests in the text package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.
2018-10-08 22:23:34 +03:00
Allon Mureinik 182e335432 Update text tests to JUnit Jupiter
Upgrade the tests in the text package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
more elegant with Jupiter's new features, but that work is left for
subsequent patches.
2018-10-08 19:47:57 +03:00
Allon Mureinik cbc8e0b295 Update reflect tests to JUnit Jupiter
Upgrade the tests in the reflect package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

Unlike org.junit.Assume, org.junit.jupiter.api.Assumptions does not have
an assumtNotNull method. Instead, assumeTrue was used with an explicit
condition of a variable being different than null.

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
more elegant with Jupiter's new features, but that work is left for
subsequent patches.
2018-10-08 01:38:55 +03:00
Allon Mureinik 884d273f42 Update exception tests to JUnit Jupiter
Upgrade the tests in the exception package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, there are some non-obvious changes worth mentioning.

Unlike org.junit.Test, org.junit.jupiter.api.Test does not have an
"expected" argument. Instead, an explicit call to
org.junit.jupiter.api.Assertions.assertThrows is used.

Another non-obvious change was performed in
ContextedRuntimeExceptionTest. Unlike JUnit Vintages's @Before, JUnit
Jupiter's @BeforeEach does not apply if a parent's method is annotated
with it and the overriding method is not, so an explicit @BeforeEach
annotation had to be added to ContexedTuntimeExceptionTest#setUp().

It's also worth noting this is a minimal patch for migrating the
package's tests to Jupiter. There are several tests that can be made
made more elegant with Jupiter's new features, but that work is left
for subsequent patches.
2018-10-07 18:28:09 +03:00
Allon Mureinik 762641dcdb Update event tests to JUnit Jupiter
Upgrade the tests in the event package to use JUnit Jupiter as
part of the effort to remove the dependency on the Vintage Engine.

While most of these changes are drop-in replacements with no functional
benefit, it is worth noting the tests that test thrown excetpions.
Prior to this patch, this package tested for exceptions in two ways,
neither of which are supported in JUnit Jupiter:
1. With the "expected" argument of the org.junit.Test annotation.
2. With the org.junit.rules.ExpectedException @Rule

Both of these usages were replaced with calls to
org.junit.jupiter.api.Assertions#assertThrows.
2018-10-06 15:05:16 +03:00