Example #1
0
        public virtual void test_of_escaping()
        {
            IniFile test = IniFile.of(CharSource.wrap(INI4));
            Multimap <string, string> keyValues1 = ImmutableListMultimap.of("a=d=", "x");

            assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1)));
        }
        public virtual void test_of_escaping()
        {
            PropertiesFile            test       = PropertiesFile.of(CharSource.wrap(FILE3));
            Multimap <string, string> keyValues1 = ImmutableListMultimap.of("a=d=", "x");

            assertEquals(test.Properties, PropertySet.of(keyValues1));
        }
        public virtual void test_of_set()
        {
            Multimap <string, string> keyValues = ImmutableListMultimap.of("a", "x", "b", "y");
            PropertiesFile            test      = PropertiesFile.of(PropertySet.of(keyValues));

            assertEquals(test.Properties, PropertySet.of(keyValues));
            assertEquals(test.ToString(), "{a=[x], b=[y]}");
        }
        public virtual void test_of_propertyNoEquals()
        {
            PropertiesFile            test      = PropertiesFile.of(CharSource.wrap("b\n"));
            Multimap <string, string> keyValues = ImmutableListMultimap.of("b", "");

            assertEquals(test.Properties, PropertySet.of(keyValues));
            assertEquals(test.ToString(), "{b=[]}");
        }
        public virtual void test_of_list()
        {
            PropertiesFile            test      = PropertiesFile.of(CharSource.wrap(FILE2));
            Multimap <string, string> keyValues = ImmutableListMultimap.of("a", "x", "a", "y");

            assertEquals(test.Properties, PropertySet.of(keyValues));
            assertEquals(test.ToString(), "{a=[x, y]}");
        }
        public virtual void test_of_noLists()
        {
            PropertiesFile            test      = PropertiesFile.of(CharSource.wrap(FILE1));
            Multimap <string, string> keyValues = ImmutableListMultimap.of("a", "x", "c", "z", "b", "y");

            assertEquals(test.Properties, PropertySet.of(keyValues));
            assertEquals(test.ToString(), "{a=[x], c=[z], b=[y]}");
        }
Example #7
0
        public virtual void test_of_propertyNoEquals()
        {
            IniFile test = IniFile.of(CharSource.wrap("[section]\na\n"));
            Multimap <string, string> keyValues1 = ImmutableListMultimap.of("a", "");

            assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1)));

            assertEquals(test.section("section"), PropertySet.of(keyValues1));
            assertEquals(test.section("section").contains("a"), true);
            assertEquals(test.section("section").valueList("a"), ImmutableList.of(""));
            assertEquals(test.section("section").contains("b"), false);
            assertEquals(test.section("section").keys(), ImmutableSet.of("a"));
            assertEquals(test.section("section").asMultimap(), ImmutableListMultimap.of("a", ""));
            assertEquals(test.ToString(), "{section={a=[]}}");
        }
Example #8
0
        public virtual void test_of_list()
        {
            IniFile test = IniFile.of(CharSource.wrap(INI3));
            Multimap <string, string> keyValues1 = ImmutableListMultimap.of("a", "x", "a", "y");

            assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1)));

            assertEquals(test.section("section"), PropertySet.of(keyValues1));
            assertEquals(test.section("section").contains("a"), true);
            assertThrowsIllegalArg(() => test.section("section").value("a"));
            assertEquals(test.section("section").valueList("a"), ImmutableList.of("x", "y"));
            assertEquals(test.section("section").contains("b"), false);
            assertEquals(test.section("section").keys(), ImmutableSet.of("a"));
            assertEquals(test.section("section").asMultimap(), ImmutableListMultimap.of("a", "x", "a", "y"));
            assertEquals(test.ToString(), "{section={a=[x, y]}}");
        }
Example #9
0
        public virtual void test_of_noLists()
        {
            IniFile test = IniFile.of(CharSource.wrap(INI1));
            Multimap <string, string> keyValues1 = ImmutableListMultimap.of("c", "x", "b", "y", "a", "z");
            Multimap <string, string> keyValues2 = ImmutableListMultimap.of("a", "m", "b", "n");

            assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1), "name", PropertySet.of(keyValues2)));

            assertEquals(test.contains("section"), true);
            assertEquals(test.section("section"), PropertySet.of(keyValues1));
            assertEquals(test.section("section").contains("c"), true);
            assertEquals(test.section("section").value("c"), "x");
            assertEquals(test.section("section").valueList("c"), ImmutableList.of("x"));
            assertEquals(test.section("section").contains("b"), true);
            assertEquals(test.section("section").value("b"), "y");
            assertEquals(test.section("section").valueList("b"), ImmutableList.of("y"));
            assertEquals(test.section("section").contains("a"), true);
            assertEquals(test.section("section").value("a"), "z");
            assertEquals(test.section("section").valueList("a"), ImmutableList.of("z"));
            assertEquals(test.section("section").contains("d"), false);
            // order must be retained
            assertEquals(ImmutableList.copyOf(test.section("section").keys()), ImmutableList.of("c", "b", "a"));
            assertEquals(test.section("section").asMultimap(), ImmutableListMultimap.of("c", "x", "b", "y", "a", "z"));

            assertEquals(test.contains("name"), true);
            assertEquals(test.section("name"), PropertySet.of(keyValues2));
            assertEquals(test.section("name").contains("a"), true);
            assertEquals(test.section("name").value("a"), "m");
            assertEquals(test.section("name").valueList("a"), ImmutableList.of("m"));
            assertEquals(test.section("name").contains("b"), true);
            assertEquals(test.section("name").value("b"), "n");
            assertEquals(test.section("name").valueList("b"), ImmutableList.of("n"));
            assertEquals(test.section("name").contains("c"), false);
            assertEquals(ImmutableList.copyOf(test.section("name").keys()), ImmutableList.of("a", "b"));
            assertEquals(test.section("name").asMultimap(), ImmutableListMultimap.of("a", "m", "b", "n"));

            assertEquals(test.contains("unknown"), false);
            assertThrowsIllegalArg(() => test.section("unknown"));
            assertEquals(test.section("section").valueList("unknown"), ImmutableList.of());
            assertThrowsIllegalArg(() => test.section("section").value("unknown"));
            assertEquals(test.ToString(), "{section={c=[x], b=[y], a=[z]}, name={a=[m], b=[n]}}");
        }