use of io.confluent.ksql.rest.entity.StreamedRow in project ksql by confluentinc.
the class ConsoleTest method testPrintErrorStreamedRow.
@Test
public void testPrintErrorStreamedRow() throws IOException {
StreamedRow row = new StreamedRow(new FakeException());
terminal.printStreamedRow(row);
}
use of io.confluent.ksql.rest.entity.StreamedRow in project ksql by confluentinc.
the class QueryStreamWriter method write.
private void write(OutputStream output, GenericRow row) throws IOException {
objectMapper.writeValue(output, new StreamedRow(row));
output.write("\n".getBytes(StandardCharsets.UTF_8));
output.flush();
}
use of io.confluent.ksql.rest.entity.StreamedRow in project ksql by confluentinc.
the class KsqlRestClientTest method testStreamRowFromServer.
@Test
public void testStreamRowFromServer() throws InterruptedException {
MockStreamedQueryResource sqr = mockApplication.getStreamedQueryResource();
RestResponse<KsqlRestClient.QueryStream> queryResponse = ksqlRestClient.makeQueryRequest("Select *");
Assert.assertNotNull(queryResponse);
Assert.assertTrue(queryResponse.isSuccessful());
// Get the stream writer from the mock server and load it up with a row
List<MockStreamedQueryResource.TestStreamWriter> writers = sqr.getWriters();
Assert.assertEquals(1, writers.size());
MockStreamedQueryResource.TestStreamWriter writer = writers.get(0);
try {
writer.enq("hello");
// Try and receive the row. Do this from another thread to avoid blocking indefinitely
KsqlRestClient.QueryStream queryStream = queryResponse.getResponse();
Thread t = new Thread(() -> queryStream.hasNext());
t.setDaemon(true);
t.start();
t.join(10000);
Assert.assertFalse(t.isAlive());
Assert.assertTrue(queryStream.hasNext());
StreamedRow sr = queryStream.next();
Assert.assertNotNull(sr);
GenericRow row = sr.getRow();
Assert.assertEquals(1, row.getColumns().size());
Assert.assertEquals("hello", row.getColumns().get(0));
} finally {
writer.finished();
}
}
use of io.confluent.ksql.rest.entity.StreamedRow in project ksql by confluentinc.
the class ConsoleTest method testPrintGenericStreamedRow.
@Test
public void testPrintGenericStreamedRow() throws IOException {
StreamedRow row = new StreamedRow(new GenericRow(Arrays.asList("col_1", "col_2")));
terminal.printStreamedRow(row);
}
Aggregations