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;
26 import org.opendaylight.yangtools.yang.common.Uint32;
29 * Unit tests for GroupModInputMessageFactory.
31 * @author giuseppex.petralia@intel.com
33 public class GroupModInputMessageFactoryTest {
34 private OFDeserializer<GroupModInput> factory;
37 public void startUp() {
38 DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
41 .getDeserializer(new MessageCodeKey(EncodeConstants.OF_VERSION_1_3, 15, GroupModInput.class));
46 ByteBuf bb = BufferHelper
47 .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");
48 GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
49 BufferHelper.checkHeaderV13(deserializedMessage);
52 Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
53 Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
54 Assert.assertEquals("Wrong group id", new GroupId(Uint32.valueOf(256)), deserializedMessage.getGroupId());
55 BucketsList bucket = deserializedMessage.getBucketsList().get(0);
56 Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
57 Assert.assertEquals("Wrong watch port", new PortNumber(Uint32.valueOf(65)), bucket.getWatchPort());
58 Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());