blob: 686c4143b02f36337fbb692129a4a64e62b5a77d [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.Set;
30import com.google.common.collect.ImmutableSet;
31import org.jboss.netty.buffer.ChannelBuffer;
32import org.jboss.netty.buffer.ChannelBuffers;
33import org.hamcrest.CoreMatchers;
34
35
36
37public class OFBsnVirtualPortCreateRequestVer13L2GreTest {
38 OFFactory factory;
39
40 final static byte[] BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED =
41 new byte[] { 0x4, 0x4, 0x0, 0x50, 0x1, 0x2, 0x3, 0x4, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0xf, 0x0, 0x1, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1b, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, (byte) 0xc0, 0x0, 0x0, 0x2, (byte) 0xc0, 0x0, 0x10, 0x2, 0x1, 0x40, 0x0, 0x0, 0x0, 0x0, (byte) 0xbe, (byte) 0xef, 0x0, 0x0, 0x4, 0x0, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
42
43 @Before
44 public void setup() {
45 factory = OFFactoryVer13.INSTANCE;
46 }
47
48 @Test
49 public void testWrite() {
50 OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
51 builder.setXid(0x01020304)
52 .setVport(
53 factory.buildBsnVportL2Gre()
54 .setFlags(
55 ImmutableSet.<OFBsnVportL2GreFlags>of(
56 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID,
57 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN,
58 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID,
59 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID
60 )
61 )
62 .setPortNo(OFPort.of(1))
63 .setLoopbackPortNo(OFPort.of(2))
64 .setLocalMac(MacAddress.of("0a:0b:0c:0d:0e:0f"))
65 .setNhMac(MacAddress.of("01:02:03:04:05:06"))
66 .setSrcIp(IPv4Address.of("192.0.0.2"))
67 .setDstIp(IPv4Address.of("192.0.16.2"))
68 .setDscp((short)1)
69 .setTtl((short)64)
70 .setVpn(0xbeef)
71 .setRateLimit(0x400)
72 .setIfName("foo")
73 .build()
74 );;
75 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = builder.build();
76 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
77 bsnVirtualPortCreateRequest.writeTo(bb);
78 byte[] written = new byte[bb.readableBytes()];
79 bb.readBytes(written);
80
81 assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
82 }
83
84 @Test
85 public void testRead() throws Exception {
86 OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
87 builder.setXid(0x01020304)
88 .setVport(
89 factory.buildBsnVportL2Gre()
90 .setFlags(
91 ImmutableSet.<OFBsnVportL2GreFlags>of(
92 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID,
93 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN,
94 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID,
95 OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID
96 )
97 )
98 .setPortNo(OFPort.of(1))
99 .setLoopbackPortNo(OFPort.of(2))
100 .setLocalMac(MacAddress.of("0a:0b:0c:0d:0e:0f"))
101 .setNhMac(MacAddress.of("01:02:03:04:05:06"))
102 .setSrcIp(IPv4Address.of("192.0.0.2"))
103 .setDstIp(IPv4Address.of("192.0.16.2"))
104 .setDscp((short)1)
105 .setTtl((short)64)
106 .setVpn(0xbeef)
107 .setRateLimit(0x400)
108 .setIfName("foo")
109 .build()
110 );;
111 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestBuilt = builder.build();
112
113 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
114
115 // FIXME should invoke the overall reader once implemented
116 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestRead = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
117 assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
118
119 assertEquals(bsnVirtualPortCreateRequestBuilt, bsnVirtualPortCreateRequestRead);
120 }
121
122 @Test
123 public void testReadWrite() throws Exception {
124 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
125
126 // FIXME should invoke the overall reader once implemented
127 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
128 assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
129
130 // write message again
131 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
132 bsnVirtualPortCreateRequest.writeTo(bb);
133 byte[] written = new byte[bb.readableBytes()];
134 bb.readBytes(written);
135
136 assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
137 }
138
139}