2 * Copyright (c) 2013 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.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter;
\r
19 * @author michal.polkorab
\r
22 public class OF10StatsReplyVendorDeserializerTest {
\r
25 * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO
\r
29 public void test() {
\r
30 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
31 buffer.writeInt(42);
\r
32 byte[] data = new byte[]{0, 1, 2, 3, 3, 2, 1, 0};
\r
33 buffer.writeBytes(data);
\r
35 OF10StatsReplyVendorDeserializer deserializer =
\r
36 new OF10StatsReplyVendorDeserializer();
\r
37 MultipartReplyExperimenter message = deserializer.deserialize(buffer);
\r
39 Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue());
\r
40 Assert.assertArrayEquals("Wrong data", data, message.getData());
\r
44 * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO
\r
48 public void testWithoutData() {
\r
49 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
50 buffer.writeInt(42);
\r
52 OF10StatsReplyVendorDeserializer deserializer =
\r
53 new OF10StatsReplyVendorDeserializer();
\r
54 MultipartReplyExperimenter message = deserializer.deserialize(buffer);
\r
56 Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue());
\r
57 Assert.assertNull("Unexpected data", message.getData());
\r