Migrate openflow-protocol-impl tests to Uint types
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / RoleReplyMessageFactoryTest.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
10
11 import io.netty.buffer.ByteBuf;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
16 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
17 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
18 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
19 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
20 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
22
23 /**
24  * Unit tests for RoleReplyMessageFactory.
25  *
26  * @author timotej.kubas
27  * @author michal.polkorab
28  */
29 public class RoleReplyMessageFactoryTest {
30
31     private OFDeserializer<RoleRequestOutput> roleFactory;
32
33     /**
34      * Initializes deserializer registry and lookups correct deserializer.
35      */
36     @Before
37     public void startUp() {
38         DeserializerRegistry registry = new DeserializerRegistryImpl();
39         registry.init();
40         roleFactory = registry.getDeserializer(
41                 new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 25, RoleRequestOutput.class));
42     }
43
44    /**
45     * Testing of {@link RoleReplyMessageFactory} for correct translation into POJO.
46     */
47     @Test
48     public void test() {
49         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 00 01 02 03 04 05 06 07");
50         RoleRequestOutput builtByFactory = BufferHelper.deserialize(roleFactory, bb);
51
52         BufferHelper.checkHeaderV13(builtByFactory);
53
54         Assert.assertEquals("Wrong role", 0x02, builtByFactory.getRole().getIntValue());
55         Assert.assertEquals("Wrong generationId", 0x01020304050607L, builtByFactory.getGenerationId().longValue());
56     }
57 }