Search in sources :

Example 6 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class ConfigFileFormatterTest method require_that_field_not_found_is_ignored.

@Test
public void require_that_field_not_found_is_ignored() throws IOException {
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    root.setString("nosuchfield", "bar");
    InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ConfigFileFormat(def).encode(baos, slime);
    assertThat(baos.toString(), is(""));
}
Also used : InnerCNode(com.yahoo.config.codegen.InnerCNode) StringReader(java.io.StringReader) DefParser(com.yahoo.config.codegen.DefParser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) Test(org.junit.Test)

Example 7 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class ConfigFileFormatterTest method require_that_illegal_boolean_becomes_false.

@Test
public void require_that_illegal_boolean_becomes_false() throws IOException {
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    root.setString("boolval", "invalid");
    InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ConfigFileFormat(def).encode(baos, slime);
    assertThat(baos.toString(), is("boolval false\n"));
}
Also used : InnerCNode(com.yahoo.config.codegen.InnerCNode) StringReader(java.io.StringReader) DefParser(com.yahoo.config.codegen.DefParser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) Test(org.junit.Test)

Example 8 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class ConfigFileFormatterTest method require_that_types_are_not_checked.

// TODO: Remove this when we can reenable typechecking.
@Test
public void require_that_types_are_not_checked() throws IOException {
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    root.setString("enumval", "null");
    root.setString("intval", "null");
    root.setString("longval", "null");
    root.setString("boolval", "null");
    root.setString("doubleval", "null");
    InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ConfigFileFormat(def).encode(baos, slime);
    assertThat(baos.toString("UTF-8"), is("enumval null\nintval null\nlongval null\nboolval false\ndoubleval null\n"));
}
Also used : InnerCNode(com.yahoo.config.codegen.InnerCNode) StringReader(java.io.StringReader) DefParser(com.yahoo.config.codegen.DefParser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) Test(org.junit.Test)

Example 9 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class ConfigFileFormatterTest method assertConfigFormat.

private void assertConfigFormat(Slime slime, String expected_simpletypes) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
    new ConfigFileFormat(def).encode(baos, slime);
    assertThat(baos.toString(), is(expected_simpletypes));
}
Also used : InnerCNode(com.yahoo.config.codegen.InnerCNode) StringReader(java.io.StringReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DefParser(com.yahoo.config.codegen.DefParser)

Example 10 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class DefaultValueApplierTest method apply.

public Slime apply(Slime slime, String... extraFields) {
    StringBuilder defBuilder = new StringBuilder();
    defBuilder.append("namespace=test").append("\n");
    defBuilder.append("str string").append("\n");
    for (String field : extraFields) {
        defBuilder.append(field).append("\n");
    }
    Cursor cursor = slime.get();
    cursor.setString("str", "myvalue");
    InnerCNode def = new DefParser("simpletypes", new StringReader(defBuilder.toString())).getTree();
    DefaultValueApplier applier = new DefaultValueApplier();
    return applier.applyDefaults(slime, def);
}
Also used : InnerCNode(com.yahoo.config.codegen.InnerCNode) StringReader(java.io.StringReader) DefParser(com.yahoo.config.codegen.DefParser) Cursor(com.yahoo.slime.Cursor)

Aggregations

InnerCNode (com.yahoo.config.codegen.InnerCNode)28 Test (org.junit.Test)23 DefParser (com.yahoo.config.codegen.DefParser)21 StringReader (java.io.StringReader)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)17 Cursor (com.yahoo.slime.Cursor)15 Slime (com.yahoo.slime.Slime)14 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)10 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)7 HttpResponse (com.yahoo.container.jdisc.HttpResponse)5 Ignore (org.junit.Ignore)5 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)3 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)3 HttpRequest (com.yahoo.container.jdisc.HttpRequest)2 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)2 ConfigBuilder (com.yahoo.config.ConfigBuilder)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Utf8Array (com.yahoo.text.Utf8Array)1 LZ4PayloadCompressor (com.yahoo.vespa.config.LZ4PayloadCompressor)1 ConfigResponse (com.yahoo.vespa.config.protocol.ConfigResponse)1