use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method put_to_nested_map.
@Test
public void put_to_nested_map() throws Exception {
Reader xmlConfig = new StringReader("<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<config name=\"foobar\">" + " <nestedmap>" + " <item key=\"bar\">" + " <inner>" + " <item key=\"bar1\">30</item>" + " <item key=\"bar2\">40</item>" + " </inner>" + " </item>" + " <item key=\"foo\">" + " <inner>" + " <item key=\"foo1\">10</item>" + " <item key=\"foo2\">20</item>" + " </inner>" + " </item>" + " </nestedmap>" + "</config>");
ConfigPayload userConfig = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(getDocument(xmlConfig)));
assertPayload("{\"nestedmap\":{" + "\"bar\":{\"inner\":{\"bar1\":\"30\",\"bar2\":\"40\"}}," + "\"foo\":{\"inner\":{\"foo1\":\"10\",\"foo2\":\"20\"}}}}", userConfig);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method testNamespace.
@Test
public void testNamespace() throws FileNotFoundException, ParserConfigurationException {
Element configRoot = getDocument(new StringReader("<config name=\"function-test\" namespace=\"config\">" + "<int_val>1</int_val> +" + "</config>"));
ConfigPayload config = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
assertPayload("{\"int_val\":\"1\"}", config);
configRoot = getDocument(new StringReader("<config name=\"config.function-test\">" + "<int_val>1</int_val> +" + "</config>"));
config = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
assertPayload("{\"int_val\":\"1\"}", config);
configRoot = getDocument(new StringReader("<config name=\"config.function_test\">" + "<int_val>1</int_val> +" + "</config>"));
config = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
assertPayload("{\"int_val\":\"1\"}", config);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method require_that_item_syntax_works_with_leaf.
@Test
public void require_that_item_syntax_works_with_leaf() throws ParserConfigurationException {
Element configRoot = getDocument("<config name=\"arraytypes\" version=\"1\">" + " <intarr>" + " <item>13</item>" + " <item>10</item>" + " <item>1337</item>" + " </intarr>" + "</config>");
ConfigPayload userConfig = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
assertPayload("{\"intarr\":[\"13\",\"10\",\"1337\"]}", userConfig);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method put_to_inner_map.
@Test
public void put_to_inner_map() throws Exception {
Reader xmlConfig = new StringReader("<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<config name=\"foobar\">" + " <innermap>" + " <item key=\"bar\">" + " <foo>baz</foo>" + " </item>" + " <item key=\"foo\">" + " <foo>bar</foo>" + " </item>" + " </innermap>" + "</config>");
ConfigPayload userConfig = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(getDocument(xmlConfig)));
assertPayload("{\"innermap\":{\"bar\":{\"foo\":\"baz\"},\"foo\":{\"foo\":\"bar\"}}}", userConfig);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method require_that_item_syntax_works_with_struct_array.
@Test
public void require_that_item_syntax_works_with_struct_array() throws ParserConfigurationException {
Element configRoot = getDocument("<config name=\"arraytypes\" version=\"1\">" + " <lolarray>" + " <item><fooarray><item>13</item></fooarray></item>" + " <item><fooarray><item>10</item></fooarray></item>" + " <item><fooarray><item>1337</item></fooarray></item>" + " </lolarray>" + "</config>");
ConfigPayload userConfig = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
assertPayload("{\"lolarray\":[{\"fooarray\":[\"13\"]},{\"fooarray\":[\"10\"]},{\"fooarray\":[\"1337\"]}]}", userConfig);
}
Aggregations