X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Ffactories%2FGetQueueConfigInputMessageFactoryTest.java;h=0d94cf6b73e5fb0ac82fdaa6f594b21b0a6273c3;hb=07de1ed897da9d7dc70c6d550f38c59339ed751e;hp=0f2a54199db5c97f1770b7a8ca834346d47925ef;hpb=1e439a51ce35e34f6203a64dba532aba9b5999af;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java index 0f2a5419..0d94cf6b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java @@ -1,14 +1,24 @@ -/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.openflowjava.protocol.impl.serialization.factories; -import static org.junit.Assert.*; -import junit.framework.Assert; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; - +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder; @@ -18,24 +28,38 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 * @author michal.polkorab */ public class GetQueueConfigInputMessageFactoryTest { - private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22; private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4; - + private SerializerRegistry registry; + private OFSerializer getQueueFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + getQueueFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetQueueConfigInput.class)); + } + + /** + * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO + * @throws Exception + */ @Test - public void testWithElements() throws Exception { + public void testGetQueueConfigInputMessage() throws Exception { GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder(); - BufferHelper.setupHeader(builder); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setPort(new PortNumber(0x00010203L)); GetQueueConfigInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - GetQueueConfigInputMessageFactory factory = GetQueueConfigInputMessageFactory.getInstance(); - factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); - + getQueueFactory.serialize(message, out); + BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16); Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt()); out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE); } - }