Copyright update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / BarrierInputMessageFactoryTest.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.serialization.factories;
10
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
13
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
16 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
17 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
20
21 /**
22  * @author michal.polkorab
23  *
24  */
25 public class BarrierInputMessageFactoryTest {
26
27     private static final byte BARRIER_REQUEST_MESSAGE_CODE_TYPE = BarrierInputMessageFactory.MESSAGE_TYPE;
28     
29     /**
30      * Testing of {@link BarrierInputMessageFactory} for correct translation from POJO
31      * @throws Exception 
32      */
33     @Test
34     public void test() throws Exception {
35         BarrierInputBuilder bib = new BarrierInputBuilder();
36         BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID);
37         BarrierInput bi = bib.build();
38         
39         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
40         BarrierInputMessageFactory bimf = BarrierInputMessageFactory.getInstance();
41         bimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, bi);
42         
43         BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8);
44     }
45
46 }