blob: 28c85b277b271282b5afd7e765f4df0da3b616a0 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001// 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
10package org.projectfloodlight.openflow.protocol.ver13;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import static org.junit.Assert.*;
27import org.junit.Test;
28import org.junit.Before;
29import java.util.List;
30import com.google.common.collect.ImmutableList;
31import org.jboss.netty.buffer.ChannelBuffer;
32import org.jboss.netty.buffer.ChannelBuffers;
33import org.hamcrest.CoreMatchers;
34
35
36
37public class OFBsnGentableEntryStatsReplyVer13Test {
38 OFFactory factory;
39
40 final static byte[] BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED =
41 new byte[] { 0x4, 0x13, 0x0, 0x60, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x3, 0x0, 0x24, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x2, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x3, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x65, 0x0, 0x24, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x6, 0x0, 0x2, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x3, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x65 };
42
43 @Before
44 public void setup() {
45 factory = OFFactoryVer13.INSTANCE;
46 }
47
48 @Test
49 public void testWrite() {
50 OFBsnGentableEntryStatsReply.Builder builder = factory.buildBsnGentableEntryStatsReply();
51 builder.setXid(0x12345678)
52 .setEntries(
53 ImmutableList.<OFBsnGentableEntryStatsEntry>of(
54 factory.bsnGentableEntryStatsEntry(
55 ImmutableList.<OFBsnTlv>of(
56 factory.bsnTlvs().port(OFPort.of(5))
57 ),
58 ImmutableList.<OFBsnTlv>of(
59 factory.bsnTlvs().rxPackets(U64.of(100)),
60 factory.bsnTlvs().txPackets(U64.of(101))
61 )
62 ),
63 factory.bsnGentableEntryStatsEntry(
64 ImmutableList.<OFBsnTlv>of(
65 factory.bsnTlvs().port(OFPort.of(6))
66 ),
67 ImmutableList.<OFBsnTlv>of(
68 factory.bsnTlvs().rxPackets(U64.of(100)),
69 factory.bsnTlvs().txPackets(U64.of(101))
70 )
71 )
72 )
73 );
74 OFBsnGentableEntryStatsReply bsnGentableEntryStatsReply = builder.build();
75 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
76 bsnGentableEntryStatsReply.writeTo(bb);
77 byte[] written = new byte[bb.readableBytes()];
78 bb.readBytes(written);
79
80 assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED));
81 }
82
83 @Test
84 public void testRead() throws Exception {
85 OFBsnGentableEntryStatsReply.Builder builder = factory.buildBsnGentableEntryStatsReply();
86 builder.setXid(0x12345678)
87 .setEntries(
88 ImmutableList.<OFBsnGentableEntryStatsEntry>of(
89 factory.bsnGentableEntryStatsEntry(
90 ImmutableList.<OFBsnTlv>of(
91 factory.bsnTlvs().port(OFPort.of(5))
92 ),
93 ImmutableList.<OFBsnTlv>of(
94 factory.bsnTlvs().rxPackets(U64.of(100)),
95 factory.bsnTlvs().txPackets(U64.of(101))
96 )
97 ),
98 factory.bsnGentableEntryStatsEntry(
99 ImmutableList.<OFBsnTlv>of(
100 factory.bsnTlvs().port(OFPort.of(6))
101 ),
102 ImmutableList.<OFBsnTlv>of(
103 factory.bsnTlvs().rxPackets(U64.of(100)),
104 factory.bsnTlvs().txPackets(U64.of(101))
105 )
106 )
107 )
108 );
109 OFBsnGentableEntryStatsReply bsnGentableEntryStatsReplyBuilt = builder.build();
110
111 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED);
112
113 // FIXME should invoke the overall reader once implemented
114 OFBsnGentableEntryStatsReply bsnGentableEntryStatsReplyRead = OFBsnGentableEntryStatsReplyVer13.READER.readFrom(input);
115 assertEquals(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED.length, input.readerIndex());
116
117 assertEquals(bsnGentableEntryStatsReplyBuilt, bsnGentableEntryStatsReplyRead);
118 }
119
120 @Test
121 public void testReadWrite() throws Exception {
122 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED);
123
124 // FIXME should invoke the overall reader once implemented
125 OFBsnGentableEntryStatsReply bsnGentableEntryStatsReply = OFBsnGentableEntryStatsReplyVer13.READER.readFrom(input);
126 assertEquals(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED.length, input.readerIndex());
127
128 // write message again
129 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
130 bsnGentableEntryStatsReply.writeTo(bb);
131 byte[] written = new byte[bb.readableBytes()];
132 bb.readBytes(written);
133
134 assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED));
135 }
136
137}