Intent manager unit test enhancements
- add test to be sure that all flows are removed when intents
are withdrawn
- add test to be sure that all flows are removed when an intent
installation fails. Currently disabled, intent cleanup is
not implemented
- enable installation time out test
Change-Id: I8c7a75292a97404ef89856647c67ef2f70ffcf6f
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java b/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
index 27e523d..87ab21a 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
@@ -34,6 +34,11 @@
final Set<FlowRule> flows = Sets.newHashSet();
boolean success;
+ int errorFlow = -1;
+ public void setErrorFlow(int errorFlow) {
+ this.errorFlow = errorFlow;
+ }
+
public void setFuture(boolean success) {
this.success = success;
}
@@ -41,16 +46,20 @@
@Override
public void apply(FlowRuleOperations ops) {
ops.stages().forEach(stage -> stage.forEach(flow -> {
- switch (flow.type()) {
- case ADD:
- case MODIFY: //TODO is this the right behavior for modify?
- flows.add(flow.rule());
- break;
- case REMOVE:
- flows.remove(flow.rule());
- break;
- default:
- break;
+ if (errorFlow == flow.rule().id().value()) {
+ success = false;
+ } else {
+ switch (flow.type()) {
+ case ADD:
+ case MODIFY: //TODO is this the right behavior for modify?
+ flows.add(flow.rule());
+ break;
+ case REMOVE:
+ flows.remove(flow.rule());
+ break;
+ default:
+ break;
+ }
}
}));
if (success) {