use of org.apache.storm.tuple.Tuple in project storm by apache.
the class TestHiveBolt method testJsonWriter.
@Test
public void testJsonWriter() throws Exception {
// json record doesn't need columns to be in the same order
// as table in hive.
JsonRecordHiveMapper mapper = new JsonRecordHiveMapper().withColumnFields(new Fields(colNames1)).withPartitionFields(new Fields(partNames));
HiveOptions hiveOptions = new HiveOptions(metaStoreURI, dbName, tblName, mapper).withTxnsPerBatch(2).withBatchSize(1);
bolt = new HiveBolt(hiveOptions);
bolt.prepare(config, null, collector);
Tuple tuple1 = generateTestTuple(1, "SJC", "Sunnyvale", "CA");
//Tuple tuple2 = generateTestTuple(2,"SFO","San Jose","CA");
bolt.execute(tuple1);
verify(collector).ack(tuple1);
//bolt.execute(tuple2);
//verify(collector).ack(tuple2);
checkDataWritten(tblName, dbName, "1,SJC,Sunnyvale,CA");
bolt.cleanup();
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class KafkaBoltTest method executeWithBrokerDown.
@Test
public void executeWithBrokerDown() throws Exception {
broker.shutdown();
String message = "value-234";
Tuple tuple = generateTestTuple(message);
bolt.execute(tuple);
verify(collector).fail(tuple);
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class KafkaBoltTest method executeWithKey.
@Test
public void executeWithKey() throws Exception {
String message = "value-123";
String key = "key-123";
Tuple tuple = generateTestTuple(key, message);
bolt.execute(tuple);
verify(collector).ack(tuple);
verifyMessage(key, message);
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class KafkaBoltTest method mockTickTuple.
private Tuple mockTickTuple() {
Tuple tuple = mock(Tuple.class);
when(tuple.getSourceComponent()).thenReturn(Constants.SYSTEM_COMPONENT_ID);
when(tuple.getSourceStreamId()).thenReturn(Constants.SYSTEM_TICK_STREAM_ID);
// Sanity check
assertTrue(TupleUtils.isTick(tuple));
return tuple;
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class KafkaBoltTest method shouldNotAcknowledgeTickTuples.
@Test
public void shouldNotAcknowledgeTickTuples() throws Exception {
// Given
Tuple tickTuple = mockTickTuple();
// When
bolt.execute(tickTuple);
// Then
verify(collector, never()).ack(tickTuple);
}
Aggregations