use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match in project openflowplugin by opendaylight.
the class IpEcnEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final short ecn = (short) 58;
final Match match = new MatchBuilder().setIpMatch(new IpMatchBuilder().setIpEcn(ecn).build()).build();
assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), ecn));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match in project openflowplugin by opendaylight.
the class Ipv4ArbitraryBitMaskDestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv4Address ipv4Address = new Ipv4Address("192.168.10.0");
final DottedQuad ipv4mask = new DottedQuad("255.255.255.0");
final Match ipv4abmMatch = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).setIpv4DestinationArbitraryBitmask(ipv4mask).build()).build();
assertMatch(ipv4abmMatch, true, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
});
final Match ipv4abmMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).build()).build();
assertMatch(ipv4abmMatchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match in project openflowplugin by opendaylight.
the class Ipv6ArbitraryBitMaskDestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv6Address ipv6Address = new Ipv6Address("aaaa:bbbb:1111:2222::");
final Ipv6ArbitraryMask ipv6mask = new Ipv6ArbitraryMask("ffff:ffff:ffff:ffff::");
final Match ipv6abmMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder().setIpv6DestinationAddressNoMask(ipv6Address).setIpv6DestinationArbitraryBitmask(ipv6mask).build()).build();
assertMatch(ipv6abmMatch, true, (out) -> {
byte[] address = new byte[16];
out.readBytes(address);
assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(ipv6Address));
byte[] mask = new byte[16];
out.readBytes(mask);
assertArrayEquals(mask, IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(ipv6mask));
});
final Match ipv6abmMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder().setIpv6DestinationAddressNoMask(ipv6Address).build()).build();
assertMatch(ipv6abmMatchNoMask, false, (out) -> {
byte[] address = new byte[16];
out.readBytes(address);
assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(ipv6Address));
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match in project openflowplugin by opendaylight.
the class Ipv6LabelEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final long ipv6flowLabel = 358;
final long ipv6flowLabelMask = 100;
final Match ipv6flowLabelMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Label(new Ipv6LabelBuilder().setIpv6Flabel(new Ipv6FlowLabel(ipv6flowLabel)).setFlabelMask(new Ipv6FlowLabel(ipv6flowLabelMask)).build()).build()).build();
assertMatch(ipv6flowLabelMatch, true, (out) -> {
assertEquals(out.readUnsignedInt(), ipv6flowLabel);
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, ByteUtil.unsignedIntToBytes(ipv6flowLabelMask));
});
final Match ipv6exyHdrMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Label(new Ipv6LabelBuilder().setIpv6Flabel(new Ipv6FlowLabel(ipv6flowLabel)).build()).build()).build();
assertMatch(ipv6exyHdrMatchNoMask, false, (out) -> assertEquals(out.readUnsignedInt(), ipv6flowLabel));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match in project openflowplugin by opendaylight.
the class MplsBosEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final short mplsBos = (short) 1;
final Match mplsBosMatch = new MatchBuilder().setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsBos(mplsBos).build()).build();
// TODO: Why are we using short in models instead of boolean?
assertMatch(mplsBosMatch, false, (out) -> assertEquals(out.readBoolean(), mplsBos != 0));
}
Aggregations