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