Search in sources :

Example 1 with HeartbeatMessage

use of io.confluent.ksql.rest.entity.HeartbeatMessage in project ksql by confluentinc.

the class HeartbeatResourceTest method shouldSendHeartbeat.

@Test
public void shouldSendHeartbeat() {
    // When:
    final HeartbeatMessage request = new HeartbeatMessage(new KsqlHostInfoEntity("localhost", 8080), 1);
    final EndpointResponse response = heartbeatResource.registerHeartbeat(request);
    // Then:
    assertThat(response.getStatus(), is(200));
    assertThat(response.getEntity(), instanceOf(HeartbeatResponse.class));
}
Also used : HeartbeatResponse(io.confluent.ksql.rest.entity.HeartbeatResponse) EndpointResponse(io.confluent.ksql.rest.EndpointResponse) HeartbeatMessage(io.confluent.ksql.rest.entity.HeartbeatMessage) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) Test(org.junit.Test)

Example 2 with HeartbeatMessage

use of io.confluent.ksql.rest.entity.HeartbeatMessage in project ksql by confluentinc.

the class KsqlClientTest method shouldSendHeartbeatRequest.

@Test
public void shouldSendHeartbeatRequest() throws Exception {
    // Given:
    KsqlHostInfoEntity entity = new KsqlHostInfoEntity(serverUri.getHost(), serverUri.getPort());
    long timestamp = System.currentTimeMillis();
    server.setResponseObject(new HeartbeatResponse(true));
    // When:
    KsqlTarget target = ksqlClient.target(serverUri);
    target.postAsyncHeartbeatRequest(entity, timestamp);
    Buffer body = server.waitForRequestBody();
    HeartbeatMessage hbm = KsqlClientUtil.deserialize(body, HeartbeatMessage.class);
    // Then:
    assertThat(server.getHttpMethod(), is(HttpMethod.POST));
    assertThat(server.getPath(), is("/heartbeat"));
    assertThat(server.getHeaders().get("Accept"), is("application/json"));
    assertThat(hbm, is(new HeartbeatMessage(entity, timestamp)));
}
Also used : Buffer(io.vertx.core.buffer.Buffer) HeartbeatResponse(io.confluent.ksql.rest.entity.HeartbeatResponse) HeartbeatMessage(io.confluent.ksql.rest.entity.HeartbeatMessage) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) Test(org.junit.Test)

Aggregations

HeartbeatMessage (io.confluent.ksql.rest.entity.HeartbeatMessage)2 HeartbeatResponse (io.confluent.ksql.rest.entity.HeartbeatResponse)2 KsqlHostInfoEntity (io.confluent.ksql.rest.entity.KsqlHostInfoEntity)2 Test (org.junit.Test)2 EndpointResponse (io.confluent.ksql.rest.EndpointResponse)1 Buffer (io.vertx.core.buffer.Buffer)1