4da9fe905c5c8e3819a9de53ca8b625555cac1b5
[controller.git] / third-party / openflowj / src / test / java / org / openflow / protocol / OFFlowRemovedTest.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.OFFlowRemoved.OFFlowRemovedReason;
17 import org.openflow.util.OFTestCase;
18
19 public class OFFlowRemovedTest extends OFTestCase {
20     public void testWriteRead() throws Exception {
21         OFFlowRemoved msg = (OFFlowRemoved) messageFactory
22                 .getMessage(OFType.FLOW_REMOVED);
23         msg.setMatch(new OFMatch());
24         byte[] hwAddr = new byte[6];
25         msg.getMatch().setDataLayerDestination(hwAddr);
26         msg.getMatch().setDataLayerSource(hwAddr);
27         msg.setReason(OFFlowRemovedReason.OFPRR_DELETE);
28         ByteBuffer bb = ByteBuffer.allocate(1024);
29         bb.clear();
30         msg.writeTo(bb);
31         bb.flip();
32         msg.readFrom(bb);
33         TestCase.assertEquals(OFType.FLOW_REMOVED, msg.getType());
34         TestCase.assertEquals(OFFlowRemovedReason.OFPRR_DELETE, msg.getReason());
35     }
36 }