be6dc48c98468a9f0f1e7b2231f23b149e442b3f
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / FeaturesReplyMessageFactoryTest.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
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
18
19 /**
20  * @author michal.polkorab
21  * @author timotej.kubas
22  */
23 public class FeaturesReplyMessageFactoryTest {
24
25     /**
26      * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
27      */
28     @Test
29     public void test() {
30         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00"
31                 + " 00 01 41 00 01 02 03");
32         GetFeaturesOutput builtByFactory = BufferHelper.decodeV13(
33                 FeaturesReplyMessageFactory.getInstance(), bb);
34
35         BufferHelper.checkHeaderV13(builtByFactory);
36         Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
37         Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
38         Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
39         Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
40         Assert.assertEquals("Wrong capabilities", new Capabilities(true, false, false, true, false, true, false), builtByFactory.getCapabilities());
41         Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
42     }
43 }