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 java.util.ArrayList;
12 import java.util.List;
14 import io.netty.buffer.ByteBuf;
16 import org.junit.Assert;
17 import org.junit.Test;
18 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;
25 * @author michal.polkorab
26 * @author timotej.kubas
28 public class HelloMessageFactoryTest {
30 /** Number of currently supported version / codec */
31 public static final Short VERSION_YET_SUPPORTED = 0x04;
34 * Testing {@link HelloMessageFactory} for correct translation into POJO
38 ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type
40 + "00 00 00 11 " // bitmap 1
41 + "00 00 00 00 " // bitmap 2
42 + "00 00 00 00" // padding
44 HelloMessage builtByFactory = BufferHelper.decodeV13(
45 HelloMessageFactory.getInstance(), bb);
47 BufferHelper.checkHeaderV13(builtByFactory);
48 List<Elements> element = createElement();
49 Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType());
50 Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap());
53 private static List<Elements> createElement() {
54 ElementsBuilder elementsBuilder = new ElementsBuilder();
55 List<Elements> elementsList = new ArrayList<>();
56 List<Boolean> booleanList = new ArrayList<>();
57 booleanList.add(true);
58 booleanList.add(false);
59 booleanList.add(false);
60 booleanList.add(false);
61 booleanList.add(true);
62 for (int i = 1; i < 60; i++) {
63 booleanList.add(false);
65 elementsBuilder.setType(HelloElementType.forValue(1));
66 elementsBuilder.setVersionBitmap(booleanList);
67 elementsList.add(elementsBuilder.build());