blob: b36d99f485a5301cf81aeb878979151cf87b3656 [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 OFBsnVirtualPortCreateRequestVer13QInQTest {
36 OFFactory factory;
37
38 final static byte[] BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED =
39 new byte[] { 0x4, 0x4, 0x0, 0x30, 0x1, 0x2, 0x3, 0x4, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2, 0x0, 0x3, 0x0, 0x4, 0x0, 0x5, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
40
41 @Before
42 public void setup() {
43 factory = OFFactoryVer13.INSTANCE;
44 }
45
46 @Test
47 public void testWrite() {
48 OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
49 builder.setXid(0x01020304)
50 .setVport(
51 factory.buildBsnVportQInQ()
52 .setPortNo(1)
53 .setIngressTpid(2)
54 .setIngressVlanId(3)
55 .setEgressTpid(4)
56 .setEgressVlanId(5)
57 .setIfName("foo")
58 .build()
59 );;
60 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = builder.build();
61 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
62 bsnVirtualPortCreateRequest.writeTo(bb);
63 byte[] written = new byte[bb.readableBytes()];
64 bb.readBytes(written);
65
66 assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
67 }
68
69 @Test
70 public void testRead() throws Exception {
71 OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
72 builder.setXid(0x01020304)
73 .setVport(
74 factory.buildBsnVportQInQ()
75 .setPortNo(1)
76 .setIngressTpid(2)
77 .setIngressVlanId(3)
78 .setEgressTpid(4)
79 .setEgressVlanId(5)
80 .setIfName("foo")
81 .build()
82 );;
83 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestBuilt = builder.build();
84
85 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
86
87 // FIXME should invoke the overall reader once implemented
88 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestRead = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
89 assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
90
91 assertEquals(bsnVirtualPortCreateRequestBuilt, bsnVirtualPortCreateRequestRead);
92 }
93
94 @Test
95 public void testReadWrite() throws Exception {
96 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
97
98 // FIXME should invoke the overall reader once implemented
99 OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
100 assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
101
102 // write message again
103 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
104 bsnVirtualPortCreateRequest.writeTo(bb);
105 byte[] written = new byte[bb.readableBytes()];
106 bb.readBytes(written);
107
108 assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
109 }
110
111}