2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
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
9 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
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;
21 * @author michal.polkorab
24 public class EchoReplyInputMessageFactoryTest {
26 private static final byte ECHO_REPLY_MESSAGE_CODE_TYPE = EchoReplyInputMessageFactory.MESSAGE_TYPE;
29 * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
33 public void testV13() throws Exception {
34 EchoReplyInputBuilder erib = new EchoReplyInputBuilder();
35 BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID);
36 EchoReplyInput eri = erib.build();
38 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
39 EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();
40 eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, eri);
42 BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);
46 * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
50 public void testV10() throws Exception {
51 EchoReplyInputBuilder erib = new EchoReplyInputBuilder();
52 BufferHelper.setupHeader(erib, EncodeConstants.OF10_VERSION_ID);
53 EchoReplyInput eri = erib.build();
55 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
56 EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();
57 eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, eri);
59 BufferHelper.checkHeaderV10(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);