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 org.junit.Assert;
\r
8 import org.junit.Test;
\r
9 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
\r
10 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
\r
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
\r
16 * @author timotej.kubas
\r
17 * @author michal.polkorab
\r
19 public class SetConfigMessageFactoryTest {
\r
20 private static final byte MESSAGE_TYPE = 9;
\r
21 private static final int MESSAGE_LENGTH = 12;
\r
24 * Testing of {@link SetConfigMessageFactory} for correct translation from POJO
\r
25 * @throws Exception
\r
28 public void testSetConfigMessage() throws Exception {
\r
29 SetConfigInputBuilder builder = new SetConfigInputBuilder();
\r
30 BufferHelper.setupHeader(builder);
\r
31 SwitchConfigFlag flag = SwitchConfigFlag.FRAGNORMAL;
\r
32 builder.setFlags(flag);
\r
33 builder.setMissSendLen(10);
\r
34 SetConfigInput message = builder.build();
\r
36 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
37 SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();
\r
38 factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
\r
40 BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
\r
41 Assert.assertEquals("Wrong flags", message.getFlags().getIntValue(), out.readUnsignedShort());
\r
42 Assert.assertEquals("Wrong missSendLen", message.getMissSendLen().intValue(), out.readUnsignedShort());
\r