X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fdeserialization%2Ffactories%2FFlowRemovedMessageFactoryTest.java;h=cc0f35d836e6fadcfa1e312ae48cad85b116aa4b;hb=07de1ed897da9d7dc70c6d550f38c59339ed751e;hp=6e91cff972e5cb360037332a72d703d83e2916cd;hpb=2c0d6baf3a4ca0c6de5992d68e5f2eb200a918ed;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java index 6e91cff9..cc0f35d8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java @@ -1,41 +1,67 @@ -/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; - -/** - * @author timotej.kubas - * @author michal.polkorab - */ -public class FlowRemovedMessageFactoryTest { - - /** - * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO - */ - @Test - public void test(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02" - + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07"); - FlowRemovedMessage builtByFactory = BufferHelper.decodeV13(FlowRemovedMessageFactory.getInstance(), bb); - - BufferHelper.checkHeaderV13(builtByFactory); - - Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L); - Assert.assertTrue(builtByFactory.getPriority() == 0x03); - Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue()); - Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId()); - Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue()); - Assert.assertEquals("Wrong durationNsec", 0x05L, builtByFactory.getDurationNsec().longValue()); - Assert.assertEquals("Wrong idleTimeout", 0x01, builtByFactory.getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeout", 0x03, builtByFactory.getHardTimeout().intValue()); - Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue()); - Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue()); - } - -} +/* + * 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.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +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.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; + +/** + * @author timotej.kubas + * @author michal.polkorab + */ +public class FlowRemovedMessageFactoryTest { + + private OFDeserializer flowFactory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + flowFactory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 11, FlowRemovedMessage.class)); + } + + /** + * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO + */ + @Test + public void test(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02" + + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07"); + FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + + Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L); + Assert.assertTrue(builtByFactory.getPriority() == 0x03); + Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue()); + Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId()); + Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue()); + Assert.assertEquals("Wrong durationNsec", 0x05L, builtByFactory.getDurationNsec().longValue()); + Assert.assertEquals("Wrong idleTimeout", 0x01, builtByFactory.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeout", 0x03, builtByFactory.getHardTimeout().intValue()); + Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue()); + Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue()); + } + +}