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 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 OFBsnGentableBucketStatsReplyVer13Test { |
| 38 | OFFactory factory; |
| 39 | |
| 40 | final static byte[] BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED = |
| 41 | new byte[] { 0x4, 0x13, 0x0, 0x38, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x5, (byte) 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x12, 0x34, 0x23, 0x45, 0x34, 0x56, 0x45, 0x67, 0x56, 0x78, 0x67, (byte) 0x89, 0x78, (byte) 0x9a, (byte) 0x89, (byte) 0xab }; |
| 42 | |
| 43 | @Before |
| 44 | public void setup() { |
| 45 | factory = OFFactoryVer13.INSTANCE; |
| 46 | } |
| 47 | |
| 48 | @Test |
| 49 | public void testWrite() { |
| 50 | OFBsnGentableBucketStatsReply.Builder builder = factory.buildBsnGentableBucketStatsReply(); |
| 51 | builder.setXid(0x12345678) |
| 52 | .setEntries( |
| 53 | ImmutableList.<OFBsnGentableBucketStatsEntry>of( |
| 54 | factory.bsnGentableBucketStatsEntry(U128.of(0x8877665544332211L, 0xFFEEDDCCBBAA9988L)), |
| 55 | factory.bsnGentableBucketStatsEntry(U128.of(0x1234234534564567L, 0x56786789789A89ABL)) |
| 56 | ) |
| 57 | ); |
| 58 | OFBsnGentableBucketStatsReply bsnGentableBucketStatsReply = builder.build(); |
| 59 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 60 | bsnGentableBucketStatsReply.writeTo(bb); |
| 61 | byte[] written = new byte[bb.readableBytes()]; |
| 62 | bb.readBytes(written); |
| 63 | |
| 64 | assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED)); |
| 65 | } |
| 66 | |
| 67 | @Test |
| 68 | public void testRead() throws Exception { |
| 69 | OFBsnGentableBucketStatsReply.Builder builder = factory.buildBsnGentableBucketStatsReply(); |
| 70 | builder.setXid(0x12345678) |
| 71 | .setEntries( |
| 72 | ImmutableList.<OFBsnGentableBucketStatsEntry>of( |
| 73 | factory.bsnGentableBucketStatsEntry(U128.of(0x8877665544332211L, 0xFFEEDDCCBBAA9988L)), |
| 74 | factory.bsnGentableBucketStatsEntry(U128.of(0x1234234534564567L, 0x56786789789A89ABL)) |
| 75 | ) |
| 76 | ); |
| 77 | OFBsnGentableBucketStatsReply bsnGentableBucketStatsReplyBuilt = builder.build(); |
| 78 | |
| 79 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED); |
| 80 | |
| 81 | // FIXME should invoke the overall reader once implemented |
| 82 | OFBsnGentableBucketStatsReply bsnGentableBucketStatsReplyRead = OFBsnGentableBucketStatsReplyVer13.READER.readFrom(input); |
| 83 | assertEquals(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED.length, input.readerIndex()); |
| 84 | |
| 85 | assertEquals(bsnGentableBucketStatsReplyBuilt, bsnGentableBucketStatsReplyRead); |
| 86 | } |
| 87 | |
| 88 | @Test |
| 89 | public void testReadWrite() throws Exception { |
| 90 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED); |
| 91 | |
| 92 | // FIXME should invoke the overall reader once implemented |
| 93 | OFBsnGentableBucketStatsReply bsnGentableBucketStatsReply = OFBsnGentableBucketStatsReplyVer13.READER.readFrom(input); |
| 94 | assertEquals(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED.length, input.readerIndex()); |
| 95 | |
| 96 | // write message again |
| 97 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 98 | bsnGentableBucketStatsReply.writeTo(bb); |
| 99 | byte[] written = new byte[bb.readableBytes()]; |
| 100 | bb.readBytes(written); |
| 101 | |
| 102 | assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED)); |
| 103 | } |
| 104 | |
| 105 | } |