use of org.apache.storm.tuple.Fields in project flink by apache.
the class BoltWrapperTest method testWrapperToManyAttributes1.
@Test(expected = IllegalArgumentException.class)
public void testWrapperToManyAttributes1() throws Exception {
final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
final String[] schema = new String[26];
for (int i = 0; i < schema.length; ++i) {
schema[i] = "a" + i;
}
declarer.declare(new Fields(schema));
PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);
new BoltWrapper<Object, Object>(mock(IRichBolt.class));
}
use of org.apache.storm.tuple.Fields in project flink by apache.
the class SpoutWrapperTest method testRunExecuteFixedNumber.
@SuppressWarnings("unchecked")
@Test
public void testRunExecuteFixedNumber() throws Exception {
final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
declarer.declare(new Fields("dummy"));
PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);
final StreamingRuntimeContext taskContext = mock(StreamingRuntimeContext.class);
when(taskContext.getExecutionConfig()).thenReturn(mock(ExecutionConfig.class));
when(taskContext.getTaskName()).thenReturn("name");
final IRichSpout spout = mock(IRichSpout.class);
final int numberOfCalls = this.r.nextInt(50);
final SpoutWrapper<?> spoutWrapper = new SpoutWrapper<Object>(spout, numberOfCalls);
spoutWrapper.setRuntimeContext(taskContext);
spoutWrapper.run(mock(SourceContext.class));
verify(spout, times(numberOfCalls)).nextTuple();
}
use of org.apache.storm.tuple.Fields in project flink by apache.
the class WrapperSetupHelperTest method testRawType.
@Test(expected = IllegalArgumentException.class)
public void testRawType() throws Exception {
IComponent boltOrSpout;
if (this.r.nextBoolean()) {
boltOrSpout = mock(IRichSpout.class);
} else {
boltOrSpout = mock(IRichBolt.class);
}
final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
declarer.declare(new Fields("dummy1", "dummy2"));
PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);
WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, new HashSet<String>(singleton(Utils.DEFAULT_STREAM_ID)));
}
use of org.apache.storm.tuple.Fields in project flink by apache.
the class StormFieldsGroupingITCase method testProgram.
@Override
protected void testProgram() throws Exception {
final String[] tokens = this.resultPath.split(":");
final String outputFile = tokens[tokens.length - 1];
final TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(spoutId, new FiniteRandomSpout(0, 10, 2));
builder.setBolt(boltId, new TaskIdBolt(), 2).fieldsGrouping(spoutId, FiniteRandomSpout.STREAM_PREFIX + 0, new Fields("number"));
builder.setBolt(sinkId, new BoltFileSink(outputFile)).shuffleGrouping(boltId);
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
Config conf = new Config();
// only required to stabilize integration test
conf.put(FlinkLocalCluster.SUBMIT_BLOCKING, true);
cluster.submitTopology(topologyId, conf, FlinkTopology.createTopology(builder));
cluster.shutdown();
}
use of org.apache.storm.tuple.Fields in project flink by apache.
the class StormTupleTest method testGetByField.
private <T> StormTuple<?> testGetByField(int arity, int index, T value) throws Exception {
assert (index < arity);
Tuple tuple = Tuple.getTupleClass(arity).newInstance();
tuple.setField(value, index);
ArrayList<String> attributeNames = new ArrayList<String>(arity);
for (int i = 0; i < arity; ++i) {
if (i == index) {
attributeNames.add(fieldName);
} else {
attributeNames.add("" + i);
}
}
Fields schema = new Fields(attributeNames);
return new StormTuple<>(tuple, schema, -1, null, null, null);
}
Aggregations