Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / test / java / org / openflow / protocol / OFPortStatusTest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.openflow.protocol;
11
12 import java.nio.ByteBuffer;
13
14 import junit.framework.TestCase;
15
16 import org.openflow.protocol.OFPortStatus.OFPortReason;
17 import org.openflow.util.OFTestCase;
18
19 public class OFPortStatusTest extends OFTestCase {
20     public void testWriteRead() throws Exception {
21         OFPortStatus msg = (OFPortStatus) messageFactory
22                 .getMessage(OFType.PORT_STATUS);
23         msg.setDesc(new OFPhysicalPort());
24         msg.getDesc().setHardwareAddress(new byte[6]);
25         msg.getDesc().setName("eth0");
26         msg.setReason((byte) OFPortReason.OFPPR_ADD.ordinal());
27         ByteBuffer bb = ByteBuffer.allocate(1024);
28         bb.clear();
29         msg.writeTo(bb);
30         bb.flip();
31         msg.readFrom(bb);
32         TestCase.assertEquals(OFType.PORT_STATUS, msg.getType());
33         TestCase.assertEquals((byte) OFPortReason.OFPPR_ADD.ordinal(), msg
34                 .getReason());
35         TestCase.assertNotNull(msg.getDesc());
36     }
37 }