* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.impl.protocol.serialization.messages;
import static org.junit.Assert.assertEquals;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSerializerTest;
+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.flow.types.port.rev130925.PortConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class PortMessageSerializerTest extends AbstractSerializerTest {
private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
private static final short LENGTH = 40;
- private static final Long XID = 42L;
- private static final short VERSION = EncodeConstants.OF13_VERSION_ID;
+ private static final Uint32 XID = Uint32.valueOf(42);
+ private static final Uint8 VERSION = EncodeConstants.OF_VERSION_1_3;
private static final String PORT_NUMBER = OutputPortValues.ALL.toString();
private static final Long PORT_NUMBER_VAL = BinContent.intToUnsignedLong(PortNumberValues.ALL.getIntValue());
- private static final String MAC_ADDRESS = "E9:2A:55:BA:FA:4D";
+ private static final String MAC_ADDRESS = "e9:2a:55:ba:fa:4d";
// Port config
private static final Boolean IS_NOFWD = false;
@Override
protected void init() {
- serializer = getRegistry().getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PortMessage.class));
+ serializer = getRegistry()
+ .getSerializer(new MessageTypeKey<>(EncodeConstants.OF_VERSION_1_3, PortMessage.class));
}
@Test
- public void testSerialize() throws Exception {
+ public void testSerialize() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(MESSAGE, out);
// Header
- assertEquals(out.readByte(), VERSION);
+ assertEquals(out.readByte(), VERSION.byteValue());
assertEquals(out.readByte(), serializer.getMessageType());
assertEquals(out.readShort(), LENGTH);
assertEquals(out.readInt(), XID.intValue());
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
byte[] address = new byte[6];
out.readBytes(address);
- assertEquals(
- new MacAddress(ByteBufUtils.macAddressToString(address)).getValue(),
- new MacAddress(MAC_ADDRESS).getValue());
+ assertEquals(new MacAddress(MAC_ADDRESS), IetfYangUtil.macAddressFor(address));
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);
// Port config