Search in sources :

Example 86 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project cassandra-mesos-deprecated by mesosphere.

the class SeedManagerTest method before.

@Before
public void before() {
    InMemoryState state = new InMemoryState();
    PersistedCassandraFrameworkConfiguration config = new PersistedCassandraFrameworkConfiguration(state, "name", 60, 30, "2.1", 0.5, 1024, 1024, 512, 1, 1, "role", "./backup", ".", false, true, "RACK1", "DC1", Arrays.asList(ExternalDc.newBuilder().setName("dc").setUrl("http://dc").build()), "name");
    seedManager = new SeedManager(config, new ObjectMapper(), new SystemClock()) {

        @Override
        @Nullable
        protected JsonNode fetchJson(@NotNull final String url) {
            try {
                return new ObjectMapper().readTree(jsonResponse);
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    };
}
Also used : SystemClock(io.mesosphere.mesos.util.SystemClock) InMemoryState(org.apache.mesos.state.InMemoryState) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Nullable(org.jetbrains.annotations.Nullable) Before(org.junit.Before)

Example 87 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project cassandra-mesos-deprecated by mesosphere.

the class ClusterBackupControllerTest method testNamedBackup.

@Test
public void testNamedBackup() throws Exception {
    // start named backup
    Tuple2<Integer, JsonNode> tup = fetchJson("/cluster/backup/start?name=name", true);
    assertEquals(200, tup._1.intValue());
    JsonNode json = tup._2;
    assertTrue(json.has("started"));
    assertTrue(json.get("started").asBoolean());
    // status
    tup = fetchJson("/cluster/backup/status", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.get("running").asBoolean());
    JsonNode status = json.get("backup");
    assertEquals("name", status.get("backupName").asText());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 88 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project cassandra-mesos-deprecated by mesosphere.

the class ClusterBackupControllerTest method testBackup.

@Test
public void testBackup() throws Exception {
    threeNodeCluster();
    Tuple2<Integer, JsonNode> tup = fetchJson("/cluster/backup/start", true);
    assertEquals(200, tup._1.intValue());
    JsonNode json = tup._2;
    assertTrue(json.has("started"));
    assertTrue(json.get("started").asBoolean());
    // fail for backup
    tup = fetchJson("/cluster/backup/start", true);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.has("started"));
    assertFalse(json.get("started").asBoolean());
    // status
    tup = fetchJson("/cluster/backup/status", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.get("running").asBoolean());
    JsonNode status = json.get("backup");
    assertTrue(status.has("type"));
    assertTrue(status.has("started"));
    assertTrue(status.get("started").isNumber());
    assertTrue(status.has("finished"));
    assertTrue(status.get("finished").isNull());
    assertTrue(status.has("aborted"));
    assertFalse(status.get("aborted").asBoolean());
    assertTrue(status.has("remainingNodes"));
    assertTrue(status.get("remainingNodes").isArray());
    assertTrue(status.has("currentNode"));
    assertTrue(status.has("completedNodes"));
    assertTrue(status.get("completedNodes").isArray());
    assertTrue(status.get("backupName").asText(), status.get("backupName").asText().startsWith("backup-"));
    // abort
    tup = fetchJson("/cluster/backup/abort", true);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.get("aborted").asBoolean());
    tup = fetchJson("/cluster/backup/status", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    status = json.get("backup");
    assertTrue(status.has("aborted"));
    assertTrue(status.get("aborted").asBoolean());
    // last
    tup = fetchJson("/cluster/backup/last", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertFalse(json.get("present").asBoolean());
    assertTrue(json.get("backup").isNull());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 89 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project cassandra-mesos-deprecated by mesosphere.

the class ClusterCleanupControllerTest method testCleanup.

@Test
public void testCleanup() throws Exception {
    threeNodeCluster();
    Tuple2<Integer, JsonNode> tup = fetchJson("/cluster/cleanup/start", true);
    assertEquals(200, tup._1.intValue());
    JsonNode json = tup._2;
    assertTrue(json.has("started"));
    assertTrue(json.get("started").asBoolean());
    // fail for cleanup
    tup = fetchJson("/cluster/repair/start", true);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.has("started"));
    assertFalse(json.get("started").asBoolean());
    // status
    tup = fetchJson("/cluster/cleanup/status", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.get("running").asBoolean());
    JsonNode status = json.get("cleanup");
    assertTrue(status.has("type"));
    assertTrue(status.has("started"));
    assertTrue(status.get("started").isNumber());
    assertTrue(status.has("finished"));
    assertTrue(status.get("finished").isNull());
    assertTrue(status.has("aborted"));
    assertFalse(status.get("aborted").asBoolean());
    assertTrue(status.has("remainingNodes"));
    assertTrue(status.get("remainingNodes").isArray());
    assertTrue(status.has("currentNode"));
    assertTrue(status.has("completedNodes"));
    assertTrue(status.get("completedNodes").isArray());
    // abort
    tup = fetchJson("/cluster/cleanup/abort", true);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertTrue(json.get("aborted").asBoolean());
    tup = fetchJson("/cluster/cleanup/status", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    status = json.get("cleanup");
    assertTrue(status.has("aborted"));
    assertTrue(status.get("aborted").asBoolean());
    // last
    tup = fetchJson("/cluster/cleanup/last", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertFalse(json.get("present").asBoolean());
    assertTrue(json.get("cleanup").isNull());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 90 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project JsonPath by jayway.

the class JacksonJsonNodeJsonProviderTest method longs_are_unwrapped.

@Test
public void longs_are_unwrapped() {
    JsonNode node = using(JACKSON_JSON_NODE_CONFIGURATION).parse(JSON_DOCUMENT).read("$.long-max-property");
    long unwrapped = using(JACKSON_JSON_NODE_CONFIGURATION).parse(JSON_DOCUMENT).read("$.long-max-property", long.class);
    assertThat(unwrapped).isEqualTo(Long.MAX_VALUE);
    assertThat(unwrapped).isEqualTo(node.asLong());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1055 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)275 Test (org.junit.Test)267 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)165 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)125 IOException (java.io.IOException)124 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)97 HashMap (java.util.HashMap)78 ArrayList (java.util.ArrayList)75 HttpGet (org.apache.http.client.methods.HttpGet)69 JsonException (jmri.server.json.JsonException)66 Deployment (org.activiti.engine.test.Deployment)66 InputStream (java.io.InputStream)64 StringEntity (org.apache.http.entity.StringEntity)54 ByteArrayInputStream (java.io.ByteArrayInputStream)53 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)49 Map (java.util.Map)45 Task (org.activiti.engine.task.Task)41 HttpPost (org.apache.http.client.methods.HttpPost)39 Tree (org.apache.jackrabbit.oak.api.Tree)30