[ONOS-3405] Change EthType Json encoding to Hex and extend decoding with Hex support alongside int
Change-Id: I629f52016256d6c5cc258ab9e1c5a7b916991d5b
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
index b00632c..7d8580a 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
@@ -138,8 +138,8 @@
* @return true if the JSON matches the criterion, false otherwise.
*/
private boolean matchCriterion(EthTypeCriterion criterion) {
- final int ethType = criterion.ethType().toShort();
- final int jsonEthType = jsonCriterion.get("ethType").intValue();
+ final int ethType = criterion.ethType().toShort() & 0xffff;
+ final int jsonEthType = Integer.decode(jsonCriterion.get("ethType").textValue()) & 0xffff;
if (ethType != jsonEthType) {
description.appendText("ethType was "
+ Integer.toString(jsonEthType));
diff --git a/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json b/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
index ccb2e16..82c0f59 100644
--- a/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
+++ b/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
@@ -9,7 +9,7 @@
{"type":"IN_PORT", "port":23},
{"type":"IN_PHY_PORT", "port":44},
{"type":"METADATA", "metadata":123456},
- {"type":"ETH_TYPE","ethType":2054},
+ {"type":"ETH_TYPE","ethType":"0x806"},
{"type":"ETH_SRC","mac":"00:11:22:33:44:55"},
{"type":"ETH_DST","mac":"00:11:22:33:44:55"},
{"type":"VLAN_VID","vlanId":777},
diff --git a/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json b/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
index 74b9546..2a184b3 100644
--- a/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
+++ b/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
@@ -35,5 +35,5 @@
],
"deferred":[]
},
- "selector": {"criteria":[{"type":"ETH_TYPE","ethType":2054}]}
+ "selector": {"criteria":[{"type":"ETH_TYPE","ethType":"0x806"}]}
}