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.augments.rev131002.ExperimenterError;
\r
19 * @author michal.polkorab
\r
22 public class OF13ExperimenterErrorMessageDeserializerTest {
\r
25 * Testing of {@link OF13ExperimenterErrorMessageDeserializer} for correct translation into POJO
\r
26 * @throws Exception
\r
29 public void test() {
\r
30 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
31 buffer.writeShort(35000);
\r
32 buffer.writeInt(70000);
\r
33 byte[] data = new byte[]{5, 5, 5, 6, 7, 8, 9, 10};
\r
34 buffer.writeBytes(data);
\r
36 OF13ExperimenterErrorMessageDeserializer deserializer =
\r
37 new OF13ExperimenterErrorMessageDeserializer();
\r
38 ExperimenterError message = deserializer.deserialize(buffer);
\r
40 Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue());
\r
41 Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue());
\r
42 Assert.assertArrayEquals("Wrong data", data, message.getExpData());
\r
46 * Testing of {@link OF13ExperimenterErrorMessageDeserializer} for correct translation into POJO
\r
47 * @throws Exception
\r
50 public void testWithoutData() {
\r
51 ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
\r
52 buffer.writeShort(35000);
\r
53 buffer.writeInt(70000);
\r
55 OF13ExperimenterErrorMessageDeserializer deserializer =
\r
56 new OF13ExperimenterErrorMessageDeserializer();
\r
57 ExperimenterError message = deserializer.deserialize(buffer);
\r
59 Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue());
\r
60 Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue());
\r
61 Assert.assertNull("Unexpected data", message.getExpData());
\r