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 OFBsnGentableEntryDescStatsReplyVer13Test { |
| 38 | OFFactory factory; |
| 39 | |
| 40 | final static byte[] BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED = |
| 41 | new byte[] { 0x4, 0x13, 0x0, 0x64, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2, 0x0, 0x26, 0x0, 0x8, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x1, 0x0, 0xa, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, 0x0, 0x0, 0x26, 0x0, 0x8, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0xa, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, 0x1 }; |
| 42 | |
| 43 | @Before |
| 44 | public void setup() { |
| 45 | factory = OFFactoryVer13.INSTANCE; |
| 46 | } |
| 47 | |
| 48 | @Test |
| 49 | public void testWrite() { |
| 50 | OFBsnGentableEntryDescStatsReply.Builder builder = factory.buildBsnGentableEntryDescStatsReply(); |
| 51 | builder.setXid(0x12345678) |
| 52 | .setEntries( |
| 53 | ImmutableList.<OFBsnGentableEntryDescStatsEntry>of( |
| 54 | factory.buildBsnGentableEntryDescStatsEntry() |
| 55 | .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998800L)) |
| 56 | .setKey(ImmutableList.<OFBsnTlv>of( |
| 57 | factory.bsnTlvs().port(OFPort.of(5)) |
| 58 | )) |
| 59 | .setValue(ImmutableList.<OFBsnTlv>of( |
| 60 | factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:00")) |
| 61 | )) |
| 62 | .build(), |
| 63 | factory.buildBsnGentableEntryDescStatsEntry() |
| 64 | .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998801L)) |
| 65 | .setKey(ImmutableList.<OFBsnTlv>of( |
| 66 | factory.bsnTlvs().port(OFPort.of(6)) |
| 67 | )) |
| 68 | .setValue(ImmutableList.<OFBsnTlv>of( |
| 69 | factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:01")) |
| 70 | )) |
| 71 | .build() |
| 72 | ) |
| 73 | ); |
| 74 | OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReply = builder.build(); |
| 75 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 76 | bsnGentableEntryDescStatsReply.writeTo(bb); |
| 77 | byte[] written = new byte[bb.readableBytes()]; |
| 78 | bb.readBytes(written); |
| 79 | |
| 80 | assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED)); |
| 81 | } |
| 82 | |
| 83 | @Test |
| 84 | public void testRead() throws Exception { |
| 85 | OFBsnGentableEntryDescStatsReply.Builder builder = factory.buildBsnGentableEntryDescStatsReply(); |
| 86 | builder.setXid(0x12345678) |
| 87 | .setEntries( |
| 88 | ImmutableList.<OFBsnGentableEntryDescStatsEntry>of( |
| 89 | factory.buildBsnGentableEntryDescStatsEntry() |
| 90 | .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998800L)) |
| 91 | .setKey(ImmutableList.<OFBsnTlv>of( |
| 92 | factory.bsnTlvs().port(OFPort.of(5)) |
| 93 | )) |
| 94 | .setValue(ImmutableList.<OFBsnTlv>of( |
| 95 | factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:00")) |
| 96 | )) |
| 97 | .build(), |
| 98 | factory.buildBsnGentableEntryDescStatsEntry() |
| 99 | .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998801L)) |
| 100 | .setKey(ImmutableList.<OFBsnTlv>of( |
| 101 | factory.bsnTlvs().port(OFPort.of(6)) |
| 102 | )) |
| 103 | .setValue(ImmutableList.<OFBsnTlv>of( |
| 104 | factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:01")) |
| 105 | )) |
| 106 | .build() |
| 107 | ) |
| 108 | ); |
| 109 | OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReplyBuilt = builder.build(); |
| 110 | |
| 111 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED); |
| 112 | |
| 113 | // FIXME should invoke the overall reader once implemented |
| 114 | OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReplyRead = OFBsnGentableEntryDescStatsReplyVer13.READER.readFrom(input); |
| 115 | assertEquals(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex()); |
| 116 | |
| 117 | assertEquals(bsnGentableEntryDescStatsReplyBuilt, bsnGentableEntryDescStatsReplyRead); |
| 118 | } |
| 119 | |
| 120 | @Test |
| 121 | public void testReadWrite() throws Exception { |
| 122 | ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED); |
| 123 | |
| 124 | // FIXME should invoke the overall reader once implemented |
| 125 | OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReply = OFBsnGentableEntryDescStatsReplyVer13.READER.readFrom(input); |
| 126 | assertEquals(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex()); |
| 127 | |
| 128 | // write message again |
| 129 | ChannelBuffer bb = ChannelBuffers.dynamicBuffer(); |
| 130 | bsnGentableEntryDescStatsReply.writeTo(bb); |
| 131 | byte[] written = new byte[bb.readableBytes()]; |
| 132 | bb.readBytes(written); |
| 133 | |
| 134 | assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED)); |
| 135 | } |
| 136 | |
| 137 | } |