This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
The following commit(s) were added to refs/heads/master by this push:
new 082ab1d4 Sort members
082ab1d4 is described below
commit 082ab1d43074516133779e6bae68fb8e43cc830b
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 6 15:34:23 2026 -0400
Sort members
---
.../converters/BigDecimalLocaleConverter.java | 10 ++--
.../converters/BigIntegerLocaleConverter.java | 10 ++--
.../converters/BigDecimalLocaleConverterTest.java | 20 +++----
.../converters/BigIntegerLocaleConverterTest.java | 24 ++++----
.../beanutils2/converters/EnumConverterTest.java | 64 +++++++++++-----------
.../converters/InstantConverterTest.java | 18 +++---
.../converters/IntegerLocaleConverterTest.java | 18 +++---
7 files changed, 82 insertions(+), 82 deletions(-)
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
index 31956fca..7c50b269 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
@@ -62,6 +62,11 @@ public class BigDecimalLocaleConverter extends
DecimalLocaleConverter<BigDecimal
super(defaultValue, locale, pattern, useDefault, locPattern);
}
+ @Override
+ protected boolean isParseBigDecimal() {
+ return true;
+ }
+
/**
* Parses the specified locale-sensitive input object into an output
object of BigDecimal type.
*
@@ -84,9 +89,4 @@ public class BigDecimalLocaleConverter extends
DecimalLocaleConverter<BigDecimal
throw new ConversionException("Supplied number is not of type
BigDecimal: " + result);
}
}
-
- @Override
- protected boolean isParseBigDecimal() {
- return true;
- }
}
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
index 73433fff..cca5c2b3 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
@@ -63,6 +63,11 @@ public class BigIntegerLocaleConverter extends
DecimalLocaleConverter<BigInteger
super(defaultValue, locale, pattern, useDefault, locPattern);
}
+ @Override
+ protected boolean isParseBigDecimal() {
+ return true;
+ }
+
/**
* Parses the specified locale-sensitive input object into an output
object of BigInteger type.
*
@@ -88,9 +93,4 @@ public class BigIntegerLocaleConverter extends
DecimalLocaleConverter<BigInteger
}
return BigInteger.valueOf(result.longValue());
}
-
- @Override
- protected boolean isParseBigDecimal() {
- return true;
- }
}
diff --git
a/src/test/java/org/apache/commons/beanutils2/converters/BigDecimalLocaleConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/converters/BigDecimalLocaleConverterTest.java
index 247bb4d8..d1f9a9a8 100644
---
a/src/test/java/org/apache/commons/beanutils2/converters/BigDecimalLocaleConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/converters/BigDecimalLocaleConverterTest.java
@@ -151,16 +151,6 @@ class BigDecimalLocaleConverterTest extends
AbstractLocaleConverterTest<BigDecim
convertNull(converter, defaultValue);
}
- /**
- * A value with more significant digits than a {@code double} can hold
must not be rounded through {@code double}.
- */
- @Test
- void testConvertLargeValueKeepsPrecision() {
- converter = BigDecimalLocaleConverter.builder().get();
- final String big = "9999999999999999999";
- convertValueNoPattern(converter, big, new BigDecimal(big));
- }
-
/**
* Test Converter(defaultValue, locale, pattern, localizedPattern)
constructor
*/
@@ -196,4 +186,14 @@ class BigDecimalLocaleConverterTest extends
AbstractLocaleConverterTest<BigDecim
convertInvalid(converter, "(C)", defaultValue);
convertNull(converter, "(C)", defaultValue);
}
+
+ /**
+ * A value with more significant digits than a {@code double} can hold
must not be rounded through {@code double}.
+ */
+ @Test
+ void testConvertLargeValueKeepsPrecision() {
+ converter = BigDecimalLocaleConverter.builder().get();
+ final String big = "9999999999999999999";
+ convertValueNoPattern(converter, big, new BigDecimal(big));
+ }
}
diff --git
a/src/test/java/org/apache/commons/beanutils2/converters/BigIntegerLocaleConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/converters/BigIntegerLocaleConverterTest.java
index 476a6f8e..63197fdf 100644
---
a/src/test/java/org/apache/commons/beanutils2/converters/BigIntegerLocaleConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/converters/BigIntegerLocaleConverterTest.java
@@ -151,18 +151,6 @@ class BigIntegerLocaleConverterTest extends
AbstractLocaleConverterTest<BigInteg
convertNull(converter, defaultValue);
}
- /**
- * A value with more digits than fit in a {@code long} must keep its full
magnitude instead of saturating to {@link Long#MAX_VALUE}.
- */
- @Test
- void testConvertLargeValueKeepsMagnitude() {
- converter = BigIntegerLocaleConverter.builder().get();
- final String big = "9999999999999999999";
- convertValueNoPattern(converter, big, new BigInteger(big));
- final String huge = "123456789012345678901234567890";
- convertValueNoPattern(converter, huge, new BigInteger(huge));
- }
-
/**
* Test Converter(defaultValue, locale, pattern, localizedPattern)
constructor
*/
@@ -204,6 +192,18 @@ class BigIntegerLocaleConverterTest extends
AbstractLocaleConverterTest<BigInteg
convertNull(converter, "(C)", defaultValue);
}
+ /**
+ * A value with more digits than fit in a {@code long} must keep its full
magnitude instead of saturating to {@link Long#MAX_VALUE}.
+ */
+ @Test
+ void testConvertLargeValueKeepsMagnitude() {
+ converter = BigIntegerLocaleConverter.builder().get();
+ final String big = "9999999999999999999";
+ convertValueNoPattern(converter, big, new BigInteger(big));
+ final String huge = "123456789012345678901234567890";
+ convertValueNoPattern(converter, huge, new BigInteger(huge));
+ }
+
/**
* Tests that a non-integer value is rejected rather than silently
truncated to an integer.
*/
diff --git
a/src/test/java/org/apache/commons/beanutils2/converters/EnumConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/converters/EnumConverterTest.java
index 260d9196..75b57325 100644
---
a/src/test/java/org/apache/commons/beanutils2/converters/EnumConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/converters/EnumConverterTest.java
@@ -39,9 +39,6 @@ class EnumConverterTest {
ORDERED, READY, DELIVERED;
}
- /** Set from {@link StaticInitProbe}'s static initializer; read without
touching the probe class. */
- static volatile boolean probeInitialized;
-
/** Non-enum helper whose static initializer records that it ran. */
public static final class StaticInitProbe {
static {
@@ -49,6 +46,9 @@ class EnumConverterTest {
}
}
+ /** Set from {@link StaticInitProbe}'s static initializer; read without
touching the probe class. */
+ static volatile boolean probeInitialized;
+
private Converter<Enum<PizzaStatus>> converter;
protected Class<?> getExpectedType() {
@@ -70,29 +70,8 @@ class EnumConverterTest {
}
@Test
- void testSimpleConversion() throws Exception {
- final String[] message = { "from String", "from String", "from
String", "from String", "from String", "from String", "from String", "from
String", };
- final Object[] input = { "DELIVERED", "ORDERED", "READY" };
- final PizzaStatus[] expected = { PizzaStatus.DELIVERED,
PizzaStatus.ORDERED, PizzaStatus.READY };
- for (int i = 0; i < expected.length; i++) {
- assertEquals(expected[i], converter.convert(PizzaStatus.class,
input[i]), message[i] + " to Enum");
- }
- for (int i = 0; i < expected.length; i++) {
- assertEquals(input[i], converter.convert(String.class,
expected[i]), input[i] + " to String");
- }
- }
-
- /**
- * Tests a conversion to an unsupported type.
- */
- @Test
- void testUnsupportedType() {
- assertThrows(ConversionException.class, () ->
converter.convert(Integer.class, "http://www.apache.org"));
- }
-
- @Test
- void testConvertTimeUnit() {
- assertEquals(TimeUnit.NANOSECONDS, converter.convert(Enum.class,
"java.util.concurrent.TimeUnit.NANOSECONDS"));
+ void testBrokenNamingConvention() {
+ assertThrows(ConversionException.class, () ->
converter.convert(Enum.class, "JAVA-TIME-DAYOFWEEK#MONDAY"));
}
@Test
@@ -106,8 +85,8 @@ class EnumConverterTest {
}
@Test
- void testBrokenNamingConvention() {
- assertThrows(ConversionException.class, () ->
converter.convert(Enum.class, "JAVA-TIME-DAYOFWEEK#MONDAY"));
+ void testConvertTimeUnit() {
+ assertEquals(TimeUnit.NANOSECONDS, converter.convert(Enum.class,
"java.util.concurrent.TimeUnit.NANOSECONDS"));
}
@Test
@@ -115,15 +94,36 @@ class EnumConverterTest {
assertThrows(ConversionException.class, () ->
converter.convert(Enum.class, "java.lang.String#MONDAY"));
}
+ @Test
+ void testNonEnumClassIsNotInitialized() {
+ final String name = StaticInitProbe.class.getName() + "#VALUE";
+ assertThrows(ConversionException.class, () ->
converter.convert(Enum.class, name));
+ assertFalse(probeInitialized, "Resolving a non-enum class must not run
its static initializer");
+ }
+
@Test
void testNonExistingClasses() {
assertThrows(ConversionException.class, () ->
converter.convert(Enum.class, "java.lang.does.not.exist#MONDAY"));
}
@Test
- void testNonEnumClassIsNotInitialized() {
- final String name = StaticInitProbe.class.getName() + "#VALUE";
- assertThrows(ConversionException.class, () ->
converter.convert(Enum.class, name));
- assertFalse(probeInitialized, "Resolving a non-enum class must not run
its static initializer");
+ void testSimpleConversion() throws Exception {
+ final String[] message = { "from String", "from String", "from
String", "from String", "from String", "from String", "from String", "from
String", };
+ final Object[] input = { "DELIVERED", "ORDERED", "READY" };
+ final PizzaStatus[] expected = { PizzaStatus.DELIVERED,
PizzaStatus.ORDERED, PizzaStatus.READY };
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], converter.convert(PizzaStatus.class,
input[i]), message[i] + " to Enum");
+ }
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(input[i], converter.convert(String.class,
expected[i]), input[i] + " to String");
+ }
+ }
+
+ /**
+ * Tests a conversion to an unsupported type.
+ */
+ @Test
+ void testUnsupportedType() {
+ assertThrows(ConversionException.class, () ->
converter.convert(Integer.class, "http://www.apache.org"));
}
}
diff --git
a/src/test/java/org/apache/commons/beanutils2/converters/InstantConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/converters/InstantConverterTest.java
index 29bcb5b9..ef381f6f 100644
---
a/src/test/java/org/apache/commons/beanutils2/converters/InstantConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/converters/InstantConverterTest.java
@@ -54,13 +54,6 @@ class InstantConverterTest {
converter = null;
}
- @Test
- void testConvertingMilliseconds() {
- final Instant expected = Instant.ofEpochMilli(1596500083605L);
- final Instant actual = converter.convert(Instant.class,
1596500083605L);
- assertEquals(expected, actual);
- }
-
@Test
void testConvertingInstantString() {
final Instant expected = Instant.ofEpochMilli(1196676930000L);
@@ -69,12 +62,19 @@ class InstantConverterTest {
}
@Test
- void testText() {
- assertThrows(ConversionException.class, () ->
converter.convert(Instant.class, "Hello, world!"));
+ void testConvertingMilliseconds() {
+ final Instant expected = Instant.ofEpochMilli(1596500083605L);
+ final Instant actual = converter.convert(Instant.class,
1596500083605L);
+ assertEquals(expected, actual);
}
@Test
void testLocalizedNumber() {
assertThrows(ConversionException.class, () ->
converter.convert(Instant.class, "200,000,000,000"));
}
+
+ @Test
+ void testText() {
+ assertThrows(ConversionException.class, () ->
converter.convert(Instant.class, "Hello, world!"));
+ }
}
diff --git
a/src/test/java/org/apache/commons/beanutils2/converters/IntegerLocaleConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/converters/IntegerLocaleConverterTest.java
index 9fcefe7c..23981a01 100644
---
a/src/test/java/org/apache/commons/beanutils2/converters/IntegerLocaleConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/converters/IntegerLocaleConverterTest.java
@@ -192,6 +192,15 @@ class IntegerLocaleConverterTest extends
AbstractLocaleConverterTest<Integer> {
convertNull(converter, "(C)", defaultValue);
}
+ /**
+ * Tests that a non-integer value is rejected rather than silently
truncated to an integer.
+ */
+ @Test
+ void testNonIntegerRejected() {
+ converter =
IntegerLocaleConverter.builder().setDefault(defaultValue).setLocale(defaultLocale).get();
+ convertValueNoPattern(converter, "non-integer", "5.5", defaultValue);
+ }
+
/**
* Test Converting a number
*/
@@ -215,13 +224,4 @@ class IntegerLocaleConverterTest extends
AbstractLocaleConverterTest<Integer> {
final int result = converter.convert(target, (Object)
value.toString());
assertEquals(value.intValue(), result, "Wrong result");
}
-
- /**
- * Tests that a non-integer value is rejected rather than silently
truncated to an integer.
- */
- @Test
- void testNonIntegerRejected() {
- converter =
IntegerLocaleConverter.builder().setDefault(defaultValue).setLocale(defaultLocale).get();
- convertValueNoPattern(converter, "non-integer", "5.5", defaultValue);
- }
}