Search in sources :

Example 11 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchTcpSrcMaskedTest.

/**
 * Tests source TCP port masked criterion.
 */
@Test
public void matchTcpSrcMaskedTest() {
    Criterion criterion = Criteria.matchTcpSrcMasked(tpPort, tpPortMask);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Example 12 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method getCriterion.

/**
 * Reads in a criterion from the given resource and decodes it.
 *
 * @param resourceName resource to use to read the JSON for the rule
 * @return decoded criterion
 * @throws IOException if processing the resource fails
 */
private Criterion getCriterion(String resourceName) throws IOException {
    InputStream jsonStream = CriterionCodecTest.class.getResourceAsStream(resourceName);
    JsonNode json = context.mapper().readTree(jsonStream);
    MatcherAssert.assertThat(json, notNullValue());
    Criterion criterion = criterionCodec.decode((ObjectNode) json, context);
    Assert.assertThat(criterion, notNullValue());
    return criterion;
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) InputStream(java.io.InputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 13 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchUdpDstMaskedTest.

/**
 * Tests destination UDP port masked criterion.
 */
@Test
public void matchUdpDstMaskedTest() {
    Criterion criterion = Criteria.matchUdpDstMasked(tpPort, tpPortMask);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Example 14 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchInPortTest.

/**
 * Tests in port criterion.
 */
@Test
public void matchInPortTest() {
    Criterion criterion = Criteria.matchInPort(port);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Example 15 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchIPv6NDSourceLinkLayerAddressTest.

/**
 * Tests IPV6 SLL criterion.
 */
@Test
public void matchIPv6NDSourceLinkLayerAddressTest() {
    Criterion criterion = Criteria.matchIPv6NDSourceLinkLayerAddress(mac1);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Aggregations

Criterion (org.onosproject.net.flow.criteria.Criterion)122 Test (org.junit.Test)54 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)54 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)51 CriterionJsonMatcher.matchesCriterion (org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion)46 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)43 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)42 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)39 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)39 Instruction (org.onosproject.net.flow.instructions.Instruction)37 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)35 TrafficSelector (org.onosproject.net.flow.TrafficSelector)33 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)29 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)25 FlowRule (org.onosproject.net.flow.FlowRule)25 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)24 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)22 Instructions (org.onosproject.net.flow.instructions.Instructions)19 List (java.util.List)17