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 java.util.Set; |
| 28 | import org.junit.Test; |
| 29 | import org.junit.Before; |
| 30 | import org.jboss.netty.buffer.ChannelBuffer; |
| 31 | import org.jboss.netty.buffer.ChannelBuffers; |
| 32 | import org.hamcrest.CoreMatchers; |
| 33 | |
| 34 | |
| 35 | |
| 36 | public class OFBsnSetAuxCxnsRequestVer13Test { |
| 37 | OFFactory factory; |
| 38 | |
| 39 | final static byte[] BSN_SET_AUX_CXNS_REQUEST_SERIALIZED = |
| 40 | new byte[] { 0x4, 0x4, 0x0, 0x14, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x3a, 0x0, 0x0, 0x0, 0x1 }; |
| 41 | |
| 42 | @Before |
| 43 | public void setup() { |
| 44 | factory = OFFactoryVer13.INSTANCE; |
| 45 | } |
| 46 | |
| 47 | @Test |
| 48 | public void testWrite() { |
| 49 | OFBsnSetAuxCxnsRequest.Builder builder = factory.buildBsnSetAuxCxnsRequest(); |
| 50 | builder.setXid(0x12345678) |
| 51 | .setNumAux(1); |
| 52 | OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest = builder.build(); |
| 53 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 54 | bsnSetAuxCxnsRequest.writeTo(bb); |
| 55 | byte[] written = new byte[bb.readableBytes()]; |
| 56 | bb.readBytes(written); |
| 57 | |
| 58 | assertThat(written, CoreMatchers.equalTo(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED)); |
| 59 | } |
| 60 | |
| 61 | @Test |
| 62 | public void testRead() throws Exception { |
| 63 | OFBsnSetAuxCxnsRequest.Builder builder = factory.buildBsnSetAuxCxnsRequest(); |
| 64 | builder.setXid(0x12345678) |
| 65 | .setNumAux(1); |
| 66 | OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequestBuilt = builder.build(); |
| 67 | |
| 68 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED); |
| 69 | |
| 70 | // FIXME should invoke the overall reader once implemented |
| 71 | OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequestRead = OFBsnSetAuxCxnsRequestVer13.READER.readFrom(input); |
| 72 | assertEquals(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED.length, input.readerIndex()); |
| 73 | |
| 74 | assertEquals(bsnSetAuxCxnsRequestBuilt, bsnSetAuxCxnsRequestRead); |
| 75 | } |
| 76 | |
| 77 | @Test |
| 78 | public void testReadWrite() throws Exception { |
| 79 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED); |
| 80 | |
| 81 | // FIXME should invoke the overall reader once implemented |
| 82 | OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest = OFBsnSetAuxCxnsRequestVer13.READER.readFrom(input); |
| 83 | assertEquals(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED.length, input.readerIndex()); |
| 84 | |
| 85 | // write message again |
| 86 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 87 | bsnSetAuxCxnsRequest.writeTo(bb); |
| 88 | byte[] written = new byte[bb.readableBytes()]; |
| 89 | bb.readBytes(written); |
| 90 | |
| 91 | assertThat(written, CoreMatchers.equalTo(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED)); |
| 92 | } |
| 93 | |
| 94 | } |