use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testLayer3MatchArp.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testLayer3MatchArp() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(ArpOp.class);
entriesBuilder.setHasMask(false);
final ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
final ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
arpOpBuilder.setOpCode(17);
arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
entriesBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(ArpSpa.class);
entriesBuilder.setHasMask(false);
final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));
arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(ArpTpa.class);
entriesBuilder.setHasMask(false);
final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));
arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(ArpSha.class);
entriesBuilder.setHasMask(false);
final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));
arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);
entriesBuilder.setHasMask(false);
final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));
arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();
final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong arp op", 17, arpMatch.getArpOp().intValue());
Assert.assertEquals("Wrong arp spa", "10.0.0.3/32", arpMatch.getArpSourceTransportAddress().getValue());
Assert.assertEquals("Wrong arp tpa", "10.0.0.4/32", arpMatch.getArpTargetTransportAddress().getValue());
Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03", arpMatch.getArpSourceHardwareAddress().getAddress().getValue());
Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04", arpMatch.getArpTargetHardwareAddress().getAddress().getValue());
}
Aggregations