use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ConfigFileFormatterTest method require_that_basic_formatting_is_correct_with_types.
@Test
public void require_that_basic_formatting_is_correct_with_types() throws IOException {
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString("stringval", "foo");
root.setLong("intval", 324234);
root.setLong("longval", 324);
root.setDouble("doubleval", 3.455);
root.setString("enumval", "VAL2");
root.setBool("boolval", true);
assertConfigFormat(slime, expected_simpletypes);
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class DeployHandlerLogger method log.
@Override
public void log(Level level, String message) {
if ((level == LogLevel.FINE || level == LogLevel.DEBUG || level == LogLevel.SPAM) && !verbose) {
return;
}
String fullMsg = Tenants.logPre(app) + message;
Cursor entry = logroot.addObject();
entry.setLong("time", System.currentTimeMillis());
entry.setString("level", level.getName());
entry.setString("message", fullMsg);
// Also tee to a normal log, Vespa log for example, but use level fine
log.log(LogLevel.FINE, fullMsg);
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ConfigPayloadBuilderTest method createSlime.
private Cursor createSlime(ConfigPayloadBuilder builder) {
Slime slime = new Slime();
Cursor root = slime.setObject();
builder.resolve(root);
return root;
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ConfigPayloadBuilderTest method require_that_arrays_can_be_indexed_structs.
@Test
public void require_that_arrays_can_be_indexed_structs() {
ConfigPayloadBuilder builder = new ConfigPayloadBuilder();
ConfigPayloadBuilder.Array array = builder.getArray("foo");
ConfigPayloadBuilder elem1 = array.set(4);
elem1.setField("bar", "baz");
ConfigPayloadBuilder elem2 = array.set(2);
elem2.setField("foo", "bar");
Cursor root = createSlime(builder);
Cursor a = root.field("foo");
assertEquals("baz", a.entry(0).field("bar").asString());
assertEquals("bar", a.entry(1).field("foo").asString());
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ConfigPayloadBuilderTest method require_that_builder_can_be_created_from_payload.
@Test
public void require_that_builder_can_be_created_from_payload() throws IOException {
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString("foo", "bar");
Cursor obj = root.setObject("foorio");
obj.setString("bar", "bam");
Cursor obj2 = obj.setObject("bario");
obj2.setString("bim", "bul");
Cursor a2 = obj.setArray("blim");
Cursor arrayobj = a2.addObject();
arrayobj.setString("fim", "fam");
Cursor arrayobj2 = a2.addObject();
arrayobj2.setString("blim", "blam");
Cursor a1 = root.setArray("arrio");
a1.addString("himbio");
ConfigPayloadBuilder builder = new ConfigPayloadBuilder(new ConfigPayload(slime));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ConfigPayload.fromBuilder(builder).serialize(baos, new JsonFormat(true));
assertThat(baos.toString(), is("{\"foo\":\"bar\",\"foorio\":{\"bar\":\"bam\",\"bario\":{\"bim\":\"bul\"},\"blim\":[{\"fim\":\"fam\"},{\"blim\":\"blam\"}]},\"arrio\":[\"himbio\"]}"));
}
Aggregations