2 * Copyright (c) 2015 NetIDE Consortium 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
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
10 import io.netty.buffer.ByteBuf;
11 import java.util.ArrayList;
12 import java.util.Arrays;
13 import java.util.List;
14 import org.junit.Assert;
15 import org.junit.Test;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
19 import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
24 * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetConfigInputMessageFactory}.
25 * @author giuseppex.petralia@intel.com
27 public class SetConfigInputMessageFactoryTest extends DefaultDeserializerFactoryTest<SetConfigInput> {
30 * Initializes deserializer registry and lookups OF13 deserializer.
32 public SetConfigInputMessageFactoryTest() {
33 super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 9, SetConfigInput.class));
37 * Testing {@link SetConfigInputMessageFactory} for correct header version.
40 public void testVersions() {
41 List<Byte> versions = new ArrayList<>(Arrays.asList(
42 EncodeConstants.OF10_VERSION_ID,
43 EncodeConstants.OF13_VERSION_ID,
44 EncodeConstants.OF14_VERSION_ID,
45 EncodeConstants.OF15_VERSION_ID
47 ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a");
48 testHeaderVersions(versions, bb);
53 ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a");
54 SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
57 Assert.assertEquals("Wrong flags ", SwitchConfigFlag.forValue(2), deserializedMessage.getFlags());
58 Assert.assertEquals("Wrong Miss Send len ", 10, deserializedMessage.getMissSendLen().intValue());