blob: c9f993347fae0ba45c1b849dea2ff8996456a13a [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.EnumSet;
30import java.util.Set;
31import com.google.common.collect.Sets;
32import org.jboss.netty.buffer.ChannelBuffer;
33import org.jboss.netty.buffer.ChannelBuffers;
34import org.hamcrest.CoreMatchers;
35
36
37
38public class OFGetConfigReplyVer13Test {
39 OFFactory factory;
40
41 final static byte[] GET_CONFIG_REPLY_SERIALIZED =
42 new byte[] { 0x4, 0x8, 0x0, 0xc, 0x12, 0x34, 0x56, 0x78, 0x0, 0x2, (byte) 0xff, (byte) 0xff };
43
44 @Before
45 public void setup() {
46 factory = OFFactoryVer13.INSTANCE;
47 }
48
49 @Test
50 public void testWrite() {
51 OFGetConfigReply.Builder builder = factory.buildGetConfigReply();
52 builder.setXid(0x12345678)
53 .setFlags(Sets.immutableEnumSet(OFConfigFlags.FRAG_REASM))
54 .setMissSendLen(0xffff)
55 .build();
56 OFGetConfigReply getConfigReply = builder.build();
57 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
58 getConfigReply.writeTo(bb);
59 byte[] written = new byte[bb.readableBytes()];
60 bb.readBytes(written);
61
62 assertThat(written, CoreMatchers.equalTo(GET_CONFIG_REPLY_SERIALIZED));
63 }
64
65 @Test
66 public void testRead() throws Exception {
67 OFGetConfigReply.Builder builder = factory.buildGetConfigReply();
68 builder.setXid(0x12345678)
69 .setFlags(Sets.immutableEnumSet(OFConfigFlags.FRAG_REASM))
70 .setMissSendLen(0xffff)
71 .build();
72 OFGetConfigReply getConfigReplyBuilt = builder.build();
73
74 ChannelBuffer input = ChannelBuffers.copiedBuffer(GET_CONFIG_REPLY_SERIALIZED);
75
76 // FIXME should invoke the overall reader once implemented
77 OFGetConfigReply getConfigReplyRead = OFGetConfigReplyVer13.READER.readFrom(input);
78 assertEquals(GET_CONFIG_REPLY_SERIALIZED.length, input.readerIndex());
79
80 assertEquals(getConfigReplyBuilt, getConfigReplyRead);
81 }
82
83 @Test
84 public void testReadWrite() throws Exception {
85 ChannelBuffer input = ChannelBuffers.copiedBuffer(GET_CONFIG_REPLY_SERIALIZED);
86
87 // FIXME should invoke the overall reader once implemented
88 OFGetConfigReply getConfigReply = OFGetConfigReplyVer13.READER.readFrom(input);
89 assertEquals(GET_CONFIG_REPLY_SERIALIZED.length, input.readerIndex());
90
91 // write message again
92 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
93 getConfigReply.writeTo(bb);
94 byte[] written = new byte[bb.readableBytes()];
95 bb.readBytes(written);
96
97 assertThat(written, CoreMatchers.equalTo(GET_CONFIG_REPLY_SERIALIZED));
98 }
99
100}