blob: 6d593cd2f9edcfd0a4b8e25f040e5463408b9476 [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 OFBsnFlowIdleVer13Test {
36 OFFactory factory;
37
38 final static byte[] BSN_FLOW_IDLE_SERIALIZED =
39 new byte[] { 0x4, 0x4, 0x0, 0x38, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x28, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, 0x42, 0x68, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x16, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0x2a, 0x2, 0x0, 0x1, 0x0, 0x0 };
40
41 @Before
42 public void setup() {
43 factory = OFFactoryVer13.INSTANCE;
44 }
45
46 @Test
47 public void testWrite() {
48 OFBsnFlowIdle.Builder builder = factory.buildBsnFlowIdle();
49 builder.setXid(0x12345678)
50 .setCookie(U64.parseHex("FEDCBA9876543210"))
51 .setPriority(17000)
52 .setTableId(TableId.of(20))
53 .setMatch(
54 factory.buildMatch()
55 .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
56 .setExact(MatchField.ARP_OP, ArpOpcode.of(1))
57 .build()
58 );;
59 OFBsnFlowIdle bsnFlowIdle = builder.build();
60 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
61 bsnFlowIdle.writeTo(bb);
62 byte[] written = new byte[bb.readableBytes()];
63 bb.readBytes(written);
64
65 assertThat(written, CoreMatchers.equalTo(BSN_FLOW_IDLE_SERIALIZED));
66 }
67
68 @Test
69 public void testRead() throws Exception {
70 OFBsnFlowIdle.Builder builder = factory.buildBsnFlowIdle();
71 builder.setXid(0x12345678)
72 .setCookie(U64.parseHex("FEDCBA9876543210"))
73 .setPriority(17000)
74 .setTableId(TableId.of(20))
75 .setMatch(
76 factory.buildMatch()
77 .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
78 .setExact(MatchField.ARP_OP, ArpOpcode.of(1))
79 .build()
80 );;
81 OFBsnFlowIdle bsnFlowIdleBuilt = builder.build();
82
83 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_FLOW_IDLE_SERIALIZED);
84
85 // FIXME should invoke the overall reader once implemented
86 OFBsnFlowIdle bsnFlowIdleRead = OFBsnFlowIdleVer13.READER.readFrom(input);
87 assertEquals(BSN_FLOW_IDLE_SERIALIZED.length, input.readerIndex());
88
89 assertEquals(bsnFlowIdleBuilt, bsnFlowIdleRead);
90 }
91
92 @Test
93 public void testReadWrite() throws Exception {
94 ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_FLOW_IDLE_SERIALIZED);
95
96 // FIXME should invoke the overall reader once implemented
97 OFBsnFlowIdle bsnFlowIdle = OFBsnFlowIdleVer13.READER.readFrom(input);
98 assertEquals(BSN_FLOW_IDLE_SERIALIZED.length, input.readerIndex());
99
100 // write message again
101 ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
102 bsnFlowIdle.writeTo(bb);
103 byte[] written = new byte[bb.readableBytes()];
104 bb.readBytes(written);
105
106 assertThat(written, CoreMatchers.equalTo(BSN_FLOW_IDLE_SERIALIZED));
107 }
108
109}