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 2022/08/06 13:15:30 UTC
[commons-configuration] branch master updated: Add tests for CONFIGURATION-793
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git
The following commit(s) were added to refs/heads/master by this push:
new d492d263 Add tests for CONFIGURATION-793
d492d263 is described below
commit d492d263443e6d51491bedf019e80e3dab0e6c5a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 6 09:15:24 2022 -0400
Add tests for CONFIGURATION-793
One passing, one failing and disabled.
---
.../configuration2/TestJSONConfiguration.java | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java b/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
index 6401dac5..c303b349 100644
--- a/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
@@ -18,6 +18,7 @@
package org.apache.commons.configuration2;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.io.FileReader;
@@ -29,6 +30,7 @@ import java.util.Map;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
@@ -58,6 +60,13 @@ public class TestJSONConfiguration {
assertEquals("bar", jsonConfiguration.getString("foo"));
}
+ /**
+ * Tests CONFIGURATION-793.
+ */
+ public void testGetList_nested_with_list() {
+ assertEquals(Arrays.asList("col1", "col2"), jsonConfiguration.getList(String.class, "key4.key5"));
+ }
+
@Test
public void testGetProperty_dictionary() {
assertEquals("Martin D'vloper", jsonConfiguration.getProperty("martin.name"));
@@ -105,6 +114,26 @@ public class TestJSONConfiguration {
assertEquals(Arrays.asList("nested1", "nested2", "nested3"), property);
}
+ /**
+ * Tests CONFIGURATION-793.
+ */
+ @Disabled
+ @Test
+ public void testListOfObjects() {
+ final Configuration subset = jsonConfiguration.subset("capitals");
+ assertNotNull(subset);
+ assertEquals(2, subset.size());
+
+ final List<Object> list = jsonConfiguration.getList("capitals");
+ assertNotNull(list);
+ assertEquals(2, list.size());
+
+// assertEquals(list.get(0).get("country"), "USA");
+// assertEquals(list.get(0).get("capital"), "Washington");
+// assertEquals(list.get(1).get("country"), "UK");
+// assertEquals(list.get(1).get("capital"), "London");
+ }
+
@Test
public void testSave() throws IOException, ConfigurationException {
// save the Configuration as a String...