blob: bea5123b3aafd27a77a3e55bf644678126c01394 [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 OFBsnGentableEntryDeleteVer13Test {
38 OFFactory factory;
39
40 final static byte[] BSN_GENTABLE_ENTRY_DELETE_SERIALIZED =
41 new byte[] { 0x4, 0x4, 0x0, 0x24, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2f, 0x0, 0x14, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x1, 0x0, 0xa, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab };
42
43 @Before
44 public void setup() {
45 factory = OFFactoryVer13.INSTANCE;
46 }
47
48 @Test
49 public void testWrite() {
50 OFBsnGentableEntryDelete.Builder builder = factory.buildBsnGentableEntryDelete();
51 builder.setXid(0x12345678)
52 .setTableId(GenTableId.of(20))
53 .setKey(
54 ImmutableList.<OFBsnTlv>of(
55 factory.bsnTlvs().port(OFPort.of(5)),
56 factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
57 )
58 );
59 OFBsnGentableEntryDelete bsnGentableEntryDelete = builder.build();
60 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
61 bsnGentableEntryDelete.writeTo(bb);
62 byte[] written = new byte[bb.readableBytes()];
63 bb.readBytes(written);
64
65 assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED));
66 }
67
68 @Test
69 public void testRead() throws Exception {
70 OFBsnGentableEntryDelete.Builder builder = factory.buildBsnGentableEntryDelete();
71 builder.setXid(0x12345678)
72 .setTableId(GenTableId.of(20))
73 .setKey(
74 ImmutableList.<OFBsnTlv>of(
75 factory.bsnTlvs().port(OFPort.of(5)),
76 factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
77 )
78 );
79 OFBsnGentableEntryDelete bsnGentableEntryDeleteBuilt = builder.build();
80
81 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED);
82
83 // FIXME should invoke the overall reader once implemented
84 OFBsnGentableEntryDelete bsnGentableEntryDeleteRead = OFBsnGentableEntryDeleteVer13.READER.readFrom(input);
85 assertEquals(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED.length, input.readerIndex());
86
87 assertEquals(bsnGentableEntryDeleteBuilt, bsnGentableEntryDeleteRead);
88 }
89
90 @Test
91 public void testReadWrite() throws Exception {
92 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED);
93
94 // FIXME should invoke the overall reader once implemented
95 OFBsnGentableEntryDelete bsnGentableEntryDelete = OFBsnGentableEntryDeleteVer13.READER.readFrom(input);
96 assertEquals(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED.length, input.readerIndex());
97
98 // write message again
99 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
100 bsnGentableEntryDelete.writeTo(bb);
101 byte[] written = new byte[bb.readableBytes()];
102 bb.readBytes(written);
103
104 assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED));
105 }
106
107}