blob: 3b0ae82c3cdc4af147dadbbb7cefb032af7e246e [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 org.jboss.netty.buffer.ChannelBuffer;
30import org.jboss.netty.buffer.ChannelBuffers;
31import org.hamcrest.CoreMatchers;
32
33
34
35public class OFOxmBsnGlobalVrfAllowedVer13Test {
36 OFOxms factory;
37
38 final static byte[] OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED =
39 new byte[] { 0x0, 0x3, 0x6, 0x1, 0x1 };
40
41 @Before
42 public void setup() {
43 factory = OFOxmsVer13.INSTANCE;
44 }
45
46 @Test
47 public void testWrite() {
48 OFOxmBsnGlobalVrfAllowed.Builder builder = factory.buildBsnGlobalVrfAllowed();
49 builder.setValue(OFBooleanValue.TRUE);
50 OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowed = builder.build();
51 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
52 oxmBsnGlobalVrfAllowed.writeTo(bb);
53 byte[] written = new byte[bb.readableBytes()];
54 bb.readBytes(written);
55
56 assertThat(written, CoreMatchers.equalTo(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED));
57 }
58
59 @Test
60 public void testRead() throws Exception {
61 OFOxmBsnGlobalVrfAllowed.Builder builder = factory.buildBsnGlobalVrfAllowed();
62 builder.setValue(OFBooleanValue.TRUE);
63 OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowedBuilt = builder.build();
64
65 ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED);
66
67 // FIXME should invoke the overall reader once implemented
68 OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowedRead = OFOxmBsnGlobalVrfAllowedVer13.READER.readFrom(input);
69 assertEquals(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED.length, input.readerIndex());
70
71 assertEquals(oxmBsnGlobalVrfAllowedBuilt, oxmBsnGlobalVrfAllowedRead);
72 }
73
74 @Test
75 public void testReadWrite() throws Exception {
76 ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED);
77
78 // FIXME should invoke the overall reader once implemented
79 OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowed = OFOxmBsnGlobalVrfAllowedVer13.READER.readFrom(input);
80 assertEquals(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED.length, input.readerIndex());
81
82 // write message again
83 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
84 oxmBsnGlobalVrfAllowed.writeTo(bb);
85 byte[] written = new byte[bb.readableBytes()];
86 bb.readBytes(written);
87
88 assertThat(written, CoreMatchers.equalTo(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED));
89 }
90
91}