Search in sources :

Example 11 with JsonFormat

use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.

the class ConfigInstanceSerializerTest method assertConfigEquals.

static void assertConfigEquals(String expectedJson, ConfigInstance config) {
    Slime slime = new Slime();
    ConfigInstance.serialize(config, new ConfigInstanceSerializer(slime));
    JsonFormat jsonFormat = new JsonFormat(true);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        jsonFormat.encode(baos, slime);
    } catch (IOException e) {
        fail();
    }
    assertJsonEquals(baos.toString(), expectedJson);
}
Also used : JsonFormat(com.yahoo.slime.JsonFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Slime(com.yahoo.slime.Slime)

Example 12 with JsonFormat

use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.

the class SessionActiveHandlerTest method assertActivationMessageOK.

private void assertActivationMessageOK(ActivateRequest activateRequest, String message) throws IOException {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    new JsonFormat(true).encode(byteArrayOutputStream, activateRequest.getMetaData().getSlime());
    assertThat(message, containsString("\"tenant\":\"" + tenant + "\",\"message\":\"Session " + activateRequest.getSessionId() + activatedMessage));
    assertThat(message, containsString("/application/v2/tenant/" + tenant + "/application/" + appName + "/environment/" + "prod" + "/region/" + "default" + "/instance/" + "default"));
    assertTrue(hostProvisioner.activated);
    assertThat(hostProvisioner.lastHosts.size(), is(1));
}
Also used : JsonFormat(com.yahoo.slime.JsonFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 13 with JsonFormat

use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.

the class ConfigChangeActionsSlimeConverterTest method toJson.

private static String toJson(ConfigChangeActions actions) throws IOException {
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    new ConfigChangeActionsSlimeConverter(actions).toSlime(root);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    new JsonFormat(false).encode(outputStream, slime);
    return outputStream.toString();
}
Also used : JsonFormat(com.yahoo.slime.JsonFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 14 with JsonFormat

use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.

the class ProjectBundleClassPaths method save.

static void save(OutputStream out, ProjectBundleClassPaths mappings) throws IOException {
    Slime slime = new Slime();
    Cursor rootCursor = slime.setObject();
    Cursor mainBundleCursor = rootCursor.setObject("mainBundle");
    BundleClasspathMapping.save(mainBundleCursor, mappings.mainBundle);
    Cursor dependenciesCursor = rootCursor.setArray("providedDependencies");
    mappings.providedDependencies.forEach(d -> BundleClasspathMapping.save(dependenciesCursor.addObject(), d));
    new JsonFormat(false).encode(out, slime);
}
Also used : JsonFormat(com.yahoo.slime.JsonFormat) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 15 with JsonFormat

use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.

the class JobsResponse method render.

@Override
public void render(OutputStream stream) throws IOException {
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    Cursor jobArray = root.setArray("jobs");
    for (String jobName : jobControl.jobs()) jobArray.addObject().setString("name", jobName);
    Cursor inactiveArray = root.setArray("inactive");
    for (String jobName : jobControl.inactiveJobs()) inactiveArray.addString(jobName);
    new JsonFormat(true).encode(stream, slime);
}
Also used : JsonFormat(com.yahoo.slime.JsonFormat) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Aggregations

JsonFormat (com.yahoo.slime.JsonFormat)15 Slime (com.yahoo.slime.Slime)10 Cursor (com.yahoo.slime.Cursor)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 IOException (java.io.IOException)2 ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)1 DeployLogger (com.yahoo.config.application.api.DeployLogger)1 Utf8Array (com.yahoo.text.Utf8Array)1 DeployHandlerLogger (com.yahoo.vespa.config.server.deploy.DeployHandlerLogger)1 MessageDigest (java.security.MessageDigest)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Test (org.junit.Test)1