Search in sources :

Example 81 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project hive by apache.

the class MetricsTestUtils method verifyMetricsJson.

public static void verifyMetricsJson(String json, MetricsCategory category, String metricsName, Object expectedValue) throws Exception {
    JsonNode jsonNode = getJsonNode(json, category, metricsName);
    Assert.assertEquals(expectedValue.toString(), jsonNode.asText());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 82 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project hive by apache.

the class MetricsTestUtils method verifyMetricsJson.

public static void verifyMetricsJson(String json, MetricsCategory category, String metricsName, Double expectedValue, Double delta) throws Exception {
    JsonNode jsonNode = getJsonNode(json, category, metricsName);
    Assert.assertEquals(expectedValue, Double.valueOf(jsonNode.asText()), delta);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 83 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project kafka by apache.

the class JsonConverterTest method shortToJson.

@Test
public void shortToJson() {
    JsonNode converted = parse(converter.fromConnectData(TOPIC, Schema.INT16_SCHEMA, (short) 12));
    validateEnvelope(converted);
    assertEquals(parse("{ \"type\": \"int16\", \"optional\": false }"), converted.get(JsonSchema.ENVELOPE_SCHEMA_FIELD_NAME));
    assertEquals(12, converted.get(JsonSchema.ENVELOPE_PAYLOAD_FIELD_NAME).intValue());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 84 with JsonNode

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

the class LiveEndpointsControllerTest method testLiveNodes.

@Test
public void testLiveNodes() throws Exception {
    Tuple2<Integer, JsonNode> tup = fetchJson("/live-nodes?limit=2", false);
    // must return HTTP/500 if no nodes are present
    assertEquals(400, tup._1.intValue());
    // add one live node
    addNode("exec1", "1.2.3.4");
    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(200, tup._1.intValue());
    JsonNode json = tup._2;
    assertEquals(9042, json.get("nativePort").asInt());
    assertEquals(9160, json.get("rpcPort").asInt());
    assertEquals(7199, json.get("jmxPort").asInt());
    JsonNode nodes = json.get("liveNodes");
    assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
    assertThat(nodes).hasSize(1).contains(TextNode.valueOf("1.2.3.4"));
    // test more output formats
    Tuple2<Integer, String> str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    assertEquals("1.2.3.4 9042", str._2);
    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    assertEquals("-node 1.2.3.4 -port native=9042 thrift=9160 jmx=7199", str._2);
    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    assertEquals("-h 1.2.3.4 -p 7199", str._2);
    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(200, str._1.intValue());
    assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 1.2.3.4\n", str._2);
    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    assertEquals("1.2.3.4 9042", str._2);
    str = fetchText("/live-nodes/stress", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    assertEquals("-node 1.2.3.4 -port native=9042 thrift=9160 jmx=7199", str._2);
    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    assertEquals("-h 1.2.3.4 -p 7199", str._2);
    str = fetchText("/live-nodes/text", "text/plain");
    assertEquals(200, str._1.intValue());
    assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 1.2.3.4\n", str._2);
    //
    // mark node as dead
    //
    cluster.recordHealthCheck("exec1", healthCheckDetailsFailed());
    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(400, tup._1.intValue());
    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(400, str._1.intValue());
    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(400, str._1.intValue());
    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(400, str._1.intValue());
    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(400, str._1.intValue());
    // add a live nodes
    addNode("exec2", "2.2.2.2");
    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertEquals(9042, json.get("nativePort").asInt());
    assertEquals(9160, json.get("rpcPort").asInt());
    assertEquals(7199, json.get("jmxPort").asInt());
    nodes = json.get("liveNodes");
    assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
    assertThat(nodes).hasSize(1).contains(TextNode.valueOf("2.2.2.2"));
    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    assertEquals("2.2.2.2 9042", str._2);
    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    assertEquals("-node 2.2.2.2 -port native=9042 thrift=9160 jmx=7199", str._2);
    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    assertEquals("-h 2.2.2.2 -p 7199", str._2);
    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(200, str._1.intValue());
    assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 2.2.2.2\n", str._2);
    // mark 1st node as live
    cluster.recordHealthCheck("exec1", healthCheckDetailsSuccess("NORMAL", true));
    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertEquals(9042, json.get("nativePort").asInt());
    assertEquals(9160, json.get("rpcPort").asInt());
    assertEquals(7199, json.get("jmxPort").asInt());
    nodes = json.get("liveNodes");
    assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
    assertThat(nodes).hasSize(2).contains(TextNode.valueOf("1.2.3.4")).contains(TextNode.valueOf("2.2.2.2"));
    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(200, str._1.intValue());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 85 with JsonNode

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

the class QaReportControllerTest method testQaReportResources.

@Test
public void testQaReportResources() throws Exception {
    threeNodeCluster();
    final Tuple2<Integer, JsonNode> tup = fetchJson("/qa/report/resources", false);
    assertEquals(200, tup._1.intValue());
    final JsonNode json = tup._2;
    for (int i = 0; i < activeNodes; i++) {
        final Tuple2<Protos.SlaveID, String> slave = slaves[i];
        final JsonNode node = json.get("nodes").get(executorMetadata[i].getExecutor().getExecutorId().getValue());
        assertEquals(slave._2, node.get("ip").asText());
        assertTrue(node.has("workdir"));
        assertTrue(node.has("hostname"));
        assertTrue(node.has("targetRunState"));
        assertTrue(node.has("jmxIp"));
        assertTrue(node.has("jmxPort"));
        assertTrue(node.has("live"));
        assertTrue(node.get("logfiles").isArray());
        assertEquals(2, node.get("logfiles").size());
    }
}
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