Tests for FlowRuleStore plus bugfixes
Change-Id: Ib5b0bd9d41fbbcac1cf09684e70446326887caf7
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java
index 7540ec8..038a0d9 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java
@@ -45,10 +45,10 @@
private final SimpleFlowRuleStore store = new SimpleFlowRuleStore();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- private EventDeliveryService eventDispatcher;
+ protected EventDeliveryService eventDispatcher;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- private DeviceService deviceService;
+ protected DeviceService deviceService;
@Activate
public void activate() {
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java
index f839396..4f23ff4 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java
@@ -53,17 +53,20 @@
FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) {
DeviceId did = rule.deviceId();
+ FlowEntry entry = new DefaultFlowEntry(
+ did,
+ rule.selector(),
+ rule.treatment(),
+ rule.priority());
+
// check if this new rule is an update to an existing entry
for (FlowEntry fe : flowEntries.get(did)) {
- if (rule.equals(fe)) {
+ if (entry.equals(fe)) {
// TODO update the stats on this flowEntry?
return null;
}
}
-
- FlowEntry newfe = new DefaultFlowEntry(did,
- rule.selector(), rule.treatment(), rule.priority());
- flowEntries.put(did, newfe);
+ flowEntries.put(did, entry);
return new FlowRuleEvent(RULE_ADDED, rule);
}
@@ -73,8 +76,11 @@
* @return flow_removed event, or null if nothing removed
*/
FlowRuleEvent removeFlowRule(FlowRule rule) {
+
+ FlowEntry rem = new DefaultFlowEntry(rule.deviceId(),
+ rule.selector(), rule.treatment(), rule.priority());
synchronized (this) {
- if (flowEntries.remove(rule.deviceId(), rule)) {
+ if (flowEntries.remove(rem.deviceId(), rem)) {
return new FlowRuleEvent(RULE_REMOVED, rule);
} else {
return null;