2 * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
10 import io.netty.buffer.ByteBuf;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
19 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
28 * @author giuseppex.petralia@intel.com
31 public class GroupModInputMessageFactoryTest {
32 private OFDeserializer<GroupModInput> factory;
35 public void startUp() {
36 DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
39 .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 15, GroupModInput.class));
44 ByteBuf bb = BufferHelper
45 .buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00");
46 GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
47 BufferHelper.checkHeaderV13(deserializedMessage);
50 Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
51 Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
52 Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId());
53 BucketsList bucket = deserializedMessage.getBucketsList().get(0);
54 Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
55 Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort());
56 Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());