2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.openflowjava.protocol.ext.deserialization;
\r
11 import io.netty.buffer.ByteBuf;
\r
12 import io.netty.buffer.UnpooledByteBufAllocator;
\r
14 import org.junit.Assert;
\r
15 import org.junit.Test;
\r
16 import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils;
\r
17 import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueueProperty;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
\r
23 * @author michal.polkorab
\r
26 public class OF13QueueGetConfigReplyExperimenterDeserializerTest {
\r
29 * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO
\r
30 * @throws Exception
\r
33 public void test() {
\r
34 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
35 buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);
\r
36 buffer.writeShort(24);
\r
37 ExtBufferUtils.padBuffer(4, buffer);
\r
38 buffer.writeInt(128);
\r
39 ExtBufferUtils.padBuffer(4, buffer);
\r
40 byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3};
\r
41 buffer.writeBytes(data);
\r
43 OF13QueueGetConfigReplyExperimenterDeserializer deserializer =
\r
44 new OF13QueueGetConfigReplyExperimenterDeserializer();
\r
45 QueueProperty message = deserializer.deserialize(buffer);
\r
47 Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty());
\r
48 ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class);
\r
49 Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue());
\r
50 Assert.assertArrayEquals("Wrong data", data, exp.getData());
\r
54 * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO
\r
55 * @throws Exception
\r
58 public void testWithoutData() {
\r
59 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
60 buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);
\r
61 buffer.writeShort(16);
\r
62 ExtBufferUtils.padBuffer(4, buffer);
\r
63 buffer.writeInt(128);
\r
64 ExtBufferUtils.padBuffer(4, buffer);
\r
66 OF13QueueGetConfigReplyExperimenterDeserializer deserializer =
\r
67 new OF13QueueGetConfigReplyExperimenterDeserializer();
\r
68 QueueProperty message = deserializer.deserialize(buffer);
\r
70 Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty());
\r
71 ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class);
\r
72 Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue());
\r
73 Assert.assertNull("Unexpected data", exp.getData());
\r