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 0c3fd6d2 Add disabled tests for CONFIGURATION-848 0c3fd6d2 is described below commit 0c3fd6d268bd76d0f8937653a4989369426017e0 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Jun 30 12:52:30 2024 -0400 Add disabled tests for CONFIGURATION-848 --- .../configuration2/TestSubsetConfiguration440.java | 84 ++++++++++++++++++++++ src/test/resources/test-configuration-440.json | 51 +++++++++++++ 2 files changed, 135 insertions(+) diff --git a/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration440.java b/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration440.java new file mode 100644 index 00000000..d7d18715 --- /dev/null +++ b/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration440.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.configuration2; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertFalse; + +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +// import org.junit.Test; + +/** + * Test case for the {@link SubsetConfiguration} class. + */ +public class TestSubsetConfiguration440 { + + /** + * Tests CONFIGURATION-848. + */ + @Test + @Disabled + public void testSubsetConfigurationWithIndexAndDelimiter() throws ConfigurationException, IOException { + final JSONConfiguration jsonConfiguration = new JSONConfiguration(); + try (FileReader in = new FileReader(ConfigurationAssert.getTestFile("test-configuration-440.json").getAbsolutePath())) { + jsonConfiguration.read(in); + } + // 1. using composite configuration + final List<Configuration> list = new ArrayList<>(); + list.add(jsonConfiguration); + list.add(jsonConfiguration); + final CompositeConfiguration composite = new CompositeConfiguration(list); + Configuration subset = composite.subset("books(0).details"); + assertFalse(subset.isEmpty()); + assertEquals(2, subset.size()); + assertEquals("No Longer Human", subset.getString("title")); + // 2. using '.' delimiter + subset = new SubsetConfiguration(jsonConfiguration, "books(0).details", "."); + assertFalse(subset.isEmpty()); + assertEquals(2, subset.size()); + assertEquals("No Longer Human", subset.getString("title")); + // 3. using '@' delimiter + subset = new SubsetConfiguration(jsonConfiguration, "books(1)@details", "@"); + assertFalse(subset.isEmpty()); + assertEquals(2, subset.size()); + assertEquals("White Nights", subset.getString("title")); + } + + @Test + @Disabled + public void testSubsetWithJSONConfiguration() throws ConfigurationException, IOException { + final JSONConfiguration jsonConfiguration = new JSONConfiguration(); + try (FileReader in = new FileReader(ConfigurationAssert.getTestFile("test-configuration-440.json").getAbsolutePath())) { + jsonConfiguration.read(in); + } + final SubsetConfiguration subset = new SubsetConfiguration(jsonConfiguration, "capitals(0)", "."); + assertFalse(subset.isEmpty()); + assertEquals(2, subset.size()); + assertEquals("USA", subset.getString("country")); + } +} diff --git a/src/test/resources/test-configuration-440.json b/src/test/resources/test-configuration-440.json new file mode 100644 index 00000000..373c8924 --- /dev/null +++ b/src/test/resources/test-configuration-440.json @@ -0,0 +1,51 @@ +{ + "key1": "value1", + "key2": { + "key3": "value23" + }, + "key4": { + "key5": [ + "col1", + "col2" + ] + }, + "very": { + "nested": { + "properties": [ + "nested1", + "nested2", + "nested3" + ] + } + }, + "int1": 37, + "martin": { + "name": "Martin D'vloper", + "job": "Developer", + "skill": "Elite" + }, + "capitals": [ + { + "country": "USA", + "capital": "Washington" + }, + { + "country": "UK", + "capital": "London" + } + ], + "books": [ + { + "details": { + "title": "No Longer Human", + "author": "Osamu Dazai" + } + }, + { + "details": { + "title": "White Nights", + "author": "Fyodor Dostoevsky" + } + } + ] +}