alshabib | 86ac11c | 2014-08-14 16:14:41 -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 java.util.List; |
| 30 | import com.google.common.collect.ImmutableList; |
| 31 | import org.jboss.netty.buffer.ChannelBuffer; |
| 32 | import org.jboss.netty.buffer.ChannelBuffers; |
| 33 | import org.hamcrest.CoreMatchers; |
| 34 | |
| 35 | |
| 36 | |
| 37 | public class OFBsnGentableDescStatsReplyVer13Test { |
| 38 | OFFactory factory; |
| 39 | |
| 40 | final static byte[] BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED = |
| 41 | new byte[] { 0x4, 0x13, 0x0, 0x78, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x4, 0x0, 0x30, 0x0, 0x0, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, (byte) 0x80, 0x0, 0x0, 0x0, 0x0 }; |
| 42 | |
| 43 | @Before |
| 44 | public void setup() { |
| 45 | factory = OFFactoryVer13.INSTANCE; |
| 46 | } |
| 47 | |
| 48 | @Test |
| 49 | public void testWrite() { |
| 50 | OFBsnGentableDescStatsReply.Builder builder = factory.buildBsnGentableDescStatsReply(); |
| 51 | builder.setXid(0x12345678) |
| 52 | .setEntries( |
| 53 | ImmutableList.<OFBsnGentableDescStatsEntry>of( |
| 54 | factory.buildBsnGentableDescStatsEntry() |
| 55 | .setTableId(GenTableId.of(0)) |
| 56 | .setName("table 0") |
| 57 | .setBucketsSize(32) |
| 58 | .setMaxEntries(64) |
| 59 | .build(), |
| 60 | factory.buildBsnGentableDescStatsEntry() |
| 61 | .setTableId(GenTableId.of(1)) |
| 62 | .setName("table 1.........................") |
| 63 | .setBucketsSize(64) |
| 64 | .setMaxEntries(128) |
| 65 | .build() |
| 66 | ) |
| 67 | ); |
| 68 | OFBsnGentableDescStatsReply bsnGentableDescStatsReply = builder.build(); |
| 69 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 70 | bsnGentableDescStatsReply.writeTo(bb); |
| 71 | byte[] written = new byte[bb.readableBytes()]; |
| 72 | bb.readBytes(written); |
| 73 | |
| 74 | assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED)); |
| 75 | } |
| 76 | |
| 77 | @Test |
| 78 | public void testRead() throws Exception { |
| 79 | OFBsnGentableDescStatsReply.Builder builder = factory.buildBsnGentableDescStatsReply(); |
| 80 | builder.setXid(0x12345678) |
| 81 | .setEntries( |
| 82 | ImmutableList.<OFBsnGentableDescStatsEntry>of( |
| 83 | factory.buildBsnGentableDescStatsEntry() |
| 84 | .setTableId(GenTableId.of(0)) |
| 85 | .setName("table 0") |
| 86 | .setBucketsSize(32) |
| 87 | .setMaxEntries(64) |
| 88 | .build(), |
| 89 | factory.buildBsnGentableDescStatsEntry() |
| 90 | .setTableId(GenTableId.of(1)) |
| 91 | .setName("table 1.........................") |
| 92 | .setBucketsSize(64) |
| 93 | .setMaxEntries(128) |
| 94 | .build() |
| 95 | ) |
| 96 | ); |
| 97 | OFBsnGentableDescStatsReply bsnGentableDescStatsReplyBuilt = builder.build(); |
| 98 | |
| 99 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED); |
| 100 | |
| 101 | // FIXME should invoke the overall reader once implemented |
| 102 | OFBsnGentableDescStatsReply bsnGentableDescStatsReplyRead = OFBsnGentableDescStatsReplyVer13.READER.readFrom(input); |
| 103 | assertEquals(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex()); |
| 104 | |
| 105 | assertEquals(bsnGentableDescStatsReplyBuilt, bsnGentableDescStatsReplyRead); |
| 106 | } |
| 107 | |
| 108 | @Test |
| 109 | public void testReadWrite() throws Exception { |
| 110 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED); |
| 111 | |
| 112 | // FIXME should invoke the overall reader once implemented |
| 113 | OFBsnGentableDescStatsReply bsnGentableDescStatsReply = OFBsnGentableDescStatsReplyVer13.READER.readFrom(input); |
| 114 | assertEquals(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex()); |
| 115 | |
| 116 | // write message again |
| 117 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 118 | bsnGentableDescStatsReply.writeTo(bb); |
| 119 | byte[] written = new byte[bb.readableBytes()]; |
| 120 | bb.readBytes(written); |
| 121 | |
| 122 | assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED)); |
| 123 | } |
| 124 | |
| 125 | } |