1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
5 import io.netty.buffer.UnpooledByteBufAllocator;
\r
7 import java.util.List;
\r
9 import org.junit.Test;
\r
10 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
\r
11 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;
\r
18 import com.google.common.collect.Lists;
\r
21 * @author michal.polkorab
\r
24 public class HelloInputMessageFactoryTest {
\r
26 private static final byte HELLO_MESSAGE_CODE_TYPE = 0;
\r
29 * Testing of {@link HelloInputMessageFactory} for correct translation from POJO
\r
30 * @throws Exception
\r
33 public void testWithoutElementsSet() throws Exception {
\r
34 HelloInputBuilder hib = new HelloInputBuilder();
\r
35 BufferHelper.setupHeader(hib);
\r
36 HelloInput hi = hib.build();
\r
38 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
39 HelloInputMessageFactory himf = HelloInputMessageFactory.getInstance();
\r
40 himf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, hi);
\r
42 BufferHelper.checkHeaderV13(out, HELLO_MESSAGE_CODE_TYPE, 8);
\r
46 * Testing of {@link HelloInputMessageFactory} for correct translation from POJO
\r
47 * @throws Exception
\r
50 public void testWithElementsSet() throws Exception {
\r
51 HelloInputBuilder hib = new HelloInputBuilder();
\r
52 BufferHelper.setupHeader(hib);
\r
53 ElementsBuilder eb = new ElementsBuilder();
\r
54 eb.setType(HelloElementType.VERSIONBITMAP);
\r
55 eb.setData(new byte[]{0x01, 0x02, 0x42, 0x03});
\r
56 List<Elements> elementList = Lists.newArrayList(eb.build());
\r
57 hib.setElements(elementList);
\r
58 HelloInput hi = hib.build();
\r
60 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
61 HelloInputMessageFactory himf = HelloInputMessageFactory.getInstance();
\r
62 himf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, hi);
\r
64 BufferHelper.checkHeaderV13(out, HELLO_MESSAGE_CODE_TYPE, 8);
\r
65 // TODO - element list
\r