@Test @Ignore("This needs to be reworked to be more robust") public void basic() { flowRuleService = new MockFlowRuleService(); flowRuleService.applyFlowRules(genFlow("ATL-001", 110, 90)); flowRuleService.applyFlowRules(genFlow("ATL-001", 110, 100)); flowRuleService.applyFlowRules(genFlow("ATL-001", 110, 150)); flowRuleService.applyFlowRules(genFlow("ATL-002", 80, 70)); flowRuleService.applyFlowRules(genFlow("ATL-003", 120, 130)); flowRuleService.applyFlowRules(genFlow("ATL-004", 50)); flowRuleService.applyFlowRules(genFlow("ATL-005", 140, 10)); linkService.addLink("H00:00:00:00:00:0660", 160, "ATL-005", 140); linkService.addLink("ATL-005", 10, "ATL-004", 40); linkService.addLink("ATL-004", 50, "ATL-002", 80); linkService.addLink("ATL-002", 70, "ATL-001", 110); linkService.addLink("ATL-001", 150, "H00:00:00:00:00:0770", 170); linkService.addLink("ATL-001", 90, "ATL-004", 30); linkService.addLink("ATL-001", 100, "ATL-003", 120); linkService.addLink("ATL-003", 130, "ATL-005", 20); topologyService = new MockTopologyService(linkService.createdGraph); FlowAnalyzer flowAnalyzer = new FlowAnalyzer(); flowAnalyzer.flowRuleService = flowRuleService; flowAnalyzer.linkService = linkService; flowAnalyzer.topologyService = topologyService; String labels = flowAnalyzer.analysisOutput(); String correctOutput = "Flow Rule: Device: atl-005, [IN_PORT{port=140}], [OUTPUT{port=10}]\n" + "Analysis: Cleared!\n" + "\n" + "Flow Rule: Device: atl-003, [IN_PORT{port=120}], [OUTPUT{port=130}]\n" + "Analysis: Black Hole!\n" + "\n" + "Flow Rule: Device: atl-001, [IN_PORT{port=110}], [OUTPUT{port=90}]\n" + "Analysis: Cycle Critical Point!\n" + "\n" + "Flow Rule: Device: atl-004, [], [OUTPUT{port=50}]\n" + "Analysis: Cycle!\n" + "\n" + "Flow Rule: Device: atl-001, [IN_PORT{port=110}], [OUTPUT{port=150}]\n" + "Analysis: Cleared!\n" + "\n" + "Flow Rule: Device: atl-001, [IN_PORT{port=110}], [OUTPUT{port=100}]\n" + "Analysis: Black Hole!\n" + "\n" + "Flow Rule: Device: atl-002, [IN_PORT{port=80}], [OUTPUT{port=70}]\n" + "Analysis: Cycle!\n"; assertEquals("Wrong labels", new TreeSet(Arrays.asList(labels.replaceAll("\\s+", "").split("!"))), new TreeSet(Arrays.asList(correctOutput.replaceAll("\\s+", "").split("!")))); }
public String analysisOutput() { analyze(); String s = "\n"; for (FlowEntry flow: label.keySet()) { s += ("Flow Rule: " + flowEntryRepresentation(flow) + "\n"); s += ("Analysis: " + label.get(flow) + "!\n\n"); } return s; }
FlowAnalyzer { public String analysisOutput() { analyze(); String s = "\n"; for (FlowEntry flow: label.keySet()) { s += ("Flow Rule: " + flowEntryRepresentation(flow) + "\n"); s += ("Analysis: " + label.get(flow) + "!\n\n"); } return s; } }
FlowAnalyzer { public String analysisOutput() { analyze(); String s = "\n"; for (FlowEntry flow: label.keySet()) { s += ("Flow Rule: " + flowEntryRepresentation(flow) + "\n"); s += ("Analysis: " + label.get(flow) + "!\n\n"); } return s; }  }
FlowAnalyzer { public String analysisOutput() { analyze(); String s = "\n"; for (FlowEntry flow: label.keySet()) { s += ("Flow Rule: " + flowEntryRepresentation(flow) + "\n"); s += ("Analysis: " + label.get(flow) + "!\n\n"); } return s; }  @Activate void activate(ComponentContext context); @Deactivate void deactivate(); String analyze(); Map<FlowEntry, String> calcLabels(); String analysisOutput(); String flowEntryRepresentation(FlowEntry flow); }
FlowAnalyzer { public String analysisOutput() { analyze(); String s = "\n"; for (FlowEntry flow: label.keySet()) { s += ("Flow Rule: " + flowEntryRepresentation(flow) + "\n"); s += ("Analysis: " + label.get(flow) + "!\n\n"); } return s; }  @Activate void activate(ComponentContext context); @Deactivate void deactivate(); String analyze(); Map<FlowEntry, String> calcLabels(); String analysisOutput(); String flowEntryRepresentation(FlowEntry flow);  }