tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 1 | // Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | // Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | // Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 4 | // This library was generated by the LoxiGen Compiler. |
| 5 | // See the file LICENSE.txt which should have been included in the source distribution |
| 6 | |
| 7 | // Automatically generated by LOXI from template unit_test.java |
| 8 | // Do not modify |
| 9 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver13; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import static org.junit.Assert.*; |
| 27 | import org.junit.Test; |
| 28 | import org.junit.Before; |
| 29 | import org.jboss.netty.buffer.ChannelBuffer; |
| 30 | import org.jboss.netty.buffer.ChannelBuffers; |
| 31 | import org.hamcrest.CoreMatchers; |
| 32 | |
| 33 | |
| 34 | |
| 35 | public class OFInstructionBsnDisableSrcMacCheckVer13Test { |
| 36 | OFInstructions factory; |
| 37 | |
| 38 | final static byte[] INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED = |
| 39 | new byte[] { (byte) 0xff, (byte) 0xff, 0x0, 0x10, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; |
| 40 | |
| 41 | @Before |
| 42 | public void setup() { |
| 43 | factory = OFInstructionsVer13.INSTANCE; |
| 44 | } |
| 45 | |
| 46 | @Test |
| 47 | public void testWrite() { |
| 48 | OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheck = factory.bsnDisableSrcMacCheck(); |
| 49 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 50 | instructionBsnDisableSrcMacCheck.writeTo(bb); |
| 51 | byte[] written = new byte[bb.readableBytes()]; |
| 52 | bb.readBytes(written); |
| 53 | |
| 54 | assertThat(written, CoreMatchers.equalTo(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED)); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void testRead() throws Exception { |
| 59 | OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheckBuilt = factory.bsnDisableSrcMacCheck(); |
| 60 | |
| 61 | ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED); |
| 62 | |
| 63 | // FIXME should invoke the overall reader once implemented |
| 64 | OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheckRead = OFInstructionBsnDisableSrcMacCheckVer13.READER.readFrom(input); |
| 65 | assertEquals(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED.length, input.readerIndex()); |
| 66 | |
| 67 | assertEquals(instructionBsnDisableSrcMacCheckBuilt, instructionBsnDisableSrcMacCheckRead); |
| 68 | } |
| 69 | |
| 70 | @Test |
| 71 | public void testReadWrite() throws Exception { |
| 72 | ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED); |
| 73 | |
| 74 | // FIXME should invoke the overall reader once implemented |
| 75 | OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheck = OFInstructionBsnDisableSrcMacCheckVer13.READER.readFrom(input); |
| 76 | assertEquals(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED.length, input.readerIndex()); |
| 77 | |
| 78 | // write message again |
| 79 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 80 | instructionBsnDisableSrcMacCheck.writeTo(bb); |
| 81 | byte[] written = new byte[bb.readableBytes()]; |
| 82 | bb.readBytes(written); |
| 83 | |
| 84 | assertThat(written, CoreMatchers.equalTo(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED)); |
| 85 | } |
| 86 | |
| 87 | } |