Search in sources :

Example 1 with ConfigPayload

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);
}
Also used : ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Test(org.junit.Test)

Example 2 with ConfigPayload

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);
}
Also used : ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Element(org.w3c.dom.Element) Test(org.junit.Test)

Example 3 with ConfigPayload

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);
}
Also used : ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Element(org.w3c.dom.Element) Test(org.junit.Test)

Example 4 with ConfigPayload

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);
}
Also used : ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Test(org.junit.Test)

Example 5 with ConfigPayload

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);
}
Also used : ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Element(org.w3c.dom.Element) Test(org.junit.Test)

Aggregations

ConfigPayload (com.yahoo.vespa.config.ConfigPayload)41 Test (org.junit.Test)29 InnerCNode (com.yahoo.config.codegen.InnerCNode)10 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)6 Slime (com.yahoo.slime.Slime)6 Element (org.w3c.dom.Element)6 HttpResponse (com.yahoo.container.jdisc.HttpResponse)5 FunctionTestConfig (com.yahoo.foo.FunctionTestConfig)4 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)4 DefParser (com.yahoo.config.codegen.DefParser)3 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)3 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)3 StringReader (java.io.StringReader)3 ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)2 ApplicationId (com.yahoo.config.provision.ApplicationId)2 CfgConfigPayloadBuilder (com.yahoo.config.subscription.CfgConfigPayloadBuilder)2 ConfigInterruptedException (com.yahoo.config.subscription.ConfigInterruptedException)2 HttpRequest (com.yahoo.container.jdisc.HttpRequest)2 Utf8Array (com.yahoo.text.Utf8Array)2 ConfigCacheKey (com.yahoo.vespa.config.ConfigCacheKey)2