ONOS-2037: Fix cast exception on execution of "flows -j" command
Change-Id: If481573f405d812b0b103e1752a559d8f81d6bd8
Showing
4 changed files
with
16 additions
and
14 deletions
... | @@ -37,7 +37,7 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; | ... | @@ -37,7 +37,7 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
37 | import org.onosproject.net.flow.criteria.LambdaCriterion; | 37 | import org.onosproject.net.flow.criteria.LambdaCriterion; |
38 | import org.onosproject.net.flow.criteria.MetadataCriterion; | 38 | import org.onosproject.net.flow.criteria.MetadataCriterion; |
39 | import org.onosproject.net.flow.criteria.MplsCriterion; | 39 | import org.onosproject.net.flow.criteria.MplsCriterion; |
40 | -import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion; | 40 | +import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; |
41 | import org.onosproject.net.flow.criteria.PortCriterion; | 41 | import org.onosproject.net.flow.criteria.PortCriterion; |
42 | import org.onosproject.net.flow.criteria.SctpPortCriterion; | 42 | import org.onosproject.net.flow.criteria.SctpPortCriterion; |
43 | import org.onosproject.net.flow.criteria.TcpPortCriterion; | 43 | import org.onosproject.net.flow.criteria.TcpPortCriterion; |
... | @@ -334,9 +334,9 @@ public final class CriterionCodec extends JsonCodec<Criterion> { | ... | @@ -334,9 +334,9 @@ public final class CriterionCodec extends JsonCodec<Criterion> { |
334 | private static class FormatOchSigType implements CriterionTypeFormatter { | 334 | private static class FormatOchSigType implements CriterionTypeFormatter { |
335 | @Override | 335 | @Override |
336 | public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { | 336 | public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { |
337 | - final OpticalSignalTypeCriterion opticalSignalTypeCriterion = | 337 | + final OchSignalTypeCriterion ochSignalTypeCriterion = |
338 | - (OpticalSignalTypeCriterion) criterion; | 338 | + (OchSignalTypeCriterion) criterion; |
339 | - return root.put("signalType", opticalSignalTypeCriterion.signalType()); | 339 | + return root.put("ochSignalType", ochSignalTypeCriterion.signalType().name()); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ... | ... |
... | @@ -26,6 +26,7 @@ import org.onlab.packet.MplsLabel; | ... | @@ -26,6 +26,7 @@ import org.onlab.packet.MplsLabel; |
26 | import org.onlab.packet.VlanId; | 26 | import org.onlab.packet.VlanId; |
27 | import org.onosproject.codec.CodecContext; | 27 | import org.onosproject.codec.CodecContext; |
28 | import org.onosproject.codec.JsonCodec; | 28 | import org.onosproject.codec.JsonCodec; |
29 | +import org.onosproject.net.OchSignalType; | ||
29 | import org.onosproject.net.PortNumber; | 30 | import org.onosproject.net.PortNumber; |
30 | import org.onosproject.net.flow.criteria.Criteria; | 31 | import org.onosproject.net.flow.criteria.Criteria; |
31 | import org.onosproject.net.flow.criteria.Criterion; | 32 | import org.onosproject.net.flow.criteria.Criterion; |
... | @@ -416,7 +417,7 @@ public class CriterionCodecTest { | ... | @@ -416,7 +417,7 @@ public class CriterionCodecTest { |
416 | */ | 417 | */ |
417 | @Test | 418 | @Test |
418 | public void matchOpticalSignalTypeTest() { | 419 | public void matchOpticalSignalTypeTest() { |
419 | - Criterion criterion = Criteria.matchOpticalSignalType((byte) 250); | 420 | + Criterion criterion = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); |
420 | ObjectNode result = criterionCodec.encode(criterion, context); | 421 | ObjectNode result = criterionCodec.encode(criterion, context); |
421 | assertThat(result, matchesCriterion(criterion)); | 422 | assertThat(result, matchesCriterion(criterion)); |
422 | } | 423 | } | ... | ... |
... | @@ -37,7 +37,7 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; | ... | @@ -37,7 +37,7 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
37 | import org.onosproject.net.flow.criteria.LambdaCriterion; | 37 | import org.onosproject.net.flow.criteria.LambdaCriterion; |
38 | import org.onosproject.net.flow.criteria.MetadataCriterion; | 38 | import org.onosproject.net.flow.criteria.MetadataCriterion; |
39 | import org.onosproject.net.flow.criteria.MplsCriterion; | 39 | import org.onosproject.net.flow.criteria.MplsCriterion; |
40 | -import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion; | 40 | +import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; |
41 | import org.onosproject.net.flow.criteria.PortCriterion; | 41 | import org.onosproject.net.flow.criteria.PortCriterion; |
42 | import org.onosproject.net.flow.criteria.SctpPortCriterion; | 42 | import org.onosproject.net.flow.criteria.SctpPortCriterion; |
43 | import org.onosproject.net.flow.criteria.TcpPortCriterion; | 43 | import org.onosproject.net.flow.criteria.TcpPortCriterion; |
... | @@ -469,11 +469,11 @@ public final class CriterionJsonMatcher extends | ... | @@ -469,11 +469,11 @@ public final class CriterionJsonMatcher extends |
469 | * @param criterion criterion to match | 469 | * @param criterion criterion to match |
470 | * @return true if the JSON matches the criterion, false otherwise. | 470 | * @return true if the JSON matches the criterion, false otherwise. |
471 | */ | 471 | */ |
472 | - private boolean matchCriterion(OpticalSignalTypeCriterion criterion) { | 472 | + private boolean matchCriterion(OchSignalTypeCriterion criterion) { |
473 | - final short signalType = criterion.signalType(); | 473 | + final String signalType = criterion.signalType().name(); |
474 | - final short jsonSignalType = jsonCriterion.get("signalType").shortValue(); | 474 | + final String jsonSignalType = jsonCriterion.get("ochSignalType").textValue(); |
475 | - if (signalType != jsonSignalType) { | 475 | + if (!signalType.equals(jsonSignalType)) { |
476 | - description.appendText("signal type was " + Short.toString(signalType)); | 476 | + description.appendText("signal type was " + signalType); |
477 | return false; | 477 | return false; |
478 | } | 478 | } |
479 | return true; | 479 | return true; |
... | @@ -575,8 +575,7 @@ public final class CriterionJsonMatcher extends | ... | @@ -575,8 +575,7 @@ public final class CriterionJsonMatcher extends |
575 | return matchCriterion((LambdaCriterion) criterion); | 575 | return matchCriterion((LambdaCriterion) criterion); |
576 | 576 | ||
577 | case OCH_SIGTYPE: | 577 | case OCH_SIGTYPE: |
578 | - return matchCriterion( | 578 | + return matchCriterion((OchSignalTypeCriterion) criterion); |
579 | - (OpticalSignalTypeCriterion) criterion); | ||
580 | 579 | ||
581 | default: | 580 | default: |
582 | // Don't know how to format this type | 581 | // Don't know how to format this type | ... | ... |
... | @@ -31,11 +31,13 @@ import org.onosproject.net.ConnectPoint; | ... | @@ -31,11 +31,13 @@ import org.onosproject.net.ConnectPoint; |
31 | import org.onosproject.net.DeviceId; | 31 | import org.onosproject.net.DeviceId; |
32 | import org.onosproject.net.HostId; | 32 | import org.onosproject.net.HostId; |
33 | import org.onosproject.net.NetTestTools; | 33 | import org.onosproject.net.NetTestTools; |
34 | +import org.onosproject.net.OchSignalType; | ||
34 | import org.onosproject.net.PortNumber; | 35 | import org.onosproject.net.PortNumber; |
35 | import org.onosproject.net.flow.DefaultTrafficSelector; | 36 | import org.onosproject.net.flow.DefaultTrafficSelector; |
36 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 37 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
37 | import org.onosproject.net.flow.TrafficSelector; | 38 | import org.onosproject.net.flow.TrafficSelector; |
38 | import org.onosproject.net.flow.TrafficTreatment; | 39 | import org.onosproject.net.flow.TrafficTreatment; |
40 | +import org.onosproject.net.flow.criteria.Criteria; | ||
39 | import org.onosproject.net.intent.AbstractIntentTest; | 41 | import org.onosproject.net.intent.AbstractIntentTest; |
40 | import org.onosproject.net.intent.Constraint; | 42 | import org.onosproject.net.intent.Constraint; |
41 | import org.onosproject.net.intent.HostToHostIntent; | 43 | import org.onosproject.net.intent.HostToHostIntent; |
... | @@ -139,7 +141,7 @@ public class IntentCodecTest extends AbstractIntentTest { | ... | @@ -139,7 +141,7 @@ public class IntentCodecTest extends AbstractIntentTest { |
139 | final TrafficSelector selector = DefaultTrafficSelector.builder() | 141 | final TrafficSelector selector = DefaultTrafficSelector.builder() |
140 | .matchIPProtocol((byte) 3) | 142 | .matchIPProtocol((byte) 3) |
141 | .matchMplsLabel(MplsLabel.mplsLabel(4)) | 143 | .matchMplsLabel(MplsLabel.mplsLabel(4)) |
142 | - .matchOpticalSignalType((short) 5) | 144 | + .add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID)) |
143 | .matchLambda((short) 6) | 145 | .matchLambda((short) 6) |
144 | .matchEthDst(MacAddress.BROADCAST) | 146 | .matchEthDst(MacAddress.BROADCAST) |
145 | .matchIPDst(IpPrefix.valueOf("1.2.3.4/24")) | 147 | .matchIPDst(IpPrefix.valueOf("1.2.3.4/24")) | ... | ... |
-
Please register or login to post a comment