use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.
the class CriterionCodecTest method matchSctpSrcMaskedTest.
/**
* Tests source SCTP port masked criterion.
*/
@Test
public void matchSctpSrcMaskedTest() {
Criterion criterion = Criteria.matchSctpSrcMasked(tpPort, tpPortMask);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.
the class CriterionCodecTest method matchIPEcnTest.
/**
* Tests IP ECN criterion.
*/
@Test
public void matchIPEcnTest() {
Criterion criterion = Criteria.matchIPEcn((byte) 3);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.
the class CriterionCodecTest method matchIPv6NDTargetAddressTest.
/**
* Tests IPV6 target address criterion.
*/
@Test
public void matchIPv6NDTargetAddressTest() {
Criterion criterion = Criteria.matchIPv6NDTargetAddress(Ip6Address.valueOf("1111:2222::"));
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.
the class CriterionCodecTest method matchPiTypeDecodingTest.
/**
* Tests protocol-independent type criterion decoding.
*/
@Test
public void matchPiTypeDecodingTest() throws IOException {
Criterion criterion = getCriterion("PiCriterion.json");
Assert.assertThat(criterion.type(), is(Criterion.Type.PROTOCOL_INDEPENDENT));
Collection<PiFieldMatch> piFieldMatches = ((PiCriterion) criterion).fieldMatches();
for (PiFieldMatch piFieldMatch : piFieldMatches) {
switch(piFieldMatch.type()) {
case EXACT:
Assert.assertThat(piFieldMatch.fieldId().id(), is("ingress_port"));
Assert.assertThat(((PiExactFieldMatch) piFieldMatch).value(), is(copyFrom((byte) 0x10)));
break;
case LPM:
Assert.assertThat(piFieldMatch.fieldId().id(), is("src_addr"));
Assert.assertThat(((PiLpmFieldMatch) piFieldMatch).value(), is(copyFrom(0xa010101)));
Assert.assertThat(((PiLpmFieldMatch) piFieldMatch).prefixLength(), is(24));
break;
case TERNARY:
Assert.assertThat(piFieldMatch.fieldId().id(), is("dst_addr"));
Assert.assertThat(((PiTernaryFieldMatch) piFieldMatch).value(), is(copyFrom(0xa010101)));
Assert.assertThat(((PiTernaryFieldMatch) piFieldMatch).mask(), is(copyFrom(0xfffffff)));
break;
case RANGE:
Assert.assertThat(piFieldMatch.fieldId().id(), is("egress_port"));
Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).highValue(), is(copyFrom((byte) 0x20)));
Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).lowValue(), is(copyFrom((byte) 0x10)));
break;
case OPTIONAL:
Assert.assertThat(piFieldMatch.fieldId().id(), is("eth_dst"));
Assert.assertThat(((PiOptionalFieldMatch) piFieldMatch).value(), is(copyFrom(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 })));
break;
default:
Assert.fail();
}
}
}
use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.
the class CriterionCodecTest method matchOchSignal.
/**
* Tests lambda criterion.
*/
@Test
public void matchOchSignal() {
Lambda ochSignal = Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8);
Criterion criterion = Criteria.matchLambda(ochSignal);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
Aggregations