X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=extension%2Fopenflowjava-extension-nicira%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fnx%2Fcodec%2Fmatch%2FEthDstCodecTest.java;h=b4a479800ba55913170e6cfe79bd13ab76dc38e5;hb=dc2befb3188ea11dfd0d74d375a8d3acf3619d38;hp=d1be550d52bee71ea5678ba0c9a16ea20e7d5dfe;hpb=28f2bced3075329036dff49feaa771c8f7e24a9e;p=openflowplugin.git diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodecTest.java index d1be550d52..b4a479800b 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodecTest.java @@ -11,36 +11,30 @@ import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; -import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfEthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.EthDstCaseValue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.EthDstCaseValueBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.eth.dst.grouping.EthDstValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthDstCaseValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthDstCaseValueBuilder; public class EthDstCodecTest { + private final ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer(); + private final EthDstCodec ethDstCodec = new EthDstCodec(); - EthDstCodec ethDstCodec; - ByteBuf buffer; - MatchEntry input; + private MatchEntry input; private static final int VALUE_LENGTH = 6; private static final int NXM_FIELD_CODE = 1; private static final byte[] TEST_ADDR = new byte[VALUE_LENGTH]; - private static final MacAddress TEST_ADDRESS = new MacAddress(ByteBufUtils.macAddressToString(TEST_ADDR)); - - @Before - public void setUp() { - ethDstCodec = new EthDstCodec(); - buffer = ByteBufAllocator.DEFAULT.buffer(); - } + private static final MacAddress TEST_ADDRESS = IetfYangUtil.macAddressFor(TEST_ADDR); @Test public void serializeTest() { @@ -63,33 +57,29 @@ public class EthDstCodecTest { final EthDstCaseValue result = (EthDstCaseValue) input.getMatchEntryValue(); - assertEquals(Nxm0Class.class, input.getOxmClass()); - assertEquals(NxmOfEthDst.class, input.getOxmMatchField()); - assertEquals(false, input.isHasMask()); + assertEquals(Nxm0Class.VALUE, input.getOxmClass()); + assertEquals(NxmOfEthDst.VALUE, input.getOxmMatchField()); + assertEquals(false, input.getHasMask()); assertEquals(TEST_ADDRESS, result.getEthDstValues().getMacAddress()); } - - - private MatchEntry createMatchEntry() { + private static MatchEntry createMatchEntry() { MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); final EthDstCaseValueBuilder caseBuilder = new EthDstCaseValueBuilder(); final EthDstValuesBuilder valuesBuilder = new EthDstValuesBuilder(); - matchEntryBuilder.setOxmClass(Nxm0Class.class); - matchEntryBuilder.setOxmMatchField(NxmOfEthDst.class); + matchEntryBuilder.setOxmClass(Nxm0Class.VALUE); + matchEntryBuilder.setOxmMatchField(NxmOfEthDst.VALUE); matchEntryBuilder.setHasMask(false); - byte[] address = new byte[VALUE_LENGTH]; - - valuesBuilder.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + valuesBuilder.setMacAddress(IetfYangUtil.macAddressFor(new byte[VALUE_LENGTH])); caseBuilder.setEthDstValues(valuesBuilder.build()); matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); return matchEntryBuilder.build(); } - private void createBuffer(ByteBuf message) { + private static void createBuffer(final ByteBuf message) { message.writeShort(OxmMatchConstants.NXM_0_CLASS); int fieldMask = NXM_FIELD_CODE << 1;