2 * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.openflow.md.core;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
18 public class MessageFactoryTest {
21 public void testCreateHelloInputWoElements() {
22 short highestVersion = (short) 0x04;
25 HelloInput helloMsg = MessageFactory.createHelloInput(highestVersion, xid);
26 Assert.assertEquals(highestVersion, helloMsg.getVersion().shortValue());
27 Assert.assertEquals(xid, helloMsg.getXid().longValue());
28 Assert.assertNull(helloMsg.getElements());
32 public void testCreateHelloInputWithElements() {
33 short highestVersion = (short) 0x04;
35 Boolean[] expectedVersionBitmap = new Boolean[]{
36 false, true, false, false, true};
38 HelloInput helloMsg = MessageFactory.createHelloInput(highestVersion, xid,
39 ConnectionConductor.VERSION_ORDER);
40 Assert.assertEquals(highestVersion, helloMsg.getVersion().shortValue());
41 Assert.assertEquals(xid, helloMsg.getXid().longValue());
42 Assert.assertEquals(1, helloMsg.getElements().size());
43 Elements actualElement = helloMsg.getElements().get(0);
44 Assert.assertEquals(HelloElementType.VERSIONBITMAP, actualElement.getType());
45 Assert.assertArrayEquals(expectedVersionBitmap, actualElement.getVersionBitmap().toArray(new Boolean[0]));