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.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 OF13MultipartReplyExperimenterDeserializerTest {
\r
25 * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO
\r
26 * @throws Exception
\r
29 public void test() {
\r
30 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
31 buffer.writeInt(456654);
\r
32 buffer.writeInt(888222);
\r
33 byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3};
\r
34 buffer.writeBytes(data);
\r
36 OF13MultipartReplyExperimenterDeserializer deserializer =
\r
37 new OF13MultipartReplyExperimenterDeserializer();
\r
38 MultipartReplyExperimenter message = deserializer.deserialize(buffer);
\r
40 Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue());
\r
41 Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue());
\r
42 Assert.assertArrayEquals("Wrong data", data, message.getData());
\r
46 * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO
\r
47 * @throws Exception
\r
50 public void testWithoutData() {
\r
51 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
52 buffer.writeInt(456654);
\r
53 buffer.writeInt(888222);
\r
55 OF13MultipartReplyExperimenterDeserializer deserializer =
\r
56 new OF13MultipartReplyExperimenterDeserializer();
\r
57 MultipartReplyExperimenter message = deserializer.deserialize(buffer);
\r
59 Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue());
\r
60 Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue());
\r
61 Assert.assertNull("Unexpected data", message.getData());
\r