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.serialization.factories;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
13 import junit.framework.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
18 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
19 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
20 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
21 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
22 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
28 * @author michal.polkorab
31 public class OF10QueueGetConfigInputMessageFactoryTest {
33 private SerializerRegistry registry;
34 private OFSerializer<GetQueueConfigInput> queueFactory;
37 * Initializes serializer registry and stores correct factory in field
40 public void startUp() {
41 registry = new SerializerRegistryImpl();
43 queueFactory = registry.getSerializer(
44 new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, GetQueueConfigInput.class));
48 * Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO
52 public void test() throws Exception {
53 GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
54 BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
55 builder.setPort(new PortNumber(6653L));
56 GetQueueConfigInput message = builder.build();
58 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
59 queueFactory.serialize(message, out);
61 BufferHelper.checkHeaderV10(out, (byte) 20, 12);
62 Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort());