import org.apache.storm.Constants; //导入依赖的package包/类
private void initMocks(String topo_input_topic) {
Fields switchSchema = new Fields(OFEMessageUtils.FIELD_SWITCH_ID, OFEMessageUtils.FIELD_STATE);
when(topologyContext.getComponentId(0)).thenReturn(topo_input_topic);
when(topologyContext.getComponentOutputFields(topo_input_topic,
topo_input_topic)).thenReturn(switchSchema);
Fields portSchema = new Fields(OFEMessageUtils.FIELD_SWITCH_ID,
OFEMessageUtils.FIELD_PORT_ID, OFEMessageUtils.FIELD_STATE);
when(topologyContext.getComponentId(1)).thenReturn(topo_input_topic);
when(topologyContext.getComponentOutputFields(topo_input_topic,
topo_input_topic)).thenReturn(portSchema);
Fields tickSchema = new Fields();
when(topologyContext.getComponentId(2)).thenReturn(Constants.SYSTEM_COMPONENT_ID);
when(topologyContext.getComponentOutputFields(Constants.SYSTEM_COMPONENT_ID, Constants.SYSTEM_TICK_STREAM_ID))
.thenReturn(tickSchema);
Fields islSchema = new Fields(topo_input_topic);
when(topologyContext.getComponentId(3)).thenReturn(topo_input_topic);
when(topologyContext.getComponentOutputFields(topo_input_topic,
topo_input_topic)).thenReturn(islSchema);
when(topologyContext.getComponentId(4)).thenReturn(OFEventWFMTopology.SPOUT_ID_INPUT);
when(topologyContext.getComponentOutputFields(
OFEventWFMTopology.SPOUT_ID_INPUT, AbstractTopology.MESSAGE_FIELD))
.thenReturn(AbstractTopology.fieldMessage);
}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/227796.html原文链接:https://javaforall.net
