2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
11 import io.netty.buffer.ByteBuf;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
16 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * @author timotej.kubas
27 public class PacketInMessageFactoryTest {
29 private static final Logger LOGGER = LoggerFactory
30 .getLogger(PacketInMessageFactoryTest.class);
33 * Testing {@link PacketInMessageFactory} for correct translation into POJO
37 ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C"
38 + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");
39 PacketInMessage builtByFactory = BufferHelper.decodeV13(PacketInMessageFactory.getInstance(), bb);
41 BufferHelper.checkHeaderV13(builtByFactory);
43 Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
44 Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
45 Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason());
46 Assert.assertEquals("Wrong tableID", new TableId(4L), builtByFactory.getTableId());
47 Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
48 Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());