You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/07/04 18:35:07 UTC
(commons-collections) 02/02: Add tests as in PR #702.
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-collections.git
commit 3c402b4b36d2752ac36c7ae2649c26317d95794e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 4 14:35:00 2026 -0400
Add tests as in PR #702.
---
.../properties/SortedPropertiesTest.java | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java b/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java
index 63c14ec49..27f640eb9 100644
--- a/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java
+++ b/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java
@@ -109,6 +109,20 @@ class SortedPropertiesTest {
assertAscendingOrder(sortedProperties);
}
+ @Test
+ void testComputeToNullRemovesKey() {
+ final SortedProperties orderedProperties = new SortedProperties();
+ orderedProperties.put("a", "1");
+ orderedProperties.put("b", "2");
+ // A remapping to null removes the mapping; the ordered key view must follow.
+ orderedProperties.compute("a", (k, v) -> null);
+ assertFalse(orderedProperties.containsKey("a"));
+ assertFalse(orderedProperties.keySet().contains("a"));
+ assertEquals(1, orderedProperties.size());
+ assertEquals("[b]", orderedProperties.keySet().toString());
+ assertEquals("{b=2}", orderedProperties.toString());
+ }
+
@Test
void testEntrySet() {
final SortedProperties sortedProperties = new SortedProperties();
@@ -213,6 +227,19 @@ class SortedPropertiesTest {
assertAscendingOrder(sortedProperties);
}
+ @Test
+ void testMergeToNullRemovesKey() {
+ final SortedProperties orderedProperties = new SortedProperties();
+ orderedProperties.put("a", "1");
+ orderedProperties.put("b", "2");
+ // A remapping to null removes the mapping; the ordered key view must follow.
+ orderedProperties.merge("a", "x", (oldVal, newVal) -> null);
+ assertFalse(orderedProperties.containsKey("a"));
+ assertFalse(orderedProperties.keySet().contains("a"));
+ assertEquals(1, orderedProperties.size());
+ assertEquals("{b=2}", orderedProperties.toString());
+ }
+
@Test
void testPut() {
final SortedProperties sortedProperties = new SortedProperties();