blob: c7d7dda8add2d2ce8c737b3250b56fccf877c250 [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 OFBsnGentableEntryAddVer13Test {
38 OFFactory factory;
39
40 final static byte[] BSN_GENTABLE_ENTRY_ADD_SERIALIZED =
41 new byte[] { 0x4, 0x4, 0x0, 0x48, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2e, 0x0, 0x14, 0x0, 0x12, (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, 0x77, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x1, 0x0, 0xa, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0xa, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa };
42
43 @Before
44 public void setup() {
45 factory = OFFactoryVer13.INSTANCE;
46 }
47
48 @Test
49 public void testWrite() {
50 OFBsnGentableEntryAdd.Builder builder = factory.buildBsnGentableEntryAdd();
51 builder.setXid(0x12345678)
52 .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998877L))
53 .setTableId(GenTableId.of(20))
54 .setKey(
55 ImmutableList.<OFBsnTlv>of(
56 factory.bsnTlvs().port(OFPort.of(5)),
57 factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
58 )
59 )
60 .setValue(
61 ImmutableList.<OFBsnTlv>of(
62 factory.bsnTlvs().port(OFPort.of(6)),
63 factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:aa"))
64 )
65 );
66 OFBsnGentableEntryAdd bsnGentableEntryAdd = builder.build();
67 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
68 bsnGentableEntryAdd.writeTo(bb);
69 byte[] written = new byte[bb.readableBytes()];
70 bb.readBytes(written);
71
72 assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_ADD_SERIALIZED));
73 }
74
75 @Test
76 public void testRead() throws Exception {
77 OFBsnGentableEntryAdd.Builder builder = factory.buildBsnGentableEntryAdd();
78 builder.setXid(0x12345678)
79 .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998877L))
80 .setTableId(GenTableId.of(20))
81 .setKey(
82 ImmutableList.<OFBsnTlv>of(
83 factory.bsnTlvs().port(OFPort.of(5)),
84 factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
85 )
86 )
87 .setValue(
88 ImmutableList.<OFBsnTlv>of(
89 factory.bsnTlvs().port(OFPort.of(6)),
90 factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:aa"))
91 )
92 );
93 OFBsnGentableEntryAdd bsnGentableEntryAddBuilt = builder.build();
94
95 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_ADD_SERIALIZED);
96
97 // FIXME should invoke the overall reader once implemented
98 OFBsnGentableEntryAdd bsnGentableEntryAddRead = OFBsnGentableEntryAddVer13.READER.readFrom(input);
99 assertEquals(BSN_GENTABLE_ENTRY_ADD_SERIALIZED.length, input.readerIndex());
100
101 assertEquals(bsnGentableEntryAddBuilt, bsnGentableEntryAddRead);
102 }
103
104 @Test
105 public void testReadWrite() throws Exception {
106 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_ADD_SERIALIZED);
107
108 // FIXME should invoke the overall reader once implemented
109 OFBsnGentableEntryAdd bsnGentableEntryAdd = OFBsnGentableEntryAddVer13.READER.readFrom(input);
110 assertEquals(BSN_GENTABLE_ENTRY_ADD_SERIALIZED.length, input.readerIndex());
111
112 // write message again
113 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
114 bsnGentableEntryAdd.writeTo(bb);
115 byte[] written = new byte[bb.readableBytes()];
116 bb.readBytes(written);
117
118 assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_ADD_SERIALIZED));
119 }
120
121}