use of org.apache.storm.sql.runtime.datasource.socket.trident.SocketState in project storm by apache.
the class TestSocketDataSourceProvider method testSocketSink.
@Test
public void testSocketSink() throws IOException {
ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(URI.create("socket://localhost:8888"), null, null, new Properties(), FIELDS);
Assert.assertNotNull(ds);
ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
Assert.assertEquals(SocketState.Factory.class, consumer.getStateFactory().getClass());
Assert.assertEquals(SocketStateUpdater.class, consumer.getStateUpdater().getClass());
// makeState() fails on creating State so we just mock SocketState anyway
SocketState mockState = mock(SocketState.class);
StateUpdater stateUpdater = consumer.getStateUpdater();
List<TridentTuple> tupleList = mockTupleList();
stateUpdater.updateState(mockState, tupleList, null);
for (TridentTuple t : tupleList) {
String serializedValue = new String(SERIALIZER.write(t.getValues(), null).array());
verify(mockState).write(serializedValue + "\n");
}
}
Aggregations