Copyright update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / EchoReplyInputMessageFactoryTest.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.util.BufferHelper;
16 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
19
20 /**
21  * @author michal.polkorab
22  *
23  */
24 public class EchoReplyInputMessageFactoryTest {
25
26     private static final byte ECHO_REPLY_MESSAGE_CODE_TYPE = EchoReplyInputMessageFactory.MESSAGE_TYPE;
27     
28     /**
29      * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
30      * @throws Exception 
31      */
32     @Test
33     public void testV13() throws Exception {
34         EchoReplyInputBuilder erib = new EchoReplyInputBuilder();
35         BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID);
36         EchoReplyInput eri = erib.build();
37         
38         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
39         EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();
40         eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, eri);
41         
42         BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);
43     }
44     
45     /**
46      * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
47      * @throws Exception 
48      */
49     @Test
50     public void testV10() throws Exception {
51         EchoReplyInputBuilder erib = new EchoReplyInputBuilder();
52         BufferHelper.setupHeader(erib, EncodeConstants.OF10_VERSION_ID);
53         EchoReplyInput eri = erib.build();
54         
55         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
56         EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();
57         eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, eri);
58         
59         BufferHelper.checkHeaderV10(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);
60     }
61
62 }